When I use flag package
// main.go
import (
...
"flag"
)
func main() {
...
flag.Parse()
switch flag.Arg(0) {
case "doSomething1":
...
case "doSomething2":
...
}
}
If doSomething1 argument print some error message for me, whatever I fix the source code, it can not remove the old error code and compile again.
// command-line
# go build ./main.go
# ./main doSomething1
# error doSomething1 can not work
-- I fix my code
# ./main doSomething1
# error doSomething1 can not work
-- the error message also show me again
-- I have to delete main and build again
# rm ./main
# go build ./main.go
# ./main.go doSomething1
# doSomething1 now can work