/workman

A simple cli tool to manage your go.work file.๐Ÿฅฃ

Primary LanguageGoMIT LicenseMIT

workman

A simple cli tool to manage your go.work file.

How to install

  • method 1: Use the go command go install github.com/das6ng/workman@latest.

  • method 2: Go to the release page.

How to use

just run workman in any module inside a go.work defined workspace, and you'll see the command line UI interactives.

BTW, the command itself already support json output and arg-based operations. Run workman -h to see the usage.

Usage of workman:
  -l    list go.work info
  -n    no command line ui
  -u string
        update go.work (default "{}")

There is a dashengyeah.vscode-go-work-manager plugin, enjoy it! ๐ŸŽƒ

Example

  1. Our workspace

Folder tree:

~/work/
โ”œโ”€โ”€ go.work
โ”œโ”€โ”€ mod1/
โ”‚   โ””โ”€โ”€ go.mod
โ”œโ”€โ”€ mod2/
โ”‚   โ””โ”€โ”€ go.mod
โ”œโ”€โ”€ mod3/
โ”‚   โ””โ”€โ”€ go.mod
โ”œโ”€โ”€ mod4/
โ”‚   โ””โ”€โ”€ go.mod
โ”œโ”€โ”€ mod5/
โ”‚   โ””โ”€โ”€ go.mod
โ””โ”€โ”€ mod6/
    โ””โ”€โ”€ go.mod

Our go.work file:

go 1.18

use (
    mod1
    mod2
    mod3
)
  1. Let's try $ workman.

Output:

Workspace: ~/work/go.work go1.18
Module usage:
โˆš mod1
โˆš mod2
โˆš mod3
 ยท mod4
 ยท mod5
 ยท mod6
change: <Tab> | exit: <Esc>/<q>

It displays the go.work file path and the go version in it.

  1. It's interactive. press <Tab> key to change the modules we are using.

Output:

Modules:
> [โœ“] mod1
  [โœ“] mod2
  [โœ“] mod3
  [โœ—] mod4
  [โœ—] mod5
  [โœ—] mod6
enter: select | tab: confirm | left: none | right: all | type to filter

Follow the instructions to turn OFF mod1 mod3, and turn ON mod6.

Modules:
  [โœ—] mod1
  [โœ“] mod2
  [โœ—] mod3
  [โœ—] mod4
  [โœ—] mod5
> [โœ“] mod6
enter: select | tab: confirm | left: none | right: all | type to filter

Press <Tab> to confirm. Then it backs to display the current go.work status.

Workspace: /home/dash/work/go.work go1.18
Module usage:
โˆš mod2
โˆš mod6
 ยท mod1
 ยท mod3
 ยท mod4
 ยท mod5
change: <Tab> | exit: <Esc>/<q>

Press <Esc> to quit the tool. And cat go.work to see its content.

go 1.18

use (
    mod2
    mod6
)

That's it.