goprintconst

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2022 License: MIT Imports: 8 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL