pantheon-se/go-composer

Installs Go into vendor/bin

1.0.1 2023-04-18 14:06 UTC

This package is auto-updated.

Last update: 2024-04-18 18:50:46 UTC


README

License Packagist Version Tests

Go Composer

Composer Plugin to install other utilities via Composer with Go.

Based on node-composer by mariusbuescher, this Composer plugin will install a version of Go into your vendor/bin directory so that they are available to use during your Composer builds. This plugin helps automate the download of the binaries which are linked to the bin-directory specified in your composer.json.

Once installed, you can then use Go in your composer-scripts.

Setup

Simply install the plugin, and the latest Go will be installed - no other configurations are necessary. Optionally, you can specify the go-version in your composer.json extra configs to declare a specific version of Go.

Example composer.json

{
  "name": "my/project",
  "type": "project",
  "license": "MIT",
  "require": {
    "pantheon-se/go-composer": "*"
  },
  "extra": {
    "pantheon-se": {
      "go-composer": {
        "go-version": true
      }
    }
  },
  "config": {
    "allow-plugins": {
      "pantheon-se/go-composer": true
    }
  }
}

Configuration

There are three parameters you can configure:

  • Go version (go-version)
  • The download url template for the Go binary archives (go-download-url).

In the Node download url, replace the following placeholders with your specific needs:

  • version: ${version}
  • type of your os: ${osType}
  • system architecture: ${architecture}
  • file format ${format}

Example composer.json with specific versions of Go

{
  "extra": {
    "pantheon-se": {
      "go-composer": {
        "go-version": "1.20.2",
        "go-download-url": "https://go.dev/dl/go${version}.${osType}-${architecture}.${format}"
      }
    }
  }
}