Help us shape the future of Go! Take the 2026 Go Developer Survey

output

package
v1.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(w io.Writer, env *Envelope, format string) error

Print 按 format 输出 Envelope:json(默认,Agent 用)/ table / yaml。

Types

type Envelope

type Envelope struct {
	OK    bool        `json:"ok"`
	Data  interface{} `json:"data,omitempty"`
	Error *ErrorInfo  `json:"error,omitempty"`
	Meta  *Meta       `json:"meta,omitempty"`
}

Envelope 是 CLI 对 Agent/脚本的统一输出契约(对齐 gitlink-cli)。

func Fail

func Fail(code interface{}, message, suggestion string) *Envelope

func FromServer

func FromServer(status int, raw json.RawMessage) *Envelope

FromServer 把服务端响应映射为 Envelope。兼容:

  1. 标准壳 {code, message, data, timestamp}(internal/pkg/response)
  2. 错误体 {code, message} / {status, message}
  3. 裸 JSON(列表包装 list/tasks/items/... 会拍平到 data + meta)

func Success

func Success(data interface{}, meta *Meta) *Envelope

type ErrorInfo

type ErrorInfo struct {
	Code       interface{} `json:"code,omitempty"`
	Message    string      `json:"message"`
	Suggestion string      `json:"suggestion,omitempty"`
}

type Meta

type Meta struct {
	Page       int `json:"page,omitempty"`
	Limit      int `json:"limit,omitempty"`
	TotalCount int `json:"total_count,omitempty"`
	TotalPages int `json:"total_pages,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL