snippet

package module
v0.0.0-...-0b654b2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 10 Imported by: 0

README

snippet

testing Go files with snippets

Documentation

Overview

Package snippet compare snippets in golang file.

Snippets lines without specific upcase/lower case of letters. Name of snippet is single word.

Format of snippet:

// Snippet Name
some code
// End Name

Index

Constants

This section is empty.

Variables

View Source
var ExpectSnippets = "./expect.snippets"

ExpectSnippets is location of expect snippets

View Source
var SuffixFiles = []string{".go"}

SuffixFiles store list of acceptable fileformat

Functions

func Compare

func Compare(
	actualFilename, expectFilename string,
	diffOnly bool,
) (err error)

Compare snippers from expectFilenames and files/folders from actualFilename

func Test

func Test(t interface {
	Errorf(format string, args ...any)
	Logf(format string, args ...any)
}, folder string)

Test and update snippets in all acceptable files in `folder` with subfolders. Location with expected snippets in file "ExpectSnippets"

for update snippets run in console: UPDATE=true go test or see package `compare`

Types

type Position

type Position struct {
	Filename string
	Line     int
}

Position line of code

func (Position) String

func (p Position) String() string

type Snippet

type Snippet struct {
	Name       string
	Start, End Position
	Code       []string
}

Snippet inside code

func Get

func Get(filename string) (snippets []Snippet, err error)

Get snippets from `filename` and it is folder or file

func (Snippet) String

func (s Snippet) String() string

Jump to

Keyboard shortcuts

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