Skip to content

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

Closed
@lelvisl

Description

@lelvisl

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 Importable୦ int
//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())
	
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions