gen

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gen turns a package's // vis: directives into Go code: one vis_gen.go of ordinary vis calls, checked in and readable.

It reads the package's syntax only, with go/parser: the directives built so far (knob, signal, slo, rule) need no type information. Directives are comments of the form

// vis:<kind> key=value key="a quoted value" ...

directly above the declaration they configure.

Index

Constants

View Source
const File = "vis_gen.go"

File is the name of the file Generate's output belongs in.

Variables

This section is empty.

Functions

func Generate

func Generate(dir string) ([]byte, error)

Generate reads the Go package in dir and returns the source of vis_gen.go, or nil if the package has no directives.

Types

type Diag

type Diag struct {
	Pos    token.Pos
	Msg    string
	Advice bool
}

Diag is one problem with a directive, at its position. Advice is a directive that works but likely isn't what was meant: vis vet reports it, and vis gen generates anyway.

func FromFiles

func FromFiles(fset *token.FileSet, files []*ast.File) ([]byte, []Diag, error)

FromFiles is Generate for files already parsed, with comments, such as an analyzer's: the package's own files, without tests or vis_gen.go. It returns the problems found instead of the source when there are any, and the source with any advice otherwise.

type Errors

type Errors []string

Errors is every problem found, each "file:line: message".

func (Errors) Error

func (e Errors) Error() string

Jump to

Keyboard shortcuts

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