{"id":18129195,"url":"https://github.com/jkawamoto/structpbconv","last_synced_at":"2025-04-15T12:19:10.663Z","repository":{"id":57483499,"uuid":"77594735","full_name":"jkawamoto/structpbconv","owner":"jkawamoto","description":"Converts structpb.Struct to another structure.","archived":false,"fork":false,"pushed_at":"2019-12-25T00:22:21.000Z","size":11,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T12:18:52.796Z","etag":null,"topics":["go","google-compute-engine","protocol-buffers"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/jkawamoto/structpbconv","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/jkawamoto.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-12-29T08:01:50.000Z","updated_at":"2022-07-04T08:04:23.000Z","dependencies_parsed_at":"2022-08-27T21:02:24.326Z","dependency_job_id":null,"html_url":"https://github.com/jkawamoto/structpbconv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkawamoto%2Fstructpbconv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkawamoto%2Fstructpbconv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkawamoto%2Fstructpbconv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkawamoto%2Fstructpbconv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jkawamoto","download_url":"https://codeload.github.com/jkawamoto/structpbconv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249067787,"owners_count":21207396,"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":["go","google-compute-engine","protocol-buffers"],"created_at":"2024-11-01T10:07:34.013Z","updated_at":"2025-04-15T12:19:10.645Z","avatar_url":"https://github.com/jkawamoto.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# structpbconv\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n\nConverts [structpb.Struct](https://github.com/golang/protobuf/blob/master/ptypes/struct/struct.pb.go)\nto another structure.\n\n## Usage\nFor example, let us assume to convert Payload of a [logging.Entry](https://godoc.org/cloud.google.com/go/logging#Entry) to\nan ActivityPayload, which is a basic log format in\n[Google Compute Engine](https://cloud.google.com/compute/).\n\nThe type of Payload of logging.Entry is `interface{}` but it can be casted\nto `*structpb.Struct` in most cases.\n\nThe following code converts the instance of `*structpb.Struct` to an\ninstance of ActivityPayload, which is also defined in that code.\n\nNote that to specify a field name, use `structpb` tag.\n\n```go\nimport (\n\t\"github.com/golang/protobuf/ptypes/struct\"\n\t\"github.com/jkawamoto/structpbconv\"\n)\n\n\ntype ActivityPayload struct {\n\tEventTimestampUs string `structpb:\"event_timestamp_us\"`\n\tEventType        string `structpb:\"event_type\"`\n\tTraceID          string `structpb:\"trace_id\"`\n\tActor            struct {\n\t\tUser string\n\t}\n\tResource struct {\n\t\tZone string\n\t\tType string\n\t\tID   string\n\t\tName string\n\t}\n\tVersion      string\n\tEventSubtype string `structpb:\"event_subtype\"`\n\tOperation    struct {\n\t\tZone string\n\t\tType string\n\t\tID   string\n\t\tName string\n\t}\n}\n\n\nfunc NewActivityPayload(payload *structpb.Struct) *ActivityPayload {\n\tvar res ActivityPayload\n\tstructpbconv.Convert(payload, \u0026res)\n\treturn \u0026res\n}\n```\n\n\n## License\nThis software is released under the MIT License, see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkawamoto%2Fstructpbconv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjkawamoto%2Fstructpbconv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkawamoto%2Fstructpbconv/lists"}