Reading https://github.com/rogpeppe/gohack en trying some things, I found 
that 
you *can* tell go.mod that it should use local files instead of a 
repository.

I have a test program outside my `~/go` tree with a `go.mod` like this:

```
module peter.nl/tester

go 1.16

replace github.com/pebbe/package => 
/home/peter/go/src/github.com/pebbe/package
```

Then I run this:
```
go get github.com/pebbe/package
```

Now I can build and run the test program, and when I change anything 
locally in 
`/home/peter/go/src/github.com/pebbe/package` and build the test program 
again,
it reflects the changes made in the package. This is exactly what I need.



Op zaterdag 20 februari 2021 om 13:45:15 UTC+1 schreef ohir:

> Dnia 2021-02-20, o godz. 04:10:38
> Peter Kleiweg <pkle...@xs4all.nl> napisaƂ(a):
>
> > Suppose I am writing a package that is in its own module, and I want
> > to test it. Not with unit tests, but with a larger program that uses
> > other non-standard packages as well.
> [...]
> > How do I get this right?
> > 
> > Is there a way to tell go.mod that it should use local files instead
> > of a repository, just for the development phase?
>
> No. You can not replace *files*. You can use workaround with 
> briliant hack of https://github.com/rogpeppe/gohack
>
> Other hack is to have two or more modules you want to tinker with
> vendored simultaneously to "all interested parties". This can be achieved 
> in Linux as shared mount, on other OS it need to be exact copy.
> It is tedious but works.
>
> Look at https://github.com/golang/go/issues/27542#issue-357818109 and
> https://github.com/golang/go/issues/37755 to get hints about other hacks
> people conceived to be able to work on interdependent code.
>
> Hope this helps, 
>
> -- 
> Wojciech S. Czarnecki
> << ^oo^ >> OHIR-RIPE
>

-- 
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/529fd74b-aad4-4f93-ae19-df9e0a37723dn%40googlegroups.com.

Reply via email to