The GOPATH and GOROOT setup isn't necessary. GOPATH default is $HOME/go since Go 1.8. You can check where your GOPATH and GOROOT points to with "go env". Only need to set the PATH:
export PATH=$HOME/go/bin:/usr/local/bin:$PATH
You must validate the return of json.NewEncoder(w).Encode(&resource). Always check your return errors.
db.Create, db.First, db.Find, etc can fail, so db.Error must be checked.
Interesting -- go install and godep didn't work before I set the GOPATH and GOROOT -- I would guess it is because of brew install instead of following the website directions.
I would check the errors on a bigger app -- the chances of this one being used are next to zero! More a learning experience than anything.
Thanks for the tips!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nicely done. Simple and clean.
But I've some tips for you:
export PATH=$HOME/go/bin:/usr/local/bin:$PATH
You must validate the return of json.NewEncoder(w).Encode(&resource). Always check your return errors.
db.Create, db.First, db.Find, etc can fail, so db.Error must be checked.
Keep learning and sharing! :)
Interesting --
go install
andgodep
didn't work before I set the GOPATH and GOROOT -- I would guess it is because ofbrew install
instead of following the website directions.I would check the errors on a bigger app -- the chances of this one being used are next to zero! More a learning experience than anything.
Thanks for the tips!