🌐 BrowsePackage
Opens the project page of the specified package (typically its GitHub repository) in the default browser, equivalent to composer browse packageName.
When to use
- 📖 View the package's source code, documentation, or issue tracker page.
- 🐛 Quickly jump to the repository to file an issue when you encounter a dependency problem.
- 🔍 Evaluate the project's activity on its homepage before adopting the dependency.
Signature
go
func (c *Composer) BrowsePackage(packageName string) errorParameters
| Parameter | Type | Description |
|---|---|---|
packageName | string | Name of the package to browse |
Return value
| Value | Type | Description |
|---|---|---|
| Error | error | Returned when an error occurs while opening the package page |
Example
go
package main
import (
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.New(composer.DefaultOptions())
if err != nil {
log.Fatalf("init failed: %v", err)
}
if err := comp.BrowsePackage("symfony/console"); err != nil {
log.Fatalf("failed to open package page: %v", err)
}
}Advanced
BrowsePackageWithOptions
Use when you need to open the documentation page, issue tracker page, etc. instead of the homepage:
go
func (c *Composer) BrowsePackageWithOptions(packageName string, options map[string]string) errorgo
// Open the documentation page
err := comp.BrowsePackageWithOptions("symfony/console", map[string]string{"docs": ""})
// Open the issue tracker page
err = comp.BrowsePackageWithOptions("symfony/console", map[string]string{"issues": ""})Related browse methods
Home(): Opens the Composer global homepage.HomePackage(packageName): Similar toBrowsePackage, opens the package homepage.
Environment dependency
This feature requires the operating system to support opening a browser, and the package must declare a project URL in composer.json. Calling it on a server or CI environment without a GUI may not launch a browser.
🔍 Related methods
ShowPackage: View package information in the terminal first.ShowPackageInfo: Structured retrieval of the package'sHomepagefield.