Go dependency management

Updated at:

This topic describes how to use Go dependency management.

Background

Codeup organizes code repositories using a multi-level group structure. Because Codeup does not support globally public repositories, Go dependency management requires authentication to ensure enterprise data security.

Go 1.13 improved support for .netrc authentication. If a request is made over HTTPS and a matching .netrc entry is found, Go adds HTTP Basic Authentication credentials to the request. Go may add new authentication methods in the future, and we will continue to track and implement them.

What is .netrc

The .netrc file contains login and initialization information that automated login processes use. It typically resides in a user's home directory, but you can use the NETRC environment variable to specify a location outside the home directory. The file must be a regular file; otherwise, it is inaccessible.

The file recognizes the following tokens. You can separate them with spaces, tabs, or newlines:

- 'machine name': Identifies the remote machine name. The automated login process searches the .netrc file for a machine token that matches the remote machine specified on the ftp command line or as an argument to the open command. When the process finds a match, it processes the subsequent .netrc tokens until the end of the file is reached or another machine or default token is encountered.

- 'default': This is the same as a machine name, except that default matches any name. There can be only one default token, and it must come after all other machine tokens. This is typically used as: default login anonymous password user@site, allowing users to automatically log in to machines not specified in .netrc by using anonymous FTP. You can override this behavior by using the -n flag to disable automatic login.

default login anonymous password user@site

- 'login name': Identifies the user on the remote machine. If this token is present, the automated login process initiates the login using the specified name.

- 'password string': Provides the password. If this token is present and the remote server requires a password during the login process, the automated login process supplies this string. Note that if this token is present in the .netrc file for any user other than anonymous, ftp aborts the automatic login process if anyone other than the owner can read the .netrc file.

- 'account string': Provides an additional account password. If this token is present and the remote server requires an additional account password, the automated login process supplies this string. Otherwise, the automated login process initiates an ACCT command.

Using .netrc with Codeup

To obtain an HTTP authentication key or password in Codeup, see Configure HTTPS Password.

For example, if your username for reading a repository in Codeup is foo and your token is bar, the corresponding .netrc configuration is:

machine codeup.aliyun.com login foo password bar

Linux and macOS

Place the file in the home directory of the execution account at ~/.netrc.

Windows

  • Set the %HOME% environment variable to the value of %USERPROFILE%.

  • In the %HOME% directory, create a file named _netrc.

  • Add the configuration details to the _netrc file.

machine codeup.aliyun.com
login foo
password bar