Skip to content
This repository was archived by the owner on May 9, 2021. It is now read-only.

Make commonInitialisms public #272

Closed
b0o opened this issue Jan 27, 2017 · 5 comments
Closed

Make commonInitialisms public #272

b0o opened this issue Jan 27, 2017 · 5 comments

Comments

@b0o
Copy link

b0o commented Jan 27, 2017

This would be useful for cases where code is being generated automatically, e.g. using go generate ....

I'm generating funcs/types/methods based on a YAML file; one of my type names is "sql" - It needs to be lowercase in my YAML file because some of the generated code is private, and I need to support other type names which are camelCase - I modify the case automatically.

Thus, in order to comply with golint, I need to check the first part of each string against the commonInitialisms map (currently located at lint.go:731).

At the moment, I need to hardcode a copy of the commonInitialisms map and hope that it doesn't change in this repo. :)

@dsnet
Copy link
Member

dsnet commented Jan 28, 2017

Hi. You mention that you would like access to commonInitialisms to presumably generate lint-happy Go code. Do you think that perhaps #239 is the root solution for your problem?

@b0o
Copy link
Author

b0o commented Jan 28, 2017

@dsnet Well, my generator runs the code through GoFmt and produces some pretty decent looking code. The only thing GoLint has ever complained about was the capitalization thing. Not all generated files are going to be human-unreadable.

To answer your question, no, I don't think that #239 is the root solution for my problem - it feels like more of a bandaid.

Also, this issue isn't a huge deal to me, and I don't imagine it would be to anyone else. It would mostly be a convenience. So I understand this is very low priority 😄

@ereOn
Copy link

ereOn commented Mar 14, 2017

@b0o You are actually not alone and I have the exact same use case.

I would even go further and ask whether lintName() itself can be made public.

My generator happens to "create" CamelCased names from snake_cased ones (from a different language) and it's very difficult, if not impossible to make golint happy with those files if we can't access its internal logic for deciding when a name isn't a recommended one.

The ultimate thing would be to have a function that, given a name, returns one that is idiomatic Go for which golint doesn't complain.

@petemoore
Copy link

Indeed, I also needed it for my jsonschema2go library, which generates go types based on json schemas. I ended up duplicating the initialisms, but if it was public, I would not have needed to.

@mvdan
Copy link
Member

mvdan commented May 8, 2021

Thank you for submitting this issue! As per golang/go#38968, we are freezing and deprecating golint. There's no drop-in replacement to golint per se, but you should find that Staticcheck works well in encouraging good Go code, much like golint did in the past, since it also includes style checks. There's always gofmt and go vet too, of course.

If you would like to contribute further, I'd encourage you to engage Staticcheck's issue tracker or look at vet's open issues, as they are both actively maintained. If you have an idea that doesn't fit into either of those tools, you could look at other Go linters, or write your own - these days it's fairly straightforward with go/analysis.

To help avoid confusion, I'm closing all issues before we freeze the repository. If you have any feedback, you can leave a comment on the proposal thread where it was decided to deprecate golint - though note that the proposal has been accepted for nearly a year. Thanks!

@mvdan mvdan closed this as completed May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants