> But the go101.org is not intended to serve any code repository.
> This is why I use the replace line in go.mod.

If go101.org will never resolve the custom import path (giving meta
information, as indicated at
https://golang.org/cmd/go/#hdr-Remote_import_paths), then why make
this the module path? Because anyone who uses the import path will
always have to add a replace. Why not make the module path
github.com/... in the first place? The replace directive is an
extremely inefficient alternative to custom import meta information.

> So my package import path must be locked as "github.com/...." if go101.org 
> doesn't provide the repository meta?
> If this is true, I feel the go 1.11 module feature is not much useful.

Your example was almost there; you need a require statement, else when
the go tool encounters the go101.org/tinrouter import path it will try
to resolve that via custom import path resolution:

$ go version
go version go1.11.2 linux/amd64
$ cd $(mktemp -d)
$ go mod init blah
go: creating new go.mod: module blah
$ cat <<EOD >main.go
package main

import (
    _ "go101.org/tinyrouter"
)

func main() {
}
EOD
$ go mod edit -require=go101.org/tinyrouter@v1.0.0
-replace=go101.org/tinyrouter=github.com/go101/tinyrouter@v1.0.0
$ cat go.mod
module blah

require go101.org/tinyrouter v1.0.0

replace go101.org/tinyrouter => github.com/go101/tinyrouter v1.0.0
$ go mod tidy
go: finding github.com/go101/tinyrouter v1.0.0
go: finding github.com/gorilla/mux v1.6.2
go: finding github.com/julienschmidt/httprouter
v0.0.0-20180715161854-348b672cd90d
...
$ cat go.mod
module blah

require (
        github.com/davecgh/go-spew v1.1.1 // indirect
        github.com/dimfeld/httptreemux v5.0.1+incompatible // indirect
        github.com/gorilla/context v1.1.1 // indirect
        github.com/pmezard/go-difflib v1.0.0 // indirect
        github.com/stretchr/testify v1.2.2 // indirect
        go101.org/tinyrouter v1.0.0
)

replace go101.org/tinyrouter => github.com/go101/tinyrouter v1.0.0
$ go build

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to