diff options
author | Slack Coder <slackcoder@server.ky> | 2024-10-02 16:49:36 -0500 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2024-10-02 17:01:48 -0500 |
commit | 2597c03d1555e00dec59830b7de75e7090208e05 (patch) | |
tree | 5642202b4621ea722ee85b322d79bbad17894026 /internal/service/mirror.go | |
parent | b81d017b42cc814e603de2b49e4b78362ae73f2a (diff) | |
download | mirror-2597c03d1555e00dec59830b7de75e7090208e05.tar.xz |
config: Use TOML
TOML is simple for users, and it is used in notably projects like
rustlang. It also provides comments!
Diffstat (limited to 'internal/service/mirror.go')
-rw-r--r-- | internal/service/mirror.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/service/mirror.go b/internal/service/mirror.go new file mode 100644 index 0000000..12aaa79 --- /dev/null +++ b/internal/service/mirror.go @@ -0,0 +1,27 @@ +package service + +import ( + "bytes" + + "git.server.ky/slackcoder/mirror/internal" + "github.com/BurntSushi/toml" +) + +type Mirror struct { + Method string `toml:"method,omitempty"` + From *internal.URL `toml:"from,omitempty"` + To *internal.URL `toml:"to,omitempty"` + Description string `toml:"description,omitempty"` +} + +func (m *Mirror) Equal(arg *Mirror) bool { + return m.Method == arg.Method && m.From.String() == arg.From.String() && m.To.String() == arg.To.String() +} + +func (m *Mirror) String() string { + var buf bytes.Buffer + + toml.NewEncoder(&buf).Encode(m) + + return buf.String() +} |