1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-01-23 05:55:24 +02:00

updated the readme

This commit is contained in:
Gani Georgiev 2024-02-07 21:04:20 +02:00
parent 41aa9b189c
commit 368af1f0fc

View File

@ -32,18 +32,23 @@ The easiest way to interact with the API is to use one of the official SDK clien
## Overview
PocketBase could be [downloaded directly as a standalone app](https://github.com/pocketbase/pocketbase/releases) or it could be used as a Go framework/toolkit which allows you to build
### Use as standalone app
You could download the prebuilt executable for your platform from the [Releases page](https://github.com/pocketbase/pocketbase/releases).
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](https://github.com/pocketbase/pocketbase/blob/master/examples/base/main.go) 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](https://pocketbase.io/docs/js-overview/)_).
### Use as a Go framework/toolkit
PocketBase as 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.
### Installation
Here is a minimal example:
```sh
# go 1.21+
go get github.com/pocketbase/pocketbase
```
### Example
0. [Install Go 1.21+](https://go.dev/doc/install) (_if you haven't already_)
1. Create a new project directory with the following `main.go` file inside it:
```go
package main
@ -82,14 +87,21 @@ func main() {
}
```
### Running and building
2. To init the dependencies, run `go mod init myapp && go mod tidy`.
Running/building the application is the same as for any other Go program, aka. just `go run` and `go build`.
3. To start the application, run `go run main.go serve`.
**PocketBase embeds SQLite, but doesn't require CGO.**
4. To build a statically linked executable, you can run `CGO_ENABLED=0 go build` and then start the created executable with `./myapp serve`.
If CGO is enabled (aka. `CGO_ENABLED=1`), it will use [mattn/go-sqlite3](https://pkg.go.dev/github.com/mattn/go-sqlite3) driver, otherwise - [modernc.org/sqlite](https://pkg.go.dev/modernc.org/sqlite).
Enable CGO only if you really need to squeeze the read/write query performance at the expense of complicating cross compilation.
> [!NOTE]
> PocketBase embeds SQLite, but doesn't require CGO.
>
> If CGO is enabled (aka. `CGO_ENABLED=1`), it will use [mattn/go-sqlite3](https://pkg.go.dev/github.com/mattn/go-sqlite3) driver, otherwise - [modernc.org/sqlite](https://pkg.go.dev/modernc.org/sqlite).
> Enable CGO only if you really need to squeeze the read/write query performance at the expense of complicating cross compilation.
_For more details please refer to [Extend with Go](https://pocketbase.io/docs/go-overview/)._
### 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:
@ -100,7 +112,7 @@ To build the minimal standalone executable, like the prebuilt ones in the releas
(_https://go.dev/doc/install/source#environment_)
4. Start the created executable by running `./base serve`.
The supported build targets by the non-cgo driver at the moment are:
Note that the supported build targets by the pure Go SQLite driver at the moment are:
```
darwin amd64
@ -121,7 +133,7 @@ windows arm64
### Testing
PocketBase comes with mixed bag of unit and integration tests.
To run them, use the default `go test` command:
To run them, use the standard `go test` command:
```sh
go test ./...