Golang Build: When flags are passed, replace default
Previously, any flags that were provided to a command via settings
or parameters would be appended to the default flag of "-v". With
this change, if any flags are provided, the default is omitted.
This gives complete control of flags to the user.
Change-Id: Icad35a51d7444f7799989a9831a996ec798b2bf6
Reviewed-on: https://go-review.googlesource.com/16252
Reviewed-by: Jason Buberel <jbuberel@google.com>
diff --git a/dev/tests.py b/dev/tests.py
index 51c17b4..b37e1b0 100644
--- a/dev/tests.py
+++ b/dev/tests.py
@@ -69,7 +69,7 @@
file_path = path.join(TEST_GOPATH, 'src', 'good', 'rune_len.go')
def _run_build(view, result_queue):
- view.window().run_command('golang_build', {'flags': ['-x']})
+ view.window().run_command('golang_build', {'flags': ['-v', '-x']})
result_queue = open_file(file_path, VIEW_SETTINGS, _run_build)
result = wait_build(result_queue)
@@ -81,7 +81,7 @@
file_path = path.join(TEST_GOPATH, 'src', 'good', 'rune_len.go')
- with GolangBuildMock(sublime_settings={'build:flags': ['-x']}):
+ with GolangBuildMock(sublime_settings={'build:flags': ['-v', '-x']}):
def _run_build(view, result_queue):
view.window().run_command('golang_build')
@@ -99,7 +99,7 @@
view.window().run_command('golang_build', {'task': 'install'})
custom_view_settings = VIEW_SETTINGS.copy()
- custom_view_settings['install:flags'] = ['-x']
+ custom_view_settings['install:flags'] = ['-v', '-x']
result_queue = open_file(file_path, custom_view_settings, _run_build)
result = wait_build(result_queue)
@@ -190,7 +190,7 @@
sublime.set_clipboard('github.com/golang/example/hello')
notify_user('Paste from the clipboard into the input panel')
begin_event.set()
- view.window().run_command('golang_build_get', {'flags': ['-d']})
+ view.window().run_command('golang_build_get', {'flags': ['-v', '-d']})
result_queue = open_file(file_path, VIEW_SETTINGS, _run_build)
begin_event.wait()
@@ -203,7 +203,7 @@
file_path = path.join(TEST_GOPATH, 'src', 'good', 'rune_len.go')
- with GolangBuildMock(sublime_settings={'get:flags': ['-d']}):
+ with GolangBuildMock(sublime_settings={'get:flags': ['-v', '-d']}):
def _run_build(view, result_queue):
view.window().run_command('golang_build_get', {'url': 'github.com/golang/example/hello'})
diff --git a/golang_build.py b/golang_build.py
index e0a32a7..19d27a8 100644
--- a/golang_build.py
+++ b/golang_build.py
@@ -97,6 +97,9 @@
window=self.window
)
+ if flags is None:
+ flags = ['-v']
+
if task == 'cross_compile':
_task_cross_compile(
self,
@@ -107,7 +110,7 @@
)
return
- args = [go_bin, task, '-v']
+ args = [go_bin, task]
if flags and isinstance(flags, list):
args.extend(flags)
proc = _run_process(
@@ -181,7 +184,7 @@
env['GOOS'], env['GOARCH'] = valid_combinations[index]
- args = [go_bin, 'build', '-v']
+ args = [go_bin, 'build']
if flags and isinstance(flags, list):
args.extend(flags)
proc = _run_process(
@@ -278,6 +281,9 @@
window=self.window
)
+ if flags is None:
+ flags = ['-v']
+
def on_done(get_url):
"""
Processes the user's input and launches the "go get" command
@@ -286,7 +292,7 @@
A unicode string of the URL to get
"""
- args = [go_bin, 'get', '-v']
+ args = [go_bin, 'get']
if flags and isinstance(flags, list):
args.extend(flags)
args.append(get_url)