> Guess by "even if it wasn't" you mean "even if it wasn't top level and 
was exporting functionality"

I think he means in general, you can do this:

// go.mod says "module github.com/my/module/with-a-very-weird-name"
package foo
...

and when you import it, you still get a package "foo".  That's unless you 
rename at import time, e.g.
import (
    bar "github.com/my/module/with-a-very-weird-name"
)

Here's a complete example.  To test, cd into pkg1 then do "go mod tidy && 
go run ."  Note that package foo (in directory pkg2) *is* top level and 
*is* exporting functionality.  

==> pkg1/go.mod <==
module example.com/myprog

go 1.16

replace example.com/my/module/with-a-very-weird-name => ../pkg2

require example.com/my/module/with-a-very-weird-name 
v0.0.0-00010101000000-000000000000

==> pkg1/main.go <==
package main

import (
    "example.com/my/module/with-a-very-weird-name"
    "fmt"
)

func main() {
    fmt.Println(foo.Greeting)
}

==> pkg2/go.mod <==
module example.com/my/module/with-a-very-weird-name

go 1.16

==> pkg2/main.go <==
package foo
var Greeting = "Hello world"

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/215b42bc-58ee-469e-a2e3-b6970ffaac98n%40googlegroups.com.

Reply via email to