Help us shape the future of Go! Take the 2026 Go Developer Survey

setup

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GPGSetup runs the GPG setup flow (wired to cmd/gpg.SetupGPG).
	GPGSetup = func(_ bool) error {
		return errUnwired("GPGSetup (cmd/gpg)")
	}
	// IDEUpdate runs the Antigravity IDE installer (wired to cmd/update.RunIdeUpdate).
	IDEUpdate = func(_ context.Context, _ string, _, _ bool) error {
		return errUnwired("IDEUpdate (cmd/update)")
	}
)

Cross-domain setup steps, wired by cmd/root.go (the only package allowed to aggregate sibling commands). Defaults fail loudly so missing wiring surfaces in tests rather than silently skipping.

TODO: move GPG/IDE implementations to internal/ services so setup calls services directly instead of via root-wired function variables.

View Source
var CompauditFixCmd = &cobra.Command{
	Use:     "compaudit-fix",
	Aliases: []string{"compauditFix"},
	Short:   "Fix insecure directories reported by compaudit",
	Long:    `Runs 'compaudit' and applies 'chmod g-w,o-w' to any directories reported as insecure. This uses an interactive zsh so zsh functions like compaudit (from oh-my-zsh) are available.`,
	Run: func(cmd *cobra.Command, _args []string) {
		log.Start("Running compaudit and fixing insecure directories...")
		isVerbose := cmdutil.IsVerbose(cmd)

		execCmd := execCommand("zsh", "-ic", "compaudit | xargs --no-run-if-empty chmod g-w,o-w")
		log.Verbose(isVerbose, "Executing: %s", execCmd.String())

		outputBytes, err := execCmd.CombinedOutput()
		output := strings.TrimSpace(string(outputBytes))

		if err != nil {
			log.Error("Failed to run compaudit fix: %v", err)
			if output != "" {
				log.Error("Output: %s", output)
			}
			return
		}

		if output != "" {

			log.Message("%s", output)
		}

		log.Success("Finished applying compaudit fixes.")
	},
}

CompauditFixCmd runs 'compaudit' and removes group/world write permissions from any reported insecure directories.

View Source
var SetupASDFCmd = &cobra.Command{
	Use:   "asdf",
	Short: "Setup asdf plugins from $HOME/.tool-versions",
	Long:  `Reads $HOME/.tool-versions and installs asdf plugins listed there.`,
	Run: func(cmd *cobra.Command, args []string) {
		setupASDF(cmdutil.IsVerbose(cmd))
	},
}
View Source
var SetupCmd = &cobra.Command{
	Use:   "setup",
	Short: "Setup development tools",
	Long: `Setup various development tools.
Running this command without subcommands will run all setup steps:
- Oh My Zsh
- ASDF plugins
- Dotfiles installation
- Dotfiles secrets restore (when configured)
- Software installation
- GPG keys setup (interactive)
- GPG permissions fix`,
	RunE: func(cmd *cobra.Command, _args []string) error {
		if err := runSetup(cmd, cmdutil.IsVerbose(cmd)); err != nil {
			return fmt.Errorf("setup failed: %w", err)
		}
		return nil
	},
}
View Source
var SetupDotfilesCmd = &cobra.Command{
	Use:   "dotfiles",
	Short: "Setup dotfiles from your git repository",
	Long: `Setup dotfiles from your git repository. This command will:
	- Check and install prerequisites (Homebrew, Git, Bash)
	- Setup SSH keys for GitHub when required by the repository URL
  - Clone your dotfiles repository as a bare repository
  - Backup any conflicting files
  - Checkout dotfiles to your home directory
  - Initialize git submodules
	- Configure git to hide untracked files
	- Restore dotfiles secrets when manifest and BWS token are available`,
	RunE: func(cmd *cobra.Command, args []string) error {
		if err := setupDotfiles(cmdutil.IsVerbose(cmd)); err != nil {
			return fmt.Errorf("dotfiles setup failed: %w", err)
		}
		return nil
	},
}
View Source
var SetupOhMyZshCmd = &cobra.Command{
	Use:   "oh-my-zsh",
	Short: "Install Oh My Zsh",
	Long:  `Downloads and installs Oh My Zsh. Skips if already installed.`,
	Run: func(cmd *cobra.Command, args []string) {
		setupOhMyZsh(cmdutil.IsVerbose(cmd))
	},
}

Functions

func EnsurePrerequisites

func EnsurePrerequisites(verbose bool) error

EnsurePrerequisites checks and installs core prerequisites needed for setup flows. SSH is handled contextually by callers that need GitHub access.

Types

type Software

type Software struct {
	Name        string
	Description string
	Optional    bool
	URL         string      // For manual downloads
	Check       func() bool // Returns true if already installed
	// Install returns an error if installation fails.
	// For manual installs, this typically involves opening a URL.
	Install func() error
	// OS restriction (empty means both, otherwise "linux" or "darwin")
	OS string
}

Jump to

Keyboard shortcuts

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