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>
34 lines
613 B
Go
34 lines
613 B
Go
// 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"
|
|
// }
|
|
}
|