{"id":38025314,"url":"https://github.com/florinutz/remarshal","last_synced_at":"2026-01-16T19:33:17.414Z","repository":{"id":57611160,"uuid":"106267923","full_name":"florinutz/remarshal","owner":"florinutz","description":"similar to json.Unmarshal, but more general","archived":false,"fork":false,"pushed_at":"2017-11-03T20:51:23.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-30T01:57:31.852Z","etag":null,"topics":["golang","pointers","regex","string","struct"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/florinutz.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":"2017-10-09T10:10:41.000Z","updated_at":"2018-08-03T06:22:31.000Z","dependencies_parsed_at":"2022-09-10T09:01:53.031Z","dependency_job_id":null,"html_url":"https://github.com/florinutz/remarshal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/florinutz/remarshal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florinutz%2Fremarshal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florinutz%2Fremarshal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florinutz%2Fremarshal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florinutz%2Fremarshal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/florinutz","download_url":"https://codeload.github.com/florinutz/remarshal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florinutz%2Fremarshal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28481840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","pointers","regex","string","struct"],"created_at":"2026-01-16T19:33:17.353Z","updated_at":"2026-01-16T19:33:17.407Z","avatar_url":"https://github.com/florinutz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# remarshal\n[![Build Status](https://travis-ci.org/florinutz/remarshal.svg?branch=master)](https://travis-ci.org/florinutz/remarshal) [![Go Report Card](https://goreportcard.com/badge/github.com/florinutz/remarshal)](https://goreportcard.com/report/github.com/florinutz/remarshal)\n[![GoDoc](https://godoc.org/github.com/florinutz/remarshal?status.svg)](https://godoc.org/github.com/florinutz/remarshal)\n[![Coverage](https://codecov.io/gh/florinutz/remarshal/branch/master/graph/badge.svg)](https://codecov.io/gh/florinutz/remarshal)\n\nThe package looks up for values in a string and then attaches them to an existing struct's fields. It exposes one interface `RegexUnmarshaler`\n\n```go\nfunc Remarshal(text string, v interface{}, splitter interface{}) error\n```\n\nThe splitter can be one of:\n* `*regexp.Regexp`\n* `func(string) (map[string]string, error)`\n* anything that implements `StringMapper`\n```go\ntype StringMapper interface {\n\tGetStringMap(string) (map[string]string, error)\n}\n```\n\n## Examples\n### regex splitter\n```go\nv := \u0026struct {\n    One   string `regex_group:\"first\"`\n    Two   string // regex_group defaults to Two\n    Three string `regex_group:\"Two\"` // this takes precedence over Two\n    Four  string `regex_group:\"Three\"`\n}{}\nsplitter := regexp.MustCompile(`^(?P\u003cfirst\u003e.*)\\|(?P\u003cTwo\u003e.*)\\|(?P\u003cThree\u003e.*)\\|(?P\u003cLast\u003e.*)$`)\n\nerr := remarshal.Remarshal(\"first|second|third|... and so on\", v, splitter)\nif err != nil {\n    fmt.Println(err)\n}\n\nfmt.Printf(\"%#v\", v)\n// Output: \u0026struct { One string \"regex_group:\\\"first\\\"\"; Two string; Three string \"regex_group:\\\"Two\\\"\"; Four string \"regex_group:\\\"Three\\\"\" }{One:\"first\", Two:\"\", Three:\"second\", Four:\"third\"}\n\n```\n\n### function splitter\n```go\nv := \u0026struct{ Host, Port string }{}\n\nsplitter := func(s string) (map[string]string, error) {\n    host, port, _ := net.SplitHostPort(s)\n    return map[string]string{\n        \"Host\": host,\n        \"Port\": port,\n    }, nil\n}\n\nerr := remarshal.Remarshal(\"localhost:12345\", v, splitter)\nif err != nil {\n    fmt.Println(err)\n}\n\nfmt.Printf(\"%#v\", v)\n// Output: \u0026struct { Host string; Port string }{Host:\"localhost\", Port:\"12345\"}\n```\n\nRemarshal returns multiple errors packed into one using the [hashicorp/multierror](https://github.com/hashicorp/go-multierror) package. You can unpack them.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorinutz%2Fremarshal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorinutz%2Fremarshal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorinutz%2Fremarshal/lists"}