Skip to content

Go Linter for the second half of "Accept Interfaces, Return Structs"

License

Notifications You must be signed in to change notification settings

13rac1/return-structs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Return Structs Linter

Checks functions return structs, not interfaces.

Why

"Accept Interfaces, Return Structs"

The output of this should be considered a warning or notification, not an error because there are some valid reasons to return an interface.

I hadn't used the Go ast/parser libraries yet, so this was an excuse.

Run

One file:

go build
./return-structs example/main.go
#Returned interface found on line 15: UserInterface

Entire project:

find . -name "*.go" -not -path "./vendor/*" | xargs -n1 return-structs

TODO

  • Support ./... to search entire projects
  • Support multiple files
  • Display a help screen
  • Tests
  • Documentation

About

Go Linter for the second half of "Accept Interfaces, Return Structs"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages