-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't double up underscores with -transform=snakecase
It would treat an existing underscore as a "word", so one underscore got transformed in to 3. I run in to this semi-regularly when I copy something like a database schema to a struct: type Sequence struct { sequence_id int64 server_id int32 data_type string increment_by int64 cache_size int64 } And this gets transformed to: type Sequence struct { sequence_id int64 `db:"sequence___id"` server_id int32 `db:"server___id"` data_type string `db:"data___type"` increment_by int64 `db:"increment___by"` cache_size int64 `db:"cache___size"` } I could fix up the field names first, which needs to be done anyway, or use `-transform keep`, but this makes it do the right thing with the defaults with a minimal of friction, and I don't expect it to break anything for anyone.
- Loading branch information
Showing
4 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package foo | ||
|
||
type foo struct { | ||
foo_bar string `json:"foo_bar"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package foo | ||
|
||
type foo struct { | ||
foo_bar string | ||
} |