Skip to content

Commit 0889d13

Browse files
author
AxT-Team Bot
committed
chore: initial import
0 parents  commit 0889d13

File tree

587 files changed

+121464
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

587 files changed

+121464
-0
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
[*]
3+
charset = utf-8
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: release
2+
on:
3+
push:
4+
tags: ['v*.*.*']
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- run: echo "Release placeholder - customize per registry"

.github/workflows/test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: test
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-go@v5
9+
with: { go-version: '1.22' }
10+
- run: go build ./...

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin/
2+
dist/
3+
*.log

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# uapi-sdk-go
2+
3+
![Banner](./banner.png)
4+
5+
[![Go](https://img.shields.io/badge/Go-1.22+-00ADD8?style=flat-square&logo=go&logoColor=white)](https://go.dev/)
6+
[![Docs](https://img.shields.io/badge/Docs-uapis.cn-2EAE5D?style=flat-square)](https://uapis.cn/)
7+
8+
> [!NOTE]
9+
> 所有接口的 Go 示例都可以在 [UApi](https://uapis.cn/docs/introduction) 的接口文档页面,向下滚动至 **快速启动** 区块后直接复制。
10+
11+
## 快速开始
12+
13+
```bash
14+
go get github.com/uapis/uapi-sdk-go@latest
15+
```
16+
17+
```go
18+
package main
19+
20+
import (
21+
"fmt"
22+
"github.com/uapis/uapi-sdk-go/uapi"
23+
)
24+
25+
func main() {
26+
client := uapi.New("https://uapis.cn/api/v1", "")
27+
info, err := client.Social().GetSocialQqUserinfo(map[string]any{"qq": "10001"})
28+
if err != nil {
29+
panic(err)
30+
}
31+
fmt.Println(info)
32+
}
33+
```
34+
35+
## 特性
36+
37+
现在你不再需要反反复复的查阅文档了。
38+
39+
只需在 IDE 中键入 `client.`,所有核心模块——如 `Social()``Game()``Image()`——即刻同步展现。进一步输入即可直接定位到 `GetSocialQqUserinfo`(获取 QQ 用户信息) 这样的具体方法,其名称与文档的 `operationId` 严格保持一致,确保了开发过程的直观与高效。
40+
41+
所有方法签名只接受真实且必需的参数。当你在构建请求时,IDE 会即时提示 `qq``username` 等键名,这彻底杜绝了在 `map[string]any` 中因键名拼写错误而导致的运行时错误。
42+
43+
针对 401、404、429 等标准 HTTP 响应,SDK 已将其统一映射为具名的错误类型。这些错误均附带 `status``request_id``retry_after_seconds` 等关键上下文信息,确保你在日志中能第一时间准确、快速地诊断问题。
44+
45+
基础域名、请求超时和 `User-Agent` 已预设为合理的默认值。但你完全拥有控制权,可以通过 `uapi.Client.Builder()` 模式灵活覆盖 Token、BaseURL 等配置。
46+
47+
如果你需要查看字段细节或内部逻辑,仓库中的 `./internal` 目录同步保留了由 `openapi-generator` 生成的完整结构体,随时可供参考。
48+
49+
## 错误模型概览
50+
51+
| HTTP 状态码 | SDK 错误类型 | 附加信息 |
52+
|-------------|------------------------|------------------------------------------------------------------------------------|
53+
| 401/403 | `AuthenticationError` | `status``request_id` |
54+
| 404 | `NotFound` | `status``request_id` |
55+
| 400 | `ValidationError` | `status``request_id``details`(如缺少参数、格式错误) |
56+
| 429 | `RateLimitError` | `status``request_id``retry_after_seconds`(用于决定何时重试) |
57+
| 5xx | `ServerError` | `status``request_id` |
58+
| 其他 4xx | `ApiError` | `status``request_id``code``message``details`(用于快速定位具体业务错误) |
59+
60+
## 其他 SDK
61+
62+
| 语言 | 仓库地址 |
63+
|-------------|--------------------------------------------------------------|
64+
| Go(当前) | https://github.com/AxT-Team/uapi-go-sdk |
65+
| Python | https://github.com/AxT-Team/uapi-python-sdk |
66+
| TypeScript| https://github.com/AxT-Team/uapi-typescript-sdk |
67+
| Browser (TypeScript/JavaScript)| https://github.com/AxT-Team/uapi-browser-sdk |
68+
| Java | https://github.com/AxT-Team/uapi-java-sdk |
69+
| PHP | https://github.com/AxT-Team/uapi-php-sdk |
70+
| C# | https://github.com/AxT-Team/uapi-csharp-sdk |
71+
| C++ | https://github.com/AxT-Team/uapi-cpp-sdk |
72+
| Rust | https://github.com/AxT-Team/uapi-rust-sdk |
73+
74+
## 文档
75+
76+
访问 [UApi文档首页](https://uapis.cn/docs/introduction) 并选择任意接口,向下滚动到 **快速启动** 区块即可看到最新的 Go 示例代码。

banner.png

2.66 MB
Loading

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module github.com/uapis/uapi-sdk-go
2+
3+
go 1.22
4+
5+
require (
6+
github.com/valyala/fasthttp v1.52.0
7+
)

internal/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
2+
*.o
3+
*.a
4+
*.so
5+
6+
# Folders
7+
_obj
8+
_test
9+
10+
# Architecture specific extensions/prefixes
11+
*.[568vq]
12+
[568vq].out
13+
14+
*.cgo1.go
15+
*.cgo2.c
16+
_cgo_defun.c
17+
_cgo_gotypes.go
18+
_cgo_export.*
19+
20+
_testmain.go
21+
22+
*.exe
23+
*.test
24+
*.prof

internal/.openapi-generator-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

0 commit comments

Comments
 (0)