code.gitea.io/gitea@v1.22.3/docs/content/usage/packages/go.en-us.md (about) 1 --- 2 date: "2023-05-10T00:00:00+00:00" 3 title: "Go Package Registry" 4 slug: "go" 5 sidebar_position: 45 6 draft: false 7 toc: false 8 menu: 9 sidebar: 10 parent: "packages" 11 name: "Go" 12 sidebar_position: 45 13 identifier: "go" 14 --- 15 16 # Go Package Registry 17 18 Publish Go packages for your user or organization. 19 20 ## Publish a package 21 22 To publish a Go package perform a HTTP `PUT` operation with the package content in the request body. 23 You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. 24 The package must follow the [documented structure](https://go.dev/ref/mod#zip-files). 25 26 ``` 27 PUT https://gitea.example.com/api/packages/{owner}/go/upload 28 ``` 29 30 | Parameter | Description | 31 | --------- | ----------- | 32 | `owner` | The owner of the package. | 33 34 To authenticate to the package registry, you need to provide [custom HTTP headers or use HTTP Basic authentication](development/api-usage.md#authentication): 35 36 ```shell 37 curl --user your_username:your_password_or_token \ 38 --upload-file path/to/file.zip \ 39 https://gitea.example.com/api/packages/testuser/go/upload 40 ``` 41 42 If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. 43 44 You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. 45 46 The server responds with the following HTTP Status codes. 47 48 | HTTP Status Code | Meaning | 49 | ----------------- | ------- | 50 | `201 Created` | The package has been published. | 51 | `400 Bad Request` | The package is invalid. | 52 | `409 Conflict` | A package with the same name exist already. | 53 54 ## Install a package 55 56 To install a Go package instruct Go to use the package registry as proxy: 57 58 ```shell 59 # use latest version 60 GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name} 61 # or 62 GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}@latest 63 # use specific version 64 GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}@{package_version} 65 ``` 66 67 | Parameter | Description | 68 | ----------------- | ----------- | 69 | `owner` | The owner of the package. | 70 | `package_name` | The package name. | 71 | `package_version` | The package version. | 72 73 If the owner of the packages is private you need to [provide credentials](https://go.dev/ref/mod#private-module-proxy-auth). 74 75 More information about the `GOPROXY` environment variable and how to protect against data leaks can be found in [the documentation](https://go.dev/ref/mod#private-modules).