go-internal

module
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: BSD-3-Clause

README

This repository factors out an opinionated selection of internal packages and functionality from the Go standard library. Currently this consists mostly of packages and testing code from within the Go tool implementation.

This repo is primarily maintained by long-time Go contributors who are also currently maintaining CUE (which is primarily written in Go and which relies upon several of the packages here).

Contributions are welcome, but please open an issue for discussion first.

Packages

Included are the following:

  • dirhash: calculate hashes over directory trees the same way that the Go tool does.
  • goproxytest: a GOPROXY implementation designed for test use.
  • gotooltest: Use the Go tool inside test scripts (see testscript below)
  • imports: list of known architectures and OSs, and support for reading import statements.
  • modfile: read and write go.mod files while preserving formatting and comments.
  • module: module paths and versions.
  • par: do work in parallel.
  • semver: semantic version parsing.
  • testenv: information on the current testing environment.
  • testscript: script-based testing based on txtar files
  • txtar: simple text-based file archives for testing.

testscript

The most popular package here is the testscript package:

  • Provides a shell-like test environment that is very nicely tuned for testing Go CLI commands.
  • Extracted from the core Go team's internal testscript package (cmd/go/internal/script), which is heavily used to test the go command.
  • Supports patterns for checking stderr/stdout, command pass/fail assertions, and so on.
  • Integrates well with go test, including coverage support.
  • Inputs and sample output files can use the simple txtar text archive format, also used by the Go playground.
  • Allows automatically updating golden files.
  • Built-in support for Go concepts like build tags.
  • Accompanied by a testscript command for running standalone scripts with files embedded in txtar format.

A nice introduction to using testscripts is this blog post series. Both testscript and txtar were originally created by Russ Cox.

Directories

Path Synopsis
Package cache implements a build artifact cache.
Package cache implements a build artifact cache.
cmd
txtar-addmod
The txtar-addmod command adds a module as a txtar archive to the a testdata module directory as understood by the goproxytest package (see https://godoc.org/github.com/rogpeppe/go-internal/goproxytest).
The txtar-addmod command adds a module as a txtar archive to the a testdata module directory as understood by the goproxytest package (see https://godoc.org/github.com/rogpeppe/go-internal/goproxytest).
txtar-c
The txtar-c command archives a directory tree as a txtar archive printed to standard output.
The txtar-c command archives a directory tree as a txtar archive printed to standard output.
txtar-goproxy
The txtar-goproxy command runs a Go module proxy from a txtar module directory (as manipulated by the txtar-addmod command).
The txtar-goproxy command runs a Go module proxy from a txtar module directory (as manipulated by the txtar-addmod command).
txtar-x
The txtar-x command extracts a txtar archive to a filesystem.
The txtar-x command extracts a txtar archive to a filesystem.
Package dirhash defines hashes over directory trees.
Package dirhash defines hashes over directory trees.
Package fmtsort provides a general stable ordering mechanism for maps, on behalf of the fmt and text/template packages.
Package fmtsort provides a general stable ordering mechanism for maps, on behalf of the fmt and text/template packages.
Package goproxytest serves Go modules from a proxy server designed to run on localhost during tests, both to make tests avoid requiring specific network servers and also to make them significantly faster.
Package goproxytest serves Go modules from a proxy server designed to run on localhost during tests, both to make tests avoid requiring specific network servers and also to make them significantly faster.
Package gotooltest implements functionality useful for testing tools that use the go command.
Package gotooltest implements functionality useful for testing tools that use the go command.
internal
misspell
Package misspell impements utilities for basic spelling correction.
Package misspell impements utilities for basic spelling correction.
syscall/windows/sysdll
Package sysdll is an internal leaf package that records and reports which Windows DLL names are used by Go itself.
Package sysdll is an internal leaf package that records and reports which Windows DLL names are used by Go itself.
Package lockedfile creates and manipulates files whose contents should only change atomically.
Package lockedfile creates and manipulates files whose contents should only change atomically.
internal/filelock
Package filelock provides a platform-independent API for advisory file locking.
Package filelock provides a platform-independent API for advisory file locking.
Package modfile implements parsing and formatting for go.mod files.
Package modfile implements parsing and formatting for go.mod files.
Package module is a thin forwarding layer on top of golang.org/x/mod/module.
Package module is a thin forwarding layer on top of golang.org/x/mod/module.
Package par implements parallel execution helpers.
Package par implements parallel execution helpers.
Package renameio writes files atomically by renaming temporary files.
Package renameio writes files atomically by renaming temporary files.
Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.
Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.
Package semver is a thin forwarding layer on top of golang.org/x/mod/semver.
Package semver is a thin forwarding layer on top of golang.org/x/mod/semver.
Package testenv provides information about what functionality is available in different testing environments run by the Go team.
Package testenv provides information about what functionality is available in different testing environments run by the Go team.
Package testscript provides support for defining filesystem-based tests by creating scripts in a directory.
Package testscript provides support for defining filesystem-based tests by creating scripts in a directory.
Package txtar implements a trivial text-based file archive format.
Package txtar implements a trivial text-based file archive format.

Jump to

Keyboard shortcuts

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