Esempio n. 1
0
    def run(self, edit):
        v = self.view
        pos = gs.sel(v).begin()
        inscope = lambda p: v.score_selector(p, 'path.9o') > 0
        if not inscope(pos):
            pos -= 1
            if not inscope(pos):
                return

        path = v.substr(v.extract_scope(pos))
        if URL_PATH_PAT.match(path):
            if path.lower().startswith('gs.packages://'):
                path = os.path.join(sublime.packages_path(), path[14:])
            else:
                try:
                    if not URL_SCHEME_PAT.match(path):
                        path = 'http://%s' % path
                    gs.notify(DOMAIN, 'open url: %s' % path)
                    webbrowser.open_new_tab(path)
                except Exception:
                    gs.error_traceback(DOMAIN)

                return

        wd = v.settings().get('9o.wd') or active_wd()
        m = SPLIT_FN_POS_PAT.match(path)
        path = gs.apath((m.group(1) if m else path), wd)
        row = max(0, int(m.group(2)) - 1 if (m and m.group(2)) else 0)
        col = max(0, int(m.group(3)) - 1 if (m and m.group(3)) else 0)

        if os.path.exists(path):
            gs.focus(path, row, col, win=self.view.window())
        else:
            gs.notify(DOMAIN, "Invalid path `%s'" % path)
Esempio n. 2
0
	def run(self, edit):
		v = self.view
		pos = gs.sel(v).begin()
		inscope = lambda p: v.score_selector(p, 'path.9o') > 0
		if not inscope(pos):
			pos -= 1
			if not inscope(pos):
				return

		path = v.substr(v.extract_scope(pos))
		if URL_PATH_PAT.match(path):
			if path.lower().startswith('gs.packages://'):
				path = os.path.join(sublime.packages_path(), path[14:])
			else:
				try:
					if not URL_SCHEME_PAT.match(path):
						path = 'http://%s' % path
					gs.notify(DOMAIN, 'open url: %s' % path)
					webbrowser.open_new_tab(path)
				except Exception:
					gs.error_traceback(DOMAIN)

				return

		wd = v.settings().get('9o.wd') or active_wd()
		m = SPLIT_FN_POS_PAT.match(path)
		path = gs.apath((m.group(1) if m else path), wd)
		row = max(0, int(m.group(2))-1 if (m and m.group(2)) else 0)
		col = max(0, int(m.group(3))-1 if (m and m.group(3)) else 0)

		if os.path.exists(path):
			gs.focus(path, row, col, win=self.view.window())
		else:
			gs.notify(DOMAIN, "Invalid path `%s'" % path)
Esempio n. 3
0
		def f(res, err):
			if err:
				gs.notify(DOMAIN, err)
				return

			decls = res.get('file_decls', [])
			for d in res.get('pkg_decls', []):
				if not vfn or d['fn'] != vfn:
					decls.append(d)

			for d in decls:
				dname = (d['repr'] or d['name'])
				trailer = []
				trailer.extend(GOOS_PAT.findall(d['fn']))
				trailer.extend(GOARCH_PAT.findall(d['fn']))
				if trailer:
					trailer = ' (%s)' % ', '.join(trailer)
				else:
					trailer = ''
				d['ent'] = '%s %s%s' % (d['kind'], dname, trailer)

			ents = []
			decls.sort(key=lambda d: d['ent'])
			for d in decls:
				ents.append(d['ent'])

			def cb(i, win):
				if i >= 0:
					d = decls[i]
					gs.focus(d['fn'], d['row'], d['col'], win)

			if ents:
				gs.show_quick_panel(ents, cb)
			else:
				gs.show_quick_panel([['', 'No declarations found']])
Esempio n. 4
0
		def f(res, err):
			if err:
				gs.notify('GsDeclarations', err)
			else:
				decls = res.get('file_decls', [])
				decls.sort(key=lambda v: v.get('row', 0))
				added = 0
				for i, v in enumerate(decls):
					loc = Loc(v['fn'], v['row'], v['col'])
					s = '%s %s' % (v['kind'], (v['repr'] or v['name']))
					self.add_item(s, self.jump_to, (view, loc))
					added += 1

			if added < 1:
				self.add_item(['', 'No declarations found'])

			self.do_show_panel()
        def f(res, err):
            if err:
                gs.notify('GsDeclarations', err)
            else:
                decls = res.get('file_decls', [])
                decls.sort(key=lambda v: v.get('row', 0))
                added = 0
                for i, v in enumerate(decls):
                    loc = Loc(v['fn'], v['row'], v['col'])
                    s = '%s %s' % (v['kind'], (v['repr'] or v['name']))
                    self.add_item(s, self.jump_to, (view, loc))
                    added += 1

            if added < 1:
                self.add_item(['', 'No declarations found'])

            self.do_show_panel()
Esempio n. 6
0
        def f(res, err):
            if err:
                gs.notify(DOMAIN, err)
                return

            mats = {}
            args = {}
            decls = res.get('file_decls', [])
            decls.extend(res.get('pkg_decls', []))
            for d in decls:
                name = d['name']
                prefix, _ = match_prefix_name(name)
                if prefix and d['kind'] == 'func' and d['repr'] == '':
                    mats[True] = prefix
                    args[name] = name

            names = sorted(args.keys())
            ents = ['Run all tests and examples']
            for k in ['Test', 'Benchmark', 'Example']:
                if mats.get(k):
                    s = 'Run %ss Only' % k
                    ents.append(s)
                    if k == 'Benchmark':
                        args[s] = ['-test.run=none', '-test.bench="%s.*"' % k]
                    else:
                        args[s] = ['-test.run="%s.*"' % k]

            for k in names:
                ents.append(k)
                if k.startswith('Benchmark'):
                    args[k] = ['-test.run=none', '-test.bench="^%s$"' % k]
                else:
                    args[k] = ['-test.run="^%s$"' % k]

            def cb(i, win):
                if i >= 0:
                    a = args.get(ents[i], [])
                    win.active_view().run_command(
                        'gs9o_open', {'run': gs.lst('go', 'test', a)})

            gs.show_quick_panel(ents, cb)
Esempio n. 7
0
        def f(res, err):
            if err:
                gs.notify(DOMAIN, err)
                return

            mats = {}
            args = {}
            decls = res.get("file_decls", [])
            decls.extend(res.get("pkg_decls", []))
            for d in decls:
                name = d["name"]
                prefix, _ = match_prefix_name(name)
                if prefix and d["kind"] == "func" and d["repr"] == "":
                    mats[True] = prefix
                    args[name] = name

            names = sorted(args.keys())
            ents = ["Run all tests and examples"]
            for k in ["Test", "Benchmark", "Example"]:
                if mats.get(k):
                    s = "Run %ss Only" % k
                    ents.append(s)
                    if k == "Benchmark":
                        args[s] = ["-test.run=none", '-test.bench="%s.*"' % k]
                    else:
                        args[s] = ['-test.run="%s.*"' % k]

            for k in names:
                ents.append(k)
                if k.startswith("Benchmark"):
                    args[k] = ["-test.run=none", '-test.bench="^%s$"' % k]
                else:
                    args[k] = ['-test.run="^%s$"' % k]

            def cb(i, win):
                if i >= 0:
                    a = args.get(ents[i], [])
                    win.active_view().run_command("gs9o_open", {"run": gs.lst("go", "test", a)})

            gs.show_quick_panel(ents, cb)
Esempio n. 8
0
def install(aso_tokens, force_install):
	init_start = time.time()

	try:
		os.makedirs(gs.home_path('bin'))
	except:
		pass

	if not force_install and _bins_exist() and aso_tokens == _gen_tokens():
		m0_out = 'no'
		m_out = 'no'
	else:
		gs.notify('GoSublime', 'Installing MarGo0')
		start = time.time()
		m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN], cwd=MARGO0_SRC)
		m0_out, m0_ok = _so(m0_out, err, start, time.time())

		if os.path.exists(MARGO0_BIN):
			margo.bye_ni()

		gs.notify('GoSublime', 'Installing MarGo9')
		start = time.time()
		m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC)
		m_out, m_ok = _so(m_out, err, start, time.time())

		if m_ok and m0_ok:
			def f():
				gs.aso().set('mg9_install_tokens', _gen_tokens())
				gs.save_aso()

			sublime.set_timeout(f, 0)

	gs.notify('GoSublime', 'Syncing environment variables')
	out, err, _ = gsshell.run([MARGO9_EXE, '-env'], cwd=gs.home_path(), shell=True)

	# notify this early so we don't mask any notices below
	gs.notify('GoSublime', 'Ready')

	if err:
		gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err))
	else:
		env, err = gs.json_decode(out, {})
		if err:
			gs.notice(DOMAIN, 'Cannot load env vars: %s\nenv output: %s' % (err, out))
		else:
			gs.environ9.update(env)

	e = gs.env()
	a = (
		'GoSublime init (%0.3fs)' % (time.time() - init_start),
		'| install margo0: %s' % m0_out,
		'| install margo9: %s' % m_out,
		'|           ~bin: %s' % gs.home_path('bin'),
		'|         margo0: %s (%s)' % _tp(MARGO0_BIN),
		'|         margo9: %s (%s)' % _tp(MARGO9_BIN),
		'|         GOROOT: %s' % e.get('GOROOT', '(not set)'),
		'|         GOPATH: %s' % e.get('GOPATH', '(not set)'),
		'|          GOBIN: %s (should usually be (not set))' % e.get('GOBIN', '(not set)'),
	)
	gs.println(*a)

	missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)]
	if missing:
		gs.notice(DOMAIN, "Missing environment variable(s): %s" % ', '.join(missing))

	killSrv()
	start = time.time()
	acall('ping', {}, lambda res, err: gs.println('MarGo Ready %0.3fs' % (time.time() - start)))
Esempio n. 9
0
def install(aso_tokens, force_install):
	k = 'mg9.install.%s' % REV
	if gs.attr(k, False):
		gs.error(DOMAIN, 'Installation aborted. Install command already called for GoSublime %s.' % REV)
		return

	gs.set_attr(k, True)

	init_start = time.time()

	try:
		os.makedirs(gs.home_path('bin'))
	except:
		pass

	if not force_install and _bins_exist() and aso_tokens == _gen_tokens():
		m_out = 'no'
	else:
		gs.notify('GoSublime', 'Installing MarGo')
		start = time.time()
		m_out, err, _ = _run(['go', 'build', '-o', MARGO_BIN], cwd=MARGO_SRC)
		m_out, m_ok = _so(m_out, err, start, time.time())

		if m_ok:
			def f():
				gs.aso().set('mg9_install_tokens', _gen_tokens())
				gs.save_aso()

			sublime.set_timeout(f, 0)

	gs.notify('GoSublime', 'Syncing environment variables')
	out, err, _ = gsshell.run([MARGO_EXE, '-env'], cwd=gs.home_path(), shell=True)

	# notify this early so we don't mask any notices below
	gs.notify('GoSublime', 'Ready')
	_check_changes()

	if err:
		gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO_EXE, err))
	else:
		env, err = gs.json_decode(out, {})
		if err:
			gs.notice(DOMAIN, 'Cannot load env vars: %s\nenv output: %s' % (err, out))
		else:
			gs.environ9.update(env)

	e = gs.env()
	a = [
		'GoSublime init (%0.3fs)' % (time.time() - init_start),
		'| install margo: %s' % m_out,
	]
	a.extend(['| %14s: %s' % ln for ln in _sanity_check(e)])
	gs.println(*a)

	missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)]
	if missing:
		gs.notice(DOMAIN, "Missing environment variable(s): %s" % ', '.join(missing))

	killSrv()
	start = time.time()
	# acall('ping', {}, lambda res, err: gs.println('MarGo Ready %0.3fs' % (time.time() - start)))

	report_x = lambda: gs.println("GoSublime: Exception while cleaning up old binaries", gs.traceback())
	try:
		d = gs.home_path('bin')
		for fn in os.listdir(d):
			try:
				if fn != MARGO_EXE and fn.startswith(('gosublime', 'gocode', 'margo')):
					fn = os.path.join(d, fn)
					gs.println("GoSublime: removing old binary: %s" % fn)
					os.remove(fn)
			except Exception:
				report_x()
	except Exception:
		report_x()

	gsq.launch(DOMAIN, margo.bye_ni)
Esempio n. 10
0
def install(aso_tokens, force_install):
    init_start = time.time()

    try:
        os.makedirs(gs.home_path('bin'))
    except:
        pass

    if not force_install and _bins_exist() and aso_tokens == _gen_tokens():
        m0_out = 'no'
        m_out = 'no'
    else:
        gs.notify('GoSublime', 'Installing MarGo0')
        start = time.time()
        m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN],
                              cwd=MARGO0_SRC)
        m0_out, m0_ok = _so(m0_out, err, start, time.time())

        if os.path.exists(MARGO0_BIN):
            margo.bye_ni()

        gs.notify('GoSublime', 'Installing MarGo9')
        start = time.time()
        m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC)
        m_out, m_ok = _so(m_out, err, start, time.time())

        if m_ok and m0_ok:

            def f():
                gs.aso().set('mg9_install_tokens', _gen_tokens())
                gs.save_aso()

            sublime.set_timeout(f, 0)

    gs.notify('GoSublime', 'Syncing environment variables')
    out, err, _ = gsshell.run([MARGO9_EXE, '-env'],
                              cwd=gs.home_path(),
                              shell=True)

    # notify this early so we don't mask any notices below
    gs.notify('GoSublime', 'Ready')

    if err:
        gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err))
    else:
        env, err = gs.json_decode(out, {})
        if err:
            gs.notice(DOMAIN,
                      'Cannot load env vars: %s\nenv output: %s' % (err, out))
        else:
            gs.environ9.update(env)

    e = gs.env()
    a = (
        'GoSublime init (%0.3fs)' % (time.time() - init_start),
        '| install margo0: %s' % m0_out,
        '| install margo9: %s' % m_out,
        '|           ~bin: %s' % gs.home_path('bin'),
        '|         margo0: %s (%s)' % _tp(MARGO0_BIN),
        '|         margo9: %s (%s)' % _tp(MARGO9_BIN),
        '|         GOROOT: %s' % e.get('GOROOT', '(not set)'),
        '|         GOPATH: %s' % e.get('GOPATH', '(not set)'),
        '|          GOBIN: %s (should usually be (not set))' %
        e.get('GOBIN', '(not set)'),
    )
    gs.println(*a)

    missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)]
    if missing:
        gs.notice(DOMAIN,
                  "Missing environment variable(s): %s" % ', '.join(missing))

    killSrv()
    start = time.time()
Esempio n. 11
0
File: mg9.py Progetto: d3z/GoSublime
def install(aso_tokens, force_install):
	k = 'mg9.install.%s' % REV
	if gs.attr(k, False):
		gs.error(DOMAIN, 'Installation aborted. Install command already called for GoSublime %s.' % REV)
		return

	gs.set_attr(k, True)

	init_start = time.time()

	try:
		os.makedirs(gs.home_path('bin'))
	except:
		pass

	if not force_install and _bins_exist() and aso_tokens == _gen_tokens():
		m0_out = 'no'
		m_out = 'no'
	else:
		gs.notify('GoSublime', 'Installing MarGo0')
		start = time.time()
		m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN], cwd=MARGO0_SRC)
		m0_out, m0_ok = _so(m0_out, err, start, time.time())

		if os.path.exists(MARGO0_BIN):
			margo.bye_ni()

		gs.notify('GoSublime', 'Installing MarGo9')
		start = time.time()
		m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC)
		m_out, m_ok = _so(m_out, err, start, time.time())

		if m_ok and m0_ok:
			def f():
				gs.aso().set('mg9_install_tokens', _gen_tokens())
				gs.save_aso()

			sublime.set_timeout(f, 0)

	gs.notify('GoSublime', 'Syncing environment variables')
	out, err, _ = gsshell.run([MARGO9_EXE, '-env'], cwd=gs.home_path(), shell=True)

	# notify this early so we don't mask any notices below
	gs.notify('GoSublime', 'Ready')
	_check_changes()

	if err:
		gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err))
	else:
		env, err = gs.json_decode(out, {})
		if err:
			gs.notice(DOMAIN, 'Cannot load env vars: %s\nenv output: %s' % (err, out))
		else:
			gs.environ9.update(env)

	e = gs.env()
	a = [
		'GoSublime init (%0.3fs)' % (time.time() - init_start),
		'| install margo0: %s' % m0_out,
		'| install margo9: %s' % m_out,
	]
	a.extend(['| %14s: %s' % ln for ln in _sanity_check(e)])
	gs.println(*a)

	missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)]
	if missing:
		gs.notice(DOMAIN, "Missing environment variable(s): %s" % ', '.join(missing))

	killSrv()
	start = time.time()
Esempio n. 12
0
def install(aso_tokens, force_install):
    k = 'mg9.install.%s' % REV
    if gs.attr(k, False):
        gs.error(
            DOMAIN,
            'Installation aborted. Install command already called for GoSublime %s.'
            % REV)
        return

    gs.set_attr(k, True)

    init_start = time.time()

    try:
        os.makedirs(gs.home_path('bin'))
    except:
        pass

    if not force_install and _bins_exist() and aso_tokens == _gen_tokens():
        m0_out = 'no'
        m_out = 'no'
    else:
        gs.notify('GoSublime', 'Installing MarGo0')
        start = time.time()
        m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN],
                              cwd=MARGO0_SRC)
        m0_out, m0_ok = _so(m0_out, err, start, time.time())

        if os.path.exists(MARGO0_BIN):
            margo.bye_ni()

        gs.notify('GoSublime', 'Installing MarGo9')
        start = time.time()
        m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC)
        m_out, m_ok = _so(m_out, err, start, time.time())

        if m_ok and m0_ok:

            def f():
                gs.aso().set('mg9_install_tokens', _gen_tokens())
                gs.save_aso()

            sublime.set_timeout(f, 0)

    gs.notify('GoSublime', 'Syncing environment variables')
    out, err, _ = gsshell.run([MARGO9_EXE, '-env'],
                              cwd=gs.home_path(),
                              shell=True)

    # notify this early so we don't mask any notices below
    gs.notify('GoSublime', 'Ready')
    _check_changes()

    if err:
        gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err))
    else:
        env, err = gs.json_decode(out, {})
        if err:
            gs.notice(DOMAIN,
                      'Cannot load env vars: %s\nenv output: %s' % (err, out))
        else:
            gs.environ9.update(env)

    e = gs.env()
    a = [
        'GoSublime init (%0.3fs)' % (time.time() - init_start),
        '| install margo0: %s' % m0_out,
        '| install margo9: %s' % m_out,
    ]
    a.extend(['| %14s: %s' % ln for ln in _sanity_check(e)])
    gs.println(*a)

    missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)]
    if missing:
        gs.notice(DOMAIN,
                  "Missing environment variable(s): %s" % ', '.join(missing))

    killSrv()
    start = time.time()
Esempio n. 13
0
def install(aso_tokens, force_install):
    k = 'mg9.install.%s' % REV
    if gs.attr(k, False):
        gs.error(
            DOMAIN,
            'Installation aborted. Install command already called for GoSublime %s.'
            % REV)
        return

    gs.set_attr(k, True)

    init_start = time.time()

    try:
        os.makedirs(gs.home_path('bin'))
    except:
        pass

    if not force_install and _bins_exist() and aso_tokens == _gen_tokens():
        m_out = 'no'
    else:
        gs.notify('GoSublime', 'Installing MarGo')
        start = time.time()
        m_out, err, _ = _run(['go', 'build', '-o', MARGO_BIN], cwd=MARGO_SRC)
        m_out, m_ok = _so(m_out, err, start, time.time())

        if m_ok:

            def f():
                gs.aso().set('mg9_install_tokens', _gen_tokens())
                gs.save_aso()

            sublime.set_timeout(f, 0)

    gs.notify('GoSublime', 'Syncing environment variables')
    out, err, _ = gsshell.run([MARGO_EXE, '-env'],
                              cwd=gs.home_path(),
                              shell=True)

    # notify this early so we don't mask any notices below
    gs.notify('GoSublime', 'Ready')
    _check_changes()

    if err:
        gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO_EXE, err))
    else:
        env, err = gs.json_decode(out, {})
        if err:
            gs.notice(DOMAIN,
                      'Cannot load env vars: %s\nenv output: %s' % (err, out))
        else:
            gs.environ9.update(env)

    e = gs.env()
    a = [
        'GoSublime init (%0.3fs)' % (time.time() - init_start),
        '| install margo: %s' % m_out,
    ]
    a.extend(['| %14s: %s' % ln for ln in _sanity_check(e)])
    gs.println(*a)

    missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)]
    if missing:
        gs.notice(DOMAIN,
                  "Missing environment variable(s): %s" % ', '.join(missing))

    killSrv()
    start = time.time()
    # acall('ping', {}, lambda res, err: gs.println('MarGo Ready %0.3fs' % (time.time() - start)))

    report_x = lambda: gs.println(
        "GoSublime: Exception while cleaning up old binaries", gs.traceback())
    try:
        d = gs.home_path('bin')
        for fn in os.listdir(d):
            try:
                if fn != MARGO_EXE and fn.startswith(
                    ('gosublime', 'gocode', 'margo')):
                    fn = os.path.join(d, fn)
                    gs.println("GoSublime: removing old binary: %s" % fn)
                    os.remove(fn)
            except Exception:
                report_x()
    except Exception:
        report_x()

    gsq.launch(DOMAIN, margo.bye_ni)
Esempio n. 14
0
def install(aso_tokens, force_install):
    k = "mg9.install.%s" % REV
    if gs.attr(k, False):
        gs.error(DOMAIN, "Installation aborted. Install command already called for GoSublime %s." % REV)
        return

    gs.set_attr(k, True)

    init_start = time.time()

    try:
        os.makedirs(gs.home_path("bin"))
    except:
        pass

    if not force_install and _bins_exist() and aso_tokens == _gen_tokens():
        m0_out = "no"
        m_out = "no"
    else:
        gs.notify("GoSublime", "Installing MarGo0")
        start = time.time()
        m0_out, err, _ = _run(["go", "build", "-o", MARGO0_BIN], cwd=MARGO0_SRC)
        m0_out, m0_ok = _so(m0_out, err, start, time.time())

        if os.path.exists(MARGO0_BIN):
            margo.bye_ni()

        gs.notify("GoSublime", "Installing MarGo9")
        start = time.time()
        m_out, err, _ = _run(["go", "build", "-o", MARGO9_BIN], cwd=MARGO9_SRC)
        m_out, m_ok = _so(m_out, err, start, time.time())

        if m_ok and m0_ok:

            def f():
                gs.aso().set("mg9_install_tokens", _gen_tokens())
                gs.save_aso()

            sublime.set_timeout(f, 0)

    gs.notify("GoSublime", "Syncing environment variables")
    out, err, _ = gsshell.run([MARGO9_EXE, "-env"], cwd=gs.home_path(), shell=True)

    # notify this early so we don't mask any notices below
    gs.notify("GoSublime", "Ready")
    _check_changes()

    if err:
        gs.notice(DOMAIN, "Cannot run get env vars: %s" % (MARGO9_EXE, err))
    else:
        env, err = gs.json_decode(out, {})
        if err:
            gs.notice(DOMAIN, "Cannot load env vars: %s\nenv output: %s" % (err, out))
        else:
            gs.environ9.update(env)

    e = gs.env()
    a = [
        "GoSublime init (%0.3fs)" % (time.time() - init_start),
        "| install margo0: %s" % m0_out,
        "| install margo9: %s" % m_out,
    ]
    a.extend(["| %14s: %s" % ln for ln in _sanity_check(e)])
    gs.println(*a)

    missing = [k for k in ("GOROOT", "GOPATH") if not e.get(k)]
    if missing:
        gs.notice(DOMAIN, "Missing environment variable(s): %s" % ", ".join(missing))

    killSrv()
    start = time.time()
    # acall('ping', {}, lambda res, err: gs.println('MarGo Ready %0.3fs' % (time.time() - start)))

    report_x = lambda: gs.println("GoSublime: Exception while cleaning up old binaries", gs.traceback())
    try:
        d = gs.home_path("bin")
        for fn in os.listdir(d):
            try:
                if fn not in (MARGO9_EXE, MARGO0_EXE) and fn.startswith(("gosublime", "gocode", "margo")):
                    fn = os.path.join(d, fn)
                    gs.println("GoSublime: removing old binary: %s" % fn)
                    os.remove(fn)
            except Exception:
                report_x()
    except Exception:
        report_x()