PocketBase 代码仓库迁离 GitHub

原标题:PocketBase has moved off GitHub
58AI 研判分

开源 Go 后端 PocketBase 宣布将主仓库从 GitHub 迁移至作者自建域名 ganigeorgiev.com,官方 SDK 与文档站点保持不变。项目仍处于 v1.0.0 之前的活跃开发阶段,不保证完全向后兼容。此举反映开源项目对平台依赖与分发自主权的重新权衡。

关联知识实体

报道正文

本文目录7 个章节

⚠️ The repo has moved to https://ganigeorgiev.com/pocketbase/pocketbase.


PocketBase is an open source Go backend that includes:

  • embedded database (SQLite) with realtime subscriptions
  • built-in files and users management
  • convenient Admin dashboard UI
  • and simple REST-ish API

For documentation and examples, please visit https://pocketbase.io/docs.

[!WARNING] Please keep in mind that PocketBase is still under active development and therefore full backward compatibility is not guaranteed before reaching v1.0.0.

API SDK clients

The easiest way to interact with the PocketBase Web APIs is to use one of the official SDK clients:

You could also check the recommendations in https://pocketbase.io/docs/how-to-use/.

Overview

Use as standalone app

You could download the prebuilt executable for your platform from the Releases page. Once downloaded, extract the archive and run ./pocketbase serve in the extracted directory.

The prebuilt executables are based on the examples/base/main.go file and comes with the JS VM plugin enabled by default which allows to extend PocketBase with JavaScript (for more details please refer to Extend with JavaScript).

Use as a Go framework/toolkit

PocketBase is distributed as a regular Go library package which allows you to build your own custom app specific business logic and still have a single portable executable at the end.

Here is a minimal example:

  1. Install Go 1.27+ (if you haven't already)

  2. Create a new project directory with the following main.go file inside it:

GO
    package main

    import (
        "log"

        "github.com/pocketbase/pocketbase"
        "github.com/pocketbase/pocketbase/core"
    )

    func main() {
        app := pocketbase.New()

        app.OnServe().BindFunc(func(se *core.ServeEvent) error {
            // registers new "GET /hello" route
            se.Router.GET("/hello", func(re *core.RequestEvent) error {
                return re.String(200, "Hello world!")
            })

            return se.Next()
        })

        if err := app.Start(); err != nil {
            log.Fatal(err)
        }
    }
  1. To init the dependencies, run go mod init myapp && go mod tidy.

  2. To start the application, run go run main.go serve.

  3. To build a statically linked executable, you can run CGO_ENABLED=0 go build and then start the created executable with ./myapp serve.

For more details please refer to Extend with Go.

Building and running the repo main.go example

To build the minimal standalone executable, like the prebuilt ones in the releases page, you can simply run go build inside the examples/base directory:

  1. Install Go 1.27+ (if you haven't already)
  2. Clone/download the repo
  3. Navigate to examples/base
  4. Run CGO_ENABLED=0 go build to build a binary for your current environment (or to target other platforms use GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build; see https://go.dev/doc/install/source#environment)
  5. Start the created executable by running ./base serve.

Note that the supported build targets by the pure Go SQLite driver at the moment are:

GOOSGOARCH
darwinamd64
darwinarm64
freebsd386
freebsdamd64
freebsdarm
freebsdarm64
linux386
linuxamd64
linuxarm
linuxarm64
linuxloong64
linuxppc64le
linuxriscv64
linuxs390x
netbsdamd64
openbsdamd64
openbsdarm64
windows386
windowsamd64
windowsarm64

Testing

PocketBase comes with mixed bag of unit and integration tests. To run them, use the standard go test command:

BASH
go test ./...

Check also the Testing guide to learn how to write your own custom application tests.

Security

If you discover a security vulnerability within PocketBase, please send an e-mail to support at pocketbase.io.

You could find more details in the project Security policy.