Add format config support

This commit is contained in:
世界
2022-07-03 03:42:57 +08:00
parent 30444057bd
commit 85a695caa1
10 changed files with 77 additions and 60 deletions

View File

@@ -7,9 +7,12 @@ import (
type ListenAddress netip.Addr
func (a *ListenAddress) MarshalJSON() ([]byte, error) {
value := netip.Addr(*a).String()
return json.Marshal(value)
func (a ListenAddress) MarshalJSON() ([]byte, error) {
addr := netip.Addr(a)
if !addr.IsValid() {
return json.Marshal("")
}
return json.Marshal(addr.String())
}
func (a *ListenAddress) UnmarshalJSON(bytes []byte) error {