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

what the help man ? #37435

Closed
Darkells opened this issue Feb 25, 2020 · 3 comments
Closed

what the help man ? #37435

Darkells opened this issue Feb 25, 2020 · 3 comments

Comments

@Darkells
Copy link

I am very angry, my project boase on go module.
Now golang is 1.13.5
Why can't I import a local package

i just test simple ,
tree

  • com.dark.fish
    • util
      • Util.go
  • main.go

cannot find module providing package com.dark.fish/util/Util

GO111MODULE="auto"
Why?

@hnishi
Copy link

hnishi commented Feb 25, 2020

I think you should use the replace directive.

replace com.dark.fish/util/Util => ./com.dark.fish/util

https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive

@mattn
Copy link
Member

mattn commented Feb 25, 2020

@Darkells As @hnishi mentioned, you need to use replace directive.

$ mkdir foo
$ cd foo
$ cat > main.go
package main

import (
	"com.dark.fish/util"
)

func main() {
	util.DoSomething()
}
^D

$ cat > go.mod
module foo

replace com.dark.fish/util => ./com.dark.fish/util
^D

$ pushd .
$ mkdir -p com.dark.fish/util
$ cd com.dark.fish.util
$ cat > Util.go
package util

func DoSomething() {
	println("do something")
}
^D

$ go mod init com.dark.fish/util
$ popd
$ go build
$ ./foo

This is issue tracker of Go. Please ask like this on golang-nuts or somewhere.

@mvdan
Copy link
Member

mvdan commented Feb 25, 2020

Like @mattn said, this is not the place to ask questions.

@mvdan mvdan closed this as completed Feb 25, 2020
@golang golang locked and limited conversation to collaborators Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants