modfile

package
v1.1.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

* Copyright (c) 2021 The GoPlus Authors (goplus.org). All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

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 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 ModulePath

func ModulePath(mod []byte) string

ModulePath returns the module path from the gopmod file text. If it cannot find a module path, it returns an empty string. It is tolerant of unrelated problems in the gop.mod file.

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.

Types

type Classfile

type Classfile struct {
	ProjExt  string   // ".gmx"
	WorkExt  string   // ".spx"
	PkgPaths []string // package paths of classfile
	Syntax   *Line
}

A Classfile is the classfile 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

type ErrorList

type ErrorList = modfile.ErrorList

type Exclude

type Exclude = modfile.Exclude

An Exclude is a single exclude statement.

type Expr

type Expr = modfile.Expr

An Expr represents an input element.

type File

type File struct {
	modfile.File
	Gop       *Gop
	Classfile *Classfile
	Register  []*Register
}

A File is the parsed, interpreted form of a gop.mod 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.

func (*File) AddGopStmt added in v1.0.27

func (f *File) AddGopStmt(version string) error

func (*File) AddNewRegister

func (f *File) AddNewRegister(modPath string)

func (*File) AddRegister

func (f *File) AddRegister(modPath string)

func (*File) DropAllReplace

func (f *File) DropAllReplace()

func (*File) DropAllRequire

func (f *File) DropAllRequire()

type FileSyntax

type FileSyntax = modfile.FileSyntax

A FileSyntax represents an entire gop.mod file.

type Go

type Go = modfile.Go

A Go is the go statement.

type Gop

type Gop = modfile.Go

A Gop is the gop 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 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 Module

type Module = modfile.Module

A Module is the module statement.

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 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 Register

type Register struct {
	ClassfileMod string // module path of classfile
	Syntax       *Line
}

A Register is the register statement.

type Replace

type Replace = modfile.Replace

A Replace is a single replace statement.

type Require

type Require = modfile.Require

A Require is a single require statement.

type Retract

type Retract = modfile.Retract

A Retract is a single retract statement.

type VersionFixer

type VersionFixer = modfile.VersionFixer

type VersionInterval

type VersionInterval = modfile.VersionInterval

A VersionInterval represents a range of versions with upper and lower bounds. Intervals are closed: both bounds are included. When Low is equal to High, the interval may refer to a single version ('v1.2.3') or an interval ('[v1.2.3, v1.2.3]'); both have the same representation.

Jump to

Keyboard shortcuts

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