Skip to content

💰 Fund

Displays funding information for donatable (funding) packages in the project, equivalent to running composer fund.

When to use

Use it in CI or the terminal when you want to quickly see which dependencies declare funding support links, making it easier for users or teams to sponsor open-source authors.

Signature

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

Parameters

This method does not accept any parameters.

Return value

  • string: the raw text output of composer fund.
  • error: returns the corresponding error message if an error occurs during command 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.Fund()
	if err != nil {
		log.Fatalf("failed to get funding info: %v", err)
	}

	fmt.Println("Project funding info:")
	fmt.Println(output)
}

Advanced

  • For structured results, use FundWithJSON to get []FundingInfo.
  • To only check whether funding support exists, use HasFunding.
  • To extract a package-to-URL mapping, use GetFundingURLs.
  • To pass custom options (such as --format, --no-dev), use FundWithOptions.

Released under the MIT License