Skip to content
Permalink
Browse files

all: transition to a Go module

We can't safely convert mvdan.cc/sh v2 to a Go module, as that would
require anyone doing minor or bugfix updates to fix their import paths.
Not only is this a breaking change, but would also be impossible on
earlier Go versions like 1.10 or 1.10.2.

We want the project to be a Go module, since that will provide many
advantages. So take the opportunity and start work on v3. We'll release
v3.0.0-alpha0 right away, so that users can depend on that semantic
version.

For now, the transition to a Go module will stay in the master.v3
branch, to not break existing users - especially those using 'go get' to
install binaries. We will likely replace master with master.v3 once Go
1.12 has been released, since we'll drop Go 1.10 support then.

Updates #266.
  • Loading branch information...
mvdan committed Nov 10, 2018
1 parent cb985f0 commit 1d1cadedc9efe6525e4e30573413551910a68369
@@ -16,7 +16,7 @@ For high-level operations like performing shell expansions on strings, see the

### shfmt

go get -u mvdan.cc/sh/cmd/shfmt
go get -u mvdan.cc/sh/v3/cmd/shfmt

`shfmt` formats shell programs. It can use tabs or any number of spaces to
indent. See [canonical.sh](syntax/canonical.sh) for a quick look at its default
@@ -57,7 +57,7 @@ $ echo 'foo=(1 2)' | shfmt -p

### gosh

go get -u mvdan.cc/sh/cmd/gosh
go get -u mvdan.cc/sh/v3/cmd/gosh

Experimental shell that uses `interp`. Work in progress, so don't expect
stability just yet.
@@ -10,7 +10,7 @@ import (

"github.com/gopherjs/gopherjs/js"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

func main() {
@@ -13,8 +13,8 @@ import (

"golang.org/x/crypto/ssh/terminal"

"mvdan.cc/sh/interp"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax"
)

var (
@@ -7,8 +7,8 @@ import (
"fmt"
"testing"

"mvdan.cc/sh/internal"
"mvdan.cc/sh/interp"
"mvdan.cc/sh/v3/internal"
"mvdan.cc/sh/v3/interp"
)

// Each test has an even number of strings, which form input-output pairs for
@@ -9,7 +9,7 @@ import (
"io"
"reflect"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

func writeJSON(w io.Writer, f *syntax.File, pretty bool) error {
@@ -9,7 +9,7 @@ import (
"strings"
"testing"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

var jsonTests = []struct {
@@ -14,8 +14,8 @@ import (
"path/filepath"
"regexp"

"mvdan.cc/sh/fileutil"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/fileutil"
"mvdan.cc/sh/v3/syntax"
)

var (
@@ -13,7 +13,7 @@ import (
"strings"
"testing"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

func TestMain(m *testing.M) {
@@ -7,7 +7,7 @@ import (
"fmt"
"strconv"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

func Arithm(cfg *Config, expr syntax.ArithmExpr) (int, error) {
@@ -3,7 +3,7 @@

package expand

import "mvdan.cc/sh/syntax"
import "mvdan.cc/sh/v3/syntax"

// Braces performs Bash brace expansion on words. For example, passing it a
// literal word "foo{bar,baz}" will return two literal words, "foobar" and
@@ -15,7 +15,7 @@ import (
"strconv"
"strings"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

// A Config specifies details about how shell expansion should be performed. The
@@ -8,7 +8,7 @@ import (
"strings"
"testing"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

func parseWord(t *testing.T, src string) *syntax.Word {
@@ -12,7 +12,7 @@ import (
"unicode"
"unicode/utf8"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

func nodeLit(node syntax.Node) string {
10 go.mod
@@ -0,0 +1,10 @@
module mvdan.cc/sh/v3

go 1.11

require (
github.com/kr/pretty v0.1.0
golang.org/x/crypto v0.0.0-20181106171534-e4dc69e5b2fd
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 // indirect
)
11 go.sum
@@ -0,0 +1,11 @@
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
golang.org/x/crypto v0.0.0-20181106171534-e4dc69e5b2fd h1:VtIkGDhk0ph3t+THbvXHfMZ8QHgsBO39Nh52+74pq7w=
golang.org/x/crypto v0.0.0-20181106171534-e4dc69e5b2fd/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 h1:YoY1wS6JYVRpIfFngRf2HHo9R9dAne3xbkGOQ5rJXjU=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -13,8 +13,8 @@ import (
"strconv"
"strings"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/syntax"
)

func isBuiltin(name string) bool {
@@ -8,9 +8,9 @@ import (
"os"
"strings"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/interp"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax"
)

func Example() {
@@ -21,8 +21,8 @@ import (

"golang.org/x/sync/errgroup"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/syntax"
)

// New creates a new Runner, applying a number of options. If applying any of
@@ -17,9 +17,9 @@ import (
"testing"
"time"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/internal"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/internal"
"mvdan.cc/sh/v3/syntax"
)

func BenchmarkRun(b *testing.B) {
@@ -14,7 +14,7 @@ import (
"syscall"
"time"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/v3/expand"
)

// FromModuleContext returns the ModuleCtx value stored in ctx, if any.
@@ -15,8 +15,8 @@ import (
"testing"
"time"

"mvdan.cc/sh/internal"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/internal"
"mvdan.cc/sh/v3/syntax"
)

var modCases = []struct {
@@ -12,7 +12,7 @@ import (

"golang.org/x/crypto/ssh/terminal"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

// non-empty string is true, empty string is false
@@ -6,7 +6,7 @@ package interp
import (
"fmt"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

const illegalTok = 0
@@ -9,8 +9,8 @@ import (
"strconv"
"strings"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/syntax"
)

type overlayEnviron struct {
@@ -9,7 +9,7 @@ import (
"io/ioutil"
"os"

"mvdan.cc/sh/shell"
"mvdan.cc/sh/v3/shell"
)

func ExampleExpand() {
@@ -7,8 +7,8 @@ import (
"os"
"strings"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/syntax"
)

// Expand performs shell expansion on s as if it were within double quotes,
@@ -8,9 +8,9 @@ import (
"fmt"
"os"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/interp"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax"
)

// SourceFile sources a shell file from disk and returns the variables
@@ -12,8 +12,8 @@ import (
"strings"
"testing"

"mvdan.cc/sh/expand"
"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/syntax"

"github.com/kr/pretty"
)
@@ -9,7 +9,7 @@ import (
"regexp"
"strings"

"mvdan.cc/sh/syntax"
"mvdan.cc/sh/v3/syntax"
)

func Example() {
@@ -272,7 +272,7 @@ func expandRec(bw *braceWord) []*Word {
// passing it a single-literal word "foo{bar,baz}" will return two
// single-literal words, "foobar" and "foobaz".
//
// Deprecated: use mvdan.cc/sh/expand.Braces instead.
// Deprecated: use mvdan.cc/sh/v3/expand.Braces instead.
func ExpandBraces(word *Word) []*Word {
topBrace, any := splitBraces(word)
if !any {
@@ -16,7 +16,7 @@ import (
"testing"

"github.com/kr/pretty"
"mvdan.cc/sh/internal"
"mvdan.cc/sh/v3/internal"
)

func TestKeepComments(t *testing.T) {

0 comments on commit 1d1cade

Please sign in to comment.
You can’t perform that action at this time.