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

debug/gosym: PackageName and ReceiverName return wrong value for remote packages #15675

Closed
sean-jc opened this issue May 13, 2016 · 1 comment

Comments

@sean-jc
Copy link
Contributor

sean-jc commented May 13, 2016

Sym.PackageName() and Sym.ReceiverName() fail to account for dots in the URL of remote packages and naively split on the first dot encountered. This results in the calculated package name being truncated to just the domain of the URL. This can be fixed by treating everything before the last forward slash as being part of the package.

go1.6.2 linux/amd64

https://play.golang.org/p/fvvxbm1Ilm

package main

import (
    "debug/gosym"
    "fmt"
)

func main() {
    s := gosym.Sym{Name: "github.com/docker/docker/pkg/mflag.(*FlagSet).PrintDefaults"}
    fmt.Printf("Package  Expected: 'github.com/docker/docker/pkg/mflag'  Actual: '%s'\n", s.PackageName())
    fmt.Printf("Receiver Expected: '(*FlagSet)'  Actual: '%s'\n\n", s.ReceiverName())

    s = gosym.Sym{Name: "github.com/docker/docker/pkg/mflag.PrintDefaults"}
    fmt.Printf("Package  Expected: 'github.com/docker/docker/pkg/mflag'  Actual: '%s'\n", s.PackageName())
    fmt.Printf("Receiver Expected: ''  Actual: '%s'\n", s.ReceiverName())
}
Package  Expected: 'github.com/docker/docker/pkg/mflag'  Actual: 'github'
Receiver Expected: '(*FlagSet)'  Actual: 'com/docker/docker/pkg/mflag.(*FlagSet)'

Package  Expected: 'github.com/docker/docker/pkg/mflag'  Actual: 'github'
Receiver Expected: ''  Actual: 'com/docker/docker/pkg/mflag'
@gopherbot
Copy link

CL https://golang.org/cl/23086 mentions this issue.

@rsc rsc changed the title debug/gosym: PackageName() and ReceiverName() return wrong value for remote packages debug/gosym: PackageName and ReceiverName return wrong value for remote packages May 17, 2016
@golang golang locked and limited conversation to collaborators May 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants