A golang utility to work with uuid
types.
go get github.com/ubgo/gouuid
FuncName will return the current function's name. Check if pointer of uuid is empty then return the default 00000000-0000-0000-0000-000000000000
gouuid.DefaultIfEmpty(nil) // output: 00000000-0000-0000-0000-000000000000
uid := uuid.New()
gouuid.DefaultIfEmpty(&uid) // output: some uid b7729c88-47e9-42a7-92d3-3e6bcc585f73
Parse string as uuid and return default if error
ParseToDefault("not_uid") // output: 00000000-0000-0000-0000-000000000000
uid := uuid.New().String()
result = ParseToDefault(uid) // output: some uid b7729c88-47e9-42a7-92d3-3e6bcc585f73
Check if value exist on a given uuid slice then return the index
ids := []uuid.UUID{ParseToDefault("b7729c88-47e9-42a7-92d3-3e6bcc585f73"), ParseToDefault("83adb35a-847a-4962-8e09-8311a45dc2a2"), ParseToDefault("d9d65dfc-4643-44ab-920f-c564259fd96c")}
result, _ := IndexOf(ids, ParseToDefault("83adb35a-847a-4962-8e09-8311a45dc2a2"))
// output: 1, true
If you would like to contribute to the project, please fork it and send us a pull request. Please add tests for any new features or bug fixes.
- Author - Aman Khanakia
- Website - https://khanakia.com
gouuid is MIT licensed.