Help us shape the future of Go! Take the 2026 Go Developer Survey

composerlockparser

package module
v0.0.0-...-4f03520 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2018 License: GPL-3.0 Imports: 5 Imported by: 0

README

Go Composer Lock Parser

Basic Composer lockfile parser library written in Golang.

Usage

Initalise the composerInfo object, and use the Parse(filepath) method to read the Composer lockfile and unmarshal it into the object defined in parser.go.

The library defines two helper methods for convenience:

  1. GetPackageByName()
  2. GetPackageListByPrefix()

The first one will return the Package which has exactly the name as specified, while the second will return a []Package, where the name starts with the given string.

For example the following code will parse a composer.lock file in the project, find a project called "drupal/embed", and also find all drupal specific projects.

func main() {
  c := new(composerInfo)
  c.Parse("/path/to/composer.lock")

  // Get a single package by name.
  p := c.GetPackageByName("drupal/embed")
  fmt.Println(p)

  // Get a list of packages by the prefix.
  pList := c.GetPackageListByPrefix("drupal")
  for _, p := range pList {
    fmt.Println(p.Name)
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComposerInfo

type ComposerInfo struct {
	Packages []Package
}

func (*ComposerInfo) GetPackageByName

func (c *ComposerInfo) GetPackageByName(name string) Package

func (*ComposerInfo) GetPackageListByPrefix

func (c *ComposerInfo) GetPackageListByPrefix(prefix string) []Package

func (*ComposerInfo) Parse

func (c *ComposerInfo) Parse(path string) error

type Package

type Package struct {
	Name    string
	Version string
	Type    string
	Authors []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL