def executeFile(self): gobin = get_go_bin_path() if self.type == "RUN": command = [gobin, "run", self.file_name] elif self.type == "BUILD": command = [gobin, "build", "-x", "-v", self.file_name] elif self.type == "TEST": command = [gobin, "test", self.file_name] else: sublime.error_message("Unknown command: " + self.type) self.restoreEnv() return getView().window().run_command("exec", {'kill': True}) getView().window().run_command("exec", { 'shell': True, 'cmd': command, 'working_dir': os.path.dirname(self.file_name), 'file_regex': '^(.+\.go):([0-9]+):(?:([0-9]+):)?\s*(.*)', })
def executeProject(self): project = self.project sublime.status_message("Building project: " + project.name) self.setEnv() try: gobin = get_go_bin_path(self.project.base_path) if self.type == "INSTALL": if project.target is None: sublime.error_message("Can't infer project target " "package.") return command = "%s install %s" % (gobin, project.target) self.run_command(command) elif self.type == "TEST": test_pkgs = project.settings.get("test_pkgs", []) if not test_pkgs: sublime.error_message("No test_pkgs specified in project.") return command = "%s test %s" % (gobin, ' '.join(test_pkgs)) self.run_command(command) elif self.type == "RUN": if project.main is None: sublime.error_message("Can't infer project main file.") return command = "%s run %s" % (gobin, project.main) self.window.show_input_panel("Run command: ", command, self.run_command, None, None) else: sublime.error_message("Unknown command: " + self.type) return finally: self.restoreEnv()