Skip to content

Issue: Default Go packages fail to install with "invalid char ' '" error #163

@l50

Description

@l50

Description

When installing Go via asdf with a .default-golang-pkgs file, package installation fails with errors like:

Installing github.com/magefile/mage                          go pkg... 
go: github.com/magefile/mage                         @latest: malformed module path "github.com/magefile/mage                         ": invalid char ' '
FAIL

Steps to Reproduce

  1. Create a ~/.default-golang-pkgs file like this:
// Build & Development Tools
github.com/magefile/mage                            // Alternative to make

// VSCode Go Extension Tools
golang.org/x/tools/gopls                   			// Go language server
golang.org/x/tools/cmd/goimports           			// Format and manage imports
golang.org/x/lint/golint                   			// Go linter
github.com/cweill/gotests/gotests          			// Generate tests
github.com/fatih/gomodifytags              			// Modify struct tags
github.com/josharian/impl                  			// Generate interface implementations
github.com/haya14busa/goplay/cmd/goplay    			// Go playground client
github.com/go-delve/delve/cmd/dlv          			// Go debugger
  1. Install Go using asdf:
asdf install golang 1.25.0
  1. Observe installation failures for all packages

Expected Behavior

  • Packages should install successfully
  • Comments (both full-line and inline) should be properly ignored
  • Whitespace should be handled correctly

Actual Behavior

  • All package installations fail with "invalid char ' '" error
  • Package names appear to have trailing spaces when passed to go install

Root Cause

  1. The sed commands for parsing comments don't properly trim whitespace
  2. The package name variable is mutated when appending @latest, potentially causing issues
  3. Command execution for go get -u doesn't properly handle multi-argument commands

Environment

  • asdf-golang version: latest (commit 50c8f58, ~4 months old)
  • Go version: 1.25.0
  • OS: macOS

Proposed Fix

See PR #162 - Refactors package parsing logic to properly handle comments and whitespace, and fixes command execution using bash arrays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions