Giter Club home page Giter Club logo

jargo's Introduction

jargo

jargo is a simple library allowing access to information contained in a Java JAR file.

It is a simple wrapper to the zip libraries.

godocs

It has two functions:

func GetManifest(filename string) (error, *Manifest)

It returns a pointer to a Manifest (map[string]string) which is the key:values pairs from the META-INF/MANIFEST.MF file

func GetJarInfo(filename string) (error, *JarInfo)

GetJarInfo extracts various info from a Java JAR file:

  • It extracts the Manifest (like GetManifest)
  • It extracts an array of the filenames in the JAR file
  • It returns a pointer to a JarInfo struct:
type JarInfo struct {
	*Manifest
	Files []string
}

###Example Usage### Using Lucene analyzer jar file from: http://central.maven.org/maven2/org/apache/lucene/lucene-analyzers-stempel/5.0.0/lucene-analyzers-stempel-5.0.0.jar

package main

import (
	"fmt"
	"github.com/gnewton/jargo"
		"log"
)

func main() {
	err, manifest := jargo.GetManifest("lucene-analyzers-stempel-5.0.0.jar")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(manifest)

	fmt.Println()

	err, jar := jargo.GetJarInfo("lucene-analyzers-stempel-5.0.0.jar")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", jar)
}

Output:

&map[Ant-Version:Apache Ant 1.8.3 Specification-Version:5.0.0 Specification-Vendor:The Apache Software Foundation Implementation-Title:org.apache.lucene X-Compile-Source-JDK:1.7 X-Compile-Target-JDK:1.7 Manifest-Version:1.0 Created-By:1.7.0_55-b13 (Oracle Corporation) Extension-Name:org.apache.lucene Specification-Title:Lucene Search Engine: analyzers-stempel Implementation-Version:5.0.0 1659987 - anshumgupta - 2015-02-15 12:20 :34 Implementation-Vendor:The Apache Software Foundation]

&{Manifest:0xc20804c018 Files:[META-INF/ META-INF/MANIFEST.MF META-INF/services/ org/ org/apache/ org/apache/lucene/ org/apache/lucene/analysis/ org/apache/lucene/analysis/pl/ org/apache/lucene/analysis/stempel/ org/egothor/ org/egothor/stemmer/ META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory org/apache/lucene/analysis/pl/PolishAnalyzer$DefaultsHolder.class org/apache/lucene/analysis/pl/PolishAnalyzer.class org/apache/lucene/analysis/pl/stemmer_20000.tbl org/apache/lucene/analysis/pl/stopwords.txt org/apache/lucene/analysis/stempel/StempelFilter.class org/apache/lucene/analysis/stempel/StempelPolishStemFilterFactory.class org/apache/lucene/analysis/stempel/StempelStemmer.class org/egothor/stemmer/Cell.class org/egothor/stemmer/Compile.class org/egothor/stemmer/Diff.class org/egothor/stemmer/DiffIt.class org/egothor/stemmer/Gener.class org/egothor/stemmer/Lift.class org/egothor/stemmer/MultiTrie.class org/egothor/stemmer/MultiTrie2.class org/egothor/stemmer/Optimizer.class org/egothor/stemmer/Optimizer2.class org/egothor/stemmer/Reduce$Remap.class org/egothor/stemmer/Reduce.class org/egothor/stemmer/Row.class org/egothor/stemmer/Trie$StrEnum.class org/egothor/stemmer/Trie.class META-INF/LICENSE.txt META-INF/NOTICE.txt]}

###License###

The MIT License (MIT)
Copyright (c) 2015 Glen Newton gnewton

See LICENSE file.

jargo's People

Contributors

aquilax avatar gnewton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jargo's Issues

Move error return value to end of return value list as this is idiomatic Go

The two public functions for this library returns the error return value first:

func GetManifest(filename string) (error, *Manifest)
func GetJarInfo(filename string) (error, *JarInfo)

This is not idiomatic Go. Idiomatic Go has the error return value last in the list of values returned.
I am planning to change the signature of these two functions so that the error is returned last.

THIS IS A BREAKING API CHANGE.

Pleas let me know if this impacts you.

I will work on a branch and not merge in the changes until >= 1 week after I announce it is ready in this issue.

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.