跳到正文

Cloudflare Go

热门趋势活跃
cloudflare/cloudflare-go

Cloudflare API 的官方 Go 语言库,可在 Go 代码中管理 DNS 记录、Zone、Workers、R2 等 Cloudflare 资源。

在 GitHub 查看
星标
2099
Fork
779
关注
2099
未关闭 Issue
10

该介绍目前仅提供英文版本。

Cloudflare Go is the official Go client library for the Cloudflare API. It provides comprehensive support for all Cloudflare services including DNS, Firewall, Load Balancing, Workers, and more.

Key Features

  • Complete Cloudflare API coverage
  • Type-safe API calls
  • Automatic retries and error handling
  • Support for pagination and concurrent requests
  • Comprehensive documentation and examples

Quick Start

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "github.com/cloudflare/cloudflare-go"
)

func main() {
    // Create API client
    api, err := cloudflare.New(os.Getenv("CF_API_KEY"), os.Getenv("CF_API_EMAIL"))
    if err != nil {
        log.Fatal(err)
    }

    // Get account information
    ctx := context.Background()
    accounts, err := api.Accounts(ctx)
    if err != nil {
        log.Fatal(err)
    }

    // Print account information
    for _, account := range accounts {
        fmt.Printf("%s: %s\n", account.ID, account.Name)
    }
}

Installation

go get github.com/cloudflare/cloudflare-go

Documentation

For complete API documentation, please refer to the Cloudflare API Documentation.

Contributing

Pull requests and issues are welcome. Before submitting, please ensure:

  1. Code follows Go standard formatting
  2. Necessary tests are added
  3. Documentation is updated accordingly

License

This project is licensed under the Apache License 2.0.

按共同分类和标签排序的同类开源项目。

全部 SDK 项目 →