Skip to content

jimmidyson/goprintconst

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goprintconst

If you use Go constants as the source of truth in your build, you might end up reading their values like this:

> grep -e "MySpecial.*=.*" "foo/bar.go"
    MySpecial    = "value"

This operation can be error-prone: The regular expression might be incorrect, commands like grep or cut might be unavailable. By walking the Go abstract syntax tree (AST) to find constants, goprintconst makes the operation reliable.

Use

> goprintconst --file foo/bar.go --name MySpecial
value

By default, string and character values are unquoted. To preserve quotes, use the -raw=false flag:

> goprintconst --file foo/bar.go --name MySpecial -raw=false
"value"

Install

go install github.com/dlipovetsky/goprintconst

About

CLI that prints const declarations in a Go file.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 100.0%