mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
all: replace logtail.{Public,Private}ID with logid.{Public,Private}ID (#7404)
The log ID types were moved to a separate package so that code that only depend on log ID types do not need to link in the logic for the logtail client itself. Not all code need the logtail client. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
@@ -33,7 +33,7 @@ func NewPrivateID() (id PrivateID, err error) {
|
||||
func (id PrivateID) MarshalText() ([]byte, error) {
|
||||
b := make([]byte, hex.EncodedLen(len(id)))
|
||||
if i := hex.Encode(b, id[:]); i != len(b) {
|
||||
return nil, fmt.Errorf("logtail.PrivateID.MarshalText: i=%d", i)
|
||||
return nil, fmt.Errorf("logid.PrivateID.MarshalText: i=%d", i)
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
@@ -61,10 +61,10 @@ func (id PrivateID) IsZero() bool { return id == PrivateID{} }
|
||||
func (id *PrivateID) UnmarshalText(s []byte) error {
|
||||
b, err := hex.DecodeString(string(s))
|
||||
if err != nil {
|
||||
return fmt.Errorf("logtail.PrivateID.UnmarshalText: %v", err)
|
||||
return fmt.Errorf("logid.PrivateID.UnmarshalText: %v", err)
|
||||
}
|
||||
if len(b) != len(id) {
|
||||
return fmt.Errorf("logtail.PrivateID.UnmarshalText: invalid hex length: %d", len(b))
|
||||
return fmt.Errorf("logid.PrivateID.UnmarshalText: invalid hex length: %d", len(b))
|
||||
}
|
||||
copy(id[:], b)
|
||||
return nil
|
||||
@@ -121,14 +121,14 @@ func MustParsePublicID(s string) PublicID {
|
||||
func (id PublicID) MarshalText() ([]byte, error) {
|
||||
b := make([]byte, hex.EncodedLen(len(id)))
|
||||
if i := hex.Encode(b, id[:]); i != len(b) {
|
||||
return nil, fmt.Errorf("logtail.PublicID.MarshalText: i=%d", i)
|
||||
return nil, fmt.Errorf("logid.PublicID.MarshalText: i=%d", i)
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (id *PublicID) UnmarshalText(s []byte) error {
|
||||
if len(s) != len(id)*2 {
|
||||
return fmt.Errorf("logtail.PublicID.UnmarshalText: invalid hex length: %d", len(s))
|
||||
return fmt.Errorf("logid.PublicID.UnmarshalText: invalid hex length: %d", len(s))
|
||||
}
|
||||
for i := range id {
|
||||
a, ok1 := fromHexChar(s[i*2+0])
|
||||
|
Reference in New Issue
Block a user