- Go
- GIN
$ go get -u github.com/gin-gonic/gin
- GORM:
$ go get -u gorm.io/gorm
$ go get gorm.io/driver/postgres # postgres driver
- Validator: https://pkg.go.dev/gopkg.in/validator.v2
go get gopkg.in/validator.v2
- Test: github.com/stretchr/testify
go get github.com/stretchr/testify
- To execute just one test
go test -run TEST_name
- Postgres
- PGAdmin
- docker
- Find Postgres IP:
$ docker inspect CONTAINER_ID | grep IPAdd
- go mod init github.com/luciormoraes/go-rest-api
- go mod init go-rest-api
- Installing gin
- creating a gin server / first Endpoint(GET)
- creating packages: routes/ controllers/ models
- Installing GORM
- Change controller to create students / new endpoint
- using autoMigrate from gorm: Struct Student as gorm.Model
- return all students from DB
- new endpoints: SearchStudentByID, DeleteStudent, EditStudent, SearchStudentByIRD
- writing validations: installing Validator.v2
- applying validations model / controller: not null strings, length, just numeric values
- creating tests: check status code
- adding Testify to assert
- testing endpoints
- creating student mock, delete student mock
- rendering html pages with gin: index and 404
- register a path for static files