Skip to content

Instantly share code, notes, and snippets.

@sohlich
Created November 18, 2016 05:32
Show Gist options
  • Save sohlich/e984a00ddf60fbbfb1cc9612b5577e6e to your computer and use it in GitHub Desktop.
Save sohlich/e984a00ddf60fbbfb1cc9612b5577e6e to your computer and use it in GitHub Desktop.
Golang program argument testing
func TestConfigParse(t *testing.T) {
oldArgs := os.Args
defer func() { os.Args = oldArgs }()
os.Args = []string{"metro",
"-host=localhost",
"-port=30",
"-user=ssh",
"-password=sshpass",
"-list=lst.csv",
"-timeout=25"}
host := flag.String("host", "", "Host for SSH")
flag.Parse()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment