uber-go/nilaway

How to use nilaway for a Golang project involved conditional compilation?

Open

#154 opened on Dec 20, 2023

View on GitHub
 (1 comment) (0 reactions) (1 assignee)Go (92 forks)auto 404
driverhelp wanted

Repository metrics

Stars
 (3,862 stars)
PR merge metrics
 (PR metrics pending)

Description

I tried running nilaway cmd for our internal project, but it failed with the following error

internal/app/xxx/domain/task.go:244:18: undefined: settings.XXXXX

settings.XXXXX is indeed defined in a source file with "//go:build $flagname" statement declared at the first line

The golangci-lint has the build-flag option while nilaway's analyzer deprecated it

user% ./nilaway --help
nilaway: Run NilAway on this package to report any possible flows of nil values to erroneous sites that our system can detect

Usage: nilaway [-flag] [package]


Flags:
  -V	print version and exit
  -all
    	no effect (deprecated)
  -c int
    	display offending line with this many lines of context (default -1)
  -cpuprofile string
    	write CPU profile to this file
  -debug string
    	debug flags, any subset of "fpstv"
  -exclude-errors-in-files string
    	A comma-separated list of file prefixes to exclude from error reporting. This takes precedence over include-errors-in-files.
  -exclude-file-docstrings value
    	Comma-separated list of docstrings to exclude from analysis
  -exclude-pkgs value
    	Comma-separated list of packages to exclude from analysis
  -fix
    	apply all suggested fixes
  -flags
    	print analyzer flags in JSON
  -include-errors-in-files string
    	A comma-separated list of file prefixes to report errors, default is current working directory. (default "/Users/tiger/Downloads/working/nilaway")
  -include-pkgs value
    	Comma-separated list of packages to analyze
  -json
    	emit JSON output
  -memprofile string
    	write memory profile to this file
  -pretty-print value
    	Pretty print the error messages
  -source
    	no effect (deprecated)
  -tags string
    	no effect (deprecated)
  -test
    	indicates whether test files should be analyzed, too (default true)
  -trace string
    	write trace log to this file
  -v	no effect (deprecated)

Any suggestion for this issue? Thanks~

Contributor guide