However, the return value of strings.Split will never have length 0 because the provided separator is not empty. If provided an empty string, it will still return a slice containing a single empty string:
If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.
If sep is empty, Split splits after each UTF-8 sequence. If both s and sep are empty, Split returns an empty slice.
Maybe the condition could be replaced with if *flagBuild == "" and checked before the call to strings.Split:
if *flagBuild == "" {
// If the value of flagBuild is empty then we are done.
return true
}
args := strings.Split(*flagBuild, " ")
When run with
-build=''
, the following error occurs:The following code in the
build()
function seems to be for conditionally skipping the build command:https://github.com/githubnemo/CompileDaemon/blob/39b144afa93c8bc1b8da4d498cd72c9927c1ce49/daemon.go#L151-L158
However, the return value of
strings.Split
will never have length 0 because the provided separator is not empty. If provided an empty string, it will still return a slice containing a single empty string:Maybe the condition could be replaced with
if *flagBuild == ""
and checked before the call tostrings.Split
: