{"id":16222672,"url":"https://github.com/tsingsun/xbase","last_synced_at":"2026-06-16T16:31:42.583Z","repository":{"id":103651031,"uuid":"467018589","full_name":"tsingsun/xbase","owner":"tsingsun","description":"Go library for reading and writing DBF files","archived":false,"fork":false,"pushed_at":"2024-06-21T06:50:37.000Z","size":115,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T03:41:57.312Z","etag":null,"topics":["dbf","mapping"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsingsun.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-07T09:05:03.000Z","updated_at":"2024-06-21T06:45:43.000Z","dependencies_parsed_at":"2024-11-04T00:00:53.990Z","dependency_job_id":"01d8f02d-632e-4366-af19-f62df95b4a93","html_url":"https://github.com/tsingsun/xbase","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tsingsun/xbase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsingsun%2Fxbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsingsun%2Fxbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsingsun%2Fxbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsingsun%2Fxbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsingsun","download_url":"https://codeload.github.com/tsingsun/xbase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsingsun%2Fxbase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34415240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"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":["dbf","mapping"],"created_at":"2024-10-10T12:14:54.354Z","updated_at":"2026-06-16T16:31:42.564Z","avatar_url":"https://github.com/tsingsun.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xbase\n\n[![Language](https://img.shields.io/badge/Language-Go-blue.svg)](https://golang.org/)\n[![codecov](https://codecov.io/gh/tsingsun/xbase/branch/master/graph/badge.svg)](https://codecov.io/gh/tsingsun/xbase)\n[![Go Report Card](https://goreportcard.com/badge/github.com/tsingsun/xbase)](https://goreportcard.com/report/github.com/tsingsun/xbase)\n[![Build Status](https://github.com/tsingsun/xbase/actions/workflows/xbase.yml/badge.svg?branch=master)](https://github.com/tsingsun/xbase/actions?query=branch%3Amaster)\n[![Release](https://img.shields.io/github/release/tsingsun/xbase.svg?style=flat-square)](https://github.com/tsingsun/xbase/releases)\n[![GoDoc](https://pkg.go.dev/badge/github.com/tsingsun/xbase?status.svg)](https://pkg.go.dev/github.com/tsingsun/xbase?tab=doc)\n\nforked from [svolodeev/xbase](https://github.com/svolodeev/xbase) in the beginning,and both the project and author \nseems no action, so I forked it and refract.\n\nPackage xbase is DBF util written in GO,provides fast,idiomatic free mapping between DBF and GO values\n\nA pure Go library for working with [DBF](http://en.wikipedia.org/wiki/DBase#File_formats) files. \nThe main purpose of the library is to organize export-import of data from files in DBF format.\n\nThe XBase type is used to work with DBF files. In addition to working with existing files, \nthe XBase object allows you to create a new file of the given structure. Each XBase object can be linked with only one file.\n\n### Writing changes to a file\nThe XBase object contains data for one current record. Changing field values does not cause an immediate change to the file. \nChanges are saved when the __Save()__ method is called.\n\n### Deleting records\nDeleting a record does not physically destroy it on disk. The deletion mark is put in a special field of the record.\n\n### Error processing\nIf an error occurs when calling the method, use the __Error()__ method to get its value. By default, methods don't panic. \nThis behavior can be changed. \n\n### Serialization and Deserialization\n\neasy to serialize and deserialize according to the code page of the dbf file.\n\n### Limitations\nThe following field types are supported: __C__, __N__, __L__, __D__. Memo fields are not supported. Index files are not supported.\n\n### Examples\n\nFile creation.\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/tsingsun/xbase\"\n\t\"time\"\n)\n\nfunc main() {\n\t// Create file\n\tdb,err := xbase.New()\n    if err != nil {\n        fmt.Println(err)\n        return\n    }\n\tdb.AddField(\"NAME\", \"C\", 30)\n\tdb.AddField(\"SALARY\", \"N\", 9, 2)\n\tdb.AddField(\"BDATE\", \"D\")\n\tdb.SetCodePage(1251)\n\tdb.CreateFile(\"persons.dbf\")\n\tif db.Error() != nil {\n\t\tfmt.Println(db.Error())\n\t\treturn\n\t}\n\tdefer db.Close()\n\n\t// Add record\n\tdb.Add()\n\tdb.SetFieldValue(1, \"John Smith\")\n\tdb.SetFieldValue(2, 1234.56)\n\tdb.SetFieldValue(3, time.Date(1998, 2, 20, 0, 0, 0, 0, time.UTC))\n\tdb.Save()\n\tif db.Error() != nil {\n\t\tfmt.Println(db.Error())\n\t\treturn\n\t}\n}\n```\nReading file.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n    \"github.com/tsingsun/xbase\"\n)\n\nfunc main() {\n\t// Open the DBF file\n\tdb, err := xbase.Open(\"persons.dbf\", true)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\t// Close the file when done\n\tdefer db.Close()\n\n\t// Read the records\n\tdb.First()\n\tfor !db.EOF() {\n\t\tname := db.FieldValueAsString(1)\n\t\tsalary := db.FieldValueAsFloat(2)\n\t\tbDate := db.FieldValueAsDate(3)\n\t\tfmt.Println(name, salary, bDate)\n\t\tdb.Next()\n\t}\n}\n```\n\nFile information.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/tsingsun/xbase\"\n)\n\nfunc main() {\n\tdb,err := xbase.Open(\"persons.dbf\", true)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer db.Close()\n\n\tfmt.Println(\"Record count:\", db.RecCount())\n\tfmt.Println(\"Field count:\", db.FieldCount())\n\tfmt.Println(\"Code page:\", db.CodePage())\n\n\t// File structure\n\tfor _, f := range db.DecodedFields() {\n\t\tfmt.Println(f.Name, f.Type, f.Len, f.Dec)\n\t}\n}\n```\n\nAppend Record\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/tsingsun/xbase\"\n\t\"time\"\n)\n\nfunc main() {\n\tdb,err := xbase.Open(\"persons.dbf\", false)\n\tif err != nil {\n        fmt.Println(err)\n        return\n    }\n\tdefer db.Close()\n\n\tdb.Add()\n\tdb.SetFieldValue(1, \"John Smith\")\n\tdb.SetFieldValue(2, 1234.56)\n\tdb.SetFieldValue(3, time.Date(1998, 2, 20, 0, 0, 0, 0, time.UTC))\n\tdb.Save()\n\tif db.Error() != nil {\n\t\tfmt.Println(\"Code page:\",db.Error())\n\t}\n}\n```\n\nSerialization and Deserialization\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/tsingsun/xbase\"\n\t\"time\"\n)\n\ntype Person struct {\n\tName   string  `dbf:\"name,len=30\"`\n\tSalary float64 `dbf:\"salary,len=9,dec=2\"`\n\tBDate  time.Time `dbf:\"bdate\"`\n}\n\nfunc main() {\n\tdb, err := xbase.Open(\"persons.dbf\", false)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer db.Close()\n\n\tp := Person{\n\t\tName:   \"John Smith\", \n\t\tSalary: 1234.56,\n\t\tBDate:  time.Date(1998, 2, 20, 0, 0, 0, 0, time.UTC),\n\t}\n\t// append record by struct\n\terr = db.Append(p)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\t// Deserialize to struct\n\tvar p2 Person\n\terr = db.DecodeRecord(\u0026p2)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsingsun%2Fxbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsingsun%2Fxbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsingsun%2Fxbase/lists"}