Skip to content

godebug does not work with code that imports net/http (since go 1.6) #88

@athirn

Description

@athirn

whenever I import net/http, I get all sorts of errors when I try and run godebug. The same code works fine when I build and run it with go directly.

Here is a simple example app and the output of go debug....

$cat main.go
package main

import (
    "net/http"
)

func HandleIndex(w http.ResponseWriter, r *http.Request) {
    // io.WriteString(w, "hello, world\n")
}

func main() {

    _ = "breakpoint"

    http.HandleFunc("/", HandleIndex)

}
$godebug run main.go
/usr/local/go/src/net/interface_bsd.go:12:2: could not import golang_org/x/net/route (cannot find package "golang_org/x/net/route" in any of:
    /usr/local/go/src/golang_org/x/net/route (from $GOROOT)
    /Users/anuaimi/code/go/src/golang_org/x/net/route (from $GOPATH))
/usr/local/go/src/net/interface_darwin.go:10:2: could not import golang_org/x/net/route (cannot find package "golang_org/x/net/route" in any of:
    /usr/local/go/src/golang_org/x/net/route (from $GOROOT)
    /Users/anuaimi/code/go/src/golang_org/x/net/route (from $GOPATH))
/usr/local/go/src/net/interface_darwin.go:13:40: undeclared name: route
/usr/local/go/src/net/interface_darwin.go:14:14: undeclared name: route
/usr/local/go/src/net/interface_darwin.go:18:9: undeclared name: route
/usr/local/go/src/net/interface_darwin.go:24:14: undeclared name: route
/usr/local/go/src/net/interface_darwin.go:28:15: undeclared name: route
/usr/local/go/src/net/http/h2_bundle.go:45:2: could not import golang_org/x/net/http2/hpack (cannot find package "golang_org/x/net/http2/hpack" in any of:
    /usr/local/go/src/golang_org/x/net/http2/hpack (from $GOROOT)
    /Users/anuaimi/code/go/src/golang_org/x/net/http2/hpack (from $GOPATH))
/usr/local/go/src/net/http/h2_bundle.go:46:2: could not import golang_org/x/net/lex/httplex (cannot find package "golang_org/x/net/lex/httplex" in any of:
    /usr/local/go/src/golang_org/x/net/lex/httplex (from $GOROOT)
    /Users/anuaimi/code/go/src/golang_org/x/net/lex/httplex (from $GOPATH))
/usr/local/go/src/net/http/http.go:10:2: could not import golang_org/x/net/lex/httplex (cannot find package "golang_org/x/net/lex/httplex" in any of:
    /usr/local/go/src/golang_org/x/net/lex/httplex (from $GOROOT)
    /Users/anuaimi/code/go/src/golang_org/x/net/lex/httplex (from $GOPATH))
/usr/local/go/src/net/http/server.go:31:2: could not import golang_org/x/net/lex/httplex (cannot find package "golang_org/x/net/lex/httplex" in any of:
    /usr/local/go/src/golang_org/x/net/lex/httplex (from $GOROOT)
    /Users/anuaimi/code/go/src/golang_org/x/net/lex/httplex (from $GOPATH))
/usr/local/go/src/net/http/transfer.go:21:2: could not import golang_org/x/net/lex/httplex (cannot find package "golang_org/x/net/lex/httplex" in any of:
    /usr/local/go/src/golang_org/x/net/lex/httplex (from $GOROOT)
    /Users/anuaimi/code/go/src/golang_org/x/net/lex/httplex (from $GOPATH))
/usr/local/go/src/net/http/transport.go:30:2: could not import golang_org/x/net/lex/httplex (cannot find package "golang_org/x/net/lex/httplex" in any of:
    /usr/local/go/src/golang_org/x/net/lex/httplex (from $GOROOT)
    /Users/anuaimi/code/go/src/golang_org/x/net/lex/httplex (from $GOPATH))
/usr/local/go/src/net/http/h2_bundle.go:848:19: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:1827:11: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:1851:52: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:1862:51: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:5020:11: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:6735:20: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:3131:18: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:3187:46: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:6834:22: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:6926:30: undeclared name: hpack
/usr/local/go/src/net/http/transport.go:323:8: undeclared name: httplex
/usr/local/go/src/net/http/transport.go:327:9: undeclared name: httplex
/usr/local/go/src/net/http/h2_bundle.go:5287:26: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:5290:12: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:6659:4: undeclared name: httplex
/usr/local/go/src/net/http/h2_bundle.go:1920:2: invalid operation: hdec (variable of type *invalid type) has no field or method SetEmitEnabled
/usr/local/go/src/net/http/h2_bundle.go:1921:2: invalid operation: hdec (variable of type *invalid type) has no field or method SetMaxStringLength
/usr/local/go/src/net/http/h2_bundle.go:1922:2: invalid operation: hdec (variable of type *invalid type) has no field or method SetEmitFunc
/usr/local/go/src/net/http/h2_bundle.go:1922:27: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:1926:7: undeclared name: httplex
/usr/local/go/src/net/http/h2_bundle.go:1942:4: invalid operation: hdec (variable of type *invalid type) has no field or method SetEmitEnabled
/usr/local/go/src/net/http/h2_bundle.go:1948:4: invalid operation: hdec (variable of type *invalid type) has no field or method SetEmitEnabled
/usr/local/go/src/net/http/h2_bundle.go:1957:8: invalid operation: hdec (variable of type *invalid type) has no field or method SetEmitFunc
/usr/local/go/src/net/http/h2_bundle.go:1957:33: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:1962:16: invalid operation: hdec (variable of type *invalid type) has no field or method Write
/usr/local/go/src/net/http/h2_bundle.go:1979:12: invalid operation: hdec (variable of type *invalid type) has no field or method Close
/usr/local/go/src/net/http/h2_bundle.go:5797:7: undeclared name: httplex
/usr/local/go/src/net/http/h2_bundle.go:5801:8: undeclared name: httplex
/usr/local/go/src/net/http/h2_bundle.go:5892:2: invalid operation: cc.henc (variable of type *invalid type) has no field or method WriteField
/usr/local/go/src/net/http/h2_bundle.go:5892:21: undeclared name: hpack
/usr/local/go/src/net/http/server.go:789:25: undeclared name: httplex
/usr/local/go/src/net/http/server.go:793:7: undeclared name: httplex
/usr/local/go/src/net/http/server.go:797:8: undeclared name: httplex
/usr/local/go/src/net/http/h2_bundle.go:2517:7: undeclared name: httplex
/usr/local/go/src/net/http/h2_bundle.go:3042:20: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:3045:23: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:3899:3: invalid operation: sc.hpackEncoder (variable of type *invalid type) has no field or method SetMaxDynamicTableSize
/usr/local/go/src/net/http/h2_bundle.go:6711:22: undeclared name: httplex
/usr/local/go/src/net/http/h2_bundle.go:6838:2: invalid operation: enc (variable of type *invalid type) has no field or method WriteField
/usr/local/go/src/net/http/h2_bundle.go:6838:17: undeclared name: hpack
/usr/local/go/src/net/http/h2_bundle.go:6942:8: undeclared name: httplex
/usr/local/go/src/net/http/http.go:42:10: undeclared name: httplex
/usr/local/go/src/net/http/transfer.go:566:14: undeclared name: httplex
/usr/local/go/src/net/http/transfer.go:568:23: undeclared name: httplex
couldn't load packages due to errors: net/http, net

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions