cmd/tailscale/jsonoutput: hoist jsonoutput out of cli package (#20591)
Flatten the cmd/tailscale package hierarchy by extracting the jsonoutput package out of the cmd/tailscale/cli package. Updates #cleanup Change-Id: I92f80db75b0328e82f1596b6a42f6f6ef5a94bfa Signed-off-by: Simon Law <sfllaw@tailscale.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package jsonoutput_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"tailscale.com/cmd/tailscale/jsonoutput"
|
||||
)
|
||||
|
||||
type Hello struct {
|
||||
jsonoutput.ResponseEnvelope
|
||||
Greeting string
|
||||
}
|
||||
|
||||
func ExampleResponseEnvelope() {
|
||||
hi := Hello{
|
||||
ResponseEnvelope: jsonoutput.ResponseEnvelope{SchemaVersion: "1"},
|
||||
Greeting: "Hello, world",
|
||||
}
|
||||
out, err := json.MarshalIndent(hi, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("%s\n", out)
|
||||
// Output:
|
||||
// {
|
||||
// "SchemaVersion": "1",
|
||||
// "Greeting": "Hello, world"
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user