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

common

package
v0.67.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package common provides shared functionality for pipeleek platform-specific binaries.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "none"
	Date    = "unknown"
)

Version information - set via ldflags during build

View Source
var (
	JsonLogoutput bool
	LogFile       string
	LogColor      bool
	LogDebug      bool
	LogLevel      string
	IgnoreProxy   bool
)

Log configuration

View Source
var TerminalRestorer func()

TerminalRestorer is a function that can be called to restore terminal state

Functions

func AddCommonFlags

func AddCommonFlags(cmd *cobra.Command)

AddCommonFlags adds the common logging and output flags to a cobra command

func InitLogger

func InitLogger(cmd *cobra.Command)

InitLogger initializes the zerolog logger with the configured options

func RestoreTerminalState

func RestoreTerminalState()

RestoreTerminalState restores the terminal to its saved state

func Run

func Run(rootCmd *cobra.Command)

Run executes the common startup sequence and runs the provided root command

func SaveTerminalState

func SaveTerminalState()

SaveTerminalState saves the current terminal state for later restoration

func SetGlobalLogLevel

func SetGlobalLogLevel(cmd *cobra.Command)

SetGlobalLogLevel sets the global log level based on the configured options

func SetupPersistentPreRun

func SetupPersistentPreRun(cmd *cobra.Command)

SetupPersistentPreRun sets up the PersistentPreRun handler for logging initialization

Types

type CustomWriter

type CustomWriter struct {
	Writer *os.File
}

CustomWriter wraps an os.File with proper cross-platform newline handling

func (*CustomWriter) Write

func (cw *CustomWriter) Write(p []byte) (n int, err error)

type FatalHook

type FatalHook struct{}

FatalHook is a zerolog hook that restores terminal state before fatal exits

func (FatalHook) Run

func (h FatalHook) Run(e *zerolog.Event, level zerolog.Level, msg string)

type TerminalRestoringWriter

type TerminalRestoringWriter struct {
	// contains filtered or unexported fields
}

TerminalRestoringWriter wraps an io.Writer to restore terminal state on fatal logs

func (*TerminalRestoringWriter) Write

func (w *TerminalRestoringWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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