From 25710e72adea47e5bf9d2396718b875563374264 Mon Sep 17 00:00:00 2001 From: roblou Date: Wed, 26 Oct 2016 22:26:57 -0700 Subject: [PATCH 1/2] Fix #564 - util should not be imported from the debug adapter! --- src/debugAdapter/goDebug.ts | 5 ++++- src/util.ts | 6 +----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 102304e90..8d7d170f5 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -10,7 +10,6 @@ import { basename, dirname } from 'path'; import { spawn, ChildProcess } from 'child_process'; import { Client, RPCConnection } from 'json-rpc2'; import { getBinPath } from '../goPath'; -import {random} from './../util'; require('console-stamp')(console); @@ -709,4 +708,8 @@ class GoDebugSession extends DebugSession { } } +function random(low: number, high: number): number { + return Math.floor(Math.random() * (high - low) + low); +} + DebugSession.run(GoDebugSession); diff --git a/src/util.ts b/src/util.ts index c66a4de30..2c19eebd1 100644 --- a/src/util.ts +++ b/src/util.ts @@ -107,7 +107,7 @@ export function canonicalizeGOPATHPrefix(filename: string): string { } /** - * Gets version of Go based on the output of the command `go version`. + * Gets version of Go based on the output of the command `go version`. * Returns null if go is being used from source/tip in which case `go version` will not return release tag like go1.6.3 */ export function getGoVersion(): Promise { @@ -161,7 +161,3 @@ export function isVendorSupported(): Promise { return vendorSupport; }); } - -export function random(low: number, high: number): number { - return Math.floor(Math.random() * (high - low) + low); -} From d2103c793dfd042da198b82d5892f123439c2c72 Mon Sep 17 00:00:00 2001 From: roblou Date: Wed, 26 Oct 2016 22:29:14 -0700 Subject: [PATCH 2/2] Add warning to goPath.ts --- src/goPath.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/goPath.ts b/src/goPath.ts index 94ca8e2a0..f4be592f4 100644 --- a/src/goPath.ts +++ b/src/goPath.ts @@ -5,6 +5,9 @@ 'use strict'; +/** + * This file is loaded by both the extension and debug adapter, so it cannot import 'vscode' + */ import fs = require('fs'); import path = require('path'); import os = require('os'); @@ -48,7 +51,7 @@ export function getBinPath(binname: string) { return pathFromGoRoot; } - // Else return the binary name directly (this will likely always fail downstream) + // Else return the binary name directly (this will likely always fail downstream) return binname; } @@ -61,8 +64,8 @@ function correctBinname(binname: string) { /** * Returns Go runtime binary path. - * - * @return the path to the Go binary. + * + * @return the path to the Go binary. */ export function getGoRuntimePath(): string { if (runtimePathCache !== 'go') return runtimePathCache;