package modfile
import "cmd/go/internal/modfile"
Index ¶
- func AutoQuote(s string) string
- func Format(f *FileSyntax) []byte
- func ParseGopkgIn(path string) (root, repo, major, subdir string, ok bool)
- type Comment
- type CommentBlock
- type Comments
- type Exclude
- type Expr
- type File
- func Parse(file string, data []byte, fix VersionFixer) (*File, error)
- func (f *File) AddComment(text string)
- func (f *File) AddModuleStmt(path string)
- func (x *File) AddRequire(path, vers string)
- func (f *File) Format() ([]byte, error)
- func (f *File) SetRequire(req []module.Version)
- func (f *File) SortBlocks()
- type FileSyntax
- type LParen
- type Line
- type LineBlock
- type Module
- type Position
- type RParen
- type Replace
- type Require
- type VersionFixer
Functions ¶
func AutoQuote ¶
AutoQuote returns s or, if quoting is required for s to appear in a go.mod, the quotation of s.
func Format ¶
func Format(f *FileSyntax) []byte
func ParseGopkgIn ¶
ParseGopkgIn splits gopkg.in import paths into their constituent parts
Types ¶
type Comment ¶
type Comment struct { Start Position Token string // without trailing newline Suffix bool // an end of line (not whole line) comment }
A Comment represents a single // comment.
type CommentBlock ¶
A CommentBlock represents a top-level block of comments separate from any rule.
func (*CommentBlock) Span ¶
func (x *CommentBlock) Span() (start, end Position)
type Comments ¶
type Comments struct { Before []Comment // whole-line comments before this expression Suffix []Comment // end-of-line comments after this expression // For top-level expressions only, After lists whole-line // comments following the expression. After []Comment }
Comments collects the comments associated with an expression.
func (*Comments) Comment ¶
Comment returns the receiver. This isn't useful by itself, but a Comments struct is embedded into all the expression implementation types, and this gives each of those a Comment method to satisfy the Expr interface.
type Exclude ¶
type Expr ¶
type Expr interface { // Span returns the start and end position of the expression, // excluding leading or trailing comments. Span() (start, end Position) // Comment returns the comments attached to the expression. // This method would normally be named 'Comments' but that // would interfere with embedding a type of the same name. Comment() *Comments }
An Expr represents an input element.
type File ¶
type File struct { Module *Module Require []*Require Exclude []*Exclude Replace []*Replace Syntax *FileSyntax }
func Parse ¶
func Parse(file string, data []byte, fix VersionFixer) (*File, error)
func (*File) AddComment ¶
func (*File) AddModuleStmt ¶
func (*File) AddRequire ¶
func (*File) Format ¶
func (*File) SetRequire ¶
func (*File) SortBlocks ¶
func (f *File) SortBlocks()
type FileSyntax ¶
A FileSyntax represents an entire go.mod file.
func (*FileSyntax) Span ¶
func (x *FileSyntax) Span() (start, end Position)
type LParen ¶
An LParen represents the beginning of a parenthesized line block. It is a place to store suffix comments.
func (*LParen) Span ¶
type Line ¶
A Line is a single line of tokens.
func (*Line) Span ¶
type LineBlock ¶
type LineBlock struct { Comments Start Position LParen LParen Token []string Line []*Line RParen RParen }
A LineBlock is a factored block of lines, like
require ( "x" "y" )
func (*LineBlock) Span ¶
type Module ¶
type Position ¶
type Position struct { Line int // line in input (starting at 1) LineRune int // rune in line (starting at 1) Byte int // byte in input (starting at 0) }
A Position describes the position between two bytes of input.
type RParen ¶
An RParen represents the end of a parenthesized line block. It is a place to store whole-line (before) comments.
func (*RParen) Span ¶
type Replace ¶
type Require ¶
type VersionFixer ¶
Source Files ¶
gopkgin.go print.go read.go rule.go
- Version
- v1.11.0-beta.1
- Published
- Jun 26, 2018
- Platform
- js/wasm
- Imports
- 12 packages
- Last checked
- 10 seconds ago –
Tools for package owners.