procname

package
v12.120.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package procname provides methods for changing process name in the process tree

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongSize is returned if given slice have the wrong size
	ErrWrongSize = errors.New("Given slice must have same size as os.Arg")

	// ErrWrongArguments is returned if one of given arguments is empty
	ErrWrongArguments = errors.New("Arguments can't be empty")
)

Functions

func Replace

func Replace(from, to string) error

Replace replaces one argument in process command

WARNING: Be careful with using os.Args or options.Parse result as 'from' argument. After using this method given variable content will be replaced. Use strutil.Copy method in this case.

Example
password := "mySuppaPass"

// Replacing known password to asterisks
err := Replace(password, "*****************")

if err != nil {
	fmt.Printf("Error: %v\n", err)
}
Output:

func Set

func Set(args []string) error

Set changes current process command in process tree

Example
args := os.Args

// Mask first argument
args[1] = strings.Repeat("*", len(args[1]))

err := Set(args)

if err != nil {
	fmt.Printf("Error: %v\n", err)
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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