Our great sponsors
go-enum | goimports | |
---|---|---|
7 | 46 | |
646 | 7,202 | |
- | 0.6% | |
6.8 | 9.9 | |
25 days ago | 7 days ago | |
Go | Go | |
MIT License | BSD 3-clause "New" or "Revised" 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.
go-enum
-
Ten Years of “Go: The Good, the Bad, and the Meh
While not perfect, there are ways to generate enums automatically using go:generate, e.g. https://github.com/abice/go-enum
-
Go vs Rust
I wouldn't write a macro to save a couple of lines, but I would definitely use (not even write, just use) a macro for something like generating enum [de]serialization for both JSON and BSON in one line. Go, even with generics, still has no way of abstracting extremely common patterns like enums without separate generator tools. Clearly someone thought the macro was useful here, but without a macro they had no choice but to write a separate tool.
-
Enums?
Ive found enums in Go are a pain point, especially across an organization because there are many valid ways to implement it. It's also fairly verbose to implement. The way Ive solved for it is code generation. This is a pretty good library that my team uses in production https://github.com/abice/go-enum
-
Why no enums?
I've worked in a few different languages and Go doesn't seem all that unique in the way that it doesn't provide an ENUM primitive. However, I looked around a bit and found go-enum which seems pretty neat. Also, I have no problem writing a custom string or int/iota type. In some cases you want to be able to serialize/deserialize with them -- and in others you don't need that.
-
Does Go not have enums in the sense that I can use them as a type?
Along that same line you can take it a step further and generate the iota block too with this tool https://github.com/abice/go-enum
-
How to do Enums in Go
Looks like this does what you want: https://github.com/abice/go-enum
goimports
- Gopls/v0.15.0
-
How to find all methods which return struct "Foo" (vscode or cli)
Just a guess, but it might be somewhere in gopls https://github.com/golang/tools/tree/master/gopls/doc On this page https://langserver.org/ it says it should support "finding references"
- Major rewrite of gopls released (2 weeks ago)
-
What LSP are y'all using?
Language server protocol. Here’s a good one: https://github.com/golang/tools/blob/master/gopls/README.md
-
Can Someone Explain To Me Like I'm 5
gopls was not able to find modules in your workspace.When outside of GOPATH, gopls needs to know which modules you are working on.You can fix this by opening your workspace to a folder inside a Go module, orby using a go.work file to specify multiple modules.See the documentation for more information on setting up your workspace:https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.
- Latest gopls version still v0.11.0 from December 22?
- GitHub - orijtech/structslop: structslop is a static analyzer for Go that recommends struct field rearrangements to provide for maximum space/allocation efficiency.
-
betteralign - structs field alignment static analyzer for Go
For more gopls settings, you can see files in this folder: https://github.com/golang/tools/tree/master/gopls/doc
-
Linter for explicit hint to interface which gets implemented.
But finding which interface is satisfied by a type is trivial anyways through gopls which integrates conveniently into any LSP supporting IDE (such as VSCode and Goland).
-
Setting up helix for golang
You need to make sure you have Google's lsp server for golang installed.
What are some alternatives?
goderive - Derives and generates mundane golang functions that you do not want to maintain yourself
gofumpt - A stricter gofmt
gotype - Golang source code parsing, usage like reflect package
nvim-lspconfig - Quickstart configs for Nvim LSP
GoWrap - GoWrap is a command line tool for generating decorators for Go interfaces
goreturns - A gofmt/goimports-like tool for Go programmers that fills in Go return statements with zero values to match the func return types
go-xray - Helpers for making the use of reflection easier
GoLint - [mirror] This is a linter for Go source code. (deprecated)
generis - Versatile Go code generator.
staticcheck
typeregistry - create type dynamically in Golang
golines - A golang formatter that fixes long lines