{"id":16848107,"url":"https://github.com/araddon/gou","last_synced_at":"2025-07-03T01:38:20.210Z","repository":{"id":4201379,"uuid":"5320857","full_name":"araddon/gou","owner":"araddon","description":"Go Utilities - logging and json helpers","archived":false,"fork":false,"pushed_at":"2021-10-19T18:15:48.000Z","size":148,"stargazers_count":13,"open_issues_count":0,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-04T04:23:39.261Z","etag":null,"topics":[],"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/araddon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-06T23:10:13.000Z","updated_at":"2024-08-23T09:06:33.000Z","dependencies_parsed_at":"2022-08-06T15:15:41.040Z","dependency_job_id":null,"html_url":"https://github.com/araddon/gou","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/araddon/gou","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fgou","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fgou/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fgou/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fgou/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/araddon","download_url":"https://codeload.github.com/araddon/gou/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/araddon%2Fgou/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263244826,"owners_count":23436478,"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":[],"created_at":"2024-10-13T13:10:03.669Z","updated_at":"2025-07-03T01:38:20.182Z","avatar_url":"https://github.com/araddon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"gou - Go Utilities\n===========================\n\nGo Utilities (logging, json)\n\nJsonHelper\n===============\n\nA Go Json Helper, focused on Type coercion, and json path query.\n\n```go\n\tpackage main\n\timport . \"github.com/araddon/gou\"\n\timport . \"github.com/araddon/gou/goutest\"\n\timport \"testing\"\n\n\n\tfunc TestJsonHelper() {\n\n\t\tvar jsonData := []byte(`{\n\t\t\t\"name\":\"aaron\",\n\t\t\t\"nullstring\":null,\n\t\t\t\"ints\":[1,2,3,4],\n\t\t\t\"int\":1,\n\t\t\t\"intstr\":\"1\",\n\t\t\t\"int64\":1234567890,\n\t\t\t\"MaxSize\" : 1048576,\n\t\t\t\"strings\":[\"string1\"],\n\t\t\t\"stringscsv\":\"string1,string2\",\n\t\t\t\"nested\":{\n\t\t\t\t\"nest\":\"string2\",\n\t\t\t\t\"strings\":[\"string1\"],\n\t\t\t\t\"int\":2,\n\t\t\t\t\"list\":[\"value\"],\n\t\t\t\t\"nest2\":{\n\t\t\t\t\t\"test\":\"good\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"nested2\":[\n\t\t\t\t{\"sub\":2}\n\t\t\t],\n\t\t\t\"period.name\":\"value\"\n\t\t}`\n\n\t\tjh := NewJsonHelper(jsonData)\n\n\t\t// String method\n\t\tAssert(jh.String(\"name\") == \"aaron\", t, \"should get 'aaron' %s\", jh.String(\"name\"))\n\t\t// Int Method\n\t\tAssert(jh.Int(\"int\") == 1, t, \"get int \")\n\t\t// Selecting items from an array\n\t\tAssert(jh.Int(\"ints[0]\") == 1, t, \"get int from array %d\", jh.Int(\"ints[0]\"))\n\t\tAssert(jh.Int(\"ints[2]\") == 3, t, \"get int from array %d\", jh.Int(\"ints[0]\"))\n\t\t// Getting arrays\n\t\tAssert(len(jh.Ints(\"ints\")) == 4, t, \"get int array %v\", jh.Ints(\"ints\"))\n\t\t// Type coercion to Int64\n\t\tAssert(jh.Int64(\"int64\") == 1234567890, t, \"get int\")\n\t\tAssert(jh.Int(\"nested.int\") == 2, t, \"get int\")\n\n\t\t// Path based selection\n\t\tAssert(jh.String(\"nested.nest\") == \"string2\", t, \"should get string %s\", jh.String(\"nested.nest\"))\n\t\tAssert(jh.String(\"nested.nest2.test\") == \"good\", t, \"should get string %s\", jh.String(\"nested.nest2.test\"))\n\t\tAssert(jh.String(\"nested.list[0]\") == \"value\", t, \"get string from array\")\n\t\tAssert(jh.Int(\"nested2[0].sub\") == 2, t, \"get int from obj in array %d\", jh.Int(\"nested2[0].sub\"))\n\n\t\t// casing?\n\t\tAssert(jh.Int(\"MaxSize\") == 1048576, t, \"get int, test capitalization? \")\n\t\tsl := jh.Strings(\"strings\")\n\t\tAssert(len(sl) == 1 \u0026\u0026 sl[0] == \"string1\", t, \"get strings \")\n\t\tsl = jh.Strings(\"stringscsv\")\n\t\tAssert(len(sl) == 2 \u0026\u0026 sl[0] == \"string1\", t, \"get strings \")\n\n\t\t// Safe gets\n\t\ti64, ok := jh.Int64Safe(\"int64\")\n\t\tAssert(ok, t, \"int64safe ok\")\n\t\tAssert(i64 == 1234567890, t, \"int64safe value\")\n\n\t\ti, ok := jh.IntSafe(\"int\")\n\t\tAssert(ok, t, \"intsafe ok\")\n\t\tAssert(i == 1, t, \"intsafe value\")\n\n\t\tl := jh.List(\"nested2\")\n\t\tAssert(len(l) == 1, t, \"get list\")\n\n\t\tjhm := jh.Helpers(\"nested2\")\n\t\tAssert(len(jhm) == 1, t, \"get list of helpers\")\n\t\tAssert(jhm[0].Int(\"sub\") == 2, t, \"Should get list of helpers\")\n\n\t\t// Now lets test xpath type syntax\n\t\tAssert(jh.Int(\"/MaxSize\") == 1048576, t, \"get int, test capitalization? \")\n\t\tAssert(jh.String(\"/nested/nest\") == \"string2\", t, \"should get string %s\", jh.String(\"/nested/nest\"))\n\t\tAssert(jh.String(\"/nested/list[0]\") == \"value\", t, \"get string from array\")\n\t\t// note this one has period in name\n\t\tAssert(jh.String(\"/period.name\") == \"value\", t, \"test period in name \")\n\t}\n\n```\n\n\t\nLogging\n===============\n\nYet Another Go Logger, configureable logging.\n\n```go\n\tpackage main\n\timport \"github.com/araddon/gou\"\n\timport \"flag\"\n\n\tvar logLevel *string = flag.String(\"logging\", \"debug\", \"Which log level: [debug,info,warn,error,fatal]\")\n\n\tfunc main() {\n\n\t\tflag.Parse()\n\t\tgou.SetupLogging(*logLevel)\n\n\t\t// logging methods\n\t\tgou.Debug(\"hello\", thing, \" more \", stuff)\n\n\t\tgou.Error(\"hello\")\n\n\t\tgou.Errorf(\"hello %v\", thing)\n\t}\n\n```\n\nLicense\n===============\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faraddon%2Fgou","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faraddon%2Fgou","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faraddon%2Fgou/lists"}