gomodifytags
counterfeiter
Our great sponsors
gomodifytags | counterfeiter | |
---|---|---|
3 | 12 | |
2,179 | 913 | |
- | - | |
4.1 | 7.6 | |
4 months ago | 9 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
counterfeiter
-
Mocking database calls without a library?
then just replace whole function, don't generate manually the mock '__') or it would get out of hand fast, you can just use codegen that static typed like https://github.com/maxbrunsfeld/counterfeiter
-
Libraries you use most of your projects?
https://github.com/maxbrunsfeld/counterfeiter - generate static typed test double (can be used to mock or stub calls)
I prefer https://github.com/maxbrunsfeld/counterfeiter
-
How do you write/generate mocks for testing?
counterfeiter is another tool, it creates mocks, stubs and spies; here is a short blog I wrote covering it.
- What's the best approach for mocking a function /method?
-
Best/Easiest Rest Framework
for dependency injection I suggest you use https://github.com/maxbrunsfeld/counterfeiter, but if you using really fast database (that can spawn fast using docker and has fast trx/sec) you can use it directly without dependency injection with https://github.com/ory/dockertest
-
Migrating from NodeJS/Typescript into Golang. Any advise for big web application?
Agree with u/mmknightx there is a tool that assist in creating fake or mock classes for your interfaces https://github.com/maxbrunsfeld/counterfeiter
-
How do you control behaviour in mocked interface ?
Another alternative to use would be counterfeiter, it generates a type from your interface that could be used as a mock, stub or spy. I wrote a short post covering that tool if you're interested.
-
Flexible mocking for testing in Go (without using a framework)
Correct link is https://github.com/maxbrunsfeld/counterfeiter for those interested
What are some alternatives?
gomock - GoMock is a mocking framework for the Go programming language.
mockery - A mock code autogenerator for Go
Mmock - Mmock is an HTTP mocking application for testing and fast prototyping
prettybenchcmp - cmd tool for automatic storage and comparison of benchmarks results
gock - HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽
mockhttp - Mock object for Go http.ResponseWriter
go-localstack - Go Wrapper for using localstack
minimock - Powerful mock generation tool for Go programming language
go-sqlmock - Sql mock driver for golang to test database interactions
timex - A test-friendly replacement for golang's time package [managed by soy-programador]
webmock - Webmock for Golang, to stub requests.
httpmock - HTTP mocking for Golang