Created
September 23, 2017 05:46
-
-
Save catatsuy/e13a37ce89c6df41d6e660413baee96d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var programBinary string | |
func setup(dir string) { | |
program := `package main | |
.... | |
}` | |
goFileName := dir + "/main.go" | |
err := ioutil.WriteFile(goFileName, []byte(program), 0644) | |
if err != nil { | |
log.Fatal(err) | |
} | |
programBinary = dir + "/stub" | |
exec.Command("go", "build", "-o", programBinary, goFileName).Run() | |
} | |
func clean(dir string) { | |
err := os.Remove(dir + "/main.go") | |
if err != nil { | |
log.Fatal(err) | |
} | |
err = os.Remove(dir + "/stub") | |
if err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment