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

cmd/go2go: import package with dot in name #39722

Closed
lelvisl opened this issue Jun 19, 2020 · 3 comments
Closed

cmd/go2go: import package with dot in name #39722

lelvisl opened this issue Jun 19, 2020 · 3 comments

Comments

@lelvisl
Copy link

@lelvisl lelvisl commented Jun 19, 2020

What version of Go are you using (go version)?

$go version devel +6cf535a27b Fri Jun 19 04:37:09 2020 +0000 darwin/amd64


Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOHOSTOS="darwin"

What did you do?

import package with . in name - "github.com/paulmach/go.geojson"

What did you expect to see?

//line main.go2:1
import (
//line main.go2:4
 geojson "github.com/paulmach/go.geojson"
//line main.go2:4
 "fmt"
)

... 

type Importable୦ int
//line main.go2:19
type _ geojson.Feature

//line main.go2:19
var _ = fmt.Errorf


What did you see instead?

//line main.go2:1
import (
//line main.go2:4
 geojson "github.com/paulmach/go.geojson"
//line main.go2:4
 "fmt"
//line main.go2:4
 "github.com/paulmach/go.geojson"
//line main.go2:4
)

... 


type Importableint
//line main.go2:19
type _ geojson.Feature

//line main.go2:19
var _ = fmt.Errorf

//line main.go2:19
type _ go.geojson.Feature

My code

package main
import (
	"fmt"
	geojson "github.com/paulmach/go.geojson"
)

type Stack(type T) []T

func (s Stack(T)) Peek() T {
	return s[len(s)-1]
}

func (s *Stack(T)) Pop() {
	*s = (*s)[:len(*s)-1]
}

func (s *Stack(T)) Push(value T) {
	*s = append(*s, value)
}

type MyObject struct {
    X int
}
func main(){
	var s Stack(MyObject)
	var s2 Stack(int)
	var s3 Stack(string)
	var s4 Stack(*geojson.FeatureCollection)

	rawFeatureJSON := []byte(`
    { "type": "FeatureCollection",
      "features": [
        { "type": "Feature",
          "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
          "properties": {"prop0": "value0"}
        }
      ]
    }`)

    fc1, _ := geojson.UnmarshalFeatureCollection(rawFeatureJSON)
	s4.Push(fc1)
	s2.Push(2)
	s3.Push("kek")
	s.Push(MyObject{11})
	s.Push(MyObject{10})
	s.Pop()
	fmt.Println(s.Peek().X, s2.Peek(), s3.Peek())
	
}
@lelvisl
Copy link
Author

@lelvisl lelvisl commented Jun 19, 2020

go tool go2go run  main.go2          
# command-line-arguments
/var/folders/t3/8cp0ztfj79s_764nbywq3tpc0000gn/T/go2go-run567382554/main.go2:19: syntax error: unexpected go in type declaration
/var/folders/t3/8cp0ztfj79s_764nbywq3tpc0000gn/T/go2go-run567382554/main.go2:4: geojson redeclared as imported package name
	previous declaration at /var/folders/t3/8cp0ztfj79s_764nbywq3tpc0000gn/T/go2go-run567382554/main.go2:4
/Users/elvis/projects/golang/go/bin/go [run main.go] failed: exit status 2
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 20, 2020

Change https://golang.org/cl/239160 mentions this issue: [dev.go2go] go/go2go: get package name from package, not import path

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 20, 2020

Thanks for reporting this. This should now work on the dev.go2go branch.

gopherbot pushed a commit that referenced this issue Jun 20, 2020
No test because the test framework doesn't easily support
package paths containing a dot.

Fixes #39722

Change-Id: If43dc768b28f521d10bd2ef4288aa789aa4bee01
Reviewed-on: https://go-review.googlesource.com/c/go/+/239160
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.