Ejemplo n.º 1
0
    def run(self):
        pkg_name = "main"
        view = gs.active_valid_go_view()
        try:
            basedir = gs.basedir_or_cwd(view and view.file_name())
            for fn in os.listdir(basedir):
                if fn.endswith(".go"):
                    name, _ = mg9.pkg_name(os.path.join(basedir, fn), "")
                    if name:
                        pkg_name = name
                        break
        except Exception:
            gs.error_traceback("GsNewGoFile")

        self.window.new_file().run_command("gs_create_new_go_file", {"pkg_name": pkg_name, "file_name": "main.go"})
Ejemplo n.º 2
0
	def run(self):
		pkg_name = 'main'
		view = gs.active_valid_go_view()
		try:
			basedir = gs.basedir_or_cwd(view and view.file_name())
			for fn in os.listdir(basedir):
				if fn.endswith('.go'):
					name, _ = mg9.pkg_name(os.path.join(basedir, fn), '')
					if name:
						pkg_name = name
						break
		except Exception:
			gs.error_traceback('GsNewGoFile')

		self.window.new_file().run_command('gs_create_new_go_file', {
			'pkg_name': pkg_name,
			'file_name': 'main.go',
		})