Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/pkgsite: Code Block should show line numbers #56372

Open
valaparthvi opened this issue Oct 21, 2022 · 0 comments
Open

x/pkgsite: Code Block should show line numbers #56372

valaparthvi opened this issue Oct 21, 2022 · 0 comments
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done. pkgsite

Comments

@valaparthvi
Copy link

What is the URL of the page with the issue?

Example: https://pkg.go.dev/golang.org/x/sync/errgroup#Group.Wait

What is your user agent?

Mozilla/5.0 (X11; Linux x86_64; rv:105.0) Gecko/20100101 Firefox/105.0

Screenshot

Screenshot from 2022-10-21 17-52-28

What did you do?

Modify the example code, in this case, it was a bad code and panicked.

package main

import (
	"fmt"
	"net/http"

	"golang.org/x/sync/errgroup"
)

func main() {
	g := new(errgroup.Group)
	var urls = []string{
		"http://www.golang.org/",
		"http://www.google.com/",
		"http://www.somestupidname.com/",
	}
	for _, url := range urls {
		// Launch a goroutine to fetch the URL.
		url := url // https://golang.org/doc/faq#closures_and_goroutines
		g.Go(func() error {
			// Fetch the URL.
			resp, err := http.Get(url)
			if err != nil {
				fmt.Println("error encountered")
				resp.Body.Close()
				return nil
			}
			fmt.Println("ignoring error if any")
			resp.Body.Close()
			return nil
		})
	}
	// Wait for all HTTP fetches to complete.
	if err := g.Wait(); err == nil {
		fmt.Println("Successfully fetched all URLs.")
	}
}

What did you expect to see?

Error message

Output:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x61cb7a]

goroutine 7 [running]:
main.main.func1()
	/tmp/sandbox1760300329/prog.go:25 +0x7a
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/tmp/gopath4274196458/pkg/mod/golang.org/x/sync@v0.1.0/errgroup/errgroup.go:75 +0x64
created by golang.org/x/sync/errgroup.(*Group).Go
	/tmp/gopath4274196458/pkg/mod/golang.org/x/sync@v0.1.0/errgroup/errgroup.go:72 +0xa5

It tells the line on which error occurred. But the code is not numbered, and hence it is difficult to determine the code line that threw error.

It would be helpful if the code blocks were numbered.

What did you see instead?

@gopherbot gopherbot added this to the Unreleased milestone Oct 21, 2022
@dle8 dle8 modified the milestones: Unreleased, pkgsite/unplanned Oct 24, 2022
@dle8 dle8 self-assigned this Oct 27, 2022
@jamalc jamalc added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. pkgsite
Projects
None yet
Development

No branches or pull requests

4 participants