I have package a, which relies on an external package, language package:
package a
import (
"fmt"
"golang.org/x/text/language"
)
// Machine is a printer
type Machine struct{}
// Printer prints
type Printer interface {
Print(lang language.Tag)
}
// Print prints the language
func (p *Machine) Print(l language.Tag) {
fmt.Println(l.String())
}
For package a, I've run "dep init" and then "dep ensure".
In another package, I have a main.go file, which imports package a:
package main
import (
"testing/a"
"golang.org/x/text/language"
)
func main() {
m := a.Machine{}
m.Print(language.MustParse("en"))
}
I get an error:
cannot use "golang.org/x/text/language".MustParse("en") (type "golang.org/x/text/language".Tag) as type "testing/a/vendor/golang.org/x/text/language".Tag in argument to m.Print
If I put the main package in package a, it works fine. Why won't it work when calling from an external package?
Go version is 1.10.2
EDIT: i have full control over package a, so I can change the way I vendor things there. I can also upgrade my Go version if there is an easy fix with a newer Go version.
UPDATE: I've upgraded to Go 1.12.1 and have removed the existing vendor directory. I ran "go mod init" and "go mod vendor" for package a but still get the same error when I run main.go in package b.
cannot use "testing/b/vendor/golang.org/x/text/language".MustParse("en") (type "testing/b/vendor/golang.org/x/text/language".Tag) as type "testing/a/vendor/golang.org/x/text/language".Tag in argument to m.Print
If I try to import the vendored package directly from package a I get:
use of vendored package not allowed