Git Product home page Git Product logo

go-srcinfo's Introduction

GPL3 license GoDoc Build Status codecov Go Report Card

go-srcinfo

A golang package for parsing .SRCINFO files. SRCINFO

go-srcinfo aimes to be simple while ensuring each srcinfo is syntactically correct. Split packages and architecture specific fields are fully supported.

Examples

Reading a srcinfo from a file

package main

import (
	"fmt"
	"github.com/Morganamilo/go-srcinfo"
)

func main() {
	info, err := srcinfo.ParseFile("SRCINFO")
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(info)
}

Reading each package from a split package

package main

import (
	"fmt"
	"github.com/Morganamilo/go-srcinfo"
)

func main() {
	info, err := srcinfo.ParseFile("SRCINFO")
	if err != nil {
		fmt.Println(err)
		return
	}

	for _, pkg := range info.SplitPackages() {
		fmt.Printf("%s-%s: %s\n", pkg.Pkgname, info.Version(), pkg.Pkgdesc)
	}
}

Showing the architecture of each source

package main

import (
	"fmt"
	"github.com/Morganamilo/go-srcinfo"
)

func main() {
	info, err := srcinfo.ParseFile("SRCINFO")
	if err != nil {
		fmt.Println(err)
		return
	}

	for _, source := range info.Source {
		if source.Arch == "" {
			fmt.Printf("This source is for %s: %s\n", "any", source.Value)
		} else {
			fmt.Printf("This source is for %s: %s\n", source.Arch, source.Value)
		}
	}
}

Reading a srcinfo from a string

package main

import (
	"fmt"
	"github.com/Morganamilo/go-srcinfo"
)

const str = `
pkgbase = gdc-bin
	pkgver = 6.3.0+2.068.2
	pkgrel = 1
	url = https://gdcproject.org/
	arch = i686
	arch = x86_64
	license = GPL
	source_i686 = http://gdcproject.org/downloads/binaries/6.3.0/i686-linux-gnu/gdc-6.3.0+2.068.2.tar.xz
	md5sums_i686 = cc8dcd66b189245e39296b1382d0dfcc
	source_x86_64 = http://gdcproject.org/downloads/binaries/6.3.0/x86_64-linux-gnu/gdc-6.3.0+2.068.2.tar.xz
	md5sums_x86_64 = 16d3067ebb3938dba46429a4d9f6178f

pkgname = gdc-bin
	pkgdesc = Compiler for D programming language which uses gcc backend
	depends = gdc-gcc
	depends = perl
	depends = binutils
	depends = libgphobos
	provides = d-compiler=2.068.2
	provides = gdc=6.3.0+2.068.2

pkgname = gdc-gcc
	pkgdesc = The GNU Compiler Collection - C and C++ frontends (from GDC, gdcproject.org)
	provides = gcc=6.3.0
	provides = gcc-libs=6.3.0

pkgname = libgphobos-lib32
	pkgdesc = Standard library for D programming language, GDC port
	provides = d-runtime-lib32
	provides = d-stdlib-lib32
`
func main() {
	info, err := srcinfo.Parse(str)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(info)
}

go-srcinfo's People

Contributors

morganamilo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.