{"id":21518222,"url":"https://github.com/ucloud/ucloud-sdk-go","last_synced_at":"2026-02-06T11:48:43.421Z","repository":{"id":37451311,"uuid":"42502153","full_name":"ucloud/ucloud-sdk-go","owner":"ucloud","description":"UCloud SDK for Golang","archived":false,"fork":false,"pushed_at":"2025-05-14T13:37:52.000Z","size":4108,"stargazers_count":83,"open_issues_count":5,"forks_count":39,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-14T14:54:21.701Z","etag":null,"topics":["developer-tools","devops","sdk","ucloud","ucloud-sdk"],"latest_commit_sha":null,"homepage":"https://docs.ucloud.cn/opensdk-go/README","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ucloud.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2015-09-15T07:24:41.000Z","updated_at":"2025-05-14T13:34:17.000Z","dependencies_parsed_at":"2023-11-15T11:27:38.497Z","dependency_job_id":"6e9b6306-1d7a-4bef-b419-a0b86742fbf6","html_url":"https://github.com/ucloud/ucloud-sdk-go","commit_stats":null,"previous_names":[],"tags_count":182,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fucloud-sdk-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fucloud-sdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fucloud-sdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fucloud-sdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ucloud","download_url":"https://codeload.github.com/ucloud/ucloud-sdk-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328386,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["developer-tools","devops","sdk","ucloud","ucloud-sdk"],"created_at":"2024-11-24T00:50:50.402Z","updated_at":"2026-02-06T11:48:38.394Z","avatar_url":"https://github.com/ucloud.png","language":"Go","readme":"English | [简体中文](README_cn.md)\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://ucloud-sdk.dl.ufileos.com/logos%2Flogo-mini.png\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eUCloud Go SDK\u003c/h1\u003e\n\n[![GitHub (pre-)release](https://img.shields.io/github/release/ucloud/ucloud-sdk-go/all.svg)](https://github.com/ucloud/ucloud-sdk-go/releases)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ucloud/ucloud-sdk-go)](https://goreportcard.com/report/github.com/ucloud/ucloud-sdk-go)\n[![Codecov](https://codecov.io/gh/ucloud/ucloud-sdk-go/branch/master/graph/badge.svg)](https://codecov.io/gh/ucloud/ucloud-sdk-go)\n[![Build Status](https://travis-ci.org/ucloud/ucloud-sdk-go.svg?branch=master)](https://travis-ci.org/ucloud/ucloud-sdk-go)\n[![SonarQube](https://sonarcloud.io/api/project_badges/measure?project=ucloud-sdk-go\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=ucloud-sdk-go)\n[![GoDoc](https://godoc.org/github.com/ucloud/ucloud-sdk-go?status.svg)](https://godoc.org/github.com/ucloud/ucloud-sdk-go)\n[![GitHub](https://img.shields.io/github/license/ucloud/ucloud-sdk-go.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n\n- [Website](https://www.ucloud.cn/)\n- [Documentation](https://docs.ucloud.cn/opensdk-go/README)\n\n## Installation\n\n### Requirements\n\n- Go 1.10+\n\n### Use `go get`\n\n```bash\ngo get github.com/ucloud/ucloud-sdk-go\n```\n\n**Note** if meet network problem, you can use go proxy to speed up the downloaded, eg: use GOPROXY environment variable\n\n```go\nexport GOPROXY=https://goproxy.io\n```\n\nReplay the command to retry installation.\n\n### Use `go mod`\n\nAdd the following snippet to any code.\n\n```go\nimport _ \"github.com/ucloud/ucloud-sdk-go\"\n```\n\nAnd execute this commands：\n\n```bash\ngo mod init\ngo mod tidy\n```\n\n**Note**：If using `go mod` and `Goland IDE` together, please search `vgo` on `Settings`, and enable `vgo` support.\n\n**Note**：If using `go mod` 和 `GOPATH`, notice the `go mod init/tidy` can not run with `GOPATH`, please move out current project from `GOPATH`.\n\n### Use `dep`\n\n```bash\ndep ensure -add github.com/ucloud/ucloud-sdk-go\n```\n\n## First Using\n\nCurrently, Go SDK use `PublicKey/PrivateKey` as authentication method, the key can be found from：\n\n- [UAPI Key Generation](https://console.ucloud.cn/uapi/apikey)\n\nHere is a simple example：\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/ucloud/ucloud-sdk-go/ucloud\"\n    \"github.com/ucloud/ucloud-sdk-go/ucloud/auth\"\n    \"github.com/ucloud/ucloud-sdk-go/services/uhost\"\n)\n\nfunc main() {\n    cfg := ucloud.NewConfig()\n    cfg.Region = \"cn-bj2\"\n\n    // replace the public/private key by your own\n    credential := auth.NewCredential()\n    credential.PublicKey = \"my_public_key\"\n    credential.PrivateKey = \"my_private_key\"\n\n    uhostClient := uhost.NewClient(\u0026cfg, \u0026credential)\n\n    req := uhostClient.NewCreateUHostInstanceRequest()\n    req.Name       = ucloud.String(\"sdk-example-uhost\")\n    req.Zone       = ucloud.String(\"cn-bj2-05\")\n    req.ImageId    = ucloud.String(\"uimage-xxx\") // you can replace the image with an available id\n    req.LoginMode  = ucloud.String(\"Password\")\n    req.Password   = ucloud.String(\"my_uhost_password\")\n    req.ChargeType = ucloud.String(\"Dynamic\")\n    req.CPU        = ucloud.Int(1)\n    req.Memory     = ucloud.Int(1024)\n    req.Tag        = ucloud.String(\"sdk-example\")\n\n    // send request\n    newUHost,err := uhostClient.CreateUHostInstance(req)\n    if err != nil {\n        fmt.Printf(\"something bad happened: %s\\n\", err)\n    } else {\n        fmt.Printf(\"resource id of the uhost: %s\\n\", newUHost.UHostIds[0])\n    }\n}\n```\n\nReplace the client configuration and host image id by your custom value, then you can create a cloud host。\n\nAt this example, you had already completed a `CreateUHostInstance` request by UCloud Go SDK, it is covered most of feature of sdk, you can write your own script for free!\n\nEach API call in the SDK has a detailed comment and document, You can use Editor/IDE to jump to the specific API method code to view (can also to see [Go Doc](https://godoc.org/github.com/ucloud/ucloud-sdk-go)）, and use completion of IDE and error logging to inspect usage of SDK。\n\nIf you are interested the advanced usage about above code example, please see the documentation: \n\n- [Configuration](https://docs.ucloud.cn/opensdk-go/configure), Learn how to configure SDK, such as Logging, Retrying, Service endpoint(Public Cloud \u0026 Private Cloud), and etc.\n- [Error Handling](https://docs.ucloud.cn/opensdk-go/error), Learn how to resolve the several exception types, include parameters error, business error for *RetCode is not 0*.\n- [Type System](https://docs.ucloud.cn/opensdk-go/typesystem), Learn how to validate parameters, and normalize the response of API.\n- [Request Middleware](https://docs.ucloud.cn/opensdk-go/middleware), Learn how to intercept request that applied by SDK, and add common logic to the lifecycle.\n- [Toolbox \u0026 Helpers](https://docs.ucloud.cn/opensdk-go/helpers), The additional helpers, such as the poll function for waiting resource state.\n\n## More Examples\n\n### Examples based on Environment\n\nSDK provided some example based on environment, and provide resource provisioning logic . You can click the following link to view details：\n\n- [Client Configuration](https://github.com/ucloud/ucloud-sdk-go/tree/master/examples/configure), Introducing the usage of configuration\n- [Read External Configuration](https://github.com/ucloud/ucloud-sdk-go/tree/master/examples/external), Use external configuration, such as configuration from *UCloud CLI*\n- [Logging](https://github.com/ucloud/ucloud-sdk-go/tree/master/examples/logging), Configure options of logging\n- [Retrying](https://github.com/ucloud/ucloud-sdk-go/tree/master/examples/retry), Introducing the auto retrying feature\n- [Toolbox: State Poll](https://github.com/ucloud/ucloud-sdk-go/tree/master/examples/wait), Learn how to wait host opened gracefully \n- [Create Host](https://github.com/ucloud/ucloud-sdk-go/tree/master/examples/uhost), Introducing how to create host\n- [Create Two-Tier architecture based on Load Balancer](https://github.com/ucloud/ucloud-sdk-go/tree/master/examples/two-tier), ULB + UHost\n\n### Examples based on Request\n\nUCloud `UAPI` product provided examples based on request, you can fill request parameters and generate example of SDK, it can be copied immediately:\n\n- [Open UAPI](https://console.ucloud.cn/uapi/ucloudapi)\n- Select your interested API, such as [CreateUHostInstance](https://console.ucloud.cn/uapi/detail?id=CreateUHostInstance)\n- Fill parameters, copy the sdk example code at right panel\n- Save code into `main.go`\n- Executing `go mod init main`\n- Executing `go mod tidy`\n- `go run ./main.go`\n\n**Note** if meet network problem, you can use go proxy to speed up the downloaded, eg: use GOPROXY environment variable\n\n```go\nexport GOPROXY=https://goproxy.io\n```\n\n**Note**：If using `go mod` and `Goland IDE` together, please search `vgo` on `Settings`, and enable `vgo` support.\n\n**Note**：If using `go mod` 和 `GOPATH`, notice the `go mod init/tidy` can not run with `GOPATH`, please move out current project from `GOPATH`.\n\n## Feedback \u0026 Contribution\n\n- [Issue](https://github.com/ucloud/ucloud-sdk-go/issues)\n- [Pull Request](https://github.com/ucloud/ucloud-sdk-go/pulls)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucloud%2Fucloud-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fucloud%2Fucloud-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucloud%2Fucloud-sdk-go/lists"}