{"id":36497488,"url":"https://github.com/svr4/couchbase-lite-cgo","last_synced_at":"2026-01-12T02:04:48.626Z","repository":{"id":57548150,"uuid":"217596946","full_name":"svr4/couchbase-lite-cgo","owner":"svr4","description":"Go lang bindings for the couchbase-lite-C library.","archived":false,"fork":false,"pushed_at":"2020-06-19T15:37:23.000Z","size":179,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T16:42:31.370Z","etag":null,"topics":["cgo","couchbase","couchbase-lite","couchbase-mobile","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/svr4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-25T18:55:15.000Z","updated_at":"2023-06-12T00:44:40.000Z","dependencies_parsed_at":"2022-09-26T18:41:08.200Z","dependency_job_id":null,"html_url":"https://github.com/svr4/couchbase-lite-cgo","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/svr4/couchbase-lite-cgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svr4%2Fcouchbase-lite-cgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svr4%2Fcouchbase-lite-cgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svr4%2Fcouchbase-lite-cgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svr4%2Fcouchbase-lite-cgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/svr4","download_url":"https://codeload.github.com/svr4/couchbase-lite-cgo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svr4%2Fcouchbase-lite-cgo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28331542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgo","couchbase","couchbase-lite","couchbase-mobile","golang"],"created_at":"2026-01-12T02:03:42.049Z","updated_at":"2026-01-12T02:04:48.613Z","avatar_url":"https://github.com/svr4.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Couchbase Lite for Cgo\n\nThis project serves as the Go lang bindings for the couchbase-lite-C library developed by [Couchbase Labs](https://github.com/couchbaselabs).\n\nIt currently supports commit [e12e4a6](https://github.com/couchbaselabs/couchbase-lite-C/commit/e12e4a64911aa97be758e0957338c7d5b7201f5e) of the library.\n\nReplication is now working via `ws://` or `wss://`. Make sure to read the `replicator_test.go` file for more details on how to use replication properly with this library.\n\nThe package was built and tested on macOS (10.14.6+) using Go version `go1.12.9 darwin/amd64`.\n\n## Example\n\n1. Copy and paste the following code:\n\n```go\npackage main\n\n\nimport (\n\tcblcgo \"github.com/svr4/couchbase-lite-cgo\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar config cblcgo.DatabaseConfiguration\n\n\t// Optional encryption key.\n\tvar encryption_key cblcgo.EncryptionKey\n\tencryption_key.Algorithm = cblcgo.EncryptionNone\n\tencryption_key.Bytes = make([]byte, 0)\n\n\tconfig.Directory = \"./\"\n\tconfig.EncryptionKey = encryption_key\n\tconfig.Flags = cblcgo.Database_Create\n\n\tif db, err := cblcgo.Open(\"my_db\", \u0026config); err == nil {\n\t\t// Create a doc\n\t\tdoc := cblcgo.NewDocumentWithId(\"test\")\n\t\tdoc.Props[\"name\"] = \"Luke\"\n\t\tdoc.Props[\"lastname\"] = \"Skywalker\"\n\t\tdoc.Props[\"age\"] = 30\n\t\tdoc.Props[\"email\"] = \"son.of.skywalker@gmail.com\"\n\t\tdoc.Props[\"action\"] = \"delete\"\n\n\t\tif _, err2 := db.Save(doc, cblcgo.LastWriteWins); err2 == nil {\n\t\t\t// Retrieve the saved doc\n\t\t\tif savedDoc, e := db.GetMutableDocument(\"test\"); e == nil {\n\t\t\t\tfor k, v := range savedDoc.Props {\n\t\t\t\t\tif savedDoc.Props[k] != v {\n\t\t\t\t\t\tfmt.Println(\"Saved document and retrieved document are different.\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsavedDoc.Release()\n\t\t\t} else {\n\t\t\t\tfmt.Println(e)\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Println(err2)\n\t\t}\n\n\t\tif !db.Close() {\n\t\t\tfmt.Println(\"Couldn't close the database.\")\n\t\t}\n\n\t} else {\n\t\tfmt.Println(err)\n\t}\n\t\n}\n\n```\n\n2. In the root of your go project, run `go mod init $(pwd)`.\n\n3. Run `go build`, it will fail. You need to copy or symlink the built CouchbaseLiteC binary, using the code up to the latest supported commit described above, into the mod directory under `$GOPATH/pkg/mod/github.com/svr4/couchbase-lite-cgo@vX.X.X/`.\n\n4. **For macOS only**:\n    Make sure the `@rpath` and the `@loader_path` are set to the location of the CouchbaseLiteC binary in your go binary, with the following command:\n    `install_name_tool -change @rpath/libCouchbaseLiteC.dylib @loader_path/libCouchbaseLiteC.dylib your_go_binary`\n\n5. Run `go build`.\n\nFor more examples look in `cblcgo_test.go`.\n\n## Testing\n\nIf you want to test the package you must build the C library and move or link the necesary files under the `include` directory. The produced `libCouchbaseLiteC` binary from the build should be placed in the root of the package. Once that's in place simply run `make tests` and it should produce the `.test` binaries. To run basic tests use the script `run_basic_tests.sh`. To run replicator tests you need to do the proper configuration of couchbase server and sync gateway. Once that's in place do `cblcgo-replicator.test -test.v`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvr4%2Fcouchbase-lite-cgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvr4%2Fcouchbase-lite-cgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvr4%2Fcouchbase-lite-cgo/lists"}