d4l3k/go-pry

import "runtime" causes "too many errors"

mmullis opened this issue · 2 comments

Adding import for "runtime" causes too many errors.

Source Code:

package main

import "runtime"
import "github.com/d4l3k/go-pry/pry"

func main() {
  a := 1
  pry.Pry()
}

Result: (note: the undefined runtime.* changes each time)

 # command-line-arguments
./main.go:8: undefined: runtime.REG_RDI
./main.go:8: undefined: runtime.REG_R9
./main.go:8: undefined: runtime.REG_DS
./main.go:8: undefined: runtime.REG_CS
./main.go:8: undefined: runtime.REG_RSI
./main.go:8: undefined: runtime.REG_RCX
./main.go:8: undefined: runtime.REG_R11
./main.go:8: undefined: runtime.REG_RBX
./main.go:8: undefined: runtime.REG_RAX
./main.go:8: undefined: runtime.REG_GS
./main.go:8: too many errors
Reverting files
d4l3k commented

That's likely caused by different build tags being used in the runtime package since those look like platform specific registers.

It probably randomizes since it's generated via map iteration which is pseudo random.

Looks good. Thanks!
Couldn't quite figure out how to make a correct test case so here's a manual test session for reference:

    10: func main() {
    11:   goos := runtime.GOOS
    12:   goarch := runtime.GOARCH
    13:   maxprocs := runtime.GOMAXPROCS(0)
    14:   fmt.Println("%s %s %d",goos, goarch, maxprocs)
 => 15:   pry.Pry()
    16:   fmt.Println("Done?")
    17: }
    18: 

[17] go-pry> goos 
=> "darwin"
[1] go-pry> goarch 
=> "amd64"
[2] go-pry> maxprocs 
=> 8
[3] go-pry> runtime.GOROOT() 
=> "/usr/local/Cellar/go/1.8.3/libexec"
[4] go-pry> runtime.GOMAXPROCS(1) 
=> 8
[21] go-pry> runtime.GOMAXPROCS(0) 
=> 1