mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-27 12:31:02 +00:00 
			
		
		
		
	This PR cleans up the docs in a way to make them simpler to ingest by our [docs repo](https://gitea.com/gitea/gitea-docusaurus). 1. It includes all of the sed invocations our ingestion did, removing the need to do it at build time. 2. It replaces the shortcode variable replacement method with `@variable@` style, simply for easier sed invocations when required. 3. It removes unused files and moves the docs up a level as cleanup. --------- Signed-off-by: jolheiser <john.olheiser@gmail.com>
		
			
				
	
	
	
	
		
			2.5 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			2.5 KiB
		
	
	
	
	
	
	
	
| date | title | slug | sidebar_position | draft | toc | menu | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2023-05-10T00:00:00+00:00 | Go 软件包注册表 | go | 45 | false | false | 
 | 
Go 软件包注册表
为您的用户或组织发布 Go 软件包。
发布软件包
要发布 Go 软件包,请执行 HTTP PUT 操作,并将软件包内容放入请求主体中。
如果已经存在相同名称和版本的软件包,您无法发布软件包。您必须首先删除现有的软件包。
该软件包必须遵循文档中的结构。
PUT https://gitea.example.com/api/packages/{owner}/go/upload
| 参数 | 描述 | 
|---|---|
| owner | 软件包的所有者 | 
要身份验证到软件包注册表,您需要提供自定义 HTTP 头或使用 HTTP 基本身份验证:
curl --user your_username:your_password_or_token \
     --upload-file path/to/file.zip \
     https://gitea.example.com/api/packages/testuser/go/upload
如果您使用的是 2FA 或 OAuth,请使用个人访问令牌替代密码进行身份验证。
服务器将使用以下 HTTP 状态代码进行响应。
| HTTP 状态码 | 含义 | 
|---|---|
| 201 Created | 软件包已发布 | 
| 400 Bad Request | 软件包无效 | 
| 409 Conflict | 具有相同名称的软件包已存在 | 
安装软件包
要安装Go软件包,请指示Go使用软件包注册表作为代理:
# 使用最新版本
GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}
# 或者
GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}@latest
# 使用特定版本
GOPROXY=https://gitea.example.com/api/packages/{owner}/go go install {package_name}@{package_version}
| 参数 | 描述 | 
|---|---|
| owner | 软件包的所有者 | 
| package_name | 软件包名称 | 
| package_version | 软件包版本 | 
如果软件包的所有者是私有的,则需要提供凭据。
有关 GOPROXY 环境变量的更多信息以及如何防止数据泄漏的信息,请参阅文档。