1

Hello I have a module module github.com/foo/bar.

There is the following structure:

project/
    go.mod
    lib.go
    lib_test.go
    folder/
        subfolder/
            requires_lib.go
            requires_lib_test.go

and the file requires_lib.go has the following header:

package subfolder

import "github.com/foo/bar/lib"

but the file github.com/foo/bar/lib/ is not yet pushed, because its a prototype

When launching tests, it tries to resolve that dependency and obviously fails.

Do I have to update the master branch whenever I want to make a change in this file? Even if its present in the file system and I want to actually use the one in the filesystem

Is there any alternative?

Take into account that is another package in the same module what I want to import.

Thanks.

Jorge Lavín
  • 937
  • 8
  • 22
  • the closest i could find is https://stackoverflow.com/questions/64295033/import-local-package-thats-already-in-public-repo –  Dec 04 '20 at 10:48
  • se also https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/ –  Dec 04 '20 at 10:49
  • Its the same module but a different package. – Jorge Lavín Dec 04 '20 at 10:50
  • 1
    Code from the current module is _never_ fetched from the network. There si nothing to do and nothing to worry about. Just try it out. It works. – Volker Dec 04 '20 at 10:52
  • I've tried `module github.com/foo/bar replace github.com/foo/bar => ./ ` in `go.mod` but i can't make it work. – Jorge Lavín Dec 04 '20 at 10:57
  • someting is wrong in your description. In the file graph you have shared, there is only one module. –  Dec 04 '20 at 10:59
  • 2
    `Take into account that is another package in the same module what I want to import.` then there is nothing to download –  Dec 04 '20 at 11:00
  • Adding a replace directive for the current module is wrong. – Volker Dec 04 '20 at 12:00

0 Answers0