-
-
Save angelotinho/59ca56b75cd4d037ea42e4198a51020d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"path" | |
"strings" | |
) | |
func FindRootPath(roots []string) string { | |
if len(roots) == 0 { | |
return "" | |
} | |
root := roots[0] | |
for _, entry := range roots { | |
if len(entry) < len(root) { | |
root = entry | |
} | |
} | |
return root | |
} | |
func main() { | |
for _, file := range os.Args[1:] { | |
mapping, err := ParseFile(file) | |
if err != nil { | |
log.Fatal(err) | |
} | |
for pkg, provides := range mapping { | |
paths := []string{} | |
for path, _ := range provides { | |
paths = append(paths, path) | |
} | |
fmt.Printf("%s: %s\n", pkg, FindRootPath(paths)) | |
} | |
} | |
} | |
func eatLeader(reader *bufio.Reader) error { | |
for { | |
line, err := reader.ReadString('\n') | |
if err != nil { | |
return err | |
} | |
if strings.HasPrefix(line, "FILE ") { | |
return nil | |
} | |
} | |
} | |
type Mapping map[string]map[string]bool | |
func Partition(in, what string) (string, string) { | |
els := strings.SplitN(in, what, 2) | |
if len(els) == 2 { | |
return strings.TrimSpace(els[0]), strings.TrimSpace(els[1]) | |
} | |
return strings.TrimSpace(els[0]), "" | |
} | |
var filePathLeader = "usr/share/gocode/src/" | |
func ComposeMapping(reader *bufio.Reader) (Mapping, error) { | |
ret := Mapping{} | |
for { | |
line, err := reader.ReadString('\n') | |
if err != nil { | |
if err == io.EOF { | |
break | |
} | |
return Mapping{}, err | |
} | |
filePath, pkgEntry := Partition(line, " ") | |
_, pkg := Partition(pkgEntry, "/") | |
if strings.HasPrefix(filePath, filePathLeader) { | |
// XXX: _fixtures | |
// if strings.Contains(filePath, "/testdata/") { | |
// continue | |
// } | |
importPath := path.Dir(filePath[len(filePathLeader):]) | |
if _, ok := ret[pkg]; !ok { | |
ret[pkg] = map[string]bool{} | |
} | |
ret[pkg][importPath] = true | |
} | |
} | |
return ret, nil | |
} | |
func ParseFile(file string) (Mapping, error) { | |
fd, err := os.Open(file) | |
if err != nil { | |
return Mapping{}, err | |
} | |
reader := bufio.NewReader(fd) | |
eatLeader(reader) | |
return ComposeMapping(reader) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
golang-gopkg-dancannon-gorethink.v1-dev: gopkg.in/dancannon | |
golang-gopkg-tomb.v1-dev: gopkg.in/tomb.v1 | |
golang-gopkg-vmihailenco-msgpack.v2-dev: gopkg.in/vmihailenco/msgpack.v2 | |
golang-thrift-dev: thrift | |
golang-log4go-dev: code.google.com/p/log4go | |
golang-coreos-log-dev: github.com/coreos/go-log/log | |
golang-github-getsentry-raven-go-dev: github.com/getsentry/raven-go | |
golang-golang-x-tools-dev: golang.org/x/tools | |
golang-github-shurcool-sanitized-anchor-name-dev: github.com/shurcooL/sanitized_anchor_name | |
golang-github-spf13-jwalterweatherman-dev: github.com/spf13/jwalterweatherman | |
influxdb-dev: github.com/influxdb/influxdb | |
golang-mreiferson-httpclient-dev: github.com/mreiferson/go-httpclient | |
golang-github-go-ldap-ldap-dev: github.com/go-ldap/ldap | |
golang-github-jacobsa-ratelimit-dev: github.com/jacobsa/ratelimit | |
golang-github-peterh-liner-dev: github.com/peterh/liner | |
golang-google-cloud-compute-metadata-dev: google.golang.org/cloud/internal | |
golang-github-abbot-go-http-auth-dev: github.com/abbot/go-http-auth | |
golang-github-boltdb-bolt-dev: github.com/boltdb/bolt | |
golang-github-hashicorp-raft-boltdb-dev: github.com/hashicorp/raft-boltdb | |
golang-github-julienschmidt-httprouter-dev: github.com/julienschmidt/httprouter | |
golang-github-naoina-go-stringutil-dev: github.com/naoina/go-stringutil | |
golang-github-odeke-em-command-dev: github.com/odeke-em/command | |
golang-github-prometheus-log-dev: github.com/prometheus/log | |
golang-goleveldb-dev: github.com/syndtr/goleveldb/leveldb | |
golang-codesearch-dev: code.google.com/p/codesearch/index | |
golang-github-bmizerany-pat-dev: github.com/bmizerany/pat | |
golang-gocheck-dev: launchpad.net/gocheck | |
golang-pq-dev: github.com/lib/pq | |
golang-godebiancontrol-dev: github.com/mstap | |
golang-robustirc-bridge-dev: github.com/robustirc/bridge/robustsession | |
golang-github-samuel-go-zookeeper-dev: github.com/samuel/go-zookeeper/zk | |
golang-gopkg-fatih-pool.v2-dev: gopkg.in/fatih/pool.v2 | |
golang-goyaml-dev: launchpad.net/goyaml | |
golang-doozer-dev: github.com/4ad/doozer | |
golang-github-jacobsa-oglemock-dev: github.com/jacobsa/oglemock | |
golang-pault-go-topsort-dev: pault.ag/go/topsort | |
golang-github-golang-leveldb-dev: github.com/golang/leveldb | |
golang-procfs-dev: github.com/prometheus/procfs | |
golang-github-rakyll-statik-dev: github.com/rakyll/statik | |
golang-github-streadway-amqp-dev: github.com/streadway/amqp | |
golang-golang-x-oauth2-dev: golang.org/x/oauth2 | |
golang-google-appengine-dev: google.golang.org/appengine | |
golang-x-text-dev: code.google.com/p | |
golang-siphash-dev: github.com/dchest/siphash | |
golang-logrus-dev: github.com/Sirupsen/logrus | |
golang-go.crypto-dev: code.google.com/p | |
golang-gogoprotobuf-dev: code.google.com/p | |
golang-gopkg-eapache-queue.v1-dev: github.com/eapache | |
golang-github-hashicorp-raft-dev: github.com/hashicorp/raft | |
golang-github-jacobsa-oglematchers-dev: github.com/jacobsa/oglematchers | |
golang-github-vishvananda-netlink-dev: github.com/vishvananda/netlink | |
golang-pault-go-config-dev: pault.ag/go/config | |
toxiproxy-dev: github.com/Shopify/toxiproxy | |
golang-github-d2g-dhcp4-dev: github.com/d2g/dhcp4 | |
golang-yaml.v2-dev: gopkg.in/yaml.v2 | |
golang-barcode-dev: github.com/boombuler/barcode | |
golang-testify-dev: github.com/stretchr/testify | |
golang-github-azure-go-pkcs12-dev: github.com/Azure/go-pkcs12 | |
golang-github-go-sql-driver-mysql-dev: github.com/go-sql-driver/mysql | |
golang-github-jacobsa-timeutil-dev: github.com/jacobsa/timeutil | |
golang-github-odeke-em-cache-dev: github.com/odeke-em/cache | |
golang-github-samalba-dockerclient-dev: github.com/samalba/dockerclient | |
golang-golang-x-sys-dev: golang.org/x/sys | |
golang-collectd-dev: collectd.org/api | |
golang-goptlib-dev: git.torproject.org/pluggable-transports/goptlib.git | |
golang-github-inconshreveable-mousetrap-dev: github.com/inconshreveable/mousetrap | |
golang-github-jacobsa-syncutil-dev: github.com/jacobsa/syncutil | |
golang-bindata-dev: github.com/jteeuwen/go-bindata | |
golang-protobuf-extensions-dev: github.com/matttproud/golang_protobuf_extensions/ext | |
golang-gopkg-asn1-ber.v1-dev: gopkg.in/asn1-ber.v1 | |
golang-go-xdg-dev: launchpad.net/go-xdg/v0 | |
golang-xmpp-dev: github.com/agl/xmpp | |
golang-pb-dev: github.com/cheggaaa/pb | |
golang-dbus-dev: github.com/godbus/dbus | |
golang-github-rakyll-globalconf-dev: github.com/rakyll/globalconf | |
golang-github-glacjay-goini-dev: github.com/glacjay/goini | |
golang-github-go-xorm-core-dev: github.com/go-xorm/core | |
golang-github-google-btree-dev: github.com/google/btree | |
golang-golang-x-exp-dev: golang.org/x/exp/mmap | |
golang-golang-x-net-dev: code.google.com/p | |
obfs4proxy: git.torproject.org/pluggable-transports/obfs4.git/common/log | |
golang-docker-dev: github.com/docker/docker/pkg | |
golang-github-ugorji-go-msgpack-dev: github.com/ugorji/go-msgpack | |
golang-github-gorilla-handlers-dev: github.com/gorilla/handlers | |
golang-github-jtolds-gls-dev: github.com/jtolds/gls | |
golang-guestfs-dev: libguestfs.org/guestfs | |
golang-bazil-fuse-dev: bazil.org/fuse | |
dh-make-golang: github.com/Debian/dh-make-golang | |
golang-websocket-dev: github.com/gorilla/websocket | |
golang-github-odeke-em-cli-spinner-dev: github.com/odeke-em/cli-spinner | |
golang-github-davecgh-go-spew-dev: github.com/davecgh/go-spew/spew | |
golang-github-garyburd-redigo-dev: github.com/garyburd/redigo/redis | |
golang-github-docker-libtrust-dev: github.com/docker/libtrust | |
golang-termbox-dev: github.com/nsf/termbox-go | |
golang-github-spf13-pflag-dev: github.com/spf13/pflag | |
golang-github-azure-go-autorest-dev: github.com/Azure | |
golang-etcd-dev: github.com/coreos/go-etcd/etcd | |
golang-github-coreos-go-iptables-dev: github.com/coreos/go-iptables/iptables | |
golang-clockwork-dev: github.com/jonboulle/clockwork | |
golang-github-kimor79-gollectd-dev: github.com/kimor79/gollectd | |
golang-openldap-dev: github.com/mqu/openldap | |
golang-github-odeke-em-ripper-dev: github.com/odeke-em/ripper | |
golang-ginkgo-dev: github.com/onsi/ginkgo | |
golang-github-bradfitz-gomemcache-dev: github.com/bradfitz/gomemcache/memcache | |
golang-github-bradfitz-http2-dev: github.com/bradfitz/http2 | |
golang-gopkg-mgo.v2-dev: labix.org/v2 | |
golang-github-agtorre-gocolorize-dev: github.com/agtorre/gocolorize | |
golang-github-bmizerany-assert-dev: github.com/bmizerany/assert | |
golang-github-mattn-go-sqlite3-dev: github.com/mattn/go-sqlite3 | |
golang-sorcix-irc-dev: github.com/sorcix/irc | |
golang-objx-dev: github.com/stretchr/objx | |
golang-gopacket-dev: code.google.com/p/gopacket | |
golang-ed25519-dev: github.com/agl/ed25519 | |
golang-blackfriday-dev: github.com/russross/blackfriday | |
golang-github-vishvananda-netns-dev: github.com/vishvananda/netns | |
golang-github-jacobsa-util-dev: github.com/jacobsa/util/lrucache | |
golang-github-ugorji-go-codec-dev: github.com/ugorji/go | |
golang-toml-dev: github.com/BurntSushi/toml | |
golang-github-jacobsa-ogletest-dev: github.com/jacobsa/ogletest | |
golang-fsnotify-dev: gopkg.in | |
golang-github-tobi-airbrake-go-dev: github.com/tobi/airbrake-go | |
golang-github-vaughan0-go-ini-dev: github.com/vaughan0/go-ini | |
golang-rrd-dev: github.com/ziutek/rrd | |
golang-github-pborman-uuid-dev: github.com/pborman/uuid | |
golang-github-cloudfoundry-gosigar-dev: github.com/cloudfoundry/gosigar | |
golang-github-rainycape-unidecode-dev: github.com/rainycape/unidecode | |
golang-gocapability-dev: github.com/syndtr/gocapability/capability | |
golang-github-armon-go-metrics-dev: github.com/armon/go-metrics | |
golang-github-jacobsa-fuse-dev: github.com/jacobsa/fuse | |
golang-dns-dev: github.com/miekg/dns | |
golang-github-naoina-toml-dev: github.com/naoina/toml | |
golang-go-patricia-dev: gopkg.in/tchap | |
golang-go-semver-dev: github.com/coreos/go-semver | |
golang-github-jacobsa-reqtrace-dev: github.com/jacobsa/reqtrace | |
golang-github-gorilla-mux-dev,devel/golang-mux-dev: github.com/gorilla/mux | |
golang-github-kardianos-osext-dev: github.com/kardianos/osext | |
golang-gopkg-tomb.v2-dev: gopkg.in/tomb.v2 | |
golang-go-md2man-dev: github.com/cpuguy83/go-md2man | |
golang-gopkg-eapache-go-resiliency.v1-dev: github.com/eapache | |
golang-github-gorhill-cronexpr-dev: github.com/gorhill/cronexpr | |
golang-codegangsta-cli-dev: github.com/codegangsta/cli | |
golang-glog-dev: github.com/golang/glog | |
golang-pty-dev: github.com/kr/pty | |
golang-text-dev: github.com/kr/text | |
golang-go-dbus-dev: launchpad.net/go-dbus/v1 | |
golang-pault-go-debian-dev: pault.ag/go/debian/control | |
golang-github-cenkalti-backoff-dev: github.com/cenkalti/backoff | |
golang-context-dev: github.com/gorilla/context | |
golang-git2go-dev: github.com/libgit2/git2go | |
golang-prometheus-client-dev: github.com/prometheus/client_golang/text | |
golang-google-api-dev: google.golang.org/api/dns/v1 | |
golang-check.v1-dev: gopkg.in/check.v1 | |
golang-github-golang-snappy-dev: code.google.com/p | |
golang-github-jacobsa-gcloud-dev: github.com/jacobsa/gcloud/gcs | |
golang-vhost-dev: github.com/inconshreveable/go-vhost | |
golang-github-jacobsa-bazilfuse-dev: github.com/jacobsa/bazilfuse | |
golang-go-flags-dev: github.com/jessevdk/go-flags | |
golang-pretty-dev: github.com/kr/pretty | |
golang-gomega-dev: github.com/onsi/gomega | |
golang-github-opencontainers-specs-dev: github.com/opencontainers/specs | |
golang-gosqlite-dev: code.google.com/p/gosqlite/sqlite | |
golang-etcd-server-dev: github.com/coreos/etcd | |
golang-go-zfs-dev: github.com/mistifyio/go-zfs | |
golang-metrics-dev: github.com/rcrowley/go-metrics | |
golang-github-coreos-go-systemd-dev: github.com/coreos/go-systemd/dbus | |
golang-github-mattn-go-isatty-dev: github.com/mattn/go-isatty | |
golang-github-hashicorp-go-msgpack-dev: github.com/hashicorp/go-msgpack/codec | |
slt: github.com/inconshrevable/slt | |
golang-libgeoip-dev: github.com/nranchev/go-libGeoIP | |
golang-github-robfig-pathtree-dev: github.com/robfig/pathtree | |
golang-nzaat-dev: ancient-solutions.com/hash/nzaat | |
golang-goprotobuf-dev: code.google.com/p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment