百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

faunadb-go

> 编程语言
开源

Fauna v4 的 Go 驱动程序 (已淘汰)

184 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Fauna v4 的 Go 驱动程序 (已淘汰)

Golang driver for Fauna v4 (deprecated)

[!WARNING] Fauna is decommissioning FQL v4 on June 30, 2025.

This driver is not compatible with FQL v10, the latest version. Fauna accounts created after August 21, 2024 must use FQL v10. Ensure you migrate existing projects to the official v10 driver by the v4 EOL date: https://github.com/fauna/fauna-go.

For more information, see the v4 end of life (EOL) announcement and related FAQ.

The official Golang driver for Fauna v4.

See the Fauna v4 documentation and Tttorials for guides and a complete database API reference.

Supported Go Versions

Currently, the driver is tested on:

  • 1.13
  • 1.14
  • 1.15
  • 1.16

Using the Driver

Installing

To get the latest version run:

go get github.com/fauna/faunadb-go/v4/faunadb

Please note that our driver undergoes breaking changes from time to time, so depending on our main branch is not recommended. It is recommended to use one of the following methods instead:

Importing

For better usage, we recommend that you import this driver with an alias import.

Using dep or go get

To import a specific version when using go get, use:

import f "github.com/fauna/faunadb-go/v4/faunadb"

Basic Usage

package main

import (
	"fmt"

	f "github.com/fauna/faunadb-go/v4/faunadb"
)

type User struct {
	Name string `fauna:"name"`
}

func main() {
	client := f.NewFaunaClient("your-secret-here")

	res, err := client.Query(f.Get(f.Ref(f.Collection("user"), "42")))
	if err != nil {
		panic(err)
	}

	var user User

	if err := res.At(f.ObjKey("data")).Get(&user); err != nil {
		panic(err)
	}

	fmt.Println(user)
}

Streaming feature usage

…

Omitempty usage

…

Result (empty/zero fields will be ignored):

{
  "ref": Ref(Collection("categories"), "295143889346494983"),
  "ts": 1617729997710000,
  "data": {
    "name": "John"
  }
}

Http2 support

Driver uses http2 by default. To use http 1.x provide custom http client to FaunaClient

package main

import f "github.com/fauna/faunadb-go/v4/faunadb"

func main() {
	secret := ""
	customHttpClient := http.Client{}
	dbClient = f.NewFaunaClient(secret, f.HTTP(&customHttpClient))
}

For more information about Fauna Query Language (FQL), consult our query language reference documentation.

Specific reference documentation for the driver is hosted at GoDoc.

Most users found tests for the driver as a very useful form of documentation Check it out here.

Contributing

GitHub pull requests are very welcome.

Driver Development

Run go get -t ./... in order to install project's dependencies.

Run tests against FaunaDB Cloud by passing your root database key to the test suite, as follows: FAUNA_ROOT_KEY="your-cloud-secret" go test ./....

If you have access to another running FaunaDB database, use the FAUNA_ENDPOINT environment variable to specify its URI.

Alternatively, tests can be run via a Docker container with FAUNA_ROOT_KEY="your-cloud-secret" make docker-test (an alternate Debian-based Go image can be provided via RUNTIME_IMAGE).

Tip: Setting the FAUNA_QUERY_TIMEOUT_MS environment variable will set a timeout in milliseconds for all queries.

LICENSE

Copyright 2020 Fauna, Inc.

Licensed under the Mozilla Public License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Go

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言