goworkspace

module
v0.0.0-...-ee20070 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2022 License: MIT

README

goworkspace

Tutorial

We want to work on https://github.com/udhos/goworkspace-lib

  1. Test first

Run the app.

$ go run app/main.go 
lib.Modify("fooBAR") => "FOOBAR"
  1. Download module

Point workspace to a local copy of the module.

git clone https://github.com/udhos/goworkspace-lib
go work init goworkspace-lib
$ more go.work
go 1.18

use ./goworkspace-lib
  1. Change the module, replacing ToUpper with ToLower

Edit the function.

vi goworkspace-lib/lib/lib.go
  1. Test again

Run the app.

$ go run app/main.go 
lib.Modify("fooBAR") => "foobar"

Hints

Do NOT commit go.work

Do NOT add go.work to source control, it is intended for local work.

It might be handy to add to .gitignore:

go.work
goworkspace-lib
Enhanced replace directive

go.work supports an enhanced replace directive. Example:

replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5

replace (
    golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5
    golang.org/x/net => example.com/fork/net v1.4.5
    golang.org/x/net v1.2.3 => ./fork/net
    golang.org/x/net => ./fork/net
)

See: https://go.dev/ref/mod#workspaces

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL