osutils

package
v1.5.93 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v1.5.71

func Bool(name string, def bool) bool

Bool reads name from the environment as a boolean, returning def when it is unset, empty, or not something a boolean can be read from.

It accepts what strconv.ParseBool accepts — 1/t/T/TRUE/true/True and their false counterparts — which is the answer the rest of this tree already gives (tools/filesystem, tools/search, core/settings_query all parse booleans that way). The hand-rolled `== "true"` and `!= "1"` checks were the deviation, and each turned a reasonable spelling into silence: BOOTNODE_ENABLED=1 left bootnode off, ZAP_DISABLED=1 left the listener up, and neither said so. An operator's off-switch that does nothing is worse than one that does not exist.

An unparseable value yields def rather than its opposite: someone who wrote something meaningless has not asked for the other thing.

func IsProbablyGoRun added in v0.29.4

func IsProbablyGoRun() bool

IsProbablyGoRun loosely checks if the current program was started with "go run".

func LaunchURL

func LaunchURL(url string) error

LaunchURL attempts to open the provided url in the user's default browser.

It is platform dependent and it uses:

  • "open" on macOS
  • "rundll32" on Windows
  • "xdg-open" on everything else (Linux, FreeBSD, etc.)

func MoveDirContent

func MoveDirContent(src string, dest string, rootExclude ...string) error

MoveDirContent moves the src dir content, that is not listed in the exclude list, to dest dir (it will be created if missing).

The rootExclude argument is used to specify a list of src root entries to exclude.

Note that this method doesn't delete the old src dir.

It is an alternative to os.Rename() for the cases where we can't rename/delete the src dir (see https://github.com/hanzoai/base/issues/2519).

func YesNoPrompt

func YesNoPrompt(message string, fallback bool) bool

YesNoPrompt performs a console prompt that asks the user for Yes/No answer.

If the user just press Enter (aka. doesn't type anything) it returns the fallback value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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