Skip to content

📋 GlobalList

Lists packages installed in the Composer global environment.

When to use

Use this when you need to confirm which tools are globally installed, troubleshoot whether a command is available, or take inventory before cleanup. Equivalent to running composer global show.

Signature

go
func (c *Composer) GlobalList() (string, error)

Parameters

This method takes no parameters.

Return value

  • string: The raw output of composer global show, including the names and versions of globally installed packages.
  • error: Returns the corresponding error message when an error occurs during execution.

Example

go
package main

import (
	"fmt"
	"log"

	"github.com/scagogogo/composer-skills/pkg/composer"
)

func main() {
	comp, err := composer.New(composer.DefaultOptions())
	if err != nil {
		log.Fatalf("Initialization failed: %v", err)
	}

	output, err := comp.GlobalList()
	if err != nil {
		log.Fatalf("Failed to get global list: %v", err)
	}

	fmt.Println("Globally installed packages:")
	fmt.Println(output)
}

Advanced

  • The output is plain text; if you need structured results, parse the returned string yourself, or refer to ShowWithOptions with --format=json.
  • To install/remove global packages, see GlobalRequire and GlobalRemove.
  • To view the global environment path, use GlobalHome; to view status, use GlobalStatus.

Released under the MIT License