Files
tailscale/cmd/tailscale/jsonoutput/example_responseenvelope_test.go
T
Simon LawandGitHub 358c975aea 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>
2026-07-27 13:41:15 -07:00

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"
// }
}