Skip to content

Commit d3f09ee

Browse files
committed
Run all non-run commands against current directory.
This doesn't assume any directory structure and allows for building packages outside of the GOPATH.
1 parent 4809d74 commit d3f09ee

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Support/gomate.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def Go::go(command, options={})
2222
opts = {:use_hashbang => false, :version_args => ['version'], :version_regex => /\Ago version (.*)/}
2323
opts[:verb] = options[:verb] if options[:verb]
2424

25+
# Default to running against directory, which in go should be the package.
26+
# Doesn't hold for "go run", which needs to be executed against the file.
27+
# The same will happend if directory is not set.
2528
directory = ENV['TM_DIRECTORY']
2629
if directory
2730
opts[:chdir] = directory
@@ -30,14 +33,7 @@ def Go::go(command, options={})
3033
if command == 'run' || !directory
3134
args.push(ENV['TM_FILEPATH'])
3235
else
33-
# Default to running against directory, which in go should be the package
34-
# Useful for more cases, like install and build
35-
# Assumes a standard setup and may not function with all pkg managers
36-
opts[:chdir] = ENV['TM_DIRECTORY']
37-
pkg_length = ENV['GOPATH'].length + 4 # GOPATH + /src/
38-
go_pkg = ENV['TM_DIRECTORY'][pkg_length..-1] # subtract above, is pkg name
3936
args.push("-v") # list packages being operated on
40-
args.push(go_pkg)
4137
end
4238
args.push(opts)
4339

@@ -96,4 +92,3 @@ def Go::gofmt
9692
end
9793
end
9894
end
99-

0 commit comments

Comments
 (0)