Skip to content

Commit

Permalink
modfile: forward to x/mod (#208)
Browse files Browse the repository at this point in the history
The canonical implementation of this code has now been made available
inside the x/mod module, so use that. The API is almost identical,
with the exception of `ParseGopkgIn` which isn't there.
  • Loading branch information
rogpeppe committed Mar 27, 2023
1 parent 66d1a7a commit 6e5fb8c
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 1,887 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/rogpeppe/go-internal

go 1.19

require golang.org/x/mod v0.9.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
57 changes: 57 additions & 0 deletions modfile/forward.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Package modfile implements parsing and formatting for go.mod files.
//
// This is now just a simple forwarding layer over golang.org/x/mod/modfile
// apart from the ParseGopkgIn function which doesn't exist there.
//
// See that package for documentation.
package modfile

import (
"golang.org/x/mod/modfile"
)

type Position = modfile.Position
type Expr = modfile.Expr
type Comment = modfile.Comment
type Comments = modfile.Comments
type FileSyntax = modfile.FileSyntax
type CommentBlock = modfile.CommentBlock
type Line = modfile.Line
type LineBlock = modfile.LineBlock
type LParen = modfile.LParen
type RParen = modfile.RParen
type File = modfile.File
type Module = modfile.Module
type Go = modfile.Go
type Require = modfile.Require
type Exclude = modfile.Exclude
type Replace = modfile.Replace
type VersionFixer = modfile.VersionFixer

func Format(f *FileSyntax) []byte {
return modfile.Format(f)
}

func ModulePath(mod []byte) string {
return modfile.ModulePath(mod)
}

func Parse(file string, data []byte, fix VersionFixer) (*File, error) {
return modfile.Parse(file, data, fix)
}

func ParseLax(file string, data []byte, fix VersionFixer) (*File, error) {
return modfile.ParseLax(file, data, fix)
}

func IsDirectoryPath(ns string) bool {
return modfile.IsDirectoryPath(ns)
}

func MustQuote(s string) bool {
return modfile.MustQuote(s)
}

func AutoQuote(s string) string {
return modfile.AutoQuote(s)
}
164 changes: 0 additions & 164 deletions modfile/print.go

This file was deleted.

0 comments on commit 6e5fb8c

Please sign in to comment.