mirror of https://github.com/tailscale/tailscale/
types/key: make Public implement TextMarshaler, TextUnmarshaler
So it can be a map key with encoding/jsonreviewable/pr232/r1
parent
f51f18b42b
commit
810c1e9704
@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package key
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTextUnmarshal(t *testing.T) {
|
||||
p := Public{1, 2}
|
||||
text, err := p.MarshalText()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var p2 Public
|
||||
if err := p2.UnmarshalText(text); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p != p2 {
|
||||
t.Fatalf("mismatch; got %x want %x", p2, p)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue