modfile

package
v0.13.10 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoQuote

func AutoQuote(s string) string

AutoQuote returns s or, if quoting is required for s to appear in a gop.mod, the quotation of s.

func ClassExt added in v0.12.1

func ClassExt(fname string) string

ClassExt returns classExt of specified fname.

func Format

func Format(f *FileSyntax) []byte

Format returns a gop.mod file as a byte slice, formatted in standard style.

func IsDirectoryPath

func IsDirectoryPath(ns string) bool

IsDirectoryPath reports whether the given path should be interpreted as a directory path. Just like on the go command line, relative paths and rooted paths are directory paths; the rest are module paths.

func MustQuote

func MustQuote(s string) bool

MustQuote reports whether s must be quoted in order to appear as a single token in a gop.mod line.

func SplitFname added in v0.12.1

func SplitFname(fname string) (className, classExt string)

SplitFname splits fname into (className, classExt).

Types

type Class added in v0.10.0

type Class struct {
	Ext    string // can be "_[class].gox" or ".[class]", eg "_yap.gox" or ".spx"
	Class  string // "Sprite"
	Syntax *Line
}

A Class is the work class statement.

type Comment

type Comment = modfile.Comment

A Comment represents a single // comment.

type CommentBlock

type CommentBlock = modfile.CommentBlock

A CommentBlock represents a top-level block of comments separate from any rule.

type Comments

type Comments = modfile.Comments

Comments collects the comments associated with an expression.

type Error

type Error modfile.Error

func (*Error) Error added in v0.9.12

func (p *Error) Error() string

func (*Error) Summary added in v0.9.12

func (p *Error) Summary() string

func (*Error) Unwrap added in v0.9.12

func (p *Error) Unwrap() error

type ErrorList

type ErrorList = errors.List

type Expr

type Expr = modfile.Expr

An Expr represents an input element.

type File

type File struct {
	Gop       *Gop
	Projects  []*Project
	ClassMods []string // calc by require statements in go.mod (not gop.mod).

	Syntax *FileSyntax
}

A File is the parsed, interpreted form of a gop.mod file.

func New added in v0.13.0

func New(gopmod, gopVer string) *File

func Parse

func Parse(file string, data []byte, fix VersionFixer) (*File, error)

Parse parses and returns a gop.mod file.

file is the name of the file, used in positions and errors.

data is the content of the file.

fix is an optional function that canonicalizes module versions. If fix is nil, all module versions must be canonical (module.CanonicalVersion must return the same string).

func ParseLax

func ParseLax(file string, data []byte, fix VersionFixer) (*File, error)

ParseLax is like Parse but ignores unknown statements. It is used when parsing gop.mod files other than the main module, under the theory that most statement types we add in the future will only apply in the main module, like exclude and replace, and so we get better gradual deployments if old go commands simply ignore those statements when found in gop.mod files in dependencies.

type FileSyntax

type FileSyntax = modfile.FileSyntax

A FileSyntax represents an entire gop.mod file.

type Gop

type Gop = modfile.Go

A Gop is the gop statement.

type Import added in v0.11.1

type Import struct {
	Name   string // maybe empty
	Path   string
	Syntax *Line
}

A Import is the import statement.

type InvalidExtError

type InvalidExtError struct {
	Ext string
	Err error
}

func (*InvalidExtError) Error

func (e *InvalidExtError) Error() string

func (*InvalidExtError) Unwrap

func (e *InvalidExtError) Unwrap() error

type InvalidSymbolError added in v0.10.0

type InvalidSymbolError struct {
	Sym string
	Err error
}

func (*InvalidSymbolError) Error added in v0.10.0

func (e *InvalidSymbolError) Error() string

func (*InvalidSymbolError) Unwrap added in v0.10.0

func (e *InvalidSymbolError) Unwrap() error

type LParen

type LParen = modfile.LParen

An LParen represents the beginning of a parenthesized line block. It is a place to store suffix comments.

type Line

type Line = modfile.Line

A Line is a single line of tokens.

type LineBlock

type LineBlock = modfile.LineBlock

A LineBlock is a factored block of lines, like

require (
	"x"
	"y"
)

type Position

type Position = modfile.Position

A Position describes an arbitrary source position in a file, including the file, line, column, and byte offset.

type Project added in v0.10.0

type Project struct {
	Ext      string    // can be "_[class].gox" or ".[class]", eg "_yap.gox" or ".gmx"
	Class    string    // "Game"
	Works    []*Class  // work class of classfile
	PkgPaths []string  // package paths of classfile and optional inline-imported packages.
	Import   []*Import // auto-imported packages
	Syntax   *Line
}

A Project is the project statement.

func (*Project) IsProj added in v0.12.2

func (p *Project) IsProj(ext, fname string) bool

IsProj checks if a (ext, fname) pair is a project file or not.

type RParen

type RParen = modfile.RParen

An RParen represents the end of a parenthesized line block. It is a place to store whole-line (before) comments.

type VersionFixer

type VersionFixer = modfile.VersionFixer

Jump to

Keyboard shortcuts

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