gotoolbox

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 17 Imported by: 0

README

gotoolbox

My personal set of tools for the "go tool" command.

(TODO)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsGlibcEnv = sync.OnceValue(
	func() bool {

		if out, err := os.ReadFile("/proc/self/maps"); err == nil {
			if muslRegex.Match(out) {
				return false
			}
		}

		if lddPath, err := exec.LookPath("ldd"); err == nil {
			if ldd, err := os.ReadFile(lddPath); err == nil {
				if muslRegex.Match(ldd) {
					return false
				} else if glibcRegex.Match(ldd) {
					return true
				}
			}

			if lddVersion, err := exec.Command(
				lddPath, "--version",
			).CombinedOutput(); err == nil {
				if muslRegex.Match(lddVersion) {
					return false
				} else if glibcRegex.Match(lddVersion) {
					return true
				}
			}
		}

		return false
	},
)

IsGlibcEnv returns true if the host platform is a GNU libc environment. Otherwise, e.g. on musl libc environments, returns false.

Functions

func CacheDirPath added in v0.0.2

func CacheDirPath() string

func Download added in v0.0.2

func Download(url string) (io.ReadCloser, error)

func Exec

func Exec(binPath string) error

func OpenFileInArchive added in v0.0.2

func OpenFileInArchive(
	archiveFile *os.File,
	archiveFileSize int64,
	archiveFormat ArchiveFormat,
	inArchiveFilePath string,
) (io.ReadCloser, error)

func SelectByLibc added in v0.0.2

func SelectByLibc(glibc, other string) string

SelectByLibc returns [glibc] if glibc was detected, otherwise returns [other] on e.g. musl libc environments. If glibc was not explicitly detected it will default to [other].

Types

type ArchiveFormat added in v0.0.2

type ArchiveFormat int
const (
	NotAnArchive ArchiveFormat = iota
	ZipArchive
	TarArchive
	TarGzipArchive
	TarBzip2Archive
)

type Artifact added in v0.0.2

type Artifact struct {
	CacheName         string
	DownloadURL       string
	Checksum          Checksum
	ArchiveFormat     ArchiveFormat
	InArchiveFilePath string
}

Artifact defines where and how to download the artifact for a tool.

type Checksum added in v0.0.2

type Checksum struct {
	Algorithm crypto.Hash
	Digest    string
}

Checksum defines how to verify the downloaded Artifact.

type ReadCloserWrapper added in v0.0.2

type ReadCloserWrapper struct {
	io.Reader
	Closer io.Closer
}

ReadCloserWrapper is an io.ReadCloser which wraps an io.Reader with an optionally definable io.Closer.

func (*ReadCloserWrapper) Close added in v0.0.2

func (r *ReadCloserWrapper) Close() error

type Tool added in v0.0.2

type Tool struct {
	Name     string
	Artifact Artifact
}

Tool defines a gotoolbox tool.

func (*Tool) DownloadIfNeeded added in v0.0.2

func (t *Tool) DownloadIfNeeded() (string, error)

TODO: Compare with dprint and goreleaser npm install.js scripts.

func (*Tool) Run added in v0.0.2

func (t *Tool) Run()

Directories

Path Synopsis
dprint module
goreleaser module

Jump to

Keyboard shortcuts

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