From 82990443c4f862462ef8ee56b13b8d8df7fcd2a5 Mon Sep 17 00:00:00 2001 From: Hieu Phan Date: Sun, 19 Apr 2020 23:58:33 +0700 Subject: [PATCH] add gomod & support main package --- README.md | 1 + go.mod | 9 +++++++++ go.sum | 11 +++++++++++ runner.conf.sample | 1 + runner/build.go | 2 +- runner/settings.go | 5 +++++ 6 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/README.md b/README.md index e20633e..52e27a9 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Check the `_examples` folder if you want to use it with Martini or Gocraft Web. Here is a sample config file with the default settings: root: . + main_package: . tmp_path: ./tmp build_name: runner-build build_log: runner-build-errors.log diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..927051b --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/pilu/fresh + +go 1.13 + +require ( + github.com/howeyc/fsnotify v0.9.0 + github.com/mattn/go-colorable v0.1.6 + github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..9e5df48 --- /dev/null +++ b/go.sum @@ -0,0 +1,11 @@ +github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY= +github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA= +github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a h1:Tg4E4cXPZSZyd3H1tJlYo6ZreXV0ZJvE/lorNqyw1AU= +github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a/go.mod h1:9Or9aIl95Kp43zONcHd5tLZGKXb9iLx0pZjau0uJ5zg= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/runner.conf.sample b/runner.conf.sample index 0d4364a..ac40a52 100644 --- a/runner.conf.sample +++ b/runner.conf.sample @@ -1,4 +1,5 @@ root: . +main_package: . tmp_path: ./tmp build_name: runner-build build_log: runner-build-errors.log diff --git a/runner/build.go b/runner/build.go index 7f0242f..e446aef 100644 --- a/runner/build.go +++ b/runner/build.go @@ -10,7 +10,7 @@ import ( func build() (string, bool) { buildLog("Building...") - cmd := exec.Command("go", "build", "-o", buildPath(), root()) + cmd := exec.Command("go", "build", "-o", buildPath(), mainPackage()) stderr, err := cmd.StderrPipe() if err != nil { diff --git a/runner/settings.go b/runner/settings.go index 10117ec..57c1eca 100644 --- a/runner/settings.go +++ b/runner/settings.go @@ -20,6 +20,7 @@ const ( var settings = map[string]string{ "config_path": "./runner.conf", "root": ".", + "main_package": ".", "tmp_path": "./tmp", "build_name": "runner-build", "build_log": "runner-build-errors.log", @@ -112,6 +113,10 @@ func root() string { return settings["root"] } +func mainPackage() string { + return settings["main_package"] +} + func tmpPath() string { return settings["tmp_path"] }