Skip to content

🔍 IsComposerInstalled

Checks whether Composer is installed and returns the path and version at the same time.

When to Use

Use this when you need to obtain the install status, executable path, and version number in one call. Suitable for diagnostic, logging, and initialization scenarios. ✅

Signature

go
func IsComposerInstalled() (bool, string, string)

Parameters

ParameterTypeDescription
NonePackage-level function, takes no parameters

Return Value

  • bool: Whether it is installed.
  • string: Path to the composer executable (empty string when not installed).
  • string: Composer version string (empty string when not installed or retrieval fails). 🔖

Example

go
package main

import (
	"fmt"

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

func main() {
	installed, path, version := installer.IsComposerInstalled()
	if installed {
		fmt.Printf("installed: %s (version %s)\n", path, version)
	} else {
		fmt.Println("Composer not installed")
	}
}

Advanced

  • The version number is obtained via CheckComposerVersion; on failure it silently returns an empty string without affecting the boolean result. 🛠️
  • If you want to auto-install when not installed, use EnsureComposerInstalled. 🚀
  • This is an enhanced version of the Installer instance method IsInstalled (it additionally returns the path and version). 🧩

Released under the MIT License