Skip to content

chrisfarms/yenc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yenc.go

A single/multipart yenc decoder. Usually used for binary files stored on Usenet servers.

Installation

The easy way:

go get github.com/chrisfarms/yenc

Docs

Decode accepts an io.Reader (of yenc encoded data - complete with headers) and returns a *Part.

func Decode(input io.Reader) (*Part, error)

The Part struct contains all the decoded data.

type Part struct {

    // part num
    Number int

    // size from part trailer
    Size int
    
    // file boundarys
    Begin, End int
    
    // filename from yenc header
    Name string

    // the decoded data
    Body []byte
    
    // ..contains filtered or unexported fields..
}

Example

package main
import (
	"github.com/chrisfarms/yenc"
	"os"
)
func main(){
	f,err := os.Open("some_file.yenc")
	if err != nil {
	    panic("could not open file")
	}
	part,err := yenc.Decode(f)
	if err != nil {
	    panic("decoding: " + err.Error())
	}
	fmt.Println("Filename", part.Name)
	fmt.Println("Body Bytes", part.Body)
}

About

yenc decoder package for Go (golang)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages