{"id":38000149,"url":"https://github.com/eleven26/goss","last_synced_at":"2026-01-16T19:07:51.884Z","repository":{"id":56808001,"uuid":"525804350","full_name":"eleven26/goss","owner":"eleven26","description":"一个简洁的云存储 golang 库，兼容 amazon s3 协议，支持但不限于阿里云、腾讯云、七牛云、华为云、aws s3、minio。","archived":false,"fork":false,"pushed_at":"2023-12-06T14:38:48.000Z","size":280,"stargazers_count":52,"open_issues_count":1,"forks_count":14,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-06T16:41:04.240Z","etag":null,"topics":["aws","aws-s3","cloudstorage","cos","golang","kodo","minio","oss","s3","s3-storage","storage"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eleven26.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-17T13:28:43.000Z","updated_at":"2024-12-24T10:05:34.000Z","dependencies_parsed_at":"2023-09-28T10:33:44.481Z","dependency_job_id":"9c28bd55-af7c-4a65-8e9f-e1e8becc2970","html_url":"https://github.com/eleven26/goss","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/eleven26/goss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven26%2Fgoss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven26%2Fgoss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven26%2Fgoss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven26%2Fgoss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eleven26","download_url":"https://codeload.github.com/eleven26/goss/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eleven26%2Fgoss/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28481471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-s3","cloudstorage","cos","golang","kodo","minio","oss","s3","s3-storage","storage"],"created_at":"2026-01-16T19:07:50.868Z","updated_at":"2026-01-16T19:07:51.870Z","avatar_url":"https://github.com/eleven26.png","language":"Go","readme":"# goss\n\n✨ `goss` 是一个简洁的云存储 golang 库，兼容 amazon s3 协议，支持但不限于**阿里云**、**腾讯云**、**七牛云**、**华为云**、**aws s3**、**minio**。\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/eleven26/goss/v4.svg)](https://pkg.go.dev/github.com/eleven26/goss/v4)\n[![Go Report Card](https://goreportcard.com/badge/github.com/eleven26/goss/v4)](https://goreportcard.com/report/github.com/eleven26/goss/v4)\n[![Go](https://github.com/eleven26/goss/actions/workflows/go.yml/badge.svg)](https://github.com/eleven26/goss/actions/workflows/go.yml)\n[![codecov](https://codecov.io/gh/eleven26/goss/branch/main/graph/badge.svg?token=UU4lLD2n4k)](https://codecov.io/gh/eleven26/goss)\n[![GitHub license](https://img.shields.io/github/license/eleven26/goss)](https://github.com/eleven26/goss/blob/main/LICENSE)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/eleven26/goss)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/eleven26/goss)\n\n\n## 🚀 安装\n\n```shell\ngo get -u github.com/eleven26/goss/v4\n```\n\n\n## ⚙️ 配置\n\n所有支持的配置项：\n\n```go\ntype Config struct {\n    Endpoint          string `yaml:\"endpoint\"`\n    AccessKey         string `yaml:\"access_key\"`\n    SecretKey         string `yaml:\"secret_key\"`\n    Region            string `yaml:\"region\"`\n    Bucket            string `yaml:\"bucket\"`\n\n    // 如果是使用 minio，并且没有使用 https，需要设置为 true\n    UseSsl            *bool  `yaml:\"use_ssl\"`\n    // 如果是使用 minio，需要设置为 true\n    HostnameImmutable *bool  `yaml:\"hostname_immutable\"`\n}\n```\n\n配置的方式，在创建实例的时候通过 `WithConfig` 来传递：\n\n```go\ngoss, err := goss.New(goss.WithConfig(\u0026goss.Config{\n    Endpoint: \"\",\n    AccessKey: \"\",\n    SecretKey: \"\",\n    Region: \"\",\n    Bucket: \"\",\n}))\n```\n\n\n## 💡 基本用法\n\n1. 你可以通过下面的代码来导入 `goss`:\n\n```go\nimport \"github.com/eleven26/goss/v4\"\n```\n\n2. 使用之前需要创建实例：\n\n```go\ngoss, err := goss.New(goss.WithConfig(\u0026Config{\n    Endpoint: \"\",\n    AccessKey: \"\",\n    SecretKey: \"\",\n    Region: \"\",\n    Bucket: \"\",\n}))\n```\n\n3. 使用\n\n```go\n// goss.GetString 会获取路径指定的文件，返回字符串\nfmt.Println(goss.GetString(context.TODO(), \"test/foo.txt\"))\n```\n\n\n## 📚 接口\n\n`goss` 支持以下操作：\n\n- [Put](#Put)\n- [PutFromFile](#PutFromFile)\n- [Get](#Get)\n- [GetString](#GetString)\n- [GetBytes](#GetBytes)\n- [GetToFile](#GetToFile)\n- [Delete](#Delete)\n- [Exists](#Exists)\n- [Files](#Files)\n- [Size](#Size)\n\n### Put\n\n上传文件到云存储。第一个参数是 `key`，第二个参数是 `io.Reader`。\n\n```go\ndata := []byte(\"this is some data stored as a byte slice in Go Lang!\")\nr := bytes.NewReader(data)\nerr := goss.Put(context.TODO(), \"test/test.txt\", r)\n```\n\n### PutFromFile\n\n上传文件到云存储。第一个参数是 `key`，第二个参数是本地文件路径。\n\n```go\nerr := goss.PutFromFile(context.TODO(), \"test/test.txt\", \"/path/to/test.txt\")\n```\n\n### Get\n\n从云存储获取文件。参数是 `key`。返回值是 `io.ReadCloser` 和 `error`。\n\n```go\n// rc 是 `io.ReadCloser`\nrc, err := goss.Get(context.TODO(), \"test/test.txt\")\ndefer rc.Close()\n\nbs, err := io.ReadAll(rc)\nfmt.Println(string(bs))\n```\n\n### GetString\n\n从云存储获取文件。参数是 `key`。返回值是 `string` 和 `error`\n\n```go\ncontent, err := goss.GetString(context.TODO(), \"test/test.txt\")\nfmt.Println(content)\n```\n\n### GetBytes\n\n从云存储获取文件。参数是 `key`。返回值是 `[]byte` 和 `error`\n\n```go\nbs, err := goss.GetBytes(context.TODO(), \"test/test.txt\")\nfmt.Println(string(bs))\n```\n\n### GetToFile\n\n下载云存储文件到本地。第一个参数是 `key`，第二个参数是本地路径。\n\n```go\n// 第一个参数是云端路径，第二个参数是本地路径\nerr := goss.GetToFile(context.TODO(), \"test/test.txt\", \"/path/to/local\")\n```\n\n### Delete\n\n删除云存储文件。\n\n```go\nerr := goss.Delete(context.TODO(), \"test/test.txt\")\n```\n\n### Exists\n\n判断云存储文件是否存在。\n\n```go\nexists, err := goss.Exists(context.TODO(), \"test/test.txt\")\n```\n\n### Files\n\n根据前缀获取文件列表。\n\n```go\nexists, err := goss.Files(context.TODO(), \"test/\")\n```\n\n### Size\n\n获取云存储文件大小。\n\n```go\nsize, err := goss.Size(context.TODO(), \"test/test.txt\")\n```\n\n## 参考文档\n\n1. [阿里云对象存储](https://help.aliyun.com/product/31815.html)\n2. [腾讯云对象存储](https://cloud.tencent.com/document/product/436)\n3. [七牛云对象存储](https://developer.qiniu.com/kodo)\n4. [华为云对象存储](https://support.huaweicloud.com/obs/index.html)\n5. [aws s3](https://docs.aws.amazon.com/sdk-for-go/api/service/s3/)\n6. [minio](https://github.com/minio/minio)\n\n## 各云厂商对 s3 的支持\n\n1. [阿里云: OSS与Amazon S3的兼容性](https://help.aliyun.com/document_detail/389025.html)\n2. [腾讯云: 使用 AWS S3 SDK 访问 COS](https://cloud.tencent.com/document/product/436/37421)\n3. [七牛云: AWS S3 兼容](https://developer.qiniu.com/kodo/4086/aws-s3-compatible)\n4. 华为云：支持 s3，但是官网文档找不到相关关于 s3 兼容的相关描述\n5. [minio: AWS S3 Compatibility](https://min.io/product/s3-compatibility)\n\n## 注意事项\n\n1. 七牛云的 `endpoint` 和 `region` 配置请参考这个文档：[AWS S3 兼容 - 服务域名](https://developer.qiniu.com/kodo/4088/s3-access-domainname)\n\n## Changelog\n\n### [4.0.0] - 2023-09-28\n\n#### Changed\n\n- 所有方法添加 `context.Context` 作为第一个参数。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feleven26%2Fgoss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feleven26%2Fgoss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feleven26%2Fgoss/lists"}