Skip to content

1talent/gotraining

Repository files navigation

Get started with golang

cobra cli

echo framework

Run it

go build -o app
./app server
open http://localhost:1323

Using golang cobra command line tool

go install github.com/spf13/cobra-cli@latest

This allows us to use the cobra-cli command in our command line.

cobra-cli add <filename>

Managing our golang models with postgres

Part 1: Manage postgres schema with sql-migrate

go install -v github.com/rubenv/sql-migrate/...

This allows us to use the sql-migrate command in our command line.

# required running DB
# required driver config file dbconfig.yml
sql-migrate up
sql-migrate down
sql-migrate status

Part 2: SQL Boiler to generate golang models

go install github.com/volatiletech/sqlboiler/v4@latest
go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest

This allows us to use the sqlboiler command in our command line.

# required running DB
# required driver config file sqlboiler.toml 
sqlboiler psql

Part 3: go swagger to generate API models and payload

# note to create parameter types
swagger generate model --spec=api/definitions/auth.yml --target=internal --model-package=types 

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published