I
I
Ilya2021-05-16 21:40:15
go
Ilya, 2021-05-16 21:40:15

How to create a global module from a package with go.mod?

It is assumed that I create a folder in C:\Users\...\go\src\github.com\myname\slices, for example, for convenient work with slices. I am writing a package package slices, and now I want to use it globally in any code of my repository github.com\myname\...
. I know that you need to initialize it first and then register it in the folder with the code that imports it

go mod init
go mod edit -replace github.com\myname\slices=C:\Users\...\go\src\github.com\myname\slices
go mod tidy

But, why can't I just access my local code repository via github.com\myname\slicesglobally and without pandemonium?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question