libguard

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package libguard reads the source of a library ovdb builds on, for the tests that hold ovdb's text and branches to the values that library can produce. Where a library exports a list of its values the test uses that list; where it exports only constants (github.com/strongo/cli-helpers' skillsync actions, selfupdate failure kinds) these helpers read them from the source of the exact version go.mod selects, so the library gaining a value fails a test, with a message saying what to add, instead of reaching a person as a panic or a silently wrong line.

Only tests import this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstNamesWithPrefix

func ConstNamesWithPrefix(files []*ast.File, prefix string) []string

ConstNamesWithPrefix lists, in source order, the names of the constants in files that start with prefix.

func HasStringLiteral

func HasStringLiteral(files []*ast.File, text string) bool

HasStringLiteral reports whether any file holds the string literal text.

func Source

func Source(t testing.TB, importPath string) []*ast.File

Source parses the non-test Go files of the package importPath as the build resolves it. It fails the test when the go command or the source is not available: a guard that cannot read the library must not pass quietly.

func StringConstsOfType

func StringConstsOfType(files []*ast.File, typeName string) []string

StringConstsOfType lists, sorted, the string values of the constants of type typeName in files, written as `Name Type = "value"`, `Name = Type("value")`, `Name Type = Type("value")`, or several names at once, `A, B Type = "a", "b"`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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