{"id":16418366,"url":"https://github.com/hemantasapkota/goma","last_synced_at":"2025-10-26T20:31:23.500Z","repository":{"id":57609293,"uuid":"62608906","full_name":"hemantasapkota/goma","owner":"hemantasapkota","description":"Build native mobile apps faster: Write logic in GO. Views in ReactNative.","archived":false,"fork":false,"pushed_at":"2022-02-06T23:48:43.000Z","size":35,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-01T00:13:21.074Z","etag":null,"topics":["android","android-studio","database","gomobile","ios","react-native","xcode"],"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/hemantasapkota.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":"2016-07-05T05:40:32.000Z","updated_at":"2024-10-12T14:09:41.000Z","dependencies_parsed_at":"2022-08-27T11:11:59.292Z","dependency_job_id":null,"html_url":"https://github.com/hemantasapkota/goma","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemantasapkota%2Fgoma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemantasapkota%2Fgoma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemantasapkota%2Fgoma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemantasapkota%2Fgoma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hemantasapkota","download_url":"https://codeload.github.com/hemantasapkota/goma/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238397100,"owners_count":19465114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["android","android-studio","database","gomobile","ios","react-native","xcode"],"created_at":"2024-10-11T07:13:56.966Z","updated_at":"2025-10-26T20:31:18.214Z","avatar_url":"https://github.com/hemantasapkota.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Goma - ごま #\n\u003e Build native mobile apps faster by writing your application logic in GO\n\nWith Goma, you can write your mobile app's business logic in GO and reuse them across platforms like IOS and Android. It comes with an embedded database that allows you to save/restore application's objects.\n\nGoma utilizes [gomobile](https://godoc.org/golang.org/x/mobile/cmd/gomobile) to generate platform specific libraries for your apps.\n\n## Requirements\n\n- At least Go 1.5.3 or above\n- Xcode\n- Android Studio or Eclipse\n\n# Installation\n\nGet or update **Goma** with:\n\n` go get -u github.com/hemantasapkota/goma`\n\n# Concepts \u0026 Usage\n\n## goma.Object - Definition \u0026 Construction ##\n\nAnything that is persitable can be modeled with a Goma object. It can be your app's **view**, **model** or **both**.\n\nA complete goma object should embed [goma.Object](object.go) and implement the [goma.DBObject](object.go) interface.\n\n```go\ntype Person struct {\n  *goma.Object\n   Name string `json:\"name\"`\n   Age int `json:\"age\"`\n}\n\n// Implement goma.DBObject interface's Key() method\nfunc (p *Person) Key() string {\n  return \"sampleApp.Person\"\n}\n```\n\n## goma.Object - Saving to the database ##\n\n```go\n\nperson := \u0026Peron{\n Name: \"Jon Panda\",\n Age: 20,\n}\n\nerr := person.Save(person)\nif err != nil {\n // do something\n}\n\n```\n\nThe object is serialized to JSON and stored in DB.\n\n```\n{\"name\":\"Jon Panda\",\"age\":20}\n```\n\n## goma.Object - Restoring from the database ##\n\n```go\nperson := \u0026Person{}\nerr := person.Restore(person)\n\nif err != nil {\n // do something\n}\n```\n**Note**: For consistency purpose, it's recommended that GOMA object receivers be of pointer type. See this [blog](https://nathanleclaire.com/blog/2014/08/09/dont-get-bitten-by-pointer-vs-non-pointer-method-receivers-in-golang/) post for more details.\n\n## Marshaling - Return values from Goma ##\n\n[gomobile](https://godoc.org/golang.org/x/mobile/cmd/gomobile) has some restrictions as to what types you can return. They are primitives ( ```int, int64, float float64, string, and bool``` ) and ( byte array ) ```[]byte```. \n\nGoma leverages Go's excellent JSON support. Complex types like structs, arrays, and maps can be easily marshalled into JSON.\n\n## Synchronization of Objects ##\n\nSynchronization is required to ensure multiple goroutine don't modify the same object at the same time. Using mutexes to sycnhronize read/write access to the objects can solve this problem.\n\n```go\ntype ContainerItem struct {\n\tId int `json:\"id\"`\n}\n\ntype Container struct {\n\t*Object\n\tsync.Mutex\n\n\tChildren []ContainerItem\n}\n\nfunc (c *Container) Key() string {\n\treturn \"goma.container\"\n}\n\nfunc (c *Container) AddChild(child ContainerItem) {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tc.Children = append(c.Children, child)\n}\n```\n\n# Wiki\n* [Interfacing with Android and IOS](https://github.com/hemantasapkota/goma/wiki/Interfacing-with-Android-and-IOS)\n\n# Examples\n\n* [Meal Tracker](https://github.com/hemantasapkota/goma-examples/tree/master/fitness) - A simple meal tracker that I use personally\n\nSee https://github.com/hemantasapkota/goma-examples\n\n## Contribute\n\nWe would love for you to contribute to **Goma**, check the ``LICENSE`` file for more info.\n\n## Meta\n\nHemanta Sapkota \n\nDistributed under the MIT license. See ``LICENSE`` for more information.\n\n[https://github.com/hemantasapkota](https://github.com/hemantasapkota/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemantasapkota%2Fgoma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhemantasapkota%2Fgoma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemantasapkota%2Fgoma/lists"}