🔗 GetFundingURLs
Gets all packages in the project that declare funding support and their sponsorship URLs, returning a mapping of package name to URL list.
When to use
Use it when you want to aggregate all sponsorable links in a dashboard, README generator, or funding prompt component. It only returns packages with Funding=true and a non-empty URLs.
Signature
go
func (c *Composer) GetFundingURLs() (map[string][]string, error)Parameters
This method does not accept any parameters.
Return value
map[string][]string: mapping of package name to an array of funding URLs. If no packages declare funding support, an empty map (notnil) is returned.error: returns the corresponding error message when the underlyingFundWithJSONexecution or parsing fails.
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)
}
urls, err := comp.GetFundingURLs()
if err != nil {
log.Fatalf("failed to get funding URLs: %v", err)
}
if len(urls) == 0 {
fmt.Println("No fundable packages")
return
}
for pkg, links := range urls {
fmt.Printf("%s:\n", pkg)
for _, u := range links {
fmt.Printf(" - %s\n", u)
}
}
}Advanced
- The implementation is based on
FundWithJSON, filtering out entries withFunding=falseor no URLs. - To only check whether funding exists, use
HasFunding; for the raw text output, useFund.