Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Fix #564 - util should not be imported from the debug adapter! (#576)
Browse files Browse the repository at this point in the history
* Fix #564 - util should not be imported from the debug adapter!

* Add warning to goPath.ts
  • Loading branch information
roblourens authored and ramya-rao-a committed Oct 27, 2016
1 parent 30fe13e commit 73460e0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
9 changes: 6 additions & 3 deletions src/goPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SemVersion> {
Expand Down Expand Up @@ -161,7 +161,3 @@ export function isVendorSupported(): Promise<boolean> {
return vendorSupport;
});
}

export function random(low: number, high: number): number {
return Math.floor(Math.random() * (high - low) + low);
}

0 comments on commit 73460e0

Please sign in to comment.