Today is the first day of Spring, time for something new.
Summary
- use Go to access the lab Postgres server running in Docker container
- save query to a csv file
- check out how testing works
Is Go, the Programming Language of the Cloud? You decide.
The code
Source code is on My github repo
I had to spend more time than I thought to figure out how to get nullable table column values. I had to do this to get a DECIMAL nullable value back:
func convert2str(v sql.NullFloat64) string {
var strVal = ""
if v.Valid {
var tmpVal, err = v.Value()
if err == nil {
strVal = fmt.Sprintf("%f", tmpVal)
}
}
return strVal
}
To run:
go run
to test:
go test
Good stuffs
- Go has built-in dependency management, build, testing, …,
- Short hand syntaxes = less typing
- Easy to learn