5 ms·
I wish more people encouraged people new to Go to look at some of the targets you'll arrive at so that people don't come into Go thinking the end result is goin
by Xeoncross 4y ago
I wish more people encouraged people new to Go to look at some of the targets you'll arrive at so that people don't come into Go thinking the end result is going to be using the Go version of Laravel, Spring, or Rails.
Go has some interesting ideas about models/ORM's, OpenAPI, validation, templates, embedded binary files and other things. When types matter, like in Go, code generation is often very important as well which isn't as common in scripting languages.
https://goa.design/ https://goa.design/ for grpc/rest servers based on specs
https://gokit.io/ https://gokit.io/ for microservices
https://github.com/mustafaakin/gongular https://github.com/mustafaakin/gongular demonstrates object-based validation using struct tags
https://sqlc.dev/ https://sqlc.dev/ for generated models based on SQL (skip the whole idea of an ORM)
https://github.com/jmoiron/sqlx https://github.com/jmoiron/sqlx for more traditional object population from SQL
https://pkg.go.dev/errors https://pkg.go.dev/errors for an understanding of wrapping errors and nested error causes
https://gqlgen.com/ https://gqlgen.com/ for auto-generated revolvers based on GraphQL schemas
https://pkg.go.dev/io#Reader https://pkg.go.dev/io#Reader all the Reader/Writer/Closer's as they are everywhere since Go cares about performance and therefore streaming abilities. No more string passing.
As mentioned in the article, flags matter in Go. The most popular https://cobra.dev/ https://cobra.dev/ and the simpler https://pkg.go.dev/github.com/peterbourgon/ff/v3/ffcli https://pkg.go.dev/github.com/peterbourgon/ff/v3/ffcli provide some good examples
This comment is mostly for web apps, different domains will require looking at all the approaches taken in https://github.com/avelino/awesome-go https://github.com/avelino/awesome-go by leading packages
- morelisp 4y ago> When types matter... https://github.com/mustafaakin/gongular https://github.com/mustafaakin/gongular demonstrates object-based validation using struct tags Yikes. When types matter, you make a newtype and use UnmarshalText!
- Xeoncross 4y agoYeah, that's another good approach but not the most beginner friendly. A large portion of the Go community uses/abuses struct tags so knowing about them and seeing a system designed around them is important even if you won't use gongular because you're using ent or goa. echo, buffalo, gin, etc... all use object struct tags for input data binding and there are two large validation packages that focus on this use.
- morelisp 4y agoMy point is, "struct tags for validation", despite being depressingly common, is definitely something more for "the Go version of Laravel, Spring, or Rails." I would not highlight anything built that way for developers looking for Go's interesting ideas.