Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix skipping build command #57

Open
yi-jiayu opened this issue Jan 10, 2021 · 0 comments
Open

Fix skipping build command #57

yi-jiayu opened this issue Jan 10, 2021 · 0 comments

Comments

@yi-jiayu
Copy link

When run with -build='', the following error occurs:

2021/01/10 16:51:52 Running build command!
2021/01/10 16:51:52 Error while building:

The following code in the build() function seems to be for conditionally skipping the build command:

CompileDaemon/daemon.go

Lines 151 to 158 in 39b144a

func build() bool {
log.Println(okColor("Running build command!"))
args := strings.Split(*flagBuild, " ")
if len(args) == 0 {
// If the user has specified and empty then we are done.
return true
}

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, " ") 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant