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

gpg

package
v1.54.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: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GPGCmd = &cobra.Command{
	Use:   "gpg",
	Short: "Manage GPG keys for commit signing and encryption",
	Long:  `Manage GPG keys for commit signing, encryption, initial setup, and expiration renewal.`,
	RunE: func(cmd *cobra.Command, _args []string) error {
		return cmd.Help()
	},
}
View Source
var RenewGPGCmd = &cobra.Command{
	Use:     "renew",
	Aliases: []string{"update", "extend"},
	Short:   "Renew or extend GPG key and subkey expiration",
	Long: `Interactively inspect and extend expiration dates for your GPG key and subkeys.
Imports the master key from a local/cloud backup directory, updates expiration dates,
archives old key files to archive/<date-expired>/, re-exports updated secret and public
key files back to your backup folder with standard names (for cloud sync), publishes
public keys, and strips the master key locally (keeping subkeys only for security).`,
	RunE: func(cmd *cobra.Command, _args []string) error {
		return renewGPG(cmdutil.IsVerbose(cmd))
	},
}
View Source
var SetupGPGCmd = &cobra.Command{
	Use:     "setup",
	Aliases: []string{"init"},
	Short:   "Setup GPG keys for signing and encryption",
	Long: `Setup GPG keys for signing commits and encryption. This command will:
  - Prompt you for GPG key files to import
  - Import master key and subkeys
  - Set ultimate trust on the key
  - Configure Git to use your GPG key for signing
  - Optionally remove the master key (keeping only subkeys for security)
  - Configure ~/.gnupg and wrapper permissions and restart gpg-agent`,
	RunE: func(cmd *cobra.Command, args []string) error {
		if err := setupGPG(cmdutil.IsVerbose(cmd)); err != nil {
			return fmt.Errorf("gpg setup failed: %w", err)
		}
		return nil
	},
}
View Source
var SyncGPGCmd = &cobra.Command{
	Use:     "sync",
	Aliases: []string{"pull", "fetch", "refresh"},
	Short:   "Sync updated GPG public key and expiration dates from keyservers",
	Long: `Pull and sync updated GPG public keys and signatures from OpenPGP keyservers
and GitHub on secondary devices without needing access to your master key.`,
	RunE: func(cmd *cobra.Command, _args []string) error {
		return syncGPG(cmdutil.IsVerbose(cmd))
	},
}

Functions

func SetupGPG

func SetupGPG(verbose bool) error

SetupGPG is the exported entry point for the GPG setup flow, so the setup orchestrator can invoke it via root wiring without a sibling cmd import.

Types

type GPGKeyInfo

type GPGKeyInfo struct {
	KeyID       string   // 16-character Long Key ID (e.g. BE363376C8A71C92)
	Fingerprint string   // 40-character Primary Fingerprint
	UID         string   // e.g. "Eric N. Garcia <eng618@garciaericn.com>"
	HasMaster   bool     // true if master secret key is present (sec vs sec#)
	Subkeys     []string // Subkey IDs / fingerprints
}

GPGKeyInfo represents a GPG secret key found in the local keyring.

Jump to

Keyboard shortcuts

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