$ go mod edit -replace example.com/greetings=../greetings
$ go mod init example.com/hello
go: creating new go.mod: module example.com/hello
module example.com/hello
go 1.16
replace example.com/greetings => ../greetings
require example.com/greetings v0.0.0-00010101000000-000000000000
module example.com/hello
go 1.16
replace example.com/greetings => ../greetings
$ go run .
Hi, Gladys. Welcome!
require example.com/greetings v1.1.0
cd ..
mkdir hello
cd hello
package main
import (
"fmt"
"example.com/greetings"
)
func main() {
// Get a greeting message and print it.
message := greetings.Hello("Gladys")
fmt.Println(message)
}
$ go mod tidy
go: found example.com/greetings in example.com/greetings v0.0.0-00010101000000-000000000000
<home>/
|-- greetings/
|-- hello/
Recommend
Go Call your code from another module
Go Compile and install the application
Go Return greetings for multiple people
Tutorial: Get started with Go Call code in an external package
Tutorial: Get started with Go Write some code
Go Tutorial: Getting started with fuzzing Completed code
Go Tutorial: Getting started with fuzzing Fix the double reverse error Fix the error Run the code
Go Tutorial: Getting started with fuzzing Fix the double reverse error Fix the error Write the code
Go Tutorial: Getting started with fuzzing Fix the invalid string error Fix the error Run the code
Go Tutorial: Getting started with fuzzing Fix the invalid string error Fix the error Write the code
Go Tutorial: Getting started with fuzzing Fix the invalid string error Diagnose the error
Go Tutorial: Getting started with fuzzing Add a fuzz test Run the code
Go Tutorial: Getting started with fuzzing Add a fuzz test Write the code
Go Tutorial: Getting started with fuzzing Add a unit test Run the code
Go Tutorial: Getting started with fuzzing Add a unit test Write the code
Go Tutorial: Getting started with fuzzing Add code to test Run the code
Go Tutorial: Getting started with fuzzing Add code to test Write the code
Go Tutorial: Getting started with fuzzing Create a folder for your code
Tutorial: Create a Go module Start a module that others can use
Go Tutorial: Getting started with multi-module workspaces Create a module for your code
Tutorial: Developing a RESTful API with Go and Gin Completed code
Tutorial: Developing a RESTful API with Go and Gin Write a handler to add a new item Run the code
Tutorial: Developing a RESTful API with Go and Gin Write a handler to add a new item Write the code