Closed brianfoshee closed 9 years ago
@letsgitgrowing let me know what you think of the direction of this branch or if you have any questions. Read the updated message above (it originally was not as broad in scope).
Reviewing branch now.
A handy tip: Instead of needing to cd
into each package's directory to run tests, lint, and vet, add ./...
to each command's args from the project's root directory and the command will run for each directory which has a package in it.
go test ./...
go vet ./...
golint ./...
@letsgitgrowing the test for GetReadings()
look good. I wouldn't worry about testing JSON marshaling in there, though. We can test that in the http handler tests.
Also, let's verify at some point that this issue in the postgres driver package isn't a problem with our inserting a timestamp without timezone
column type. The code for that whole repository is an interesting read.
Before this gets squashed/merged let's run go vet
, golint
and go fmt
on all files.
Whoops, forgot about those tools :)
I just updated the vim-go plugin to the latest version, and it'll now run the goimports
tool if you set let g:go_fmt_command = "goimports"
in your .vimrc
. So it'll run both gofmt
on saving a file to format the code, and then it'll import any packages that you need (or remove the ones you're not using).
Did you have any luck with that windows terminal emulator?
This PR now does a few things beyond what it was originally opened for:
common
package which encapsulates MyTime and Reading.main_test.go
was renamed `common/myTime_test.go' because that's all it testedcd comon/
and then rungo test -v
to run tests forcommon
packagedb
package to encapsulate database related functionalityMockDbManager
and accompanying test for use in http tests (http tests not implemented) #6cd db/
and then rungo test -v
to run tests fordb
packagesqlx
package which was being used fordb.Select()
, in favor of using the builtindatabase/sql
package's functionality for retrieving rows.Reading.Temperature
toReading.WaterTemperature
#4Reading.DeviceId
toReading.DeviceID
(per the go lint tool)Things it needs:
PostgresDbManager
and accompanying testsMyTime
function for marshalling JSONmain.go
to use theAddReading()
andGetReadings()
functionsMockDbManager
Original commit message:
This isn't ready to merge yet (needs testing) but is to remove a 3rd party dependency. the
sqlx.Select()
function is handy, but using thedatabase/sql
package in the stdlib doesn't add any complexity, just some verbosity during theNext()
andScan()
actions (these lines https://github.com/crakalakin/aquaponics-data/blob/remove-sqlx/main.go#L59-L76).After finally understanding the next/scan functions from watching http://www.confreaks.com/videos/3440-gophercon2014-building-database-applications-with-database-sql, I decided this would be a good thing to try.