{"id":16104748,"url":"https://github.com/sergeymakinen/go-systemdconf","last_synced_at":"2025-03-17T17:31:33.340Z","repository":{"id":57511178,"uuid":"231278694","full_name":"sergeymakinen/go-systemdconf","owner":"sergeymakinen","description":"systemd configuration file parser/serializer","archived":false,"fork":false,"pushed_at":"2024-04-19T12:17:02.000Z","size":293,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T06:52:35.230Z","etag":null,"topics":["go","golang","marshal","parser","serializer","systemd","systemd-configuration","systemd-networkd","systemd-unit","unit","unmarshal"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sergeymakinen.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-01-02T00:10:23.000Z","updated_at":"2024-12-05T09:51:20.000Z","dependencies_parsed_at":"2023-10-13T07:01:05.683Z","dependency_job_id":null,"html_url":"https://github.com/sergeymakinen/go-systemdconf","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeymakinen%2Fgo-systemdconf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeymakinen%2Fgo-systemdconf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeymakinen%2Fgo-systemdconf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeymakinen%2Fgo-systemdconf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergeymakinen","download_url":"https://codeload.github.com/sergeymakinen/go-systemdconf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243874945,"owners_count":20361921,"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","golang","marshal","parser","serializer","systemd","systemd-configuration","systemd-networkd","systemd-unit","unit","unmarshal"],"created_at":"2024-10-09T19:06:09.695Z","updated_at":"2025-03-17T17:31:32.909Z","avatar_url":"https://github.com/sergeymakinen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# systemdconf\n\n[![tests](https://github.com/sergeymakinen/go-systemdconf/workflows/tests/badge.svg)](https://github.com/sergeymakinen/go-systemdconf/actions?query=workflow%3Atests)\n[![Go Reference](https://pkg.go.dev/badge/github.com/sergeymakinen/go-systemdconf.svg)](https://pkg.go.dev/github.com/sergeymakinen/go-systemdconf/v2)\n[![Go Report Card](https://goreportcard.com/badge/github.com/sergeymakinen/go-systemdconf)](https://goreportcard.com/report/github.com/sergeymakinen/go-systemdconf)\n[![codecov](https://codecov.io/gh/sergeymakinen/go-systemdconf/branch/master/graph/badge.svg)](https://codecov.io/gh/sergeymakinen/go-systemdconf)\n\nPackage systemdconf implements encoding and decoding of systemd configuration files\nas defined by systemd.syntax (see https://www.freedesktop.org/software/systemd/man/systemd.syntax.html for details).\n\nThe mapping between systemd and Go is described\nin the documentation for the Marshal and Unmarshal functions\n\n## Installation\n\nUse go get:\n\n```bash\ngo get github.com/sergeymakinen/go-systemdconf/v2\n```\n\nThen import the package into your own code:\n\n```go\nimport \"github.com/sergeymakinen/go-systemdconf/v2\"\n```\n\n\n## Example\n\n### Marshal\n\n```go\nservice := unit.ServiceFile{\n    Unit: unit.UnitSection{\n        Description: systemdconf.Value{\"Simple firewall\"},\n    },\n    Service: unit.ServiceSection{\n        Type:            systemdconf.Value{\"oneshot\"},\n        RemainAfterExit: systemdconf.Value{\"yes\"},\n        ExecStart: systemdconf.Value{\n            \"/usr/local/sbin/simple-firewall-start1\",\n            \"/usr/local/sbin/simple-firewall-start2\",\n        },\n        ExecStop: systemdconf.Value{\"/usr/local/sbin/simple-firewall-stop\"},\n    },\n    Install: unit.InstallSection{\n        WantedBy: systemdconf.Value{\"multi-user.target\"},\n    },\n}\nb, _ := systemdconf.Marshal(service)\n\nfmt.Println(string(b))\n// Output: \n// [Unit]\n// Description=Simple firewall\n//\n// [Service]\n// Type=oneshot\n// RemainAfterExit=yes\n// ExecStart=/usr/local/sbin/simple-firewall-start1\n// ExecStart=/usr/local/sbin/simple-firewall-start2\n// ExecStop=/usr/local/sbin/simple-firewall-stop\n//\n// [Install]\n// WantedBy=multi-user.target\n```\n\n### Unmarshal\n\n```go\nfile := `[Unit]\nDescription=Simple firewall\n\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=/usr/local/sbin/simple-firewall-start\nExecStop=/usr/local/sbin/simple-firewall-stop\n\n[Install]\nWantedBy=multi-user.target`\n\nvar service unit.ServiceFile\nsystemdconf.Unmarshal([]byte(file), \u0026service)\n\nfmt.Println(service.Unit.Description)\nb, _ := service.Service.RemainAfterExit.Bool()\nfmt.Println(b)\n// Output: \n// Simple firewall\n// true\n```\n\n## License\n\nBSD 3-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergeymakinen%2Fgo-systemdconf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergeymakinen%2Fgo-systemdconf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergeymakinen%2Fgo-systemdconf/lists"}