From 1cd473b9659ed569a3fe890e297bd3832772f6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Santos?= Date: Sun, 2 Jan 2022 12:04:29 +0000 Subject: [PATCH] Update docs and remove list command --- README.md | 17 +++++++++++++++++ gomod-sync/README.md | 34 ++++++++++++++++++++++++---------- gomod-sync/cmd/list.go | 29 ----------------------------- 3 files changed, 41 insertions(+), 39 deletions(-) delete mode 100644 gomod-sync/cmd/list.go diff --git a/README.md b/README.md index 19cd0eeff..360278841 100644 --- a/README.md +++ b/README.md @@ -225,6 +225,23 @@ To regenerate the test cases, navigate into the **go** directory and run `go run exercises//.meta/gen.go`. You should see that the `/cases_test.go` file has changed. Commit the change. +## Managing the Go version + +For an easy managment of the Go version in the `go.mod` file in all exercises, we can use `gomod-sync`. +This is a tool made in Go that can be seen in the `gomod-sync/` folder. + +To update all go.mod files according to the config file (`gomod-sync/config.json`) run: + +```console +$ cd gomod-sync && go run main.go update +``` + +To check all exercise go.mod files specify the correct Go version, run: + +```console +$ cd gomod-sync && go run main.go check +``` + ## Pull requests Pull requests are welcome. diff --git a/gomod-sync/README.md b/gomod-sync/README.md index 4f104293a..82d183b6f 100644 --- a/gomod-sync/README.md +++ b/gomod-sync/README.md @@ -9,13 +9,29 @@ Some exercises must have its `go.mod` specify a Go version that is different fro This is supported by the `exceptions` key of the configuration file, where an entry must exist for each exercise that must not have the default version. +## Quick start + +To update all go.mod files according to the config file (gomod-sync/config.json) run: + +```console +$ cd gomod-sync +$ go run main.go update +``` + +To check all exercise go.mod files specify the correct Go version, run: + +```console +$ cd gomod-sync +$ go run main.go check +``` + ## Installing ### Compiling locally ```console -cd gomod-sync -go build +$ cd gomod-sync +$ go build ``` This will create an executable `gomod-sync` (`gomod-sync.exe` in windows) in the current directory @@ -24,28 +40,26 @@ that you can run to execute the program. ### Running without compiling ```console -cd gomod-sync -go run main.go [command] [flags] +$ cd gomod-sync +$ go run main.go [flags] ``` ### Running the tests ```console -cd gomod-sync -go test ./... +$ cd gomod-sync +$ go test ./... ``` ## Usage ``` - gomod-sync command [flags] + gomod-sync commandUpdate gitig [flags] Available Commands: check Checks if all go.mod files are in the target version - completion generate the autocompletion script for the specified shell - help Help about any command - list List go.mod files and the Go version they specify update Updates go.mod files to the target version + help Help about any command ``` diff --git a/gomod-sync/cmd/list.go b/gomod-sync/cmd/list.go deleted file mode 100644 index 4889f65b5..000000000 --- a/gomod-sync/cmd/list.go +++ /dev/null @@ -1,29 +0,0 @@ -package cmd - -import ( - "fmt" - - "github.com/exercism/go/gomod-sync/gomod" - "github.com/spf13/cobra" -) - -func init() { - rootCmd.AddCommand(listCmd) -} - -var listCmd = &cobra.Command{ - Use: "list", - Short: "List go.mod files and the Go version they specify", - RunE: func(cmd *cobra.Command, args []string) error { - files, err := gomod.Infos(exercisesPathFlag) - if err != nil { - return fmt.Errorf("could not get go.mod information: %w", err) - } - - for _, file := range files { - fmt.Printf("%s => %s\n", file.Path, file.GoVersion) - } - - return nil - }, -}