For example, if you accidentally tag v1.0.0, you can tag v1.0.1 with the following directives:

retract v1.0.0 // Published accidentally.
retract v1.0.1 // Contains retraction only.
For example, if you accidentally tag v1.0.0, you can tag v1.0.1 with the following directives:

retract v1.0.0 // Published accidentally.
retract v1.0.1 // Contains retraction only.
For more, see retract directive in the Go Modules Reference.

retract version // rationale
retract [version-low,version-high] // rationale
Retracting a single version

retract v1.1.0 // Published accidentally.
Retracting a range of versions

retract [v1.0.0,v1.0.5] // Build broken on some platforms.
Note that a replace directive alone does not add a module to the module graph. A require directive that refers to a replaced module version is also needed, either in the main module’s go.mod file or a dependency’s go.mod file. If you don’t have a specific version to replace, you can use a fake version, as in the example below. Note that this will break modules that depend on your module, since replace directives are only applied in the main module.

require example.com/mod v0.0.0-replace

replace example.com/mod v0.0.0-replace => ./mod
You can use the go mod edit command to exclude a module, as in the following example.

go mod edit -exclude=example.com/theirmodule@v1.3.0
For example, if you’re developing in a stringtools directory, your temporary module path might be /stringtools, as in the following example, where company-name is your company’s name:

go mod init <company-name>/stringtools
Go generates a go.mod file when you run the go mod init command. The following example creates a go.mod file, setting the module’s module path to example/mymodule:

$ go mod init example/mymodule
A go.mod file includes directives as shown in the following example. These are described elsewhere in this topic.

module example.com/mymodule

go 1.14

require (
    example.com/othermodule v1.2.3
    example.com/thismodule v1.2.3
    example.com/thatmodule v1.2.3
)

replace example.com/thatmodule => ../thatmodule
exclude example.com/thismodule v1.3.0
For more, see go directive in the Go Modules Reference.

go minimum-go-version

Recommend

Go go.mod file reference retract Example

Go go.mod file reference retract Syntax

Go go.mod file reference exclude Notes

Go go.mod file reference exclude Example

Go go.mod file reference exclude Syntax

Go go.mod file reference replace Notes

Go go.mod file reference replace Examples

Go go.mod file reference replace Syntax

Go go.mod file reference require Syntax

Go go.mod file reference go Syntax

Go go.mod file reference module Notes

Go go.mod file reference module Examples

Go go.mod file reference module Syntax

Go go.mod file reference Example

Go go.mod file reference

Go Publishing a module Publishing steps

Go Developing a major version update Branching for a major release

Go Module release and versioning workflow Publishing breaking API changes

Go Module release and versioning workflow Publishing the first stable version

Go Module release and versioning workflow Publishing the first (unstable) version

Go Module release and versioning workflow Publishing pre-release versions

Go Contribution Guide Miscellaneous topics Sending multiple dependent changes

Go Contribution Guide Miscellaneous topics Set up git aliases

Go Contribution Guide Miscellaneous topics Reviewing code by others

Go Contribution Guide Miscellaneous topics Synchronize your client

Go Contribution Guide Miscellaneous topics Specifying a reviewer / CCing others

Go Contribution Guide Miscellaneous topics Quickly testing your changes

Go Contribution Guide Miscellaneous topics Troubleshooting mail errors

Go Contribution Guide Miscellaneous topics Copyright headers

Contribution Guide Good commit messages

Go Contribution Guide Sending a change via Gerrit Step 5: Revise changes after a review

Go Contribution Guide Sending a change via Gerrit Step 4: Send changes for review

Go Contribution Guide Sending a change via Gerrit Step 3: Test your changes In the golang.org/x/... repositories

Contribution Guide Sending a change via Gerrit Step 3: Test your changes In the main Go repository

Go Contribution Guide Sending a change via Gerrit Step 2: Prepare changes in a new branch

Go Contribution Guide Sending a change via Gerrit Step 1: Clone the source code

Go Contribution Guide Sending a change via Gerrit Overview

Go Contribution Guide Becoming a contributor Step 4: Install the git-codereview command

Contribution Guide Becoming a contributor Step 0: Select a Google Account

Go Contribution Guide Becoming a contributor Overview

Go Diagnostics Debugging

Go Diagnostics Profiling

How to Write Go Code Testing

How to Write Go Code Your first program Importing packages from remote modules

How to Write Go Code Your first program Importing packages from your module

How to Write Go Code Your first program

The Go Programming Language Specification System considerations Size and alignment guarantees

The Go Programming Language Specification System considerations Package unsafe

The Go Programming Language Specification Run-time panics

The Go Programming Language Specification Errors