Categories
golang Mariadb

Go mysql config

I found that when using mysql.Config, I need to add AllowNativePasswords: true for a connection to mariadb from my go program

 30 cfg := mysql.Config{
 31         User: os.Getenv("DBUSER"),
 32         Passwd: os.Getenv("DBPASS"),
 33         Net: "tcp",
 34         Addr: "172.18.0.6:3306",
 35         AllowNativePasswords: true,
 36         DBName: "recordings",
 37     }
 ...
 42 db, err = sql.Open("mysql",cfg.FormatDSN())

Categories
golang

golang dependencies

when I build a module locally, I need to adjust the location in the calling modules go.mod file using the local directory structure relative to the calling modules location. example below:

$ go mod edit -replace=example.com/theirmodule@v0.0.0-unpublished=../theirmodule
$ go get -d example.com/theirmodule@v0.0.0-unpublished

More info here…

/https://go.dev/doc/modules/managing-dependencies#naming_module

Categories
Uncategorized

Rants

CMake

On and off, over the years, I really tried to like cmake. “It does everything! It does it fast It finds libraries for you!”.

CMake is not special. It is yet another bloated tool that requires way too many hours of reading documentation to find out how best to use it. Just tried to add postgres library libpq to work with my c++ program. The documentation said, oh, just use find library postgresql.

yeah.

If you cannot get a tool to work for you within a reasonable amount of time, get rid of it. Cmake is now off my system and I am not looking back.

Categories
Docker postgres

Postgres docker import data

To load a csv file into a table, one way to do it is to use the docker cp command to copy the file into the container. You can then run the \copy command from a cmd line in the container.

docker cp ./projects.csv  some-postgres:/projects.csv
docker exec -it some-postgres psql -U postgres
** from psql:
postgres=# \copy projects(id,project_name,description) from '/projects.csv' csv header;