Are runnable examples supported for pkgsite locally?

97 Views Asked by At

I have the following "whole file" example that works locally without issue:

func Example_should_be_runnable() {
    o := bytes.NewBufferString("")

    // RootCmd() just wraps &cobra.Command
    cmd := RootCmd()
    cmd.SetOut(o)
    cmd.SetArgs([]string{"--myarg=blah"})

    err := cmd.Execute()
    if err != nil {
        fmt.Println(err)
    }

    fmt.Println(o)
    // Output:
  // expected_output
}

But when I spin up pkgsite locally and run the example on the webpage I see this error:

go: github.com/me/[email protected]: reading https://proxy.golang.org/github.com/me/myproj/@v/v0.0.0.mod: 404 Not Found
    server response:
    not found: github.com/me/[email protected]: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/177f425a899fd5149a7c1317bd8fa47cefb9929d4ba6abf74aad8c54d873f458: exit status 128:
        fatal: could not read Username for 'https://github.com': terminal prompts disabled
    Confirm the import path was entered correctly.
    If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.

I'm trying to figure out whats happening, but I'm confused about what pkgsite is trying to do.

Is it trying to fetch my package from the public https://proxy.golang.org when running the example? Is that a bug/issue? Because the rest of my GoDoc document links (syntax like [mypackage.PkgExamples] for example) correctly go to http://127.0.0.1:8080/ and work fine.

It shouldn't be going to https://proxy.golang.org at all when running locally right?

0

There are 0 best solutions below