godebiancontrol

package module
v0.0.0-...-8c93e18 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2018 License: BSD-3-Clause Imports: 4 Imported by: 9

README

Maintenance mode

Note that new projects should prefer to use https://pault.ag/go/debian instead of this package.

Usage

Install:

go get github.com/stapelberg/godebiancontrol

…and then use it in your code:

package main

import (
    "github.com/stapelberg/godebiancontrol"
    "os"
    "log"
)
    
func main() {
    file, err := os.Open("/var/lib/apt/lists/http.debian.net_debian_dists_testing_main_binary-amd64_Packages")
    if err != nil {
        log.Fatal(err)
    }
    defer file.Close()
        
    p, err := godebiancontrol.Parse(file)
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("The first package in the list is %s\n", p[0]["Package"])
}

Find the documentation at:

https://godoc.org/github.com/stapelberg/godebiancontrol

Documentation

Overview

Package debiancontrol implements a parser for Debian control files.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PGPSignatureStripper

func PGPSignatureStripper(input io.Reader) io.Reader

PGPSignatureStripper returns a reader that strips the PGP signature (if any) from the input data without verifying it.

Types

type FieldType

type FieldType int
const (
	Simple FieldType = iota
	Folded
	Multiline
)

type Paragraph

type Paragraph map[string]string

func Parse

func Parse(input io.Reader) (paragraphs []Paragraph, err error)

Parses a Debian control file and returns a slice of Paragraphs.

Implemented according to chapter 5.1 (Syntax of control files) of the Debian Policy Manual: http://www.debian.org/doc/debian-policy/ch-controlfields.html

Example
package main

import (
	"fmt"
	"github.com/stapelberg/godebiancontrol"
	"log"
	"os"
)

func main() {
	file, err := os.Open("debian-mirror/dists/sid/main/source/Sources")
	if err != nil {
		log.Fatal(err)
	}
	defer file.Close()

	paragraphs, err := godebiancontrol.Parse(file)
	if err != nil {
		log.Fatal(err)
	}

	// Print a list of which source package uses which package format.
	for _, pkg := range paragraphs {
		fmt.Printf("%s uses %s\n", pkg["Package"], pkg["Format"])
	}
}
Output:

Jump to

Keyboard shortcuts

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