Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Stronger typing for columns/fields in Go #3174

Unanswered
ptman asked this question in Feature Requests & Ideas
Discussion options

Hi,

Type safety is nice. Having the computer catch more bugs is nice. Is anyone else doing something like this:

CREATE TABLE users (user_id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY);
package types
type UserID int64
version: '2'
sql:
- gen:
 go:
 overrides:
 - column: 'users.user_id'
 go_type:
 import: 'types'
 type: 'UserID'

This gives types to e.g. ID columns, so that you don't accidentally assign one bigint/int64 ID column to another, mixing tables/relations.

Is anyone else doing something similar? Can this be made easier? More automated?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /