Pronunciation: /ɡoʊʊʊ/
Go lang web app "framework" showcasing straightforward, no-magic, web development with the Go language. Includes batch template processing and interaction with postgresql databases, and Model-View architecture.
- Anti-magic
- So simple, that it's complex.
- So complex, that it works.
- If it doesn't work, publish it.
- model
struct
type- embedded
Modeller
interface throughBaseModel
struct
- view
- parses templates in
tmpl/
folder and defines how they are rendered - uses
html/template
to parse and render - handles routes
- fetches rows from database as type Model interfaces
- conversion
- models implement
interface{}
and[]interface{}
types - Go's dynamic feature is interface type conversion, generally checked at runtime
- Interface -> JSON
interface{} -> []byte
- Interface -> Struct
[]interface{}
->map[string]interface{}
- GetStructValues
interface{} -> []interface{}
- InterfaceName:
interface{} -> string
- models implement
- util
- generic error handler
HandlerErr(err error)
- generic error handler
- Gophers
- Hip
- New
- Unproven
Are you good?
- resolve dependencies
- go get https://github.com/bmizerany/pq (pure Go postgres driver for
database/sql
) - don't want to use postgresql? Use it anyway.
- Sign up for a free Heroku Postgres account here.
- Create a database and save the connection params for the next step.
- go get https://github.com/bmizerany/pq (pure Go postgres driver for
- configure the database connection variable
dpParams
in the model package (model/model.go
) go install
iff first buildgo build && ./gooo
- http://localhost:8080
- Gooo celebrate
- Gooo outside
- resolve dependencies
- go get https://github.com/bmizerany/pq (pure Go postgres driver for
database/sql
) - don't want to use postgresql? Use it anyway.
- Sign up for a free Heroku Postgres account here.
- Create a database and save the connection params for the next step.
- go get https://github.com/bmizerany/pq (pure Go postgres driver for
- define your model interfaces and configure the database connection in the model package (
model/model.go
)- implement your model interface types with anonymous
BaseModel
field- use
`json:"-"`
for type safety and Go lang future proofing
- use
- implement functions and variables available to all models with anonymous
BaseModel
field in theModel
interface type
- implement your model interface types with anonymous
- define your views as request handler functions in the view package (
view/view.go
) - write your templates in
tmpl/
(Go text/template syntax) - define routes in main package gooo.go
go install
iff first buildgo build && ./gooo
- http://localhost:8080
- Gooo celebrate
- Gooo outside
Enjoy,
- Aaron Lifton