gomodifytags
sqlc
Our great sponsors
gomodifytags | sqlc | |
---|---|---|
3 | 169 | |
2,186 | 10,837 | |
- | 5.6% | |
4.1 | 9.7 | |
5 months ago | 6 days ago | |
Go | Go | |
BSD 3-clause "New" or "Revised" License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
gomodifytags
-
Which Tools Do You use daily for Golang development?
gomodifytags
-
Libraries you use most of your projects?
https://github.com/fatih/gomodifytags - generate or modify struct tags
-
Improving the code from the official Go RESTful API tutorial
I suspect it's because Go's general philosophy is that it's better to be verbose and explicit (than terse and magical). Probably falls under "clear is better than clever" from Rob Pike's Go Proverbs: http://go-proverbs.github.io/
I think if this feature was added, it would not be with struct tags, but with an Encoder.SetFieldTransform(json.SnakeCase) or similar setting.
That might be quite a nice feature, actually. You could provide your own function to transform names when marshaling, and for unmarshaling it would strip punctuation and match case insensitively (because it's hard to do the reverse transform, for example should user_id go to UserId or UserID, and if the latter, how does the transform know?).
In any case, it seems like an issue was opened proposing something like that a couple of years ago (https://github.com/golang/go/issues/23027), and Russ Cox responded that the JSON package is basically done, but you could either fork it and add the feature, or use a tool that modifies struct tags like https://github.com/fatih/gomodifytags
sqlc
-
Give Up Sooner
"Is there a way to get sqlc to use pointers for nullable columns instead of the sql.Null types?"
-
Show HN: Sqlbind a Python library to compose raw SQL
I came across this yesterday for golang: https://sqlc.dev which is somewhat like what you want, maybe.
Not sure it allows you to parameterize table names but the basic idea is codegen from sql queries so you are working with go code (autocompletion etc).
- API completa em Golang - Parte 7
-
ORMs are nice but they are the wrong abstraction
Agreed, but tools like https://sqlc.dev, which I mention in the article, are a good trade-off that allows you to have verified, testable, SQL in your code.
- API completa em Golang - Parte 6
-
Go ORMs Compared
sqlc is not strictly a conventional ORM. It offers a unique approach by generating Go code from SQL queries. This allows developers to write SQL, which sqlc then converts into type-safe Go code, reducing the boilerplate significantly. It ensures that your queries are syntactically correct and type-safe. sqlc is ideal for those who prefer writing SQL and are looking for an efficient way to integrate it into a Go application.
-
Type-safe Data Access in Go using Prisma and sqlc
I was browsing awesome-go for ideas on how to setup my data access layer when I stumbled on sqlc. It seemed like a great option. Code generation is a strategy often used in the Go ecosystem and making my queries safe at compile time was an idea I really liked. Knex was great, but it required of me that I test thoroughly my queries at runtime and that I sanitize my query results to ensure type safety within my application.
-
Level UP your RDBMS Productivity in GO
Now, we are going to generate the code. For this purpose, we are going to use sqlc.
-
What 3rd-party libraries do you use often/all the time?
https://github.com/sqlc-dev/sqlc — for use with //go:generate
- API completa em Golang - Parte 1
What are some alternatives?
dynamic-struct - Golang package for editing struct's fields during runtime and mapping structs to other structs.
sqlx - general purpose extensions to golang's database/sql
gopium - Gopium 🌺: Smart Go Structures Optimizer and Manager
GORM - The fantastic ORM library for Golang, aims to be developer friendly
autogold - Automatically update your Go tests
SQLBoiler - Generate a Go ORM tailored to your database schema.
go-wiki - This is a Golang open-source module that makes it easy to access and parse data from Wikipedia (Wikipedia API wrapper)
ent - An entity framework for Go
go - The Go programming language
jet - Type safe SQL builder with code generation and automatic query result data mapping
teller - Cloud native secrets management for developers - never leave your command line for secrets.
pgx - PostgreSQL driver and toolkit for Go