testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOsImport

func AddOsImport(code string) string

AddOsImport ensures "os" is in the imports if os.Getenv is used

func InjectDevURIs

func InjectDevURIs(code string) string

InjectDevURIs adds dev endpoint options when HYPHEN_DEV=true

func IsCompleteProgram

func IsCompleteProgram(code string) bool

IsCompleteProgram checks if code has package main and func main

func ReplaceCredentials

func ReplaceCredentials(code string) string

ReplaceCredentials replaces placeholder strings with os.Getenv calls

func RunGoCode

func RunGoCode(t *testing.T, code string) (string, error)

RunGoCode writes code to a temp directory, sets up go.mod with local SDK, runs the code, and returns the combined stdout/stderr output.

Types

type CodeBlock

type CodeBlock struct {
	Code    string
	Line    int    // Line number in source for debugging
	Section string // README section name (if applicable)
}

CodeBlock represents a Go code block extracted from a markdown file

func ExtractGoCodeBlocks

func ExtractGoCodeBlocks(markdownPath string) ([]CodeBlock, error)

ExtractGoCodeBlocks parses a markdown file and returns all ```go blocks

Jump to

Keyboard shortcuts

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