-
-
-
-`
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/cover/testdata/main.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/cover/testdata/main.go
deleted file mode 100644
index c704b157..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/cover/testdata/main.go
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Test runner for coverage test. This file is not coverage-annotated; test.go is.
-// It knows the coverage counter is called "coverTest".
-
-package main
-
-import (
- "fmt"
- "os"
-)
-
-func main() {
- testAll()
- verify()
-}
-
-type block struct {
- count uint32
- line uint32
-}
-
-var counters = make(map[block]bool)
-
-// check records the location and expected value for a counter.
-func check(line, count uint32) {
- b := block{
- count,
- line,
- }
- counters[b] = true
-}
-
-// checkVal is a version of check that returns its extra argument,
-// so it can be used in conditionals.
-func checkVal(line, count uint32, val int) int {
- b := block{
- count,
- line,
- }
- counters[b] = true
- return val
-}
-
-var PASS = true
-
-// verify checks the expected counts against the actual. It runs after the test has completed.
-func verify() {
- for b := range counters {
- got, index := count(b.line)
- if b.count == anything && got != 0 {
- got = anything
- }
- if got != b.count {
- fmt.Fprintf(os.Stderr, "test_go:%d expected count %d got %d [counter %d]\n", b.line, b.count, got, index)
- PASS = false
- }
- }
- if !PASS {
- fmt.Fprintf(os.Stderr, "FAIL\n")
- os.Exit(2)
- }
-}
-
-// count returns the count and index for the counter at the specified line.
-func count(line uint32) (uint32, int) {
- // Linear search is fine. Choose perfect fit over approximate.
- // We can have a closing brace for a range on the same line as a condition for an "else if"
- // and we don't want that brace to steal the count for the condition on the "if".
- // Therefore we test for a perfect (lo==line && hi==line) match, but if we can't
- // find that we take the first imperfect match.
- index := -1
- indexLo := uint32(1e9)
- for i := range coverTest.Count {
- lo, hi := coverTest.Pos[3*i], coverTest.Pos[3*i+1]
- if lo == line && line == hi {
- return coverTest.Count[i], i
- }
- // Choose the earliest match (the counters are in unpredictable order).
- if lo <= line && line <= hi && indexLo > lo {
- index = i
- indexLo = lo
- }
- }
- if index == -1 {
- fmt.Fprintln(os.Stderr, "cover_test: no counter for line", line)
- PASS = false
- return 0, 0
- }
- return coverTest.Count[index], index
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/cover/testdata/test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/cover/testdata/test.go
deleted file mode 100644
index 80b1f6b1..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/cover/testdata/test.go
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This program is processed by the cover command, and then testAll is called.
-// The test driver in main.go can then compare the coverage statistics with expectation.
-
-// The word LINE is replaced by the line number in this file. When the file is executed,
-// the coverage processing has changed the line numbers, so we can't use runtime.Caller.
-
-package main
-
-const anything = 1e9 // Just some unlikely value that means "we got here, don't care how often"
-
-func testAll() {
- testSimple()
- testBlockRun()
- testIf()
- testFor()
- testRange()
- testSwitch()
- testTypeSwitch()
- testSelect1()
- testSelect2()
-}
-
-func testSimple() {
- check(LINE, 1)
-}
-
-func testIf() {
- if true {
- check(LINE, 1)
- } else {
- check(LINE, 0)
- }
- if false {
- check(LINE, 0)
- } else {
- check(LINE, 1)
- }
- for i := 0; i < 3; i++ {
- if checkVal(LINE, 3, i) <= 2 {
- check(LINE, 3)
- }
- if checkVal(LINE, 3, i) <= 1 {
- check(LINE, 2)
- }
- if checkVal(LINE, 3, i) <= 0 {
- check(LINE, 1)
- }
- }
- for i := 0; i < 3; i++ {
- if checkVal(LINE, 3, i) <= 1 {
- check(LINE, 2)
- } else {
- check(LINE, 1)
- }
- }
- for i := 0; i < 3; i++ {
- if checkVal(LINE, 3, i) <= 0 {
- check(LINE, 1)
- } else if checkVal(LINE, 2, i) <= 1 {
- check(LINE, 1)
- } else if checkVal(LINE, 1, i) <= 2 {
- check(LINE, 1)
- } else if checkVal(LINE, 0, i) <= 3 {
- check(LINE, 0)
- }
- }
-}
-
-func testFor() {
- for i := 0; i < 10; i++ {
- check(LINE, 10)
- }
-}
-
-func testRange() {
- for _, f := range []func(){
- func() { check(LINE, 1) },
- } {
- f()
- check(LINE, 1)
- }
-}
-
-func testBlockRun() {
- check(LINE, 1)
- {
- check(LINE, 1)
- }
- {
- check(LINE, 1)
- }
- check(LINE, 1)
- {
- check(LINE, 1)
- }
- {
- check(LINE, 1)
- }
- check(LINE, 1)
-}
-
-func testSwitch() {
- for i := 0; i < 5; i++ {
- switch i {
- case 0:
- check(LINE, 1)
- case 1:
- check(LINE, 1)
- case 2:
- check(LINE, 1)
- default:
- check(LINE, 2)
- }
- }
-}
-
-func testTypeSwitch() {
- var x = []interface{}{1, 2.0, "hi"}
- for _, v := range x {
- switch v.(type) {
- case int:
- check(LINE, 1)
- case float64:
- check(LINE, 1)
- case string:
- check(LINE, 1)
- case complex128:
- check(LINE, 0)
- default:
- check(LINE, 0)
- }
- }
-}
-
-func testSelect1() {
- c := make(chan int)
- go func() {
- for i := 0; i < 1000; i++ {
- c <- i
- }
- }()
- for {
- select {
- case <-c:
- check(LINE, anything)
- case <-c:
- check(LINE, anything)
- default:
- check(LINE, 1)
- return
- }
- }
-}
-
-func testSelect2() {
- c1 := make(chan int, 1000)
- c2 := make(chan int, 1000)
- for i := 0; i < 1000; i++ {
- c1 <- i
- c2 <- i
- }
- for {
- select {
- case <-c1:
- check(LINE, 1000)
- case <-c2:
- check(LINE, 1000)
- default:
- check(LINE, 1)
- return
- }
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/eg/eg.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/eg/eg.go
deleted file mode 100644
index 6241a022..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/eg/eg.go
+++ /dev/null
@@ -1,121 +0,0 @@
-// The eg command performs example-based refactoring.
-package main
-
-import (
- "flag"
- "fmt"
- "go/parser"
- "go/printer"
- "go/token"
- "os"
- "path/filepath"
-
- "code.google.com/p/go.tools/go/loader"
- "code.google.com/p/go.tools/refactor/eg"
-)
-
-var (
- helpFlag = flag.Bool("help", false, "show detailed help message")
- templateFlag = flag.String("t", "", "template.go file specifying the refactoring")
- transitiveFlag = flag.Bool("transitive", false, "apply refactoring to all dependencies too")
- writeFlag = flag.Bool("w", false, "rewrite input files in place (by default, the results are printed to standard output)")
- verboseFlag = flag.Bool("v", false, "show verbose matcher diagnostics")
-)
-
-const usage = `eg: an example-based refactoring tool.
-
-Usage: eg -t template.go [-w] [-transitive] ...
--t template.go specifies the template file (use -help to see explanation)
--w causes files to be re-written in place.
--transitive causes all dependencies to be refactored too.
-` + loader.FromArgsUsage
-
-func main() {
- if err := doMain(); err != nil {
- fmt.Fprintf(os.Stderr, "%s: %s.\n", filepath.Base(os.Args[0]), err)
- os.Exit(1)
- }
-}
-
-func doMain() error {
- flag.Parse()
- args := flag.Args()
-
- if *helpFlag {
- fmt.Fprint(os.Stderr, eg.Help)
- os.Exit(2)
- }
-
- if *templateFlag == "" {
- return fmt.Errorf("no -t template.go file specified")
- }
-
- conf := loader.Config{
- Fset: token.NewFileSet(),
- ParserMode: parser.ParseComments,
- SourceImports: true,
- }
-
- // The first Created package is the template.
- if err := conf.CreateFromFilenames("template", *templateFlag); err != nil {
- return err // e.g. "foo.go:1: syntax error"
- }
-
- if len(args) == 0 {
- fmt.Fprint(os.Stderr, usage)
- os.Exit(1)
- }
-
- if _, err := conf.FromArgs(args, true); err != nil {
- return err
- }
-
- // Load, parse and type-check the whole program.
- iprog, err := conf.Load()
- if err != nil {
- return err
- }
-
- // Analyze the template.
- template := iprog.Created[0]
- xform, err := eg.NewTransformer(iprog.Fset, template, *verboseFlag)
- if err != nil {
- return err
- }
-
- // Apply it to the input packages.
- var pkgs []*loader.PackageInfo
- if *transitiveFlag {
- for _, info := range iprog.AllPackages {
- pkgs = append(pkgs, info)
- }
- } else {
- pkgs = iprog.InitialPackages()
- }
- var hadErrors bool
- for _, pkg := range pkgs {
- if pkg == template {
- continue
- }
- for _, file := range pkg.Files {
- n := xform.Transform(&pkg.Info, pkg.Pkg, file)
- if n == 0 {
- continue
- }
- filename := iprog.Fset.File(file.Pos()).Name()
- fmt.Fprintf(os.Stderr, "=== %s (%d matches):\n", filename, n)
- if *writeFlag {
- if err := eg.WriteAST(iprog.Fset, filename, file); err != nil {
- fmt.Fprintf(os.Stderr, "Error: %s\n", err)
- hadErrors = true
- }
- } else {
- printer.Fprint(os.Stdout, iprog.Fset, file)
- }
- }
- }
- if hadErrors {
- os.Exit(1)
- }
- return nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/doc.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/doc.go
deleted file mode 100644
index cf17c6ae..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/doc.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// The godex command prints (dumps) exported information of packages
-// or selected package objects.
-//
-// In contrast to godoc, godex extracts this information from compiled
-// object files. Hence the exported data is truly what a compiler will
-// see, at the cost of missing commentary.
-//
-// Usage: godex [flags] {path[.name]}
-//
-// Each argument must be a (possibly partial) package path, optionally
-// followed by a dot and the name of a package object:
-//
-// godex math
-// godex math.Sin
-// godex math.Sin fmt.Printf
-// godex go/types
-//
-// godex automatically tries all possible package path prefixes if only a
-// partial package path is given. For instance, for the path "go/types",
-// godex prepends "code.google.com/p/go.tools".
-//
-// The prefixes are computed by searching the directories specified by
-// the GOROOT and GOPATH environment variables (and by excluding the
-// build OS- and architecture-specific directory names from the path).
-// The search order is depth-first and alphabetic; for a partial path
-// "foo", a package "a/foo" is found before "b/foo".
-//
-// Absolute and relative paths may be provided, which disable automatic
-// prefix generation:
-//
-// godex $GOROOT/pkg/darwin_amd64/sort
-// godex ./sort
-//
-// All but the last path element may contain dots; a dot in the last path
-// element separates the package path from the package object name. If the
-// last path element contains a dot, terminate the argument with another
-// dot (indicating an empty object name). For instance, the path for a
-// package foo.bar would be specified as in:
-//
-// godex foo.bar.
-//
-// The flags are:
-//
-// -s=""
-// only consider packages from src, where src is one of the supported compilers
-// -v=false
-// verbose mode
-//
-// The following sources (-s arguments) are supported:
-//
-// gc
-// gc-generated object files
-// gccgo
-// gccgo-generated object files
-// gccgo-new
-// gccgo-generated object files using a condensed format (experimental)
-// source
-// (uncompiled) source code (not yet implemented)
-//
-// If no -s argument is provided, godex will try to find a matching source.
-//
-package main
-
-// BUG(gri): support for -s=source is not yet implemented
-// BUG(gri): gccgo-importing appears to have occasional problems stalling godex; try -s=gc as work-around
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/gc.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/gc.go
deleted file mode 100644
index aa4979fa..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/gc.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This file implements access to gc-generated export data.
-
-package main
-
-import (
- "code.google.com/p/go.tools/go/gcimporter"
-)
-
-func init() {
- register("gc", gcimporter.Import)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/gccgo.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/gccgo.go
deleted file mode 100644
index 1f3916c9..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/gccgo.go
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This file implements access to gccgo-generated export data.
-
-package main
-
-import (
- "debug/elf"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
-
- "code.google.com/p/go.tools/go/gccgoimporter"
- "code.google.com/p/go.tools/go/importer"
- "code.google.com/p/go.tools/go/types"
-)
-
-func init() {
- incpaths := []string{"/"}
-
- // importer for default gccgo
- var inst gccgoimporter.GccgoInstallation
- inst.InitFromDriver("gccgo")
- register("gccgo", inst.GetImporter(incpaths))
-
- // importer for gccgo using condensed export format (experimental)
- register("gccgo-new", getNewImporter(append(append(incpaths, inst.SearchPaths()...), ".")))
-}
-
-// This function is an adjusted variant of gccgoimporter.GccgoInstallation.GetImporter.
-func getNewImporter(searchpaths []string) types.Importer {
- return func(imports map[string]*types.Package, pkgpath string) (pkg *types.Package, err error) {
- if pkgpath == "unsafe" {
- return types.Unsafe, nil
- }
-
- fpath, err := findExportFile(searchpaths, pkgpath)
- if err != nil {
- return
- }
-
- reader, closer, err := openExportFile(fpath)
- if err != nil {
- return nil, err
- }
- defer closer.Close()
-
- // TODO(gri) At the moment we just read the entire file.
- // We should change importer.ImportData to take an io.Reader instead.
- data, err := ioutil.ReadAll(reader)
- if err != nil && err != io.EOF {
- return nil, err
- }
-
- return importer.ImportData(packages, data)
- }
-}
-
-// This function is an exact copy of gccgoimporter.findExportFile.
-func findExportFile(searchpaths []string, pkgpath string) (string, error) {
- for _, spath := range searchpaths {
- pkgfullpath := filepath.Join(spath, pkgpath)
- pkgdir, name := filepath.Split(pkgfullpath)
-
- for _, filepath := range [...]string{
- pkgfullpath,
- pkgfullpath + ".gox",
- pkgdir + "lib" + name + ".so",
- pkgdir + "lib" + name + ".a",
- pkgfullpath + ".o",
- } {
- fi, err := os.Stat(filepath)
- if err == nil && !fi.IsDir() {
- return filepath, nil
- }
- }
- }
-
- return "", fmt.Errorf("%s: could not find export data (tried %s)", pkgpath, strings.Join(searchpaths, ":"))
-}
-
-// This function is an exact copy of gccgoimporter.openExportFile.
-func openExportFile(fpath string) (reader io.ReadSeeker, closer io.Closer, err error) {
- f, err := os.Open(fpath)
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- f.Close()
- }
- }()
- closer = f
-
- var magic [4]byte
- _, err = f.ReadAt(magic[:], 0)
- if err != nil {
- return
- }
-
- if string(magic[:]) == "v1;\n" {
- // Raw export data.
- reader = f
- return
- }
-
- ef, err := elf.NewFile(f)
- if err != nil {
- return
- }
-
- sec := ef.Section(".go_export")
- if sec == nil {
- err = fmt.Errorf("%s: .go_export section not found", fpath)
- return
- }
-
- reader = sec.Open()
- return
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/godex.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/godex.go
deleted file mode 100644
index bdfa236c..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/godex.go
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "errors"
- "flag"
- "fmt"
- "go/build"
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
-
- "code.google.com/p/go.tools/go/types"
-)
-
-var (
- source = flag.String("s", "", "only consider packages from src, where src is one of the supported compilers")
- verbose = flag.Bool("v", false, "verbose mode")
-)
-
-// lists of registered sources and corresponding importers
-var (
- sources []string
- importers []types.Importer
- importFailed = errors.New("import failed")
-)
-
-// map of imported packages
-var packages = make(map[string]*types.Package)
-
-func usage() {
- fmt.Fprintln(os.Stderr, "usage: godex [flags] {path|qualifiedIdent}")
- flag.PrintDefaults()
- os.Exit(2)
-}
-
-func report(msg string) {
- fmt.Fprintln(os.Stderr, "error: "+msg)
- os.Exit(2)
-}
-
-func main() {
- flag.Usage = usage
- flag.Parse()
-
- if flag.NArg() == 0 {
- report("no package name, path, or file provided")
- }
-
- imp := tryImports
- if *source != "" {
- imp = lookup(*source)
- if imp == nil {
- report("source (-s argument) must be one of: " + strings.Join(sources, ", "))
- }
- }
-
- for _, arg := range flag.Args() {
- path, name := splitPathIdent(arg)
- logf("\tprocessing %q: path = %q, name = %s\n", arg, path, name)
-
- // generate possible package path prefixes
- // (at the moment we do this for each argument - should probably cache the generated prefixes)
- prefixes := make(chan string)
- go genPrefixes(prefixes, !filepath.IsAbs(path) && !build.IsLocalImport(path))
-
- // import package
- pkg, err := tryPrefixes(packages, prefixes, path, imp)
- if err != nil {
- logf("\t=> ignoring %q: %s\n", path, err)
- continue
- }
-
- // filter objects if needed
- var filter func(types.Object) bool
- if name != "" {
- filter = func(obj types.Object) bool {
- // TODO(gri) perhaps use regular expression matching here?
- return obj.Name() == name
- }
- }
-
- // print contents
- print(os.Stdout, pkg, filter)
- }
-}
-
-func logf(format string, args ...interface{}) {
- if *verbose {
- fmt.Fprintf(os.Stderr, format, args...)
- }
-}
-
-// splitPathIdent splits a path.name argument into its components.
-// All but the last path element may contain dots.
-func splitPathIdent(arg string) (path, name string) {
- if i := strings.LastIndex(arg, "."); i >= 0 {
- if j := strings.LastIndex(arg, "/"); j < i {
- // '.' is not part of path
- path = arg[:i]
- name = arg[i+1:]
- return
- }
- }
- path = arg
- return
-}
-
-// tryPrefixes tries to import the package given by (the possibly partial) path using the given importer imp
-// by prepending all possible prefixes to path. It returns with the first package that it could import, or
-// with an error.
-func tryPrefixes(packages map[string]*types.Package, prefixes chan string, path string, imp types.Importer) (pkg *types.Package, err error) {
- for prefix := range prefixes {
- actual := path
- if prefix == "" {
- // don't use filepath.Join as it will sanitize the path and remove
- // a leading dot and then the path is not recognized as a relative
- // package path by the importers anymore
- logf("\ttrying no prefix\n")
- } else {
- actual = filepath.Join(prefix, path)
- logf("\ttrying prefix %q\n", prefix)
- }
- pkg, err = imp(packages, actual)
- if err == nil {
- break
- }
- logf("\t=> importing %q failed: %s\n", actual, err)
- }
- return
-}
-
-// tryImports is an importer that tries all registered importers
-// successively until one of them succeeds or all of them failed.
-func tryImports(packages map[string]*types.Package, path string) (pkg *types.Package, err error) {
- for i, imp := range importers {
- logf("\t\ttrying %s import\n", sources[i])
- pkg, err = imp(packages, path)
- if err == nil {
- break
- }
- logf("\t\t=> %s import failed: %s\n", sources[i], err)
- }
- return
-}
-
-// protect protects an importer imp from panics and returns the protected importer.
-func protect(imp types.Importer) types.Importer {
- return func(packages map[string]*types.Package, path string) (pkg *types.Package, err error) {
- defer func() {
- if recover() != nil {
- pkg = nil
- err = importFailed
- }
- }()
- return imp(packages, path)
- }
-}
-
-// register registers an importer imp for a given source src.
-func register(src string, imp types.Importer) {
- if lookup(src) != nil {
- panic(src + " importer already registered")
- }
- sources = append(sources, src)
- importers = append(importers, protect(imp))
-}
-
-// lookup returns the importer imp for a given source src.
-func lookup(src string) types.Importer {
- for i, s := range sources {
- if s == src {
- return importers[i]
- }
- }
- return nil
-}
-
-func genPrefixes(out chan string, all bool) {
- out <- ""
- if all {
- platform := build.Default.GOOS + "_" + build.Default.GOARCH
- dirnames := append([]string{build.Default.GOROOT}, filepath.SplitList(build.Default.GOPATH)...)
- for _, dirname := range dirnames {
- walkDir(filepath.Join(dirname, "pkg", platform), "", out)
- }
- }
- close(out)
-}
-
-func walkDir(dirname, prefix string, out chan string) {
- fiList, err := ioutil.ReadDir(dirname)
- if err != nil {
- return
- }
- for _, fi := range fiList {
- if fi.IsDir() && !strings.HasPrefix(fi.Name(), ".") {
- prefix := filepath.Join(prefix, fi.Name())
- out <- prefix
- walkDir(filepath.Join(dirname, fi.Name()), prefix, out)
- }
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/print.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/print.go
deleted file mode 100644
index e02f5e20..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/print.go
+++ /dev/null
@@ -1,365 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "bytes"
- "fmt"
- "go/token"
- "io"
- "math/big"
-
- "code.google.com/p/go.tools/go/exact"
- "code.google.com/p/go.tools/go/types"
-)
-
-// TODO(gri) use tabwriter for alignment?
-
-func print(w io.Writer, pkg *types.Package, filter func(types.Object) bool) {
- var p printer
- p.pkg = pkg
- p.printPackage(pkg, filter)
- io.Copy(w, &p.buf)
-}
-
-type printer struct {
- pkg *types.Package
- buf bytes.Buffer
- indent int // current indentation level
- last byte // last byte written
-}
-
-func (p *printer) print(s string) {
- // Write the string one byte at a time. We care about the presence of
- // newlines for indentation which we will see even in the presence of
- // (non-corrupted) Unicode; no need to read one rune at a time.
- for i := 0; i < len(s); i++ {
- ch := s[i]
- if ch != '\n' && p.last == '\n' {
- // Note: This could lead to a range overflow for very large
- // indentations, but it's extremely unlikely to happen for
- // non-pathological code.
- p.buf.WriteString("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"[:p.indent])
- }
- p.buf.WriteByte(ch)
- p.last = ch
- }
-}
-
-func (p *printer) printf(format string, args ...interface{}) {
- p.print(fmt.Sprintf(format, args...))
-}
-
-// methodsFor returns the named type and corresponding methods if the type
-// denoted by obj is not an interface and has methods. Otherwise it returns
-// the zero value.
-func methodsFor(obj *types.TypeName) (*types.Named, []*types.Selection) {
- named, _ := obj.Type().(*types.Named)
- if named == nil {
- // A type name's type can also be the
- // exported basic type unsafe.Pointer.
- return nil, nil
- }
- if _, ok := named.Underlying().(*types.Interface); ok {
- // ignore interfaces
- return nil, nil
- }
- methods := combinedMethodSet(named)
- if len(methods) == 0 {
- return nil, nil
- }
- return named, methods
-}
-
-func (p *printer) printPackage(pkg *types.Package, filter func(types.Object) bool) {
- // collect objects by kind
- var (
- consts []*types.Const
- typem []*types.Named // non-interface types with methods
- typez []*types.TypeName // interfaces or types without methods
- vars []*types.Var
- funcs []*types.Func
- builtins []*types.Builtin
- methods = make(map[*types.Named][]*types.Selection) // method sets for named types
- )
- scope := pkg.Scope()
- for _, name := range scope.Names() {
- obj := scope.Lookup(name)
- if obj.Exported() {
- // collect top-level exported and possibly filtered objects
- if filter == nil || filter(obj) {
- switch obj := obj.(type) {
- case *types.Const:
- consts = append(consts, obj)
- case *types.TypeName:
- // group into types with methods and types without
- if named, m := methodsFor(obj); named != nil {
- typem = append(typem, named)
- methods[named] = m
- } else {
- typez = append(typez, obj)
- }
- case *types.Var:
- vars = append(vars, obj)
- case *types.Func:
- funcs = append(funcs, obj)
- case *types.Builtin:
- // for unsafe.Sizeof, etc.
- builtins = append(builtins, obj)
- }
- }
- } else if filter == nil {
- // no filtering: collect top-level unexported types with methods
- if obj, _ := obj.(*types.TypeName); obj != nil {
- // see case *types.TypeName above
- if named, m := methodsFor(obj); named != nil {
- typem = append(typem, named)
- methods[named] = m
- }
- }
- }
- }
-
- p.printf("package %s // %q\n", pkg.Name(), pkg.Path())
-
- p.printDecl("const", len(consts), func() {
- for _, obj := range consts {
- p.printObj(obj)
- p.print("\n")
- }
- })
-
- p.printDecl("var", len(vars), func() {
- for _, obj := range vars {
- p.printObj(obj)
- p.print("\n")
- }
- })
-
- p.printDecl("type", len(typez), func() {
- for _, obj := range typez {
- p.printf("%s ", obj.Name())
- p.writeType(p.pkg, obj.Type().Underlying())
- p.print("\n")
- }
- })
-
- // non-interface types with methods
- for _, named := range typem {
- first := true
- if obj := named.Obj(); obj.Exported() {
- if first {
- p.print("\n")
- first = false
- }
- p.printf("type %s ", obj.Name())
- p.writeType(p.pkg, named.Underlying())
- p.print("\n")
- }
- for _, m := range methods[named] {
- if obj := m.Obj(); obj.Exported() {
- if first {
- p.print("\n")
- first = false
- }
- p.printFunc(m.Recv(), obj.(*types.Func))
- p.print("\n")
- }
- }
- }
-
- if len(funcs) > 0 {
- p.print("\n")
- for _, obj := range funcs {
- p.printFunc(nil, obj)
- p.print("\n")
- }
- }
-
- // TODO(gri) better handling of builtins (package unsafe only)
- if len(builtins) > 0 {
- p.print("\n")
- for _, obj := range builtins {
- p.printf("func %s() // builtin\n", obj.Name())
- }
- }
-
- p.print("\n")
-}
-
-func (p *printer) printDecl(keyword string, n int, printGroup func()) {
- switch n {
- case 0:
- // nothing to do
- case 1:
- p.printf("\n%s ", keyword)
- printGroup()
- default:
- p.printf("\n%s (\n", keyword)
- p.indent++
- printGroup()
- p.indent--
- p.print(")\n")
- }
-}
-
-// absInt returns the absolute value of v as a *big.Int.
-// v must be a numeric value.
-func absInt(v exact.Value) *big.Int {
- // compute big-endian representation of v
- b := exact.Bytes(v) // little-endian
- for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
- b[i], b[j] = b[j], b[i]
- }
- return new(big.Int).SetBytes(b)
-}
-
-var (
- one = big.NewRat(1, 1)
- ten = big.NewRat(10, 1)
-)
-
-// floatString returns the string representation for a
-// numeric value v in normalized floating-point format.
-func floatString(v exact.Value) string {
- if exact.Sign(v) == 0 {
- return "0.0"
- }
- // x != 0
-
- // convert |v| into a big.Rat x
- x := new(big.Rat).SetFrac(absInt(exact.Num(v)), absInt(exact.Denom(v)))
-
- // normalize x and determine exponent e
- // (This is not very efficient, but also not speed-critical.)
- var e int
- for x.Cmp(ten) >= 0 {
- x.Quo(x, ten)
- e++
- }
- for x.Cmp(one) < 0 {
- x.Mul(x, ten)
- e--
- }
-
- // TODO(gri) Values such as 1/2 are easier to read in form 0.5
- // rather than 5.0e-1. Similarly, 1.0e1 is easier to read as
- // 10.0. Fine-tune best exponent range for readability.
-
- s := x.FloatString(100) // good-enough precision
-
- // trim trailing 0's
- i := len(s)
- for i > 0 && s[i-1] == '0' {
- i--
- }
- s = s[:i]
-
- // add a 0 if the number ends in decimal point
- if len(s) > 0 && s[len(s)-1] == '.' {
- s += "0"
- }
-
- // add exponent and sign
- if e != 0 {
- s += fmt.Sprintf("e%+d", e)
- }
- if exact.Sign(v) < 0 {
- s = "-" + s
- }
-
- // TODO(gri) If v is a "small" fraction (i.e., numerator and denominator
- // are just a small number of decimal digits), add the exact fraction as
- // a comment. For instance: 3.3333...e-1 /* = 1/3 */
-
- return s
-}
-
-// valString returns the string representation for the value v.
-// Setting floatFmt forces an integer value to be formatted in
-// normalized floating-point format.
-// TODO(gri) Move this code into package exact.
-func valString(v exact.Value, floatFmt bool) string {
- switch v.Kind() {
- case exact.Int:
- if floatFmt {
- return floatString(v)
- }
- case exact.Float:
- return floatString(v)
- case exact.Complex:
- re := exact.Real(v)
- im := exact.Imag(v)
- var s string
- if exact.Sign(re) != 0 {
- s = floatString(re)
- if exact.Sign(im) >= 0 {
- s += " + "
- } else {
- s += " - "
- im = exact.UnaryOp(token.SUB, im, 0) // negate im
- }
- }
- // im != 0, otherwise v would be exact.Int or exact.Float
- return s + floatString(im) + "i"
- }
- return v.String()
-}
-
-func (p *printer) printObj(obj types.Object) {
- p.print(obj.Name())
- // don't write untyped types (for constants)
- typ, basic := obj.Type().Underlying().(*types.Basic)
- if basic && typ.Info()&types.IsUntyped == 0 {
- p.print(" ")
- p.writeType(p.pkg, typ)
- }
- // write constant value
- if obj, ok := obj.(*types.Const); ok {
- floatFmt := basic && typ.Info()&(types.IsFloat|types.IsComplex) != 0
- p.print(" = ")
- p.print(valString(obj.Val(), floatFmt))
- }
-}
-
-func (p *printer) printFunc(recvType types.Type, obj *types.Func) {
- p.print("func ")
- sig := obj.Type().(*types.Signature)
- if recvType != nil {
- p.print("(")
- p.writeType(p.pkg, recvType)
- p.print(") ")
- }
- p.print(obj.Name())
- p.writeSignature(p.pkg, sig)
-}
-
-// combinedMethodSet returns the method set for a named type T
-// merged with all the methods of *T that have different names than
-// the methods of T.
-//
-// combinedMethodSet is analogous to types/typeutil.IntuitiveMethodSet
-// but doesn't require a MethodSetCache.
-// TODO(gri) If this functionality doesn't change over time, consider
-// just calling IntuitiveMethodSet eventually.
-func combinedMethodSet(T *types.Named) []*types.Selection {
- // method set for T
- mset := types.NewMethodSet(T)
- var res []*types.Selection
- for i, n := 0, mset.Len(); i < n; i++ {
- res = append(res, mset.At(i))
- }
-
- // add all *T methods with names different from T methods
- pmset := types.NewMethodSet(types.NewPointer(T))
- for i, n := 0, pmset.Len(); i < n; i++ {
- pm := pmset.At(i)
- if obj := pm.Obj(); mset.Lookup(obj.Pkg(), obj.Name()) == nil {
- res = append(res, pm)
- }
- }
-
- return res
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/source.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/source.go
deleted file mode 100644
index 0f527d16..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/source.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This file implements access to export data from source.
-
-package main
-
-import (
- "code.google.com/p/go.tools/go/types"
-)
-
-func init() {
- register("source", sourceImporter)
-}
-
-func sourceImporter(packages map[string]*types.Package, path string) (*types.Package, error) {
- panic("unimplemented")
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/writetype.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/writetype.go
deleted file mode 100644
index 8f80283d..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godex/writetype.go
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This file implements writing of types. The functionality is lifted
-// directly from go/types, but now contains various modifications for
-// nicer output.
-//
-// TODO(gri) back-port once we have a fixed interface and once the
-// go/types API is not frozen anymore for the 1.3 release; and remove
-// this implementation if possible.
-
-package main
-
-import "code.google.com/p/go.tools/go/types"
-
-func (p *printer) writeType(this *types.Package, typ types.Type) {
- p.writeTypeInternal(this, typ, make([]types.Type, 8))
-}
-
-// From go/types - leave for now to ease back-porting this code.
-const GcCompatibilityMode = false
-
-func (p *printer) writeTypeInternal(this *types.Package, typ types.Type, visited []types.Type) {
- // Theoretically, this is a quadratic lookup algorithm, but in
- // practice deeply nested composite types with unnamed component
- // types are uncommon. This code is likely more efficient than
- // using a map.
- for _, t := range visited {
- if t == typ {
- p.printf("○%T", typ) // cycle to typ
- return
- }
- }
- visited = append(visited, typ)
-
- switch t := typ.(type) {
- case nil:
- p.print("")
-
- case *types.Basic:
- if t.Kind() == types.UnsafePointer {
- p.print("unsafe.")
- }
- if GcCompatibilityMode {
- // forget the alias names
- switch t.Kind() {
- case types.Byte:
- t = types.Typ[types.Uint8]
- case types.Rune:
- t = types.Typ[types.Int32]
- }
- }
- p.print(t.Name())
-
- case *types.Array:
- p.printf("[%d]", t.Len())
- p.writeTypeInternal(this, t.Elem(), visited)
-
- case *types.Slice:
- p.print("[]")
- p.writeTypeInternal(this, t.Elem(), visited)
-
- case *types.Struct:
- n := t.NumFields()
- if n == 0 {
- p.print("struct{}")
- return
- }
-
- p.print("struct {\n")
- p.indent++
- for i := 0; i < n; i++ {
- f := t.Field(i)
- if !f.Anonymous() {
- p.printf("%s ", f.Name())
- }
- p.writeTypeInternal(this, f.Type(), visited)
- if tag := t.Tag(i); tag != "" {
- p.printf(" %q", tag)
- }
- p.print("\n")
- }
- p.indent--
- p.print("}")
-
- case *types.Pointer:
- p.print("*")
- p.writeTypeInternal(this, t.Elem(), visited)
-
- case *types.Tuple:
- p.writeTuple(this, t, false, visited)
-
- case *types.Signature:
- p.print("func")
- p.writeSignatureInternal(this, t, visited)
-
- case *types.Interface:
- // We write the source-level methods and embedded types rather
- // than the actual method set since resolved method signatures
- // may have non-printable cycles if parameters have anonymous
- // interface types that (directly or indirectly) embed the
- // current interface. For instance, consider the result type
- // of m:
- //
- // type T interface{
- // m() interface{ T }
- // }
- //
- n := t.NumMethods()
- if n == 0 {
- p.print("interface{}")
- return
- }
-
- p.print("interface {\n")
- p.indent++
- if GcCompatibilityMode {
- // print flattened interface
- // (useful to compare against gc-generated interfaces)
- for i := 0; i < n; i++ {
- m := t.Method(i)
- p.print(m.Name())
- p.writeSignatureInternal(this, m.Type().(*types.Signature), visited)
- p.print("\n")
- }
- } else {
- // print explicit interface methods and embedded types
- for i, n := 0, t.NumExplicitMethods(); i < n; i++ {
- m := t.ExplicitMethod(i)
- p.print(m.Name())
- p.writeSignatureInternal(this, m.Type().(*types.Signature), visited)
- p.print("\n")
- }
- for i, n := 0, t.NumEmbeddeds(); i < n; i++ {
- typ := t.Embedded(i)
- p.writeTypeInternal(this, typ, visited)
- p.print("\n")
- }
- }
- p.indent--
- p.print("}")
-
- case *types.Map:
- p.print("map[")
- p.writeTypeInternal(this, t.Key(), visited)
- p.print("]")
- p.writeTypeInternal(this, t.Elem(), visited)
-
- case *types.Chan:
- var s string
- var parens bool
- switch t.Dir() {
- case types.SendRecv:
- s = "chan "
- // chan (<-chan T) requires parentheses
- if c, _ := t.Elem().(*types.Chan); c != nil && c.Dir() == types.RecvOnly {
- parens = true
- }
- case types.SendOnly:
- s = "chan<- "
- case types.RecvOnly:
- s = "<-chan "
- default:
- panic("unreachable")
- }
- p.print(s)
- if parens {
- p.print("(")
- }
- p.writeTypeInternal(this, t.Elem(), visited)
- if parens {
- p.print(")")
- }
-
- case *types.Named:
- s := ""
- if obj := t.Obj(); obj != nil {
- if pkg := obj.Pkg(); pkg != nil {
- if pkg != this {
- p.print(pkg.Path())
- p.print(".")
- }
- // TODO(gri): function-local named types should be displayed
- // differently from named types at package level to avoid
- // ambiguity.
- }
- s = obj.Name()
- }
- p.print(s)
-
- default:
- // For externally defined implementations of Type.
- p.print(t.String())
- }
-}
-
-func (p *printer) writeTuple(this *types.Package, tup *types.Tuple, variadic bool, visited []types.Type) {
- p.print("(")
- for i, n := 0, tup.Len(); i < n; i++ {
- if i > 0 {
- p.print(", ")
- }
- v := tup.At(i)
- if name := v.Name(); name != "" {
- p.print(name)
- p.print(" ")
- }
- typ := v.Type()
- if variadic && i == n-1 {
- p.print("...")
- typ = typ.(*types.Slice).Elem()
- }
- p.writeTypeInternal(this, typ, visited)
- }
- p.print(")")
-}
-
-func (p *printer) writeSignature(this *types.Package, sig *types.Signature) {
- p.writeSignatureInternal(this, sig, make([]types.Type, 8))
-}
-
-func (p *printer) writeSignatureInternal(this *types.Package, sig *types.Signature, visited []types.Type) {
- p.writeTuple(this, sig.Params(), sig.Variadic(), visited)
-
- res := sig.Results()
- n := res.Len()
- if n == 0 {
- // no result
- return
- }
-
- p.print(" ")
- if n == 1 && res.At(0).Name() == "" {
- // single unnamed result
- p.writeTypeInternal(this, res.At(0).Type(), visited)
- return
- }
-
- // multiple or named result(s)
- p.writeTuple(this, res, false, visited)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/README.godoc-app b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/README.godoc-app
deleted file mode 100644
index 20ae100e..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/README.godoc-app
+++ /dev/null
@@ -1,56 +0,0 @@
-godoc on appengine
-------------------
-
-Prerequisites
--------------
-
-* Go appengine SDK
- https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go
-
-* Go sources at tip under $GOROOT
-
-* Godoc sources at tip inside $GOPATH
- (go get -d code.google.com/p/go.tools/cmd/godoc)
-
-
-Directory structure
--------------------
-
-* Let $APPDIR be the directory containing the app engine files.
- (e.g., $APPDIR=$HOME/godoc-app)
-
-* $APPDIR contains the following entries (this may change depending on
- app-engine release and version of godoc):
-
- app.yaml
- code.google.com/p/go.tools/cmd/godoc
- godoc.zip
- index.split.*
-
-* The app.yaml file is set up per app engine documentation.
- For instance:
-
- application: godoc-app
- version: 1
- runtime: go
- api_version: go1
-
- handlers:
- - url: /.*
- script: _go_app
-
-
-Configuring and running godoc
------------------------------
-
-To configure godoc, run
-
- bash setup-godoc-app.bash
-
-to prepare an $APPDIR as described above. See the script for details on usage.
-
-To run godoc locally, using the App Engine development server, run
-
- /dev_appserver.py $APPDIR
-
-godoc should come up at http://localhost:8080 .
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/appinit.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/appinit.go
deleted file mode 100644
index d71ae6b9..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/appinit.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build appengine
-
-package main
-
-// This file replaces main.go when running godoc under app-engine.
-// See README.godoc-app for details.
-
-import (
- "archive/zip"
- "log"
- "path"
-
- "code.google.com/p/go.tools/godoc"
- "code.google.com/p/go.tools/godoc/static"
- "code.google.com/p/go.tools/godoc/vfs"
- "code.google.com/p/go.tools/godoc/vfs/mapfs"
- "code.google.com/p/go.tools/godoc/vfs/zipfs"
-)
-
-func init() {
- playEnabled = true
-
- log.Println("initializing godoc ...")
- log.Printf(".zip file = %s", zipFilename)
- log.Printf(".zip GOROOT = %s", zipGoroot)
- log.Printf("index files = %s", indexFilenames)
-
- goroot := path.Join("/", zipGoroot) // fsHttp paths are relative to '/'
-
- // read .zip file and set up file systems
- const zipfile = zipFilename
- rc, err := zip.OpenReader(zipfile)
- if err != nil {
- log.Fatalf("%s: %s\n", zipfile, err)
- }
- // rc is never closed (app running forever)
- fs.Bind("/", zipfs.New(rc, zipFilename), goroot, vfs.BindReplace)
- fs.Bind("/lib/godoc", mapfs.New(static.Files), "/", vfs.BindReplace)
-
- corpus := godoc.NewCorpus(fs)
- corpus.Verbose = false
- corpus.IndexEnabled = true
- corpus.IndexFiles = indexFilenames
- if err := corpus.Init(); err != nil {
- log.Fatal(err)
- }
- go corpus.RunIndexer()
-
- pres = godoc.NewPresentation(corpus)
- pres.TabWidth = 8
- pres.ShowPlayground = true
- pres.ShowExamples = true
- pres.DeclLinks = true
-
- readTemplates(pres, true)
- registerHandlers(pres)
-
- log.Println("godoc initialization complete")
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/blog.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/blog.go
deleted file mode 100644
index ddaa2c4f..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/blog.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "fmt"
- "go/build"
- "log"
- "net/http"
- "os"
- "path/filepath"
- "runtime"
- "strings"
- "sync"
-
- "code.google.com/p/go.tools/blog"
- "code.google.com/p/go.tools/godoc/redirect"
-)
-
-const (
- blogRepo = "code.google.com/p/go.blog"
- blogURL = "http://blog.golang.org/"
- blogPath = "/blog/"
-)
-
-var (
- blogServer http.Handler // set by blogInit
- blogInitOnce sync.Once
- playEnabled bool
-)
-
-func init() {
- // Initialize blog only when first accessed.
- http.HandleFunc(blogPath, func(w http.ResponseWriter, r *http.Request) {
- blogInitOnce.Do(blogInit)
- blogServer.ServeHTTP(w, r)
- })
-}
-
-func blogInit() {
- // Binary distributions will include the blog content in "/blog".
- root := filepath.Join(runtime.GOROOT(), "blog")
-
- // Prefer content from go.blog repository if present.
- if pkg, err := build.Import(blogRepo, "", build.FindOnly); err == nil {
- root = pkg.Dir
- }
-
- // If content is not available fall back to redirect.
- if fi, err := os.Stat(root); err != nil || !fi.IsDir() {
- fmt.Fprintf(os.Stderr, "Blog content not available locally. "+
- "To install, run \n\tgo get %v\n", blogRepo)
- blogServer = http.HandlerFunc(blogRedirectHandler)
- return
- }
-
- s, err := blog.NewServer(blog.Config{
- BaseURL: blogPath,
- BasePath: strings.TrimSuffix(blogPath, "/"),
- ContentPath: filepath.Join(root, "content"),
- TemplatePath: filepath.Join(root, "template"),
- HomeArticles: 5,
- PlayEnabled: playEnabled,
- })
- if err != nil {
- log.Fatal(err)
- }
- blogServer = s
-}
-
-func blogRedirectHandler(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path == blogPath {
- http.Redirect(w, r, blogURL, http.StatusFound)
- return
- }
- blogPrefixHandler.ServeHTTP(w, r)
-}
-
-var blogPrefixHandler = redirect.PrefixHandler(blogPath, blogURL)
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/codewalk.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/codewalk.go
deleted file mode 100644
index 5885c788..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/cmd/godoc/codewalk.go
+++ /dev/null
@@ -1,523 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// The /doc/codewalk/ tree is synthesized from codewalk descriptions,
-// files named $GOROOT/doc/codewalk/*.xml.
-// For an example and a description of the format, see
-// http://golang.org/doc/codewalk/codewalk or run godoc -http=:6060
-// and see http://localhost:6060/doc/codewalk/codewalk .
-// That page is itself a codewalk; the source code for it is
-// $GOROOT/doc/codewalk/codewalk.xml.
-
-package main
-
-import (
- "bytes"
- "encoding/xml"
- "errors"
- "fmt"
- "io"
- "log"
- "net/http"
- "os"
- pathpkg "path"
- "regexp"
- "sort"
- "strconv"
- "strings"
- "text/template"
- "unicode/utf8"
-
- "code.google.com/p/go.tools/godoc"
- "code.google.com/p/go.tools/godoc/vfs"
-)
-
-var codewalkHTML, codewalkdirHTML *template.Template
-
-// Handler for /doc/codewalk/ and below.
-func codewalk(w http.ResponseWriter, r *http.Request) {
- relpath := r.URL.Path[len("/doc/codewalk/"):]
- abspath := r.URL.Path
-
- r.ParseForm()
- if f := r.FormValue("fileprint"); f != "" {
- codewalkFileprint(w, r, f)
- return
- }
-
- // If directory exists, serve list of code walks.
- dir, err := fs.Lstat(abspath)
- if err == nil && dir.IsDir() {
- codewalkDir(w, r, relpath, abspath)
- return
- }
-
- // If file exists, serve using standard file server.
- if err == nil {
- pres.ServeFile(w, r)
- return
- }
-
- // Otherwise append .xml and hope to find
- // a codewalk description, but before trim
- // the trailing /.
- abspath = strings.TrimRight(abspath, "/")
- cw, err := loadCodewalk(abspath + ".xml")
- if err != nil {
- log.Print(err)
- pres.ServeError(w, r, relpath, err)
- return
- }
-
- // Canonicalize the path and redirect if changed
- if redir(w, r) {
- return
- }
-
- pres.ServePage(w, godoc.Page{
- Title: "Codewalk: " + cw.Title,
- Tabtitle: cw.Title,
- Body: applyTemplate(codewalkHTML, "codewalk", cw),
- })
-}
-
-func redir(w http.ResponseWriter, r *http.Request) (redirected bool) {
- canonical := pathpkg.Clean(r.URL.Path)
- if !strings.HasSuffix(canonical, "/") {
- canonical += "/"
- }
- if r.URL.Path != canonical {
- url := *r.URL
- url.Path = canonical
- http.Redirect(w, r, url.String(), http.StatusMovedPermanently)
- redirected = true
- }
- return
-}
-
-func applyTemplate(t *template.Template, name string, data interface{}) []byte {
- var buf bytes.Buffer
- if err := t.Execute(&buf, data); err != nil {
- log.Printf("%s.Execute: %s", name, err)
- }
- return buf.Bytes()
-}
-
-// A Codewalk represents a single codewalk read from an XML file.
-type Codewalk struct {
- Title string `xml:"title,attr"`
- File []string `xml:"file"`
- Step []*Codestep `xml:"step"`
-}
-
-// A Codestep is a single step in a codewalk.
-type Codestep struct {
- // Filled in from XML
- Src string `xml:"src,attr"`
- Title string `xml:"title,attr"`
- XML string `xml:",innerxml"`
-
- // Derived from Src; not in XML.
- Err error
- File string
- Lo int
- LoByte int
- Hi int
- HiByte int
- Data []byte
-}
-
-// String method for printing in template.
-// Formats file address nicely.
-func (st *Codestep) String() string {
- s := st.File
- if st.Lo != 0 || st.Hi != 0 {
- s += fmt.Sprintf(":%d", st.Lo)
- if st.Lo != st.Hi {
- s += fmt.Sprintf(",%d", st.Hi)
- }
- }
- return s
-}
-
-// loadCodewalk reads a codewalk from the named XML file.
-func loadCodewalk(filename string) (*Codewalk, error) {
- f, err := fs.Open(filename)
- if err != nil {
- return nil, err
- }
- defer f.Close()
- cw := new(Codewalk)
- d := xml.NewDecoder(f)
- d.Entity = xml.HTMLEntity
- err = d.Decode(cw)
- if err != nil {
- return nil, &os.PathError{Op: "parsing", Path: filename, Err: err}
- }
-
- // Compute file list, evaluate line numbers for addresses.
- m := make(map[string]bool)
- for _, st := range cw.Step {
- i := strings.Index(st.Src, ":")
- if i < 0 {
- i = len(st.Src)
- }
- filename := st.Src[0:i]
- data, err := vfs.ReadFile(fs, filename)
- if err != nil {
- st.Err = err
- continue
- }
- if i < len(st.Src) {
- lo, hi, err := addrToByteRange(st.Src[i+1:], 0, data)
- if err != nil {
- st.Err = err
- continue
- }
- // Expand match to line boundaries.
- for lo > 0 && data[lo-1] != '\n' {
- lo--
- }
- for hi < len(data) && (hi == 0 || data[hi-1] != '\n') {
- hi++
- }
- st.Lo = byteToLine(data, lo)
- st.Hi = byteToLine(data, hi-1)
- }
- st.Data = data
- st.File = filename
- m[filename] = true
- }
-
- // Make list of files
- cw.File = make([]string, len(m))
- i := 0
- for f := range m {
- cw.File[i] = f
- i++
- }
- sort.Strings(cw.File)
-
- return cw, nil
-}
-
-// codewalkDir serves the codewalk directory listing.
-// It scans the directory for subdirectories or files named *.xml
-// and prepares a table.
-func codewalkDir(w http.ResponseWriter, r *http.Request, relpath, abspath string) {
- type elem struct {
- Name string
- Title string
- }
-
- dir, err := fs.ReadDir(abspath)
- if err != nil {
- log.Print(err)
- pres.ServeError(w, r, relpath, err)
- return
- }
- var v []interface{}
- for _, fi := range dir {
- name := fi.Name()
- if fi.IsDir() {
- v = append(v, &elem{name + "/", ""})
- } else if strings.HasSuffix(name, ".xml") {
- cw, err := loadCodewalk(abspath + "/" + name)
- if err != nil {
- continue
- }
- v = append(v, &elem{name[0 : len(name)-len(".xml")], cw.Title})
- }
- }
-
- pres.ServePage(w, godoc.Page{
- Title: "Codewalks",
- Body: applyTemplate(codewalkdirHTML, "codewalkdir", v),
- })
-}
-
-// codewalkFileprint serves requests with ?fileprint=f&lo=lo&hi=hi.
-// The filename f has already been retrieved and is passed as an argument.
-// Lo and hi are the numbers of the first and last line to highlight
-// in the response. This format is used for the middle window pane
-// of the codewalk pages. It is a separate iframe and does not get
-// the usual godoc HTML wrapper.
-func codewalkFileprint(w http.ResponseWriter, r *http.Request, f string) {
- abspath := f
- data, err := vfs.ReadFile(fs, abspath)
- if err != nil {
- log.Print(err)
- pres.ServeError(w, r, f, err)
- return
- }
- lo, _ := strconv.Atoi(r.FormValue("lo"))
- hi, _ := strconv.Atoi(r.FormValue("hi"))
- if hi < lo {
- hi = lo
- }
- lo = lineToByte(data, lo)
- hi = lineToByte(data, hi+1)
-
- // Put the mark 4 lines before lo, so that the iframe
- // shows a few lines of context before the highlighted
- // section.
- n := 4
- mark := lo
- for ; mark > 0 && n > 0; mark-- {
- if data[mark-1] == '\n' {
- if n--; n == 0 {
- break
- }
- }
- }
-
- io.WriteString(w, `
`)
- template.HTMLEscape(w, data[0:mark])
- io.WriteString(w, "")
- template.HTMLEscape(w, data[mark:lo])
- if lo < hi {
- io.WriteString(w, "
- The method set includes not only the declared methods of the type,
- but also any methods "promoted" from anonymous fields of structs,
- such as sync.Mutex in this example.
-
- In addition, the receiver type is displayed as *T or
- T depending on whether it requires the address or just
- a copy of the receiver value.
-
-
- The method set and implements relation are also available
- via the package view.
-
-
-
-
Pointer analysis features
-
- godoc -analysis=pointer performs a precise
- whole-program pointer analysis. In other words, it
- approximates the set of memory locations to which each
- reference—not just vars of kind *T, but also
- []T, func, map,
- chan, and interface—may refer. This
- information reveals the possible destinations of each dynamic call
- (via a func variable or interface method), and the
- relationship between send and receive operations on the same
- channel.
-
-
- ⚠ Pointer analysis is currently quite slow,
- taking around two minutes for the standard library. This will
- improve markedly with the planned addition of a constraint
- optimizer.
-
-
-
Call graph navigation
-
- When pointer analysis is complete, the source view annotates the
- code with callers and callees information: callers
- information is associated with the func keyword that
- declares a function, and callees information is associated with the
- open paren '(' of
- a function call.
-
-
- In this example, hovering over the declaration of the
- rot13 function (defined in in strings/strings.test.go)
- reveals that it is called in exactly one place.
-
-
-
- Clicking the link navigates to the sole caller. (If there were
- multiple callers, a list of choices would be displayed first.)
-
-
-
- Notice that hovering over this call reveals that there are 19
- possible callees at this site, of which our rot13
- function was just one: this is a dynamic call through a variable of
- type func(rune) rune.
-
- Clicking on the call brings up the list of all 19 potential callees,
- shown truncated. Many of them are anonymous functions.
-
-
-
- Pointer analysis gives a very precise approximation of the call
- graph compared to type-based techniques.
-
- As a case in point, the next example shows the dynamic call inside
- the testing package responsible for calling all
- user-defined functions named ExampleXYZ.
-
-
-
- Recall that all such functions have type func(),
- i.e. no arguments and no results. A type-based approximation could
- only conclude that this call might dispatch to any function matching
- that type—and these are very numerous in most
- programs—but pointer analysis can track the flow of specific
- func values through the testing package.
-
- As an indication of its precision, the result contains only
- functions whose name starts with Example.
-
-
-
Intra-package call graph
-
- The same call graph information is presented in a very different way
- in the package view. For each package, an interactive tree view
- allows exploration of the call graph as it relates to just that
- package; all functions from other packages are elided.
-
- The roots of the tree are the external entry points of the package:
- not only its exported functions, but also any unexported or
- anonymous functions that are called (dynamically) from outside the
- package.
-
-
- This example shows the entry points of the
- path/filepath package, with the call graph for
- Glob expanded several levels
-
-
-
- Notice that the nodes for Glob and Join appear multiple times: the
- tree is a partial unrolling of a cyclic graph; the full unrolling
- is in general infinite.
-
-
- For each function documented in the package view, another
- interactive tree view allows exploration of the same graph starting
- at that function.
-
- This is a portion of the internal graph of
- net/http.ListenAndServe.
-
-
-
-
Channel peers (send ↔ receive)
-
- Because concurrent Go programs use channels to pass not just values
- but also control between different goroutines, it is natural when
- reading Go code to want to navigate from a channel send to the
- corresponding receive so as to understand the sequence of events.
-
-
- Godoc annotates every channel operation—make, send, range,
- receive, close—with a link to a panel displaying information
- about other operations that might alias the same channel.
-
-
- This example, from the tests of net/http, shows a send
- operation on a chan bool.
-
-
-
- Clicking on the <- send operator reveals that this
- channel is made at a unique location (line 332) and that there are
- three receive operations that might read this value.
-
- It hardly needs pointing out that some channel element types are
- very widely used (e.g. struct{}, bool, int, interface{}) and that a
- typical Go program might contain dozens of receive operations on a
- value of type chan bool; yet the pointer analysis is
- able to distinguish operations on channels at a much finer precision
- than based on their type alone.
-
-
- Notice also that the send occurs in a different (anonymous) function
- from the outer one containing the make and the receive
- operations.
-
-
- Here's another example of send on a different chan
- bool, also in package net/http:
-
-
-
- The analysis finds just one receive operation that might receive
- from this channel, in the test for this feature.
-
-
-
-
Known issues
-
- ⚠ There is no UI indication of the state of
- the analysis (pending, complete, failed) during warm-up.
-
- ⚠ All analysis results pertain to exactly
- one configuration (e.g. amd64 linux). Files that are conditionally
- compiled based on different platforms or build tags are not visible
- to the analysis.
-
- ⚠ Files that import "C" require
- preprocessing by the cgo tool. The file offsets after preprocessing
- do not align with the unpreprocessed file, so markup is misaligned.
-
- ⚠ Files are not periodically re-analyzed.
- If the files change underneath the running server, the displayed
- markup is misaligned.
-
- ⚠ Additional issues are listed at go.tools/godoc/analysis/README.
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-def.png b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-def.png
deleted file mode 100644
index b0d9e55a..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-def.png and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-field.png b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-field.png
deleted file mode 100644
index 76cbe5a3..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-field.png and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-func.png b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-func.png
deleted file mode 100644
index 69670fa2..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ident-func.png and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ipcg-func.png b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ipcg-func.png
deleted file mode 100644
index 523318d6..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ipcg-func.png and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ipcg-pkg.png b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ipcg-pkg.png
deleted file mode 100644
index e0290685..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/ipcg-pkg.png and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/typeinfo-pkg.png b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/typeinfo-pkg.png
deleted file mode 100644
index 91bd5f74..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/typeinfo-pkg.png and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/typeinfo-src.png b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/typeinfo-src.png
deleted file mode 100644
index 6e5b147e..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/analysis/typeinfo-src.png and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/bake.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/bake.go
deleted file mode 100644
index b7e61579..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/bake.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-// Command bake takes a list of file names and writes a Go source file to
-// standard output that declares a map of string constants containing the input files.
-//
-// For example, the command
-// bake foo.html bar.txt
-// produces a source file in package main that declares the variable bakedFiles
-// that is a map with keys "foo.html" and "bar.txt" that contain the contents
-// of foo.html and bar.txt.
-package main
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io/ioutil"
- "os"
- "unicode/utf8"
-)
-
-func main() {
- if err := bake(os.Args[1:]); err != nil {
- fmt.Fprintln(os.Stderr, err)
- os.Exit(1)
- }
-}
-
-func bake(files []string) error {
- w := bufio.NewWriter(os.Stdout)
- fmt.Fprintf(w, "%v\n\npackage static\n\n", warning)
- fmt.Fprintf(w, "var Files = map[string]string{\n")
- for _, fn := range files {
- b, err := ioutil.ReadFile(fn)
- if err != nil {
- return err
- }
- fmt.Fprintf(w, "\t%q: ", fn)
- if utf8.Valid(b) {
- fmt.Fprintf(w, "`%s`", sanitize(b))
- } else {
- fmt.Fprintf(w, "%q", b)
- }
- fmt.Fprintln(w, ",\n")
- }
- fmt.Fprintln(w, "}")
- return w.Flush()
-}
-
-// sanitize prepares a valid UTF-8 string as a raw string constant.
-func sanitize(b []byte) []byte {
- // Replace ` with `+"`"+`
- b = bytes.Replace(b, []byte("`"), []byte("`+\"`\"+`"), -1)
-
- // Replace BOM with `+"\xEF\xBB\xBF"+`
- // (A BOM is valid UTF-8 but not permitted in Go source files.
- // I wouldn't bother handling this, but for some insane reason
- // jquery.js has a BOM somewhere in the middle.)
- return bytes.Replace(b, []byte("\xEF\xBB\xBF"), []byte("`+\"\\xEF\\xBB\\xBF\"+`"), -1)
-}
-
-const warning = "// DO NOT EDIT ** This file was generated with the bake tool ** DO NOT EDIT //"
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/bake.sh b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/bake.sh
deleted file mode 100755
index 42f31bf3..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/bake.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2013 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-set -e
-
-STATIC="
- analysis/call3.png
- analysis/call-eg.png
- analysis/callers1.png
- analysis/callers2.png
- analysis/chan1.png
- analysis/chan2a.png
- analysis/chan2b.png
- analysis/error1.png
- analysis/help.html
- analysis/ident-def.png
- analysis/ident-field.png
- analysis/ident-func.png
- analysis/ipcg-func.png
- analysis/ipcg-pkg.png
- analysis/typeinfo-pkg.png
- analysis/typeinfo-src.png
- callgraph.html
- codewalk.html
- codewalkdir.html
- dirlist.html
- error.html
- example.html
- godoc.html
- godocs.js
- images/minus.gif
- images/plus.gif
- images/treeview-black-line.gif
- images/treeview-black.gif
- images/treeview-default-line.gif
- images/treeview-default.gif
- images/treeview-gray-line.gif
- images/treeview-gray.gif
- implements.html
- jquery.js
- jquery.treeview.css
- jquery.treeview.edit.js
- jquery.treeview.js
- methodset.html
- opensearch.xml
- package.html
- package.txt
- play.js
- playground.js
- search.html
- search.txt
- searchcode.html
- searchdoc.html
- searchtxt.html
- style.css
-"
-
-go run bake.go $STATIC | gofmt > static.go
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/callgraph.html b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/callgraph.html
deleted file mode 100644
index 49c285c4..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/callgraph.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
▹ Internal call graph
-
-
-
▾ Internal call graph
-
- This viewer shows the portion of the internal call
- graph of this package that is reachable from this function.
- See the package's call
- graph for more information.
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/doc.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/doc.go
deleted file mode 100644
index 3f3a27cb..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/doc.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package static exports a map of static file content that supports the godoc
-// user interface. The map should be used with the mapfs package, see
-// code.google.com/p/godoc/vfs/mapfs.
-package static
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/error.html b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/error.html
deleted file mode 100644
index 7573aa23..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/error.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
').appendTo(tocRow).append(dl2);
-}
-
-function bindToggle(el) {
- $('.toggleButton', el).click(function() {
- if ($(el).is('.toggle')) {
- $(el).addClass('toggleVisible').removeClass('toggle');
- } else {
- $(el).addClass('toggle').removeClass('toggleVisible');
- }
- });
-}
-function bindToggles(selector) {
- $(selector).each(function(i, el) {
- bindToggle(el);
- });
-}
-
-function bindToggleLink(el, prefix) {
- $(el).click(function() {
- var href = $(el).attr('href');
- var i = href.indexOf('#'+prefix);
- if (i < 0) {
- return;
- }
- var id = '#' + prefix + href.slice(i+1+prefix.length);
- if ($(id).is('.toggle')) {
- $(id).find('.toggleButton').first().click();
- }
- });
-}
-function bindToggleLinks(selector, prefix) {
- $(selector).each(function(i, el) {
- bindToggleLink(el, prefix);
- });
-}
-
-function setupDropdownPlayground() {
- if (!$('#page').is('.wide')) {
- return; // don't show on front page
- }
- var button = $('#playgroundButton');
- var div = $('#playground');
- var setup = false;
- button.toggle(function() {
- button.addClass('active');
- div.show();
- if (setup) {
- return;
- }
- setup = true;
- playground({
- 'codeEl': $('.code', div),
- 'outputEl': $('.output', div),
- 'runEl': $('.run', div),
- 'fmtEl': $('.fmt', div),
- 'shareEl': $('.share', div),
- 'shareRedirect': 'http://play.golang.org/p/'
- });
- },
- function() {
- button.removeClass('active');
- div.hide();
- });
- button.show();
- $('#menu').css('min-width', '+=60');
-}
-
-function setupInlinePlayground() {
- 'use strict';
- // Set up playground when each element is toggled.
- $('div.play').each(function (i, el) {
- // Set up playground for this example.
- var setup = function() {
- var code = $('.code', el);
- playground({
- 'codeEl': code,
- 'outputEl': $('.output', el),
- 'runEl': $('.run', el),
- 'fmtEl': $('.fmt', el),
- 'shareEl': $('.share', el),
- 'shareRedirect': 'http://play.golang.org/p/'
- });
-
- // Make the code textarea resize to fit content.
- var resize = function() {
- code.height(0);
- var h = code[0].scrollHeight;
- code.height(h+20); // minimize bouncing.
- code.closest('.input').height(h);
- };
- code.on('keydown', resize);
- code.on('keyup', resize);
- code.keyup(); // resize now.
- };
-
- // If example already visible, set up playground now.
- if ($(el).is(':visible')) {
- setup();
- return;
- }
-
- // Otherwise, set up playground when example is expanded.
- var built = false;
- $(el).closest('.toggle').click(function() {
- // Only set up once.
- if (!built) {
- setup();
- built = true;
- }
- });
- });
-}
-
-// fixFocus tries to put focus to div#page so that keyboard navigation works.
-function fixFocus() {
- var page = $('div#page');
- var topbar = $('div#topbar');
- page.css('outline', 0); // disable outline when focused
- page.attr('tabindex', -1); // and set tabindex so that it is focusable
- $(window).resize(function (evt) {
- // only focus page when the topbar is at fixed position (that is, it's in
- // front of page, and keyboard event will go to the former by default.)
- // by focusing page, keyboard event will go to page so that up/down arrow,
- // space, etc. will work as expected.
- if (topbar.css('position') == "fixed")
- page.focus();
- }).resize();
-}
-
-function toggleHash() {
- var hash = $(window.location.hash);
- if (hash.is('.toggle')) {
- hash.find('.toggleButton').first().click();
- }
-}
-
-function addPlusButtons() {
- var po = document.createElement('script');
- po.type = 'text/javascript';
- po.async = true;
- po.src = 'https://apis.google.com/js/platform.js';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(po, s);
-}
-
-$(document).ready(function() {
- bindSearchEvents();
- generateTOC();
- bindToggles(".toggle");
- bindToggles(".toggleVisible");
- bindToggleLinks(".exampleLink", "example_");
- bindToggleLinks(".overviewLink", "");
- bindToggleLinks(".examplesLink", "");
- bindToggleLinks(".indexLink", "");
- setupDropdownPlayground();
- setupInlinePlayground();
- fixFocus();
- setupTypeInfo();
- setupCallgraphs();
- toggleHash();
- addPlusButtons();
-
- // godoc.html defines window.initFuncs in the tag, and root.html and
- // codewalk.js push their on-page-ready functions to the list.
- // We execute those functions here, to avoid loading jQuery until the page
- // content is loaded.
- for (var i = 0; i < window.initFuncs.length; i++) window.initFuncs[i]();
-});
-
-// -- analysis ---------------------------------------------------------
-
-// escapeHTML returns HTML for s, with metacharacters quoted.
-// It is safe for use in both elements and attributes
-// (unlike the "set innerText, read innerHTML" trick).
-function escapeHTML(s) {
- return s.replace(/&/g, '&').
- replace(/\"/g, '"').
- replace(/\'/g, ''').
- replace(//g, '>');
-}
-
-// makeAnchor returns HTML for an element, given an anchorJSON object.
-function makeAnchor(json) {
- var html = escapeHTML(json.Text);
- if (json.Href != "") {
- html = "" + html + "";
- }
- return html;
-}
-
-function showLowFrame(html) {
- var lowframe = document.getElementById('lowframe');
- lowframe.style.height = "200px";
- lowframe.innerHTML = "
" + html + "
\n" +
- "
✘
"
-};
-
-document.hideLowFrame = function() {
- var lowframe = document.getElementById('lowframe');
- lowframe.style.height = "0px";
-}
-
-// onClickCallers is the onclick action for the 'func' tokens of a
-// function declaration.
-document.onClickCallers = function(index) {
- var data = document.ANALYSIS_DATA[index]
- if (data.Callers.length == 1 && data.Callers[0].Sites.length == 1) {
- document.location = data.Callers[0].Sites[0].Href; // jump to sole caller
- return;
- }
-
- var html = "Callers of " + escapeHTML(data.Callee) + ": \n";
- for (var i = 0; i < data.Callers.length; i++) {
- var caller = data.Callers[i];
- html += "" + escapeHTML(caller.Func) + "";
- var sites = caller.Sites;
- if (sites != null && sites.length > 0) {
- html += " at line ";
- for (var j = 0; j < sites.length; j++) {
- if (j > 0) {
- html += ", ";
- }
- html += "" + makeAnchor(sites[j]) + "";
- }
- }
- html += " \n";
- }
- showLowFrame(html);
-};
-
-// onClickCallees is the onclick action for the '(' token of a function call.
-document.onClickCallees = function(index) {
- var data = document.ANALYSIS_DATA[index]
- if (data.Callees.length == 1) {
- document.location = data.Callees[0].Href; // jump to sole callee
- return;
- }
-
- var html = "Callees of this " + escapeHTML(data.Descr) + ": \n";
- for (var i = 0; i < data.Callees.length; i++) {
- html += "" + makeAnchor(data.Callees[i]) + " \n";
- }
- showLowFrame(html);
-};
-
-// onClickTypeInfo is the onclick action for identifiers declaring a named type.
-document.onClickTypeInfo = function(index) {
- var data = document.ANALYSIS_DATA[index];
- var html = "Type " + data.Name + ": " +
- " (size=" + data.Size + ", align=" + data.Align + ") \n";
- html += implementsHTML(data);
- html += methodsetHTML(data);
- showLowFrame(html);
-};
-
-// implementsHTML returns HTML for the implements relation of the
-// specified TypeInfoJSON value.
-function implementsHTML(info) {
- var html = "";
- if (info.ImplGroups != null) {
- for (var i = 0; i < info.ImplGroups.length; i++) {
- var group = info.ImplGroups[i];
- var x = "" + escapeHTML(group.Descr) + " ";
- for (var j = 0; j < group.Facts.length; j++) {
- var fact = group.Facts[j];
- var y = "" + makeAnchor(fact.Other) + "";
- if (fact.ByKind != null) {
- html += escapeHTML(fact.ByKind) + " type " + y + " implements " + x;
- } else {
- html += x + " implements " + y;
- }
- html += " \n";
- }
- }
- }
- return html;
-}
-
-
-// methodsetHTML returns HTML for the methodset of the specified
-// TypeInfoJSON value.
-function methodsetHTML(info) {
- var html = "";
- if (info.Methods != null) {
- for (var i = 0; i < info.Methods.length; i++) {
- html += "" + makeAnchor(info.Methods[i]) + " \n";
- }
- }
- return html;
-}
-
-// onClickComm is the onclick action for channel "make" and "<-"
-// send/receive tokens.
-document.onClickComm = function(index) {
- var ops = document.ANALYSIS_DATA[index].Ops
- if (ops.length == 1) {
- document.location = ops[0].Op.Href; // jump to sole element
- return;
- }
-
- var html = "Operations on this channel: \n";
- for (var i = 0; i < ops.length; i++) {
- html += makeAnchor(ops[i].Op) + " by " + escapeHTML(ops[i].Fn) + " \n";
- }
- if (ops.length == 0) {
- html += "(none) \n";
- }
- showLowFrame(html);
-};
-
-$(window).load(function() {
- // Scroll window so that first selection is visible.
- // (This means we don't need to emit id='L%d' spans for each line.)
- // TODO(adonovan): ideally, scroll it so that it's under the pointer,
- // but I don't know how to get the pointer y coordinate.
- var elts = document.getElementsByClassName("selection");
- if (elts.length > 0) {
- elts[0].scrollIntoView()
- }
-});
-
-// setupTypeInfo populates the "Implements" and "Method set" toggle for
-// each type in the package doc.
-function setupTypeInfo() {
- for (var i in document.ANALYSIS_DATA) {
- var data = document.ANALYSIS_DATA[i];
-
- var el = document.getElementById("implements-" + i);
- if (el != null) {
- // el != null => data is TypeInfoJSON.
- if (data.ImplGroups != null) {
- el.innerHTML = implementsHTML(data);
- el.parentNode.parentNode.style.display = "block";
- }
- }
-
- var el = document.getElementById("methodset-" + i);
- if (el != null) {
- // el != null => data is TypeInfoJSON.
- if (data.Methods != null) {
- el.innerHTML = methodsetHTML(data);
- el.parentNode.parentNode.style.display = "block";
- }
- }
- }
-}
-
-function setupCallgraphs() {
- if (document.CALLGRAPH == null) {
- return
- }
- document.getElementById("pkg-callgraph").style.display = "block";
-
- var treeviews = document.getElementsByClassName("treeview");
- for (var i in treeviews) {
- var tree = treeviews[i];
- if (tree.id == null || tree.id.indexOf("callgraph-") != 0) {
- continue;
- }
- var id = tree.id.substring("callgraph-".length);
- $(tree).treeview({collapsed: true, animated: "fast"});
- document.cgAddChildren(tree, tree, [id]);
- tree.parentNode.parentNode.style.display = "block";
- }
-}
-
-document.cgAddChildren = function(tree, ul, indices) {
- if (indices != null) {
- for (var i = 0; i < indices.length; i++) {
- var li = cgAddChild(tree, ul, document.CALLGRAPH[indices[i]]);
- if (i == indices.length - 1) {
- $(li).addClass("last");
- }
- }
- }
- $(tree).treeview({animated: "fast", add: ul});
-}
-
-// cgAddChild adds an
element for document.CALLGRAPH node cgn to
-// the parent
element ul. tree is the tree's root
element.
-function cgAddChild(tree, ul, cgn) {
- var li = document.createElement("li");
- ul.appendChild(li);
- li.className = "closed";
-
- var code = document.createElement("code");
-
- if (cgn.Callees != null) {
- $(li).addClass("expandable");
-
- // Event handlers and innerHTML updates don't play nicely together,
- // hence all this explicit DOM manipulation.
- var hitarea = document.createElement("div");
- hitarea.className = "hitarea expandable-hitarea";
- li.appendChild(hitarea);
-
- li.appendChild(code);
-
- var childUL = document.createElement("ul");
- li.appendChild(childUL);
- childUL.setAttribute('style', "display: none;");
-
- var onClick = function() {
- document.cgAddChildren(tree, childUL, cgn.Callees);
- hitarea.removeEventListener('click', onClick)
- };
- hitarea.addEventListener('click', onClick);
-
- } else {
- li.appendChild(code);
- }
- code.innerHTML += " " + makeAnchor(cgn.Func);
- return li
-}
-
-})();
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/minus.gif b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/minus.gif
deleted file mode 100644
index 47fb7b76..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/minus.gif and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/plus.gif b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/plus.gif
deleted file mode 100644
index 69066216..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/plus.gif and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-black-line.gif b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-black-line.gif
deleted file mode 100644
index e5496877..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-black-line.gif and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-black.gif b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-black.gif
deleted file mode 100644
index b718d17f..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-black.gif and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-default-line.gif b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-default-line.gif
deleted file mode 100644
index 37114d30..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-default-line.gif and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-default.gif b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-default.gif
deleted file mode 100644
index 76eee60d..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-default.gif and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-gray-line.gif b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-gray-line.gif
deleted file mode 100644
index 37600447..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-gray-line.gif and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-gray.gif b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-gray.gif
deleted file mode 100644
index cfdf1ab6..00000000
Binary files a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/images/treeview-gray.gif and /dev/null differ
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/implements.html b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/implements.html
deleted file mode 100644
index a02340c4..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/static/implements.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
- In the call graph viewer below, each node
- is a function belonging to this package
- and its children are the functions it
- calls—perhaps dynamically.
-
-
- The root nodes are the entry points of the
- package: functions that may be called from
- outside the package.
- There may be non-exported or anonymous
- functions among them if they are called
- dynamically from another package.
-
-
- Click a node to visit that function's source code.
- From there you can visit its callers by
- clicking its declaring func
- token.
-
-
- Functions may be omitted if they were
- determined to be unreachable in the
- particular programs or tests that were
- analyzed.
-
- The method set includes not only the declared methods of the type,
- but also any methods "promoted" from anonymous fields of structs,
- such as sync.Mutex in this example.
-
- In addition, the receiver type is displayed as *T or
- T depending on whether it requires the address or just
- a copy of the receiver value.
-
-
- The method set and implements relation are also available
- via the package view.
-
-
-
-
Pointer analysis features
-
- godoc -analysis=pointer performs a precise
- whole-program pointer analysis. In other words, it
- approximates the set of memory locations to which each
- reference—not just vars of kind *T, but also
- []T, func, map,
- chan, and interface—may refer. This
- information reveals the possible destinations of each dynamic call
- (via a func variable or interface method), and the
- relationship between send and receive operations on the same
- channel.
-
-
- ⚠ Pointer analysis is currently quite slow,
- taking around two minutes for the standard library. This will
- improve markedly with the planned addition of a constraint
- optimizer.
-
-
-
Call graph navigation
-
- When pointer analysis is complete, the source view annotates the
- code with callers and callees information: callers
- information is associated with the func keyword that
- declares a function, and callees information is associated with the
- open paren '(' of
- a function call.
-
-
- In this example, hovering over the declaration of the
- rot13 function (defined in in strings/strings.test.go)
- reveals that it is called in exactly one place.
-
-
-
- Clicking the link navigates to the sole caller. (If there were
- multiple callers, a list of choices would be displayed first.)
-
-
-
- Notice that hovering over this call reveals that there are 19
- possible callees at this site, of which our rot13
- function was just one: this is a dynamic call through a variable of
- type func(rune) rune.
-
- Clicking on the call brings up the list of all 19 potential callees,
- shown truncated. Many of them are anonymous functions.
-
-
-
- Pointer analysis gives a very precise approximation of the call
- graph compared to type-based techniques.
-
- As a case in point, the next example shows the dynamic call inside
- the testing package responsible for calling all
- user-defined functions named ExampleXYZ.
-
-
-
- Recall that all such functions have type func(),
- i.e. no arguments and no results. A type-based approximation could
- only conclude that this call might dispatch to any function matching
- that type—and these are very numerous in most
- programs—but pointer analysis can track the flow of specific
- func values through the testing package.
-
- As an indication of its precision, the result contains only
- functions whose name starts with Example.
-
-
-
Intra-package call graph
-
- The same call graph information is presented in a very different way
- in the package view. For each package, an interactive tree view
- allows exploration of the call graph as it relates to just that
- package; all functions from other packages are elided.
-
- The roots of the tree are the external entry points of the package:
- not only its exported functions, but also any unexported or
- anonymous functions that are called (dynamically) from outside the
- package.
-
-
- This example shows the entry points of the
- path/filepath package, with the call graph for
- Glob expanded several levels
-
-
-
- Notice that the nodes for Glob and Join appear multiple times: the
- tree is a partial unrolling of a cyclic graph; the full unrolling
- is in general infinite.
-
-
- For each function documented in the package view, another
- interactive tree view allows exploration of the same graph starting
- at that function.
-
- This is a portion of the internal graph of
- net/http.ListenAndServe.
-
-
-
-
Channel peers (send ↔ receive)
-
- Because concurrent Go programs use channels to pass not just values
- but also control between different goroutines, it is natural when
- reading Go code to want to navigate from a channel send to the
- corresponding receive so as to understand the sequence of events.
-
-
- Godoc annotates every channel operation—make, send, range,
- receive, close—with a link to a panel displaying information
- about other operations that might alias the same channel.
-
-
- This example, from the tests of net/http, shows a send
- operation on a chan bool.
-
-
-
- Clicking on the <- send operator reveals that this
- channel is made at a unique location (line 332) and that there are
- three receive operations that might read this value.
-
- It hardly needs pointing out that some channel element types are
- very widely used (e.g. struct{}, bool, int, interface{}) and that a
- typical Go program might contain dozens of receive operations on a
- value of type chan bool; yet the pointer analysis is
- able to distinguish operations on channels at a much finer precision
- than based on their type alone.
-
-
- Notice also that the send occurs in a different (anonymous) function
- from the outer one containing the make and the receive
- operations.
-
-
- Here's another example of send on a different chan
- bool, also in package net/http:
-
-
-
- The analysis finds just one receive operation that might receive
- from this channel, in the test for this feature.
-
-
-
-
Known issues
-
- ⚠ There is no UI indication of the state of
- the analysis (pending, complete, failed) during warm-up.
-
- ⚠ All analysis results pertain to exactly
- one configuration (e.g. amd64 linux). Files that are conditionally
- compiled based on different platforms or build tags are not visible
- to the analysis.
-
- ⚠ Files that import "C" require
- preprocessing by the cgo tool. The file offsets after preprocessing
- do not align with the unpreprocessed file, so markup is misaligned.
-
- ⚠ Files are not periodically re-analyzed.
- If the files change underneath the running server, the displayed
- markup is misaligned.
-
- ⚠ Additional issues are listed at go.tools/godoc/analysis/README.
-
').appendTo(tocRow).append(dl2);
-}
-
-function bindToggle(el) {
- $('.toggleButton', el).click(function() {
- if ($(el).is('.toggle')) {
- $(el).addClass('toggleVisible').removeClass('toggle');
- } else {
- $(el).addClass('toggle').removeClass('toggleVisible');
- }
- });
-}
-function bindToggles(selector) {
- $(selector).each(function(i, el) {
- bindToggle(el);
- });
-}
-
-function bindToggleLink(el, prefix) {
- $(el).click(function() {
- var href = $(el).attr('href');
- var i = href.indexOf('#'+prefix);
- if (i < 0) {
- return;
- }
- var id = '#' + prefix + href.slice(i+1+prefix.length);
- if ($(id).is('.toggle')) {
- $(id).find('.toggleButton').first().click();
- }
- });
-}
-function bindToggleLinks(selector, prefix) {
- $(selector).each(function(i, el) {
- bindToggleLink(el, prefix);
- });
-}
-
-function setupDropdownPlayground() {
- if (!$('#page').is('.wide')) {
- return; // don't show on front page
- }
- var button = $('#playgroundButton');
- var div = $('#playground');
- var setup = false;
- button.toggle(function() {
- button.addClass('active');
- div.show();
- if (setup) {
- return;
- }
- setup = true;
- playground({
- 'codeEl': $('.code', div),
- 'outputEl': $('.output', div),
- 'runEl': $('.run', div),
- 'fmtEl': $('.fmt', div),
- 'shareEl': $('.share', div),
- 'shareRedirect': 'http://play.golang.org/p/'
- });
- },
- function() {
- button.removeClass('active');
- div.hide();
- });
- button.show();
- $('#menu').css('min-width', '+=60');
-}
-
-function setupInlinePlayground() {
- 'use strict';
- // Set up playground when each element is toggled.
- $('div.play').each(function (i, el) {
- // Set up playground for this example.
- var setup = function() {
- var code = $('.code', el);
- playground({
- 'codeEl': code,
- 'outputEl': $('.output', el),
- 'runEl': $('.run', el),
- 'fmtEl': $('.fmt', el),
- 'shareEl': $('.share', el),
- 'shareRedirect': 'http://play.golang.org/p/'
- });
-
- // Make the code textarea resize to fit content.
- var resize = function() {
- code.height(0);
- var h = code[0].scrollHeight;
- code.height(h+20); // minimize bouncing.
- code.closest('.input').height(h);
- };
- code.on('keydown', resize);
- code.on('keyup', resize);
- code.keyup(); // resize now.
- };
-
- // If example already visible, set up playground now.
- if ($(el).is(':visible')) {
- setup();
- return;
- }
-
- // Otherwise, set up playground when example is expanded.
- var built = false;
- $(el).closest('.toggle').click(function() {
- // Only set up once.
- if (!built) {
- setup();
- built = true;
- }
- });
- });
-}
-
-// fixFocus tries to put focus to div#page so that keyboard navigation works.
-function fixFocus() {
- var page = $('div#page');
- var topbar = $('div#topbar');
- page.css('outline', 0); // disable outline when focused
- page.attr('tabindex', -1); // and set tabindex so that it is focusable
- $(window).resize(function (evt) {
- // only focus page when the topbar is at fixed position (that is, it's in
- // front of page, and keyboard event will go to the former by default.)
- // by focusing page, keyboard event will go to page so that up/down arrow,
- // space, etc. will work as expected.
- if (topbar.css('position') == "fixed")
- page.focus();
- }).resize();
-}
-
-function toggleHash() {
- var hash = $(window.location.hash);
- if (hash.is('.toggle')) {
- hash.find('.toggleButton').first().click();
- }
-}
-
-function addPlusButtons() {
- var po = document.createElement('script');
- po.type = 'text/javascript';
- po.async = true;
- po.src = 'https://apis.google.com/js/platform.js';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(po, s);
-}
-
-$(document).ready(function() {
- bindSearchEvents();
- generateTOC();
- bindToggles(".toggle");
- bindToggles(".toggleVisible");
- bindToggleLinks(".exampleLink", "example_");
- bindToggleLinks(".overviewLink", "");
- bindToggleLinks(".examplesLink", "");
- bindToggleLinks(".indexLink", "");
- setupDropdownPlayground();
- setupInlinePlayground();
- fixFocus();
- setupTypeInfo();
- setupCallgraphs();
- toggleHash();
- addPlusButtons();
-
- // godoc.html defines window.initFuncs in the tag, and root.html and
- // codewalk.js push their on-page-ready functions to the list.
- // We execute those functions here, to avoid loading jQuery until the page
- // content is loaded.
- for (var i = 0; i < window.initFuncs.length; i++) window.initFuncs[i]();
-});
-
-// -- analysis ---------------------------------------------------------
-
-// escapeHTML returns HTML for s, with metacharacters quoted.
-// It is safe for use in both elements and attributes
-// (unlike the "set innerText, read innerHTML" trick).
-function escapeHTML(s) {
- return s.replace(/&/g, '&').
- replace(/\"/g, '"').
- replace(/\'/g, ''').
- replace(//g, '>');
-}
-
-// makeAnchor returns HTML for an element, given an anchorJSON object.
-function makeAnchor(json) {
- var html = escapeHTML(json.Text);
- if (json.Href != "") {
- html = "" + html + "";
- }
- return html;
-}
-
-function showLowFrame(html) {
- var lowframe = document.getElementById('lowframe');
- lowframe.style.height = "200px";
- lowframe.innerHTML = "
" + html + "
\n" +
- "
✘
"
-};
-
-document.hideLowFrame = function() {
- var lowframe = document.getElementById('lowframe');
- lowframe.style.height = "0px";
-}
-
-// onClickCallers is the onclick action for the 'func' tokens of a
-// function declaration.
-document.onClickCallers = function(index) {
- var data = document.ANALYSIS_DATA[index]
- if (data.Callers.length == 1 && data.Callers[0].Sites.length == 1) {
- document.location = data.Callers[0].Sites[0].Href; // jump to sole caller
- return;
- }
-
- var html = "Callers of " + escapeHTML(data.Callee) + ": \n";
- for (var i = 0; i < data.Callers.length; i++) {
- var caller = data.Callers[i];
- html += "" + escapeHTML(caller.Func) + "";
- var sites = caller.Sites;
- if (sites != null && sites.length > 0) {
- html += " at line ";
- for (var j = 0; j < sites.length; j++) {
- if (j > 0) {
- html += ", ";
- }
- html += "" + makeAnchor(sites[j]) + "";
- }
- }
- html += " \n";
- }
- showLowFrame(html);
-};
-
-// onClickCallees is the onclick action for the '(' token of a function call.
-document.onClickCallees = function(index) {
- var data = document.ANALYSIS_DATA[index]
- if (data.Callees.length == 1) {
- document.location = data.Callees[0].Href; // jump to sole callee
- return;
- }
-
- var html = "Callees of this " + escapeHTML(data.Descr) + ": \n";
- for (var i = 0; i < data.Callees.length; i++) {
- html += "" + makeAnchor(data.Callees[i]) + " \n";
- }
- showLowFrame(html);
-};
-
-// onClickTypeInfo is the onclick action for identifiers declaring a named type.
-document.onClickTypeInfo = function(index) {
- var data = document.ANALYSIS_DATA[index];
- var html = "Type " + data.Name + ": " +
- " (size=" + data.Size + ", align=" + data.Align + ") \n";
- html += implementsHTML(data);
- html += methodsetHTML(data);
- showLowFrame(html);
-};
-
-// implementsHTML returns HTML for the implements relation of the
-// specified TypeInfoJSON value.
-function implementsHTML(info) {
- var html = "";
- if (info.ImplGroups != null) {
- for (var i = 0; i < info.ImplGroups.length; i++) {
- var group = info.ImplGroups[i];
- var x = "" + escapeHTML(group.Descr) + " ";
- for (var j = 0; j < group.Facts.length; j++) {
- var fact = group.Facts[j];
- var y = "" + makeAnchor(fact.Other) + "";
- if (fact.ByKind != null) {
- html += escapeHTML(fact.ByKind) + " type " + y + " implements " + x;
- } else {
- html += x + " implements " + y;
- }
- html += " \n";
- }
- }
- }
- return html;
-}
-
-
-// methodsetHTML returns HTML for the methodset of the specified
-// TypeInfoJSON value.
-function methodsetHTML(info) {
- var html = "";
- if (info.Methods != null) {
- for (var i = 0; i < info.Methods.length; i++) {
- html += "" + makeAnchor(info.Methods[i]) + " \n";
- }
- }
- return html;
-}
-
-// onClickComm is the onclick action for channel "make" and "<-"
-// send/receive tokens.
-document.onClickComm = function(index) {
- var ops = document.ANALYSIS_DATA[index].Ops
- if (ops.length == 1) {
- document.location = ops[0].Op.Href; // jump to sole element
- return;
- }
-
- var html = "Operations on this channel: \n";
- for (var i = 0; i < ops.length; i++) {
- html += makeAnchor(ops[i].Op) + " by " + escapeHTML(ops[i].Fn) + " \n";
- }
- if (ops.length == 0) {
- html += "(none) \n";
- }
- showLowFrame(html);
-};
-
-$(window).load(function() {
- // Scroll window so that first selection is visible.
- // (This means we don't need to emit id='L%d' spans for each line.)
- // TODO(adonovan): ideally, scroll it so that it's under the pointer,
- // but I don't know how to get the pointer y coordinate.
- var elts = document.getElementsByClassName("selection");
- if (elts.length > 0) {
- elts[0].scrollIntoView()
- }
-});
-
-// setupTypeInfo populates the "Implements" and "Method set" toggle for
-// each type in the package doc.
-function setupTypeInfo() {
- for (var i in document.ANALYSIS_DATA) {
- var data = document.ANALYSIS_DATA[i];
-
- var el = document.getElementById("implements-" + i);
- if (el != null) {
- // el != null => data is TypeInfoJSON.
- if (data.ImplGroups != null) {
- el.innerHTML = implementsHTML(data);
- el.parentNode.parentNode.style.display = "block";
- }
- }
-
- var el = document.getElementById("methodset-" + i);
- if (el != null) {
- // el != null => data is TypeInfoJSON.
- if (data.Methods != null) {
- el.innerHTML = methodsetHTML(data);
- el.parentNode.parentNode.style.display = "block";
- }
- }
- }
-}
-
-function setupCallgraphs() {
- if (document.CALLGRAPH == null) {
- return
- }
- document.getElementById("pkg-callgraph").style.display = "block";
-
- var treeviews = document.getElementsByClassName("treeview");
- for (var i in treeviews) {
- var tree = treeviews[i];
- if (tree.id == null || tree.id.indexOf("callgraph-") != 0) {
- continue;
- }
- var id = tree.id.substring("callgraph-".length);
- $(tree).treeview({collapsed: true, animated: "fast"});
- document.cgAddChildren(tree, tree, [id]);
- tree.parentNode.parentNode.style.display = "block";
- }
-}
-
-document.cgAddChildren = function(tree, ul, indices) {
- if (indices != null) {
- for (var i = 0; i < indices.length; i++) {
- var li = cgAddChild(tree, ul, document.CALLGRAPH[indices[i]]);
- if (i == indices.length - 1) {
- $(li).addClass("last");
- }
- }
- }
- $(tree).treeview({animated: "fast", add: ul});
-}
-
-// cgAddChild adds an
element for document.CALLGRAPH node cgn to
-// the parent
- In the call graph viewer below, each node
- is a function belonging to this package
- and its children are the functions it
- calls—perhaps dynamically.
-
-
- The root nodes are the entry points of the
- package: functions that may be called from
- outside the package.
- There may be non-exported or anonymous
- functions among them if they are called
- dynamically from another package.
-
-
- Click a node to visit that function's source code.
- From there you can visit its callers by
- clicking its declaring func
- token.
-
-
- Functions may be omitted if they were
- determined to be unreachable in the
- particular programs or tests that were
- analyzed.
-
blocks.
-//
-// The syntax is simple: 1, 2, or 3 space-separated arguments:
-//
-// Whole file:
-// {{code "foo.go"}}
-// One line (here the signature of main):
-// {{code "foo.go" `/^func.main/`}}
-// Block of text, determined by start and end (here the body of main):
-// {{code "foo.go" `/^func.main/` `/^}/`
-//
-// Patterns can be `/regular expression/`, a decimal number, or "$"
-// to signify the end of the file. In multi-line matches,
-// lines that end with the four characters
-// OMIT
-// are omitted from the output, making it easy to provide marker
-// lines in the input that will not appear in the output but are easy
-// to identify by pattern.
-
-package godoc
-
-import (
- "bytes"
- "fmt"
- "log"
- "regexp"
- "strings"
-
- "code.google.com/p/go.tools/godoc/vfs"
-)
-
-// Functions in this file panic on error, but the panic is recovered
-// to an error by 'code'.
-
-// contents reads and returns the content of the named file
-// (from the virtual file system, so for example /doc refers to $GOROOT/doc).
-func (c *Corpus) contents(name string) string {
- file, err := vfs.ReadFile(c.fs, name)
- if err != nil {
- log.Panic(err)
- }
- return string(file)
-}
-
-// stringFor returns a textual representation of the arg, formatted according to its nature.
-func stringFor(arg interface{}) string {
- switch arg := arg.(type) {
- case int:
- return fmt.Sprintf("%d", arg)
- case string:
- if len(arg) > 2 && arg[0] == '/' && arg[len(arg)-1] == '/' {
- return fmt.Sprintf("%#q", arg)
- }
- return fmt.Sprintf("%q", arg)
- default:
- log.Panicf("unrecognized argument: %v type %T", arg, arg)
- }
- return ""
-}
-
-func (p *Presentation) code(file string, arg ...interface{}) (s string, err error) {
- defer func() {
- if r := recover(); r != nil {
- err = fmt.Errorf("%v", r)
- }
- }()
-
- text := p.Corpus.contents(file)
- var command string
- switch len(arg) {
- case 0:
- // text is already whole file.
- command = fmt.Sprintf("code %q", file)
- case 1:
- command = fmt.Sprintf("code %q %s", file, stringFor(arg[0]))
- text = p.Corpus.oneLine(file, text, arg[0])
- case 2:
- command = fmt.Sprintf("code %q %s %s", file, stringFor(arg[0]), stringFor(arg[1]))
- text = p.Corpus.multipleLines(file, text, arg[0], arg[1])
- default:
- return "", fmt.Errorf("incorrect code invocation: code %q %q", file, arg)
- }
- // Trim spaces from output.
- text = strings.Trim(text, "\n")
- // Replace tabs by spaces, which work better in HTML.
- text = strings.Replace(text, "\t", " ", -1)
- var buf bytes.Buffer
- // HTML-escape text and syntax-color comments like elsewhere.
- FormatText(&buf, []byte(text), -1, true, "", nil)
- // Include the command as a comment.
- text = fmt.Sprintf("
%s
", command, buf.Bytes())
- return text, nil
-}
-
-// parseArg returns the integer or string value of the argument and tells which it is.
-func parseArg(arg interface{}, file string, max int) (ival int, sval string, isInt bool) {
- switch n := arg.(type) {
- case int:
- if n <= 0 || n > max {
- log.Panicf("%q:%d is out of range", file, n)
- }
- return n, "", true
- case string:
- return 0, n, false
- }
- log.Panicf("unrecognized argument %v type %T", arg, arg)
- return
-}
-
-// oneLine returns the single line generated by a two-argument code invocation.
-func (c *Corpus) oneLine(file, text string, arg interface{}) string {
- lines := strings.SplitAfter(c.contents(file), "\n")
- line, pattern, isInt := parseArg(arg, file, len(lines))
- if isInt {
- return lines[line-1]
- }
- return lines[match(file, 0, lines, pattern)-1]
-}
-
-// multipleLines returns the text generated by a three-argument code invocation.
-func (c *Corpus) multipleLines(file, text string, arg1, arg2 interface{}) string {
- lines := strings.SplitAfter(c.contents(file), "\n")
- line1, pattern1, isInt1 := parseArg(arg1, file, len(lines))
- line2, pattern2, isInt2 := parseArg(arg2, file, len(lines))
- if !isInt1 {
- line1 = match(file, 0, lines, pattern1)
- }
- if !isInt2 {
- line2 = match(file, line1, lines, pattern2)
- } else if line2 < line1 {
- log.Panicf("lines out of order for %q: %d %d", text, line1, line2)
- }
- for k := line1 - 1; k < line2; k++ {
- if strings.HasSuffix(lines[k], "OMIT\n") {
- lines[k] = ""
- }
- }
- return strings.Join(lines[line1-1:line2], "")
-}
-
-// match identifies the input line that matches the pattern in a code invocation.
-// If start>0, match lines starting there rather than at the beginning.
-// The return value is 1-indexed.
-func match(file string, start int, lines []string, pattern string) int {
- // $ matches the end of the file.
- if pattern == "$" {
- if len(lines) == 0 {
- log.Panicf("%q: empty file", file)
- }
- return len(lines)
- }
- // /regexp/ matches the line that matches the regexp.
- if len(pattern) > 2 && pattern[0] == '/' && pattern[len(pattern)-1] == '/' {
- re, err := regexp.Compile(pattern[1 : len(pattern)-1])
- if err != nil {
- log.Panic(err)
- }
- for i := start; i < len(lines); i++ {
- if re.MatchString(lines[i]) {
- return i + 1
- }
- }
- log.Panicf("%s: no match for %#q", file, pattern)
- }
- log.Panicf("unrecognized pattern: %q", pattern)
- return 0
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/util/throttle.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/util/throttle.go
deleted file mode 100644
index 53d9ba62..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/util/throttle.go
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package util
-
-import "time"
-
-// A Throttle permits throttling of a goroutine by
-// calling the Throttle method repeatedly.
-//
-type Throttle struct {
- f float64 // f = (1-r)/r for 0 < r < 1
- dt time.Duration // minimum run time slice; >= 0
- tr time.Duration // accumulated time running
- ts time.Duration // accumulated time stopped
- tt time.Time // earliest throttle time (= time Throttle returned + tm)
-}
-
-// NewThrottle creates a new Throttle with a throttle value r and
-// a minimum allocated run time slice of dt:
-//
-// r == 0: "empty" throttle; the goroutine is always sleeping
-// r == 1: full throttle; the goroutine is never sleeping
-//
-// A value of r == 0.6 throttles a goroutine such that it runs
-// approx. 60% of the time, and sleeps approx. 40% of the time.
-// Values of r < 0 or r > 1 are clamped down to values between 0 and 1.
-// Values of dt < 0 are set to 0.
-//
-func NewThrottle(r float64, dt time.Duration) *Throttle {
- var f float64
- switch {
- case r <= 0:
- f = -1 // indicates always sleep
- case r >= 1:
- f = 0 // assume r == 1 (never sleep)
- default:
- // 0 < r < 1
- f = (1 - r) / r
- }
- if dt < 0 {
- dt = 0
- }
- return &Throttle{f: f, dt: dt, tt: time.Now().Add(dt)}
-}
-
-// Throttle calls time.Sleep such that over time the ratio tr/ts between
-// accumulated run (tr) and sleep times (ts) approximates the value 1/(1-r)
-// where r is the throttle value. Throttle returns immediately (w/o sleeping)
-// if less than tm ns have passed since the last call to Throttle.
-//
-func (p *Throttle) Throttle() {
- if p.f < 0 {
- select {} // always sleep
- }
-
- t0 := time.Now()
- if t0.Before(p.tt) {
- return // keep running (minimum time slice not exhausted yet)
- }
-
- // accumulate running time
- p.tr += t0.Sub(p.tt) + p.dt
-
- // compute sleep time
- // Over time we want:
- //
- // tr/ts = r/(1-r)
- //
- // Thus:
- //
- // ts = tr*f with f = (1-r)/r
- //
- // After some incremental run time δr added to the total run time
- // tr, the incremental sleep-time δs to get to the same ratio again
- // after waking up from time.Sleep is:
- if δs := time.Duration(float64(p.tr)*p.f) - p.ts; δs > 0 {
- time.Sleep(δs)
- }
-
- // accumulate (actual) sleep time
- t1 := time.Now()
- p.ts += t1.Sub(t0)
-
- // set earliest next throttle time
- p.tt = t1.Add(p.dt)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/util/util.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/util/util.go
deleted file mode 100644
index 1371bcd1..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/util/util.go
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package util contains utility types and functions for godoc.
-package util
-
-import (
- pathpkg "path"
- "sync"
- "time"
- "unicode/utf8"
-
- "code.google.com/p/go.tools/godoc/vfs"
-)
-
-// An RWValue wraps a value and permits mutually exclusive
-// access to it and records the time the value was last set.
-type RWValue struct {
- mutex sync.RWMutex
- value interface{}
- timestamp time.Time // time of last set()
-}
-
-func (v *RWValue) Set(value interface{}) {
- v.mutex.Lock()
- v.value = value
- v.timestamp = time.Now()
- v.mutex.Unlock()
-}
-
-func (v *RWValue) Get() (interface{}, time.Time) {
- v.mutex.RLock()
- defer v.mutex.RUnlock()
- return v.value, v.timestamp
-}
-
-// IsText reports whether a significant prefix of s looks like correct UTF-8;
-// that is, if it is likely that s is human-readable text.
-func IsText(s []byte) bool {
- const max = 1024 // at least utf8.UTFMax
- if len(s) > max {
- s = s[0:max]
- }
- for i, c := range string(s) {
- if i+utf8.UTFMax > len(s) {
- // last char may be incomplete - ignore
- break
- }
- if c == 0xFFFD || c < ' ' && c != '\n' && c != '\t' && c != '\f' {
- // decoding error or control character - not a text file
- return false
- }
- }
- return true
-}
-
-// textExt[x] is true if the extension x indicates a text file, and false otherwise.
-var textExt = map[string]bool{
- ".css": false, // must be served raw
- ".js": false, // must be served raw
-}
-
-// IsTextFile reports whether the file has a known extension indicating
-// a text file, or if a significant chunk of the specified file looks like
-// correct UTF-8; that is, if it is likely that the file contains human-
-// readable text.
-func IsTextFile(fs vfs.Opener, filename string) bool {
- // if the extension is known, use it for decision making
- if isText, found := textExt[pathpkg.Ext(filename)]; found {
- return isText
- }
-
- // the extension is not known; read an initial chunk
- // of the file and check if it looks like text
- f, err := fs.Open(filename)
- if err != nil {
- return false
- }
- defer f.Close()
-
- var buf [1024]byte
- n, err := f.Read(buf[0:])
- if err != nil {
- return false
- }
-
- return IsText(buf[0:n])
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/gatefs/gatefs.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/gatefs/gatefs.go
deleted file mode 100644
index 2e6c47f1..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/gatefs/gatefs.go
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package gatefs provides an implementation of the FileSystem
-// interface that wraps another FileSystem and limits its concurrency.
-package gatefs
-
-import (
- "fmt"
- "os"
-
- "code.google.com/p/go.tools/godoc/vfs"
-)
-
-// New returns a new FileSystem that delegates to fs.
-// If gateCh is non-nil and buffered, it's used as a gate
-// to limit concurrency on calls to fs.
-func New(fs vfs.FileSystem, gateCh chan bool) vfs.FileSystem {
- if cap(gateCh) == 0 {
- return fs
- }
- return gatefs{fs, gate(gateCh)}
-}
-
-type gate chan bool
-
-func (g gate) enter() { g <- true }
-func (g gate) leave() { <-g }
-
-type gatefs struct {
- fs vfs.FileSystem
- gate
-}
-
-func (fs gatefs) String() string {
- return fmt.Sprintf("gated(%s, %d)", fs.fs.String(), cap(fs.gate))
-}
-
-func (fs gatefs) Open(p string) (vfs.ReadSeekCloser, error) {
- fs.enter()
- defer fs.leave()
- rsc, err := fs.fs.Open(p)
- if err != nil {
- return nil, err
- }
- return gatef{rsc, fs.gate}, nil
-}
-
-func (fs gatefs) Lstat(p string) (os.FileInfo, error) {
- fs.enter()
- defer fs.leave()
- return fs.fs.Lstat(p)
-}
-
-func (fs gatefs) Stat(p string) (os.FileInfo, error) {
- fs.enter()
- defer fs.leave()
- return fs.fs.Stat(p)
-}
-
-func (fs gatefs) ReadDir(p string) ([]os.FileInfo, error) {
- fs.enter()
- defer fs.leave()
- return fs.fs.ReadDir(p)
-}
-
-type gatef struct {
- rsc vfs.ReadSeekCloser
- gate
-}
-
-func (f gatef) Read(p []byte) (n int, err error) {
- f.enter()
- defer f.leave()
- return f.rsc.Read(p)
-}
-
-func (f gatef) Seek(offset int64, whence int) (ret int64, err error) {
- f.enter()
- defer f.leave()
- return f.rsc.Seek(offset, whence)
-}
-
-func (f gatef) Close() error {
- f.enter()
- defer f.leave()
- return f.rsc.Close()
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/httpfs/httpfs.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/httpfs/httpfs.go
deleted file mode 100644
index 51a4fff2..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/httpfs/httpfs.go
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package httpfs implements http.FileSystem using a godoc vfs.FileSystem.
-package httpfs
-
-import (
- "fmt"
- "io"
- "net/http"
- "os"
-
- "code.google.com/p/go.tools/godoc/vfs"
-)
-
-func New(fs vfs.FileSystem) http.FileSystem {
- return &httpFS{fs}
-}
-
-type httpFS struct {
- fs vfs.FileSystem
-}
-
-func (h *httpFS) Open(name string) (http.File, error) {
- fi, err := h.fs.Stat(name)
- if err != nil {
- return nil, err
- }
- if fi.IsDir() {
- return &httpDir{h.fs, name, nil}, nil
- }
- f, err := h.fs.Open(name)
- if err != nil {
- return nil, err
- }
- return &httpFile{h.fs, f, name}, nil
-}
-
-// httpDir implements http.File for a directory in a FileSystem.
-type httpDir struct {
- fs vfs.FileSystem
- name string
- pending []os.FileInfo
-}
-
-func (h *httpDir) Close() error { return nil }
-func (h *httpDir) Stat() (os.FileInfo, error) { return h.fs.Stat(h.name) }
-func (h *httpDir) Read([]byte) (int, error) {
- return 0, fmt.Errorf("cannot Read from directory %s", h.name)
-}
-
-func (h *httpDir) Seek(offset int64, whence int) (int64, error) {
- if offset == 0 && whence == 0 {
- h.pending = nil
- return 0, nil
- }
- return 0, fmt.Errorf("unsupported Seek in directory %s", h.name)
-}
-
-func (h *httpDir) Readdir(count int) ([]os.FileInfo, error) {
- if h.pending == nil {
- d, err := h.fs.ReadDir(h.name)
- if err != nil {
- return nil, err
- }
- if d == nil {
- d = []os.FileInfo{} // not nil
- }
- h.pending = d
- }
-
- if len(h.pending) == 0 && count > 0 {
- return nil, io.EOF
- }
- if count <= 0 || count > len(h.pending) {
- count = len(h.pending)
- }
- d := h.pending[:count]
- h.pending = h.pending[count:]
- return d, nil
-}
-
-// httpFile implements http.File for a file (not directory) in a FileSystem.
-type httpFile struct {
- fs vfs.FileSystem
- vfs.ReadSeekCloser
- name string
-}
-
-func (h *httpFile) Stat() (os.FileInfo, error) { return h.fs.Stat(h.name) }
-func (h *httpFile) Readdir(int) ([]os.FileInfo, error) {
- return nil, fmt.Errorf("cannot Readdir from file %s", h.name)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/mapfs/mapfs.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/mapfs/mapfs.go
deleted file mode 100644
index 550c4baf..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/mapfs/mapfs.go
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package mapfs file provides an implementation of the FileSystem
-// interface based on the contents of a map[string]string.
-package mapfs
-
-import (
- "io"
- "os"
- pathpkg "path"
- "sort"
- "strings"
- "time"
-
- "code.google.com/p/go.tools/godoc/vfs"
-)
-
-// New returns a new FileSystem from the provided map.
-// Map keys should be forward slash-separated pathnames
-// and not contain a leading slash.
-func New(m map[string]string) vfs.FileSystem {
- return mapFS(m)
-}
-
-// mapFS is the map based implementation of FileSystem
-type mapFS map[string]string
-
-func (fs mapFS) String() string { return "mapfs" }
-
-func (fs mapFS) Close() error { return nil }
-
-func filename(p string) string {
- return strings.TrimPrefix(p, "/")
-}
-
-func (fs mapFS) Open(p string) (vfs.ReadSeekCloser, error) {
- b, ok := fs[filename(p)]
- if !ok {
- return nil, os.ErrNotExist
- }
- return nopCloser{strings.NewReader(b)}, nil
-}
-
-func fileInfo(name, contents string) os.FileInfo {
- return mapFI{name: pathpkg.Base(name), size: len(contents)}
-}
-
-func dirInfo(name string) os.FileInfo {
- return mapFI{name: pathpkg.Base(name), dir: true}
-}
-
-func (fs mapFS) Lstat(p string) (os.FileInfo, error) {
- b, ok := fs[filename(p)]
- if ok {
- return fileInfo(p, b), nil
- }
- ents, _ := fs.ReadDir(p)
- if len(ents) > 0 {
- return dirInfo(p), nil
- }
- return nil, os.ErrNotExist
-}
-
-func (fs mapFS) Stat(p string) (os.FileInfo, error) {
- return fs.Lstat(p)
-}
-
-// slashdir returns path.Dir(p), but special-cases paths not beginning
-// with a slash to be in the root.
-func slashdir(p string) string {
- d := pathpkg.Dir(p)
- if d == "." {
- return "/"
- }
- if strings.HasPrefix(p, "/") {
- return d
- }
- return "/" + d
-}
-
-func (fs mapFS) ReadDir(p string) ([]os.FileInfo, error) {
- p = pathpkg.Clean(p)
- var ents []string
- fim := make(map[string]os.FileInfo) // base -> fi
- for fn, b := range fs {
- dir := slashdir(fn)
- isFile := true
- var lastBase string
- for {
- if dir == p {
- base := lastBase
- if isFile {
- base = pathpkg.Base(fn)
- }
- if fim[base] == nil {
- var fi os.FileInfo
- if isFile {
- fi = fileInfo(fn, b)
- } else {
- fi = dirInfo(base)
- }
- ents = append(ents, base)
- fim[base] = fi
- }
- }
- if dir == "/" {
- break
- } else {
- isFile = false
- lastBase = pathpkg.Base(dir)
- dir = pathpkg.Dir(dir)
- }
- }
- }
- if len(ents) == 0 {
- return nil, os.ErrNotExist
- }
-
- sort.Strings(ents)
- var list []os.FileInfo
- for _, dir := range ents {
- list = append(list, fim[dir])
- }
- return list, nil
-}
-
-// mapFI is the map-based implementation of FileInfo.
-type mapFI struct {
- name string
- size int
- dir bool
-}
-
-func (fi mapFI) IsDir() bool { return fi.dir }
-func (fi mapFI) ModTime() time.Time { return time.Time{} }
-func (fi mapFI) Mode() os.FileMode {
- if fi.IsDir() {
- return 0755 | os.ModeDir
- }
- return 0444
-}
-func (fi mapFI) Name() string { return pathpkg.Base(fi.name) }
-func (fi mapFI) Size() int64 { return int64(fi.size) }
-func (fi mapFI) Sys() interface{} { return nil }
-
-type nopCloser struct {
- io.ReadSeeker
-}
-
-func (nc nopCloser) Close() error { return nil }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/mapfs/mapfs_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/mapfs/mapfs_test.go
deleted file mode 100644
index 6b7db290..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/mapfs/mapfs_test.go
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package mapfs
-
-import (
- "io/ioutil"
- "os"
- "reflect"
- "testing"
-)
-
-func TestOpenRoot(t *testing.T) {
- fs := New(map[string]string{
- "foo/bar/three.txt": "a",
- "foo/bar.txt": "b",
- "top.txt": "c",
- "other-top.txt": "d",
- })
- tests := []struct {
- path string
- want string
- }{
- {"/foo/bar/three.txt", "a"},
- {"foo/bar/three.txt", "a"},
- {"foo/bar.txt", "b"},
- {"top.txt", "c"},
- {"/top.txt", "c"},
- {"other-top.txt", "d"},
- {"/other-top.txt", "d"},
- }
- for _, tt := range tests {
- rsc, err := fs.Open(tt.path)
- if err != nil {
- t.Errorf("Open(%q) = %v", tt.path, err)
- continue
- }
- slurp, err := ioutil.ReadAll(rsc)
- if err != nil {
- t.Error(err)
- }
- if string(slurp) != tt.want {
- t.Errorf("Read(%q) = %q; want %q", tt.path, tt.want, slurp)
- }
- rsc.Close()
- }
-
- _, err := fs.Open("/xxxx")
- if !os.IsNotExist(err) {
- t.Errorf("ReadDir /xxxx = %v; want os.IsNotExist error", err)
- }
-}
-
-func TestReaddir(t *testing.T) {
- fs := New(map[string]string{
- "foo/bar/three.txt": "333",
- "foo/bar.txt": "22",
- "top.txt": "top.txt file",
- "other-top.txt": "other-top.txt file",
- })
- tests := []struct {
- dir string
- want []os.FileInfo
- }{
- {
- dir: "/",
- want: []os.FileInfo{
- mapFI{name: "foo", dir: true},
- mapFI{name: "other-top.txt", size: len("other-top.txt file")},
- mapFI{name: "top.txt", size: len("top.txt file")},
- },
- },
- {
- dir: "/foo",
- want: []os.FileInfo{
- mapFI{name: "bar", dir: true},
- mapFI{name: "bar.txt", size: 2},
- },
- },
- {
- dir: "/foo/",
- want: []os.FileInfo{
- mapFI{name: "bar", dir: true},
- mapFI{name: "bar.txt", size: 2},
- },
- },
- {
- dir: "/foo/bar",
- want: []os.FileInfo{
- mapFI{name: "three.txt", size: 3},
- },
- },
- }
- for _, tt := range tests {
- fis, err := fs.ReadDir(tt.dir)
- if err != nil {
- t.Errorf("ReadDir(%q) = %v", tt.dir, err)
- continue
- }
- if !reflect.DeepEqual(fis, tt.want) {
- t.Errorf("ReadDir(%q) = %#v; want %#v", tt.dir, fis, tt.want)
- continue
- }
- }
-
- _, err := fs.ReadDir("/xxxx")
- if !os.IsNotExist(err) {
- t.Errorf("ReadDir /xxxx = %v; want os.IsNotExist error", err)
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/namespace.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/namespace.go
deleted file mode 100644
index dbba20cb..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/namespace.go
+++ /dev/null
@@ -1,381 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package vfs
-
-import (
- "fmt"
- "io"
- "os"
- pathpkg "path"
- "sort"
- "strings"
- "time"
-)
-
-// Setting debugNS = true will enable debugging prints about
-// name space translations.
-const debugNS = false
-
-// A NameSpace is a file system made up of other file systems
-// mounted at specific locations in the name space.
-//
-// The representation is a map from mount point locations
-// to the list of file systems mounted at that location. A traditional
-// Unix mount table would use a single file system per mount point,
-// but we want to be able to mount multiple file systems on a single
-// mount point and have the system behave as if the union of those
-// file systems were present at the mount point.
-// For example, if the OS file system has a Go installation in
-// c:\Go and additional Go path trees in d:\Work1 and d:\Work2, then
-// this name space creates the view we want for the godoc server:
-//
-// NameSpace{
-// "/": {
-// {old: "/", fs: OS(`c:\Go`), new: "/"},
-// },
-// "/src/pkg": {
-// {old: "/src/pkg", fs: OS(`c:\Go`), new: "/src/pkg"},
-// {old: "/src/pkg", fs: OS(`d:\Work1`), new: "/src"},
-// {old: "/src/pkg", fs: OS(`d:\Work2`), new: "/src"},
-// },
-// }
-//
-// This is created by executing:
-//
-// ns := NameSpace{}
-// ns.Bind("/", OS(`c:\Go`), "/", BindReplace)
-// ns.Bind("/src/pkg", OS(`d:\Work1`), "/src", BindAfter)
-// ns.Bind("/src/pkg", OS(`d:\Work2`), "/src", BindAfter)
-//
-// A particular mount point entry is a triple (old, fs, new), meaning that to
-// operate on a path beginning with old, replace that prefix (old) with new
-// and then pass that path to the FileSystem implementation fs.
-//
-// Given this name space, a ReadDir of /src/pkg/code will check each prefix
-// of the path for a mount point (first /src/pkg/code, then /src/pkg, then /src,
-// then /), stopping when it finds one. For the above example, /src/pkg/code
-// will find the mount point at /src/pkg:
-//
-// {old: "/src/pkg", fs: OS(`c:\Go`), new: "/src/pkg"},
-// {old: "/src/pkg", fs: OS(`d:\Work1`), new: "/src"},
-// {old: "/src/pkg", fs: OS(`d:\Work2`), new: "/src"},
-//
-// ReadDir will when execute these three calls and merge the results:
-//
-// OS(`c:\Go`).ReadDir("/src/pkg/code")
-// OS(`d:\Work1').ReadDir("/src/code")
-// OS(`d:\Work2').ReadDir("/src/code")
-//
-// Note that the "/src/pkg" in "/src/pkg/code" has been replaced by
-// just "/src" in the final two calls.
-//
-// OS is itself an implementation of a file system: it implements
-// OS(`c:\Go`).ReadDir("/src/pkg/code") as ioutil.ReadDir(`c:\Go\src\pkg\code`).
-//
-// Because the new path is evaluated by fs (here OS(root)), another way
-// to read the mount table is to mentally combine fs+new, so that this table:
-//
-// {old: "/src/pkg", fs: OS(`c:\Go`), new: "/src/pkg"},
-// {old: "/src/pkg", fs: OS(`d:\Work1`), new: "/src"},
-// {old: "/src/pkg", fs: OS(`d:\Work2`), new: "/src"},
-//
-// reads as:
-//
-// "/src/pkg" -> c:\Go\src\pkg
-// "/src/pkg" -> d:\Work1\src
-// "/src/pkg" -> d:\Work2\src
-//
-// An invariant (a redundancy) of the name space representation is that
-// ns[mtpt][i].old is always equal to mtpt (in the example, ns["/src/pkg"]'s
-// mount table entries always have old == "/src/pkg"). The 'old' field is
-// useful to callers, because they receive just a []mountedFS and not any
-// other indication of which mount point was found.
-//
-type NameSpace map[string][]mountedFS
-
-// A mountedFS handles requests for path by replacing
-// a prefix 'old' with 'new' and then calling the fs methods.
-type mountedFS struct {
- old string
- fs FileSystem
- new string
-}
-
-// hasPathPrefix returns true if x == y or x == y + "/" + more
-func hasPathPrefix(x, y string) bool {
- return x == y || strings.HasPrefix(x, y) && (strings.HasSuffix(y, "/") || strings.HasPrefix(x[len(y):], "/"))
-}
-
-// translate translates path for use in m, replacing old with new.
-//
-// mountedFS{"/src/pkg", fs, "/src"}.translate("/src/pkg/code") == "/src/code".
-func (m mountedFS) translate(path string) string {
- path = pathpkg.Clean("/" + path)
- if !hasPathPrefix(path, m.old) {
- panic("translate " + path + " but old=" + m.old)
- }
- return pathpkg.Join(m.new, path[len(m.old):])
-}
-
-func (NameSpace) String() string {
- return "ns"
-}
-
-// Fprint writes a text representation of the name space to w.
-func (ns NameSpace) Fprint(w io.Writer) {
- fmt.Fprint(w, "name space {\n")
- var all []string
- for mtpt := range ns {
- all = append(all, mtpt)
- }
- sort.Strings(all)
- for _, mtpt := range all {
- fmt.Fprintf(w, "\t%s:\n", mtpt)
- for _, m := range ns[mtpt] {
- fmt.Fprintf(w, "\t\t%s %s\n", m.fs, m.new)
- }
- }
- fmt.Fprint(w, "}\n")
-}
-
-// clean returns a cleaned, rooted path for evaluation.
-// It canonicalizes the path so that we can use string operations
-// to analyze it.
-func (NameSpace) clean(path string) string {
- return pathpkg.Clean("/" + path)
-}
-
-type BindMode int
-
-const (
- BindReplace BindMode = iota
- BindBefore
- BindAfter
-)
-
-// Bind causes references to old to redirect to the path new in newfs.
-// If mode is BindReplace, old redirections are discarded.
-// If mode is BindBefore, this redirection takes priority over existing ones,
-// but earlier ones are still consulted for paths that do not exist in newfs.
-// If mode is BindAfter, this redirection happens only after existing ones
-// have been tried and failed.
-func (ns NameSpace) Bind(old string, newfs FileSystem, new string, mode BindMode) {
- old = ns.clean(old)
- new = ns.clean(new)
- m := mountedFS{old, newfs, new}
- var mtpt []mountedFS
- switch mode {
- case BindReplace:
- mtpt = append(mtpt, m)
- case BindAfter:
- mtpt = append(mtpt, ns.resolve(old)...)
- mtpt = append(mtpt, m)
- case BindBefore:
- mtpt = append(mtpt, m)
- mtpt = append(mtpt, ns.resolve(old)...)
- }
-
- // Extend m.old, m.new in inherited mount point entries.
- for i := range mtpt {
- m := &mtpt[i]
- if m.old != old {
- if !hasPathPrefix(old, m.old) {
- // This should not happen. If it does, panic so
- // that we can see the call trace that led to it.
- panic(fmt.Sprintf("invalid Bind: old=%q m={%q, %s, %q}", old, m.old, m.fs.String(), m.new))
- }
- suffix := old[len(m.old):]
- m.old = pathpkg.Join(m.old, suffix)
- m.new = pathpkg.Join(m.new, suffix)
- }
- }
-
- ns[old] = mtpt
-}
-
-// resolve resolves a path to the list of mountedFS to use for path.
-func (ns NameSpace) resolve(path string) []mountedFS {
- path = ns.clean(path)
- for {
- if m := ns[path]; m != nil {
- if debugNS {
- fmt.Printf("resolve %s: %v\n", path, m)
- }
- return m
- }
- if path == "/" {
- break
- }
- path = pathpkg.Dir(path)
- }
- return nil
-}
-
-// Open implements the FileSystem Open method.
-func (ns NameSpace) Open(path string) (ReadSeekCloser, error) {
- var err error
- for _, m := range ns.resolve(path) {
- if debugNS {
- fmt.Printf("tx %s: %v\n", path, m.translate(path))
- }
- r, err1 := m.fs.Open(m.translate(path))
- if err1 == nil {
- return r, nil
- }
- if err == nil {
- err = err1
- }
- }
- if err == nil {
- err = &os.PathError{Op: "open", Path: path, Err: os.ErrNotExist}
- }
- return nil, err
-}
-
-// stat implements the FileSystem Stat and Lstat methods.
-func (ns NameSpace) stat(path string, f func(FileSystem, string) (os.FileInfo, error)) (os.FileInfo, error) {
- var err error
- for _, m := range ns.resolve(path) {
- fi, err1 := f(m.fs, m.translate(path))
- if err1 == nil {
- return fi, nil
- }
- if err == nil {
- err = err1
- }
- }
- if err == nil {
- err = &os.PathError{Op: "stat", Path: path, Err: os.ErrNotExist}
- }
- return nil, err
-}
-
-func (ns NameSpace) Stat(path string) (os.FileInfo, error) {
- return ns.stat(path, FileSystem.Stat)
-}
-
-func (ns NameSpace) Lstat(path string) (os.FileInfo, error) {
- return ns.stat(path, FileSystem.Lstat)
-}
-
-// dirInfo is a trivial implementation of os.FileInfo for a directory.
-type dirInfo string
-
-func (d dirInfo) Name() string { return string(d) }
-func (d dirInfo) Size() int64 { return 0 }
-func (d dirInfo) Mode() os.FileMode { return os.ModeDir | 0555 }
-func (d dirInfo) ModTime() time.Time { return startTime }
-func (d dirInfo) IsDir() bool { return true }
-func (d dirInfo) Sys() interface{} { return nil }
-
-var startTime = time.Now()
-
-// ReadDir implements the FileSystem ReadDir method. It's where most of the magic is.
-// (The rest is in resolve.)
-//
-// Logically, ReadDir must return the union of all the directories that are named
-// by path. In order to avoid misinterpreting Go packages, of all the directories
-// that contain Go source code, we only include the files from the first,
-// but we include subdirectories from all.
-//
-// ReadDir must also return directory entries needed to reach mount points.
-// If the name space looks like the example in the type NameSpace comment,
-// but c:\Go does not have a src/pkg subdirectory, we still want to be able
-// to find that subdirectory, because we've mounted d:\Work1 and d:\Work2
-// there. So if we don't see "src" in the directory listing for c:\Go, we add an
-// entry for it before returning.
-//
-func (ns NameSpace) ReadDir(path string) ([]os.FileInfo, error) {
- path = ns.clean(path)
-
- var (
- haveGo = false
- haveName = map[string]bool{}
- all []os.FileInfo
- err error
- first []os.FileInfo
- )
-
- for _, m := range ns.resolve(path) {
- dir, err1 := m.fs.ReadDir(m.translate(path))
- if err1 != nil {
- if err == nil {
- err = err1
- }
- continue
- }
-
- if dir == nil {
- dir = []os.FileInfo{}
- }
-
- if first == nil {
- first = dir
- }
-
- // If we don't yet have Go files in 'all' and this directory
- // has some, add all the files from this directory.
- // Otherwise, only add subdirectories.
- useFiles := false
- if !haveGo {
- for _, d := range dir {
- if strings.HasSuffix(d.Name(), ".go") {
- useFiles = true
- haveGo = true
- break
- }
- }
- }
-
- for _, d := range dir {
- name := d.Name()
- if (d.IsDir() || useFiles) && !haveName[name] {
- haveName[name] = true
- all = append(all, d)
- }
- }
- }
-
- // We didn't find any directories containing Go files.
- // If some directory returned successfully, use that.
- if !haveGo {
- for _, d := range first {
- if !haveName[d.Name()] {
- haveName[d.Name()] = true
- all = append(all, d)
- }
- }
- }
-
- // Built union. Add any missing directories needed to reach mount points.
- for old := range ns {
- if hasPathPrefix(old, path) && old != path {
- // Find next element after path in old.
- elem := old[len(path):]
- elem = strings.TrimPrefix(elem, "/")
- if i := strings.Index(elem, "/"); i >= 0 {
- elem = elem[:i]
- }
- if !haveName[elem] {
- haveName[elem] = true
- all = append(all, dirInfo(elem))
- }
- }
- }
-
- if len(all) == 0 {
- return nil, err
- }
-
- sort.Sort(byName(all))
- return all, nil
-}
-
-// byName implements sort.Interface.
-type byName []os.FileInfo
-
-func (f byName) Len() int { return len(f) }
-func (f byName) Less(i, j int) bool { return f[i].Name() < f[j].Name() }
-func (f byName) Swap(i, j int) { f[i], f[j] = f[j], f[i] }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/os.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/os.go
deleted file mode 100644
index 40636909..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/os.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package vfs
-
-import (
- "fmt"
- "io/ioutil"
- "os"
- pathpkg "path"
- "path/filepath"
-)
-
-// OS returns an implementation of FileSystem reading from the
-// tree rooted at root. Recording a root is convenient everywhere
-// but necessary on Windows, because the slash-separated path
-// passed to Open has no way to specify a drive letter. Using a root
-// lets code refer to OS(`c:\`), OS(`d:\`) and so on.
-func OS(root string) FileSystem {
- return osFS(root)
-}
-
-type osFS string
-
-func (root osFS) String() string { return "os(" + string(root) + ")" }
-
-func (root osFS) resolve(path string) string {
- // Clean the path so that it cannot possibly begin with ../.
- // If it did, the result of filepath.Join would be outside the
- // tree rooted at root. We probably won't ever see a path
- // with .. in it, but be safe anyway.
- path = pathpkg.Clean("/" + path)
-
- return filepath.Join(string(root), path)
-}
-
-func (root osFS) Open(path string) (ReadSeekCloser, error) {
- f, err := os.Open(root.resolve(path))
- if err != nil {
- return nil, err
- }
- fi, err := f.Stat()
- if err != nil {
- return nil, err
- }
- if fi.IsDir() {
- return nil, fmt.Errorf("Open: %s is a directory", path)
- }
- return f, nil
-}
-
-func (root osFS) Lstat(path string) (os.FileInfo, error) {
- return os.Lstat(root.resolve(path))
-}
-
-func (root osFS) Stat(path string) (os.FileInfo, error) {
- return os.Stat(root.resolve(path))
-}
-
-func (root osFS) ReadDir(path string) ([]os.FileInfo, error) {
- return ioutil.ReadDir(root.resolve(path)) // is sorted
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/vfs.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/vfs.go
deleted file mode 100644
index 937c2b2f..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/vfs.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package vfs defines types for abstract file system access and provides an
-// implementation accessing the file system of the underlying OS.
-package vfs
-
-import (
- "io"
- "io/ioutil"
- "os"
-)
-
-// The FileSystem interface specifies the methods godoc is using
-// to access the file system for which it serves documentation.
-type FileSystem interface {
- Opener
- Lstat(path string) (os.FileInfo, error)
- Stat(path string) (os.FileInfo, error)
- ReadDir(path string) ([]os.FileInfo, error)
- String() string
-}
-
-// Opener is a minimal virtual filesystem that can only open regular files.
-type Opener interface {
- Open(name string) (ReadSeekCloser, error)
-}
-
-// A ReadSeekCloser can Read, Seek, and Close.
-type ReadSeekCloser interface {
- io.Reader
- io.Seeker
- io.Closer
-}
-
-// ReadFile reads the file named by path from fs and returns the contents.
-func ReadFile(fs Opener, path string) ([]byte, error) {
- rc, err := fs.Open(path)
- if err != nil {
- return nil, err
- }
- defer rc.Close()
- return ioutil.ReadAll(rc)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/zipfs/zipfs.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/zipfs/zipfs.go
deleted file mode 100644
index 99869c5a..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/godoc/vfs/zipfs/zipfs.go
+++ /dev/null
@@ -1,237 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package zipfs file provides an implementation of the FileSystem
-// interface based on the contents of a .zip file.
-//
-// Assumptions:
-//
-// - The file paths stored in the zip file must use a slash ('/') as path
-// separator; and they must be relative (i.e., they must not start with
-// a '/' - this is usually the case if the file was created w/o special
-// options).
-// - The zip file system treats the file paths found in the zip internally
-// like absolute paths w/o a leading '/'; i.e., the paths are considered
-// relative to the root of the file system.
-// - All path arguments to file system methods must be absolute paths.
-package zipfs
-
-import (
- "archive/zip"
- "fmt"
- "io"
- "os"
- "path"
- "sort"
- "strings"
- "time"
-
- "code.google.com/p/go.tools/godoc/vfs"
-)
-
-// zipFI is the zip-file based implementation of FileInfo
-type zipFI struct {
- name string // directory-local name
- file *zip.File // nil for a directory
-}
-
-func (fi zipFI) Name() string {
- return fi.name
-}
-
-func (fi zipFI) Size() int64 {
- if f := fi.file; f != nil {
- return int64(f.UncompressedSize)
- }
- return 0 // directory
-}
-
-func (fi zipFI) ModTime() time.Time {
- if f := fi.file; f != nil {
- return f.ModTime()
- }
- return time.Time{} // directory has no modified time entry
-}
-
-func (fi zipFI) Mode() os.FileMode {
- if fi.file == nil {
- // Unix directories typically are executable, hence 555.
- return os.ModeDir | 0555
- }
- return 0444
-}
-
-func (fi zipFI) IsDir() bool {
- return fi.file == nil
-}
-
-func (fi zipFI) Sys() interface{} {
- return nil
-}
-
-// zipFS is the zip-file based implementation of FileSystem
-type zipFS struct {
- *zip.ReadCloser
- list zipList
- name string
-}
-
-func (fs *zipFS) String() string {
- return "zip(" + fs.name + ")"
-}
-
-func (fs *zipFS) Close() error {
- fs.list = nil
- return fs.ReadCloser.Close()
-}
-
-func zipPath(name string) string {
- name = path.Clean(name)
- if !path.IsAbs(name) {
- panic(fmt.Sprintf("stat: not an absolute path: %s", name))
- }
- return name[1:] // strip leading '/'
-}
-
-func (fs *zipFS) stat(abspath string) (int, zipFI, error) {
- i, exact := fs.list.lookup(abspath)
- if i < 0 {
- // abspath has leading '/' stripped - print it explicitly
- return -1, zipFI{}, fmt.Errorf("file not found: /%s", abspath)
- }
- _, name := path.Split(abspath)
- var file *zip.File
- if exact {
- file = fs.list[i] // exact match found - must be a file
- }
- return i, zipFI{name, file}, nil
-}
-
-func (fs *zipFS) Open(abspath string) (vfs.ReadSeekCloser, error) {
- _, fi, err := fs.stat(zipPath(abspath))
- if err != nil {
- return nil, err
- }
- if fi.IsDir() {
- return nil, fmt.Errorf("Open: %s is a directory", abspath)
- }
- r, err := fi.file.Open()
- if err != nil {
- return nil, err
- }
- return &zipSeek{fi.file, r}, nil
-}
-
-type zipSeek struct {
- file *zip.File
- io.ReadCloser
-}
-
-func (f *zipSeek) Seek(offset int64, whence int) (int64, error) {
- if whence == 0 && offset == 0 {
- r, err := f.file.Open()
- if err != nil {
- return 0, err
- }
- f.Close()
- f.ReadCloser = r
- return 0, nil
- }
- return 0, fmt.Errorf("unsupported Seek in %s", f.file.Name)
-}
-
-func (fs *zipFS) Lstat(abspath string) (os.FileInfo, error) {
- _, fi, err := fs.stat(zipPath(abspath))
- return fi, err
-}
-
-func (fs *zipFS) Stat(abspath string) (os.FileInfo, error) {
- _, fi, err := fs.stat(zipPath(abspath))
- return fi, err
-}
-
-func (fs *zipFS) ReadDir(abspath string) ([]os.FileInfo, error) {
- path := zipPath(abspath)
- i, fi, err := fs.stat(path)
- if err != nil {
- return nil, err
- }
- if !fi.IsDir() {
- return nil, fmt.Errorf("ReadDir: %s is not a directory", abspath)
- }
-
- var list []os.FileInfo
- dirname := path + "/"
- prevname := ""
- for _, e := range fs.list[i:] {
- if !strings.HasPrefix(e.Name, dirname) {
- break // not in the same directory anymore
- }
- name := e.Name[len(dirname):] // local name
- file := e
- if i := strings.IndexRune(name, '/'); i >= 0 {
- // We infer directories from files in subdirectories.
- // If we have x/y, return a directory entry for x.
- name = name[0:i] // keep local directory name only
- file = nil
- }
- // If we have x/y and x/z, don't return two directory entries for x.
- // TODO(gri): It should be possible to do this more efficiently
- // by determining the (fs.list) range of local directory entries
- // (via two binary searches).
- if name != prevname {
- list = append(list, zipFI{name, file})
- prevname = name
- }
- }
-
- return list, nil
-}
-
-func New(rc *zip.ReadCloser, name string) vfs.FileSystem {
- list := make(zipList, len(rc.File))
- copy(list, rc.File) // sort a copy of rc.File
- sort.Sort(list)
- return &zipFS{rc, list, name}
-}
-
-type zipList []*zip.File
-
-// zipList implements sort.Interface
-func (z zipList) Len() int { return len(z) }
-func (z zipList) Less(i, j int) bool { return z[i].Name < z[j].Name }
-func (z zipList) Swap(i, j int) { z[i], z[j] = z[j], z[i] }
-
-// lookup returns the smallest index of an entry with an exact match
-// for name, or an inexact match starting with name/. If there is no
-// such entry, the result is -1, false.
-func (z zipList) lookup(name string) (index int, exact bool) {
- // look for exact match first (name comes before name/ in z)
- i := sort.Search(len(z), func(i int) bool {
- return name <= z[i].Name
- })
- if i >= len(z) {
- return -1, false
- }
- // 0 <= i < len(z)
- if z[i].Name == name {
- return i, true
- }
-
- // look for inexact match (must be in z[i:], if present)
- z = z[i:]
- name += "/"
- j := sort.Search(len(z), func(i int) bool {
- return name <= z[i].Name
- })
- if j >= len(z) {
- return -1, false
- }
- // 0 <= j < len(z)
- if strings.HasPrefix(z[j].Name, name) {
- return i + j, false
- }
-
- return -1, false
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/fix.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/fix.go
deleted file mode 100644
index dd3d8170..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/fix.go
+++ /dev/null
@@ -1,387 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package imports
-
-import (
- "fmt"
- "go/ast"
- "go/build"
- "go/parser"
- "go/token"
- "os"
- "path"
- "path/filepath"
- "strings"
- "sync"
-
- "code.google.com/p/go.tools/astutil"
-)
-
-// importToGroup is a list of functions which map from an import path to
-// a group number.
-var importToGroup = []func(importPath string) (num int, ok bool){
- func(importPath string) (num int, ok bool) {
- if strings.HasPrefix(importPath, "appengine") {
- return 2, true
- }
- return
- },
- func(importPath string) (num int, ok bool) {
- if strings.Contains(importPath, ".") {
- return 1, true
- }
- return
- },
-}
-
-func importGroup(importPath string) int {
- for _, fn := range importToGroup {
- if n, ok := fn(importPath); ok {
- return n
- }
- }
- return 0
-}
-
-func fixImports(fset *token.FileSet, f *ast.File) (added []string, err error) {
- // refs are a set of possible package references currently unsatisified by imports.
- // first key: either base package (e.g. "fmt") or renamed package
- // second key: referenced package symbol (e.g. "Println")
- refs := make(map[string]map[string]bool)
-
- // decls are the current package imports. key is base package or renamed package.
- decls := make(map[string]*ast.ImportSpec)
-
- // collect potential uses of packages.
- var visitor visitFn
- visitor = visitFn(func(node ast.Node) ast.Visitor {
- if node == nil {
- return visitor
- }
- switch v := node.(type) {
- case *ast.ImportSpec:
- if v.Name != nil {
- decls[v.Name.Name] = v
- } else {
- local := importPathToName(strings.Trim(v.Path.Value, `\"`))
- decls[local] = v
- }
- case *ast.SelectorExpr:
- xident, ok := v.X.(*ast.Ident)
- if !ok {
- break
- }
- if xident.Obj != nil {
- // if the parser can resolve it, it's not a package ref
- break
- }
- pkgName := xident.Name
- if refs[pkgName] == nil {
- refs[pkgName] = make(map[string]bool)
- }
- if decls[pkgName] == nil {
- refs[pkgName][v.Sel.Name] = true
- }
- }
- return visitor
- })
- ast.Walk(visitor, f)
-
- // Search for imports matching potential package references.
- searches := 0
- type result struct {
- ipath string
- name string
- err error
- }
- results := make(chan result)
- for pkgName, symbols := range refs {
- if len(symbols) == 0 {
- continue // skip over packages already imported
- }
- go func(pkgName string, symbols map[string]bool) {
- ipath, rename, err := findImport(pkgName, symbols)
- r := result{ipath: ipath, err: err}
- if rename {
- r.name = pkgName
- }
- results <- r
- }(pkgName, symbols)
- searches++
- }
- for i := 0; i < searches; i++ {
- result := <-results
- if result.err != nil {
- return nil, result.err
- }
- if result.ipath != "" {
- if result.name != "" {
- astutil.AddNamedImport(fset, f, result.name, result.ipath)
- } else {
- astutil.AddImport(fset, f, result.ipath)
- }
- added = append(added, result.ipath)
- }
- }
-
- // Nil out any unused ImportSpecs, to be removed in following passes
- unusedImport := map[string]bool{}
- for pkg, is := range decls {
- if refs[pkg] == nil && pkg != "_" && pkg != "." {
- unusedImport[strings.Trim(is.Path.Value, `"`)] = true
- }
- }
- for ipath := range unusedImport {
- if ipath == "C" {
- // Don't remove cgo stuff.
- continue
- }
- astutil.DeleteImport(fset, f, ipath)
- }
-
- return added, nil
-}
-
-// importPathToName returns the package name for the given import path.
-var importPathToName = importPathToNameGoPath
-
-// importPathToNameBasic assumes the package name is the base of import path.
-func importPathToNameBasic(importPath string) (packageName string) {
- return path.Base(importPath)
-}
-
-// importPathToNameGoPath finds out the actual package name, as declared in its .go files.
-// If there's a problem, it falls back to using importPathToNameBasic.
-func importPathToNameGoPath(importPath string) (packageName string) {
- if buildPkg, err := build.Import(importPath, "", 0); err == nil {
- return buildPkg.Name
- } else {
- return importPathToNameBasic(importPath)
- }
-}
-
-type pkg struct {
- importpath string // full pkg import path, e.g. "net/http"
- dir string // absolute file path to pkg directory e.g. "/usr/lib/go/src/fmt"
-}
-
-var pkgIndexOnce sync.Once
-
-var pkgIndex struct {
- sync.Mutex
- m map[string][]pkg // shortname => []pkg, e.g "http" => "net/http"
-}
-
-// gate is a semaphore for limiting concurrency.
-type gate chan struct{}
-
-func (g gate) enter() { g <- struct{}{} }
-func (g gate) leave() { <-g }
-
-// fsgate protects the OS & filesystem from too much concurrency.
-// Too much disk I/O -> too many threads -> swapping and bad scheduling.
-var fsgate = make(gate, 8)
-
-func loadPkgIndex() {
- pkgIndex.Lock()
- pkgIndex.m = make(map[string][]pkg)
- pkgIndex.Unlock()
-
- var wg sync.WaitGroup
- for _, path := range build.Default.SrcDirs() {
- fsgate.enter()
- f, err := os.Open(path)
- if err != nil {
- fsgate.leave()
- fmt.Fprint(os.Stderr, err)
- continue
- }
- children, err := f.Readdir(-1)
- f.Close()
- fsgate.leave()
- if err != nil {
- fmt.Fprint(os.Stderr, err)
- continue
- }
- for _, child := range children {
- if child.IsDir() {
- wg.Add(1)
- go func(path, name string) {
- defer wg.Done()
- loadPkg(&wg, path, name)
- }(path, child.Name())
- }
- }
- }
- wg.Wait()
-}
-
-func loadPkg(wg *sync.WaitGroup, root, pkgrelpath string) {
- importpath := filepath.ToSlash(pkgrelpath)
- dir := filepath.Join(root, importpath)
-
- fsgate.enter()
- defer fsgate.leave()
- pkgDir, err := os.Open(dir)
- if err != nil {
- return
- }
- children, err := pkgDir.Readdir(-1)
- pkgDir.Close()
- if err != nil {
- return
- }
- // hasGo tracks whether a directory actually appears to be a
- // Go source code directory. If $GOPATH == $HOME, and
- // $HOME/src has lots of other large non-Go projects in it,
- // then the calls to importPathToName below can be expensive.
- hasGo := false
- for _, child := range children {
- name := child.Name()
- if name == "" {
- continue
- }
- if c := name[0]; c == '.' || ('0' <= c && c <= '9') {
- continue
- }
- if strings.HasSuffix(name, ".go") {
- hasGo = true
- }
- if child.IsDir() {
- wg.Add(1)
- go func(root, name string) {
- defer wg.Done()
- loadPkg(wg, root, name)
- }(root, filepath.Join(importpath, name))
- }
- }
- if hasGo {
- shortName := importPathToName(importpath)
- pkgIndex.Lock()
- pkgIndex.m[shortName] = append(pkgIndex.m[shortName], pkg{
- importpath: importpath,
- dir: dir,
- })
- pkgIndex.Unlock()
- }
-
-}
-
-// loadExports returns a list exports for a package.
-var loadExports = loadExportsGoPath
-
-func loadExportsGoPath(dir string) map[string]bool {
- exports := make(map[string]bool)
- buildPkg, err := build.ImportDir(dir, 0)
- if err != nil {
- if strings.Contains(err.Error(), "no buildable Go source files in") {
- return nil
- }
- fmt.Fprintf(os.Stderr, "could not import %q: %v", dir, err)
- return nil
- }
- fset := token.NewFileSet()
- for _, file := range buildPkg.GoFiles {
- f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0)
- if err != nil {
- fmt.Fprintf(os.Stderr, "could not parse %q: %v", file, err)
- continue
- }
- for name := range f.Scope.Objects {
- if ast.IsExported(name) {
- exports[name] = true
- }
- }
- }
- return exports
-}
-
-// findImport searches for a package with the given symbols.
-// If no package is found, findImport returns "".
-// Declared as a variable rather than a function so goimports can be easily
-// extended by adding a file with an init function.
-var findImport = findImportGoPath
-
-func findImportGoPath(pkgName string, symbols map[string]bool) (string, bool, error) {
- // Fast path for the standard library.
- // In the common case we hopefully never have to scan the GOPATH, which can
- // be slow with moving disks.
- if pkg, rename, ok := findImportStdlib(pkgName, symbols); ok {
- return pkg, rename, nil
- }
-
- // TODO(sameer): look at the import lines for other Go files in the
- // local directory, since the user is likely to import the same packages
- // in the current Go file. Return rename=true when the other Go files
- // use a renamed package that's also used in the current file.
-
- pkgIndexOnce.Do(loadPkgIndex)
-
- // Collect exports for packages with matching names.
- var wg sync.WaitGroup
- var pkgsMu sync.Mutex // guards pkgs
- // full importpath => exported symbol => True
- // e.g. "net/http" => "Client" => True
- pkgs := make(map[string]map[string]bool)
- pkgIndex.Lock()
- for _, pkg := range pkgIndex.m[pkgName] {
- wg.Add(1)
- go func(importpath, dir string) {
- defer wg.Done()
- exports := loadExports(dir)
- if exports != nil {
- pkgsMu.Lock()
- pkgs[importpath] = exports
- pkgsMu.Unlock()
- }
- }(pkg.importpath, pkg.dir)
- }
- pkgIndex.Unlock()
- wg.Wait()
-
- // Filter out packages missing required exported symbols.
- for symbol := range symbols {
- for importpath, exports := range pkgs {
- if !exports[symbol] {
- delete(pkgs, importpath)
- }
- }
- }
- if len(pkgs) == 0 {
- return "", false, nil
- }
-
- // If there are multiple candidate packages, the shortest one wins.
- // This is a heuristic to prefer the standard library (e.g. "bytes")
- // over e.g. "github.com/foo/bar/bytes".
- shortest := ""
- for importPath := range pkgs {
- if shortest == "" || len(importPath) < len(shortest) {
- shortest = importPath
- }
- }
- return shortest, false, nil
-}
-
-type visitFn func(node ast.Node) ast.Visitor
-
-func (fn visitFn) Visit(node ast.Node) ast.Visitor {
- return fn(node)
-}
-
-func findImportStdlib(shortPkg string, symbols map[string]bool) (importPath string, rename, ok bool) {
- for symbol := range symbols {
- path := stdlib[shortPkg+"."+symbol]
- if path == "" {
- return "", false, false
- }
- if importPath != "" && importPath != path {
- // Ambiguous. Symbols pointed to different things.
- return "", false, false
- }
- importPath = path
- }
- return importPath, false, importPath != ""
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/fix_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/fix_test.go
deleted file mode 100644
index d4646384..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/fix_test.go
+++ /dev/null
@@ -1,667 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package imports
-
-import (
- "flag"
- "go/build"
- "io/ioutil"
- "os"
- "path/filepath"
- "sync"
- "testing"
-)
-
-var only = flag.String("only", "", "If non-empty, the fix test to run")
-
-var tests = []struct {
- name string
- in, out string
-}{
- // Adding an import to an existing parenthesized import
- {
- name: "factored_imports_add",
- in: `package foo
-import (
- "fmt"
-)
-func bar() {
-var b bytes.Buffer
-fmt.Println(b.String())
-}
-`,
- out: `package foo
-
-import (
- "bytes"
- "fmt"
-)
-
-func bar() {
- var b bytes.Buffer
- fmt.Println(b.String())
-}
-`,
- },
-
- // Adding an import to an existing parenthesized import,
- // verifying it goes into the first section.
- {
- name: "factored_imports_add_first_sec",
- in: `package foo
-import (
- "fmt"
-
- "appengine"
-)
-func bar() {
-var b bytes.Buffer
-_ = appengine.IsDevServer
-fmt.Println(b.String())
-}
-`,
- out: `package foo
-
-import (
- "bytes"
- "fmt"
-
- "appengine"
-)
-
-func bar() {
- var b bytes.Buffer
- _ = appengine.IsDevServer
- fmt.Println(b.String())
-}
-`,
- },
-
- // Adding an import to an existing parenthesized import,
- // verifying it goes into the first section. (test 2)
- {
- name: "factored_imports_add_first_sec_2",
- in: `package foo
-import (
- "fmt"
-
- "appengine"
-)
-func bar() {
-_ = math.NaN
-_ = fmt.Sprintf
-_ = appengine.IsDevServer
-}
-`,
- out: `package foo
-
-import (
- "fmt"
- "math"
-
- "appengine"
-)
-
-func bar() {
- _ = math.NaN
- _ = fmt.Sprintf
- _ = appengine.IsDevServer
-}
-`,
- },
-
- // Adding a new import line, without parens
- {
- name: "add_import_section",
- in: `package foo
-func bar() {
-var b bytes.Buffer
-}
-`,
- out: `package foo
-
-import "bytes"
-
-func bar() {
- var b bytes.Buffer
-}
-`,
- },
-
- // Adding two new imports, which should make a parenthesized import decl.
- {
- name: "add_import_paren_section",
- in: `package foo
-func bar() {
-_, _ := bytes.Buffer, zip.NewReader
-}
-`,
- out: `package foo
-
-import (
- "archive/zip"
- "bytes"
-)
-
-func bar() {
- _, _ := bytes.Buffer, zip.NewReader
-}
-`,
- },
-
- // Make sure we don't add things twice
- {
- name: "no_double_add",
- in: `package foo
-func bar() {
-_, _ := bytes.Buffer, bytes.NewReader
-}
-`,
- out: `package foo
-
-import "bytes"
-
-func bar() {
- _, _ := bytes.Buffer, bytes.NewReader
-}
-`,
- },
-
- // Remove unused imports, 1 of a factored block
- {
- name: "remove_unused_1_of_2",
- in: `package foo
-import (
-"bytes"
-"fmt"
-)
-
-func bar() {
-_, _ := bytes.Buffer, bytes.NewReader
-}
-`,
- out: `package foo
-
-import "bytes"
-
-func bar() {
- _, _ := bytes.Buffer, bytes.NewReader
-}
-`,
- },
-
- // Remove unused imports, 2 of 2
- {
- name: "remove_unused_2_of_2",
- in: `package foo
-import (
-"bytes"
-"fmt"
-)
-
-func bar() {
-}
-`,
- out: `package foo
-
-func bar() {
-}
-`,
- },
-
- // Remove unused imports, 1 of 1
- {
- name: "remove_unused_1_of_1",
- in: `package foo
-
-import "fmt"
-
-func bar() {
-}
-`,
- out: `package foo
-
-func bar() {
-}
-`,
- },
-
- // Don't remove empty imports.
- {
- name: "dont_remove_empty_imports",
- in: `package foo
-import (
-_ "image/png"
-_ "image/jpeg"
-)
-`,
- out: `package foo
-
-import (
- _ "image/jpeg"
- _ "image/png"
-)
-`,
- },
-
- // Don't remove dot imports.
- {
- name: "dont_remove_dot_imports",
- in: `package foo
-import (
-. "foo"
-. "bar"
-)
-`,
- out: `package foo
-
-import (
- . "bar"
- . "foo"
-)
-`,
- },
-
- // Skip refs the parser can resolve.
- {
- name: "skip_resolved_refs",
- in: `package foo
-
-func f() {
- type t struct{ Println func(string) }
- fmt := t{Println: func(string) {}}
- fmt.Println("foo")
-}
-`,
- out: `package foo
-
-func f() {
- type t struct{ Println func(string) }
- fmt := t{Println: func(string) {}}
- fmt.Println("foo")
-}
-`,
- },
-
- // Do not add a package we already have a resolution for.
- {
- name: "skip_template",
- in: `package foo
-
-import "html/template"
-
-func f() { t = template.New("sometemplate") }
-`,
- out: `package foo
-
-import "html/template"
-
-func f() { t = template.New("sometemplate") }
-`,
- },
-
- // Don't touch cgo
- {
- name: "cgo",
- in: `package foo
-
-/*
-#include
-*/
-import "C"
-`,
- out: `package foo
-
-/*
-#include
-*/
-import "C"
-`,
- },
-
- // Put some things in their own section
- {
- name: "make_sections",
- in: `package foo
-
-import (
-"os"
-)
-
-func foo () {
-_, _ = os.Args, fmt.Println
-_, _ = appengine.FooSomething, user.Current
-}
-`,
- out: `package foo
-
-import (
- "fmt"
- "os"
-
- "appengine"
- "appengine/user"
-)
-
-func foo() {
- _, _ = os.Args, fmt.Println
- _, _ = appengine.FooSomething, user.Current
-}
-`,
- },
-
- // Delete existing empty import block
- {
- name: "delete_empty_import_block",
- in: `package foo
-
-import ()
-`,
- out: `package foo
-`,
- },
-
- // Use existing empty import block
- {
- name: "use_empty_import_block",
- in: `package foo
-
-import ()
-
-func f() {
- _ = fmt.Println
-}
-`,
- out: `package foo
-
-import "fmt"
-
-func f() {
- _ = fmt.Println
-}
-`,
- },
-
- // Blank line before adding new section.
- {
- name: "blank_line_before_new_group",
- in: `package foo
-
-import (
- "fmt"
- "net"
-)
-
-func f() {
- _ = net.Dial
- _ = fmt.Printf
- _ = snappy.Foo
-}
-`,
- out: `package foo
-
-import (
- "fmt"
- "net"
-
- "code.google.com/p/snappy-go/snappy"
-)
-
-func f() {
- _ = net.Dial
- _ = fmt.Printf
- _ = snappy.Foo
-}
-`,
- },
-
- // Blank line between standard library and third-party stuff.
- {
- name: "blank_line_separating_std_and_third_party",
- in: `package foo
-
-import (
- "code.google.com/p/snappy-go/snappy"
- "fmt"
- "net"
-)
-
-func f() {
- _ = net.Dial
- _ = fmt.Printf
- _ = snappy.Foo
-}
-`,
- out: `package foo
-
-import (
- "fmt"
- "net"
-
- "code.google.com/p/snappy-go/snappy"
-)
-
-func f() {
- _ = net.Dial
- _ = fmt.Printf
- _ = snappy.Foo
-}
-`,
- },
-
- // golang.org/issue/6884
- {
- name: "issue 6884",
- in: `package main
-
-// A comment
-func main() {
- fmt.Println("Hello, world")
-}
-`,
- out: `package main
-
-import "fmt"
-
-// A comment
-func main() {
- fmt.Println("Hello, world")
-}
-`,
- },
-
- // golang.org/issue/7132
- {
- name: "issue 7132",
- in: `package main
-
-import (
-"fmt"
-
-"gu"
-"github.com/foo/bar"
-)
-
-var (
-a = bar.a
-b = gu.a
-c = fmt.Printf
-)
-`,
- out: `package main
-
-import (
- "fmt"
-
- "gu"
-
- "github.com/foo/bar"
-)
-
-var (
- a = bar.a
- b = gu.a
- c = fmt.Printf
-)
-`,
- },
-
- {
- name: "renamed package",
- in: `package main
-
-var _ = str.HasPrefix
-`,
- out: `package main
-
-import str "strings"
-
-var _ = str.HasPrefix
-`,
- },
-
- {
- name: "fragment with main",
- in: `func main(){fmt.Println("Hello, world")}`,
- out: `package main
-
-import "fmt"
-
-func main() { fmt.Println("Hello, world") }
-`,
- },
-
- {
- name: "fragment without main",
- in: `func notmain(){fmt.Println("Hello, world")}`,
- out: `import "fmt"
-
-func notmain() { fmt.Println("Hello, world") }`,
- },
-}
-
-func TestFixImports(t *testing.T) {
- simplePkgs := map[string]string{
- "fmt": "fmt",
- "os": "os",
- "math": "math",
- "appengine": "appengine",
- "user": "appengine/user",
- "zip": "archive/zip",
- "bytes": "bytes",
- "snappy": "code.google.com/p/snappy-go/snappy",
- "str": "strings",
- }
- findImport = func(pkgName string, symbols map[string]bool) (string, bool, error) {
- return simplePkgs[pkgName], pkgName == "str", nil
- }
-
- options := &Options{
- TabWidth: 8,
- TabIndent: true,
- Comments: true,
- Fragment: true,
- }
-
- for _, tt := range tests {
- if *only != "" && tt.name != *only {
- continue
- }
- buf, err := Process(tt.name+".go", []byte(tt.in), options)
- if err != nil {
- t.Errorf("error on %q: %v", tt.name, err)
- continue
- }
- if got := string(buf); got != tt.out {
- t.Errorf("results diff on %q\nGOT:\n%s\nWANT:\n%s\n", tt.name, got, tt.out)
- }
- }
-}
-
-func TestFindImportGoPath(t *testing.T) {
- goroot, err := ioutil.TempDir("", "goimports-")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(goroot)
-
- pkgIndexOnce = sync.Once{}
-
- origStdlib := stdlib
- defer func() {
- stdlib = origStdlib
- }()
- stdlib = nil
-
- // Test against imaginary bits/bytes package in std lib
- bytesDir := filepath.Join(goroot, "src", "pkg", "bits", "bytes")
- if err := os.MkdirAll(bytesDir, 0755); err != nil {
- t.Fatal(err)
- }
- bytesSrcPath := filepath.Join(bytesDir, "bytes.go")
- bytesPkgPath := "bits/bytes"
- bytesSrc := []byte(`package bytes
-
-type Buffer2 struct {}
-`)
- if err := ioutil.WriteFile(bytesSrcPath, bytesSrc, 0775); err != nil {
- t.Fatal(err)
- }
- oldGOROOT := build.Default.GOROOT
- oldGOPATH := build.Default.GOPATH
- build.Default.GOROOT = goroot
- build.Default.GOPATH = ""
- defer func() {
- build.Default.GOROOT = oldGOROOT
- build.Default.GOPATH = oldGOPATH
- }()
-
- got, rename, err := findImportGoPath("bytes", map[string]bool{"Buffer2": true})
- if err != nil {
- t.Fatal(err)
- }
- if got != bytesPkgPath || rename {
- t.Errorf(`findImportGoPath("bytes", Buffer2 ...)=%q, %t, want "%s", false`, got, rename, bytesPkgPath)
- }
-
- got, rename, err = findImportGoPath("bytes", map[string]bool{"Missing": true})
- if err != nil {
- t.Fatal(err)
- }
- if got != "" || rename {
- t.Errorf(`findImportGoPath("bytes", Missing ...)=%q, %t, want "", false`, got, rename)
- }
-}
-
-func TestFindImportStdlib(t *testing.T) {
- tests := []struct {
- pkg string
- symbols []string
- want string
- }{
- {"http", []string{"Get"}, "net/http"},
- {"http", []string{"Get", "Post"}, "net/http"},
- {"http", []string{"Get", "Foo"}, ""},
- {"bytes", []string{"Buffer"}, "bytes"},
- {"ioutil", []string{"Discard"}, "io/ioutil"},
- }
- for _, tt := range tests {
- got, rename, ok := findImportStdlib(tt.pkg, strSet(tt.symbols))
- if (got != "") != ok {
- t.Error("findImportStdlib return value inconsistent")
- }
- if got != tt.want || rename {
- t.Errorf("findImportStdlib(%q, %q) = %q, %t; want %q, false", tt.pkg, tt.symbols, got, rename, tt.want)
- }
- }
-}
-
-func strSet(ss []string) map[string]bool {
- m := make(map[string]bool)
- for _, s := range ss {
- m[s] = true
- }
- return m
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/imports.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/imports.go
deleted file mode 100644
index dd1bc4d6..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/imports.go
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package imports implements a Go pretty-printer (like package "go/format")
-// that also adds or removes import statements as necessary.
-package imports
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "go/ast"
- "go/parser"
- "go/printer"
- "go/token"
- "io"
- "regexp"
- "strconv"
- "strings"
-
- "code.google.com/p/go.tools/astutil"
-)
-
-// Options specifies options for processing files.
-type Options struct {
- Fragment bool // Accept fragement of a source file (no package statement)
- AllErrors bool // Report all errors (not just the first 10 on different lines)
-
- Comments bool // Print comments (true if nil *Options provided)
- TabIndent bool // Use tabs for indent (true if nil *Options provided)
- TabWidth int // Tab width (8 if nil *Options provided)
-}
-
-// Process formats and adjusts imports for the provided file.
-// If opt is nil the defaults are used.
-func Process(filename string, src []byte, opt *Options) ([]byte, error) {
- if opt == nil {
- opt = &Options{Comments: true, TabIndent: true, TabWidth: 8}
- }
-
- fileSet := token.NewFileSet()
- file, adjust, err := parse(fileSet, filename, src, opt)
- if err != nil {
- return nil, err
- }
-
- _, err = fixImports(fileSet, file)
- if err != nil {
- return nil, err
- }
-
- sortImports(fileSet, file)
- imps := astutil.Imports(fileSet, file)
-
- var spacesBefore []string // import paths we need spaces before
- for _, impSection := range imps {
- // Within each block of contiguous imports, see if any
- // import lines are in different group numbers. If so,
- // we'll need to put a space between them so it's
- // compatible with gofmt.
- lastGroup := -1
- for _, importSpec := range impSection {
- importPath, _ := strconv.Unquote(importSpec.Path.Value)
- groupNum := importGroup(importPath)
- if groupNum != lastGroup && lastGroup != -1 {
- spacesBefore = append(spacesBefore, importPath)
- }
- lastGroup = groupNum
- }
-
- }
-
- printerMode := printer.UseSpaces
- if opt.TabIndent {
- printerMode |= printer.TabIndent
- }
- printConfig := &printer.Config{Mode: printerMode, Tabwidth: opt.TabWidth}
-
- var buf bytes.Buffer
- err = printConfig.Fprint(&buf, fileSet, file)
- if err != nil {
- return nil, err
- }
- out := buf.Bytes()
- if adjust != nil {
- out = adjust(src, out)
- }
- if len(spacesBefore) > 0 {
- out = addImportSpaces(bytes.NewReader(out), spacesBefore)
- }
- return out, nil
-}
-
-// parse parses src, which was read from filename,
-// as a Go source file or statement list.
-func parse(fset *token.FileSet, filename string, src []byte, opt *Options) (*ast.File, func(orig, src []byte) []byte, error) {
- parserMode := parser.Mode(0)
- if opt.Comments {
- parserMode |= parser.ParseComments
- }
- if opt.AllErrors {
- parserMode |= parser.AllErrors
- }
-
- // Try as whole source file.
- file, err := parser.ParseFile(fset, filename, src, parserMode)
- if err == nil {
- return file, nil, nil
- }
- // If the error is that the source file didn't begin with a
- // package line and we accept fragmented input, fall through to
- // try as a source fragment. Stop and return on any other error.
- if !opt.Fragment || !strings.Contains(err.Error(), "expected 'package'") {
- return nil, nil, err
- }
-
- // If this is a declaration list, make it a source file
- // by inserting a package clause.
- // Insert using a ;, not a newline, so that the line numbers
- // in psrc match the ones in src.
- psrc := append([]byte("package main;"), src...)
- file, err = parser.ParseFile(fset, filename, psrc, parserMode)
- if err == nil {
- // If a main function exists, we will assume this is a main
- // package and leave the file.
- if containsMainFunc(file) {
- return file, nil, nil
- }
-
- adjust := func(orig, src []byte) []byte {
- // Remove the package clause.
- // Gofmt has turned the ; into a \n.
- src = src[len("package main\n"):]
- return matchSpace(orig, src)
- }
- return file, adjust, nil
- }
- // If the error is that the source file didn't begin with a
- // declaration, fall through to try as a statement list.
- // Stop and return on any other error.
- if !strings.Contains(err.Error(), "expected declaration") {
- return nil, nil, err
- }
-
- // If this is a statement list, make it a source file
- // by inserting a package clause and turning the list
- // into a function body. This handles expressions too.
- // Insert using a ;, not a newline, so that the line numbers
- // in fsrc match the ones in src.
- fsrc := append(append([]byte("package p; func _() {"), src...), '}')
- file, err = parser.ParseFile(fset, filename, fsrc, parserMode)
- if err == nil {
- adjust := func(orig, src []byte) []byte {
- // Remove the wrapping.
- // Gofmt has turned the ; into a \n\n.
- src = src[len("package p\n\nfunc _() {"):]
- src = src[:len(src)-len("}\n")]
- // Gofmt has also indented the function body one level.
- // Remove that indent.
- src = bytes.Replace(src, []byte("\n\t"), []byte("\n"), -1)
- return matchSpace(orig, src)
- }
- return file, adjust, nil
- }
-
- // Failed, and out of options.
- return nil, nil, err
-}
-
-// containsMainFunc checks if a file contains a function declaration with the
-// function signature 'func main()'
-func containsMainFunc(file *ast.File) bool {
- for _, decl := range file.Decls {
- if f, ok := decl.(*ast.FuncDecl); ok {
- if f.Name.Name != "main" {
- continue
- }
-
- if len(f.Type.Params.List) != 0 {
- continue
- }
-
- if f.Type.Results != nil && len(f.Type.Results.List) != 0 {
- continue
- }
-
- return true
- }
- }
-
- return false
-}
-
-func cutSpace(b []byte) (before, middle, after []byte) {
- i := 0
- for i < len(b) && (b[i] == ' ' || b[i] == '\t' || b[i] == '\n') {
- i++
- }
- j := len(b)
- for j > 0 && (b[j-1] == ' ' || b[j-1] == '\t' || b[j-1] == '\n') {
- j--
- }
- if i <= j {
- return b[:i], b[i:j], b[j:]
- }
- return nil, nil, b[j:]
-}
-
-// matchSpace reformats src to use the same space context as orig.
-// 1) If orig begins with blank lines, matchSpace inserts them at the beginning of src.
-// 2) matchSpace copies the indentation of the first non-blank line in orig
-// to every non-blank line in src.
-// 3) matchSpace copies the trailing space from orig and uses it in place
-// of src's trailing space.
-func matchSpace(orig []byte, src []byte) []byte {
- before, _, after := cutSpace(orig)
- i := bytes.LastIndex(before, []byte{'\n'})
- before, indent := before[:i+1], before[i+1:]
-
- _, src, _ = cutSpace(src)
-
- var b bytes.Buffer
- b.Write(before)
- for len(src) > 0 {
- line := src
- if i := bytes.IndexByte(line, '\n'); i >= 0 {
- line, src = line[:i+1], line[i+1:]
- } else {
- src = nil
- }
- if len(line) > 0 && line[0] != '\n' { // not blank
- b.Write(indent)
- }
- b.Write(line)
- }
- b.Write(after)
- return b.Bytes()
-}
-
-var impLine = regexp.MustCompile(`^\s+(?:\w+\s+)?"(.+)"`)
-
-func addImportSpaces(r io.Reader, breaks []string) []byte {
- var out bytes.Buffer
- sc := bufio.NewScanner(r)
- inImports := false
- done := false
- for sc.Scan() {
- s := sc.Text()
-
- if !inImports && !done && strings.HasPrefix(s, "import") {
- inImports = true
- }
- if inImports && (strings.HasPrefix(s, "var") ||
- strings.HasPrefix(s, "func") ||
- strings.HasPrefix(s, "const") ||
- strings.HasPrefix(s, "type")) {
- done = true
- inImports = false
- }
- if inImports && len(breaks) > 0 {
- if m := impLine.FindStringSubmatch(s); m != nil {
- if m[1] == string(breaks[0]) {
- out.WriteByte('\n')
- breaks = breaks[1:]
- }
- }
- }
-
- fmt.Fprintln(&out, s)
- }
- return out.Bytes()
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/mkindex.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/mkindex.go
deleted file mode 100644
index 755e2394..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/mkindex.go
+++ /dev/null
@@ -1,173 +0,0 @@
-// +build ignore
-
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Command mkindex creates the file "pkgindex.go" containing an index of the Go
-// standard library. The file is intended to be built as part of the imports
-// package, so that the package may be used in environments where a GOROOT is
-// not available (such as App Engine).
-package main
-
-import (
- "bytes"
- "fmt"
- "go/ast"
- "go/build"
- "go/format"
- "go/parser"
- "go/token"
- "io/ioutil"
- "log"
- "os"
- "path"
- "path/filepath"
- "strings"
-)
-
-var (
- pkgIndex = make(map[string][]pkg)
- exports = make(map[string]map[string]bool)
-)
-
-func main() {
- // Don't use GOPATH.
- ctx := build.Default
- ctx.GOPATH = ""
-
- // Populate pkgIndex global from GOROOT.
- for _, path := range ctx.SrcDirs() {
- f, err := os.Open(path)
- if err != nil {
- log.Print(err)
- continue
- }
- children, err := f.Readdir(-1)
- f.Close()
- if err != nil {
- log.Print(err)
- continue
- }
- for _, child := range children {
- if child.IsDir() {
- loadPkg(path, child.Name())
- }
- }
- }
- // Populate exports global.
- for _, ps := range pkgIndex {
- for _, p := range ps {
- e := loadExports(p.dir)
- if e != nil {
- exports[p.dir] = e
- }
- }
- }
-
- // Construct source file.
- var buf bytes.Buffer
- fmt.Fprint(&buf, pkgIndexHead)
- fmt.Fprintf(&buf, "var pkgIndexMaster = %#v\n", pkgIndex)
- fmt.Fprintf(&buf, "var exportsMaster = %#v\n", exports)
- src := buf.Bytes()
-
- // Replace main.pkg type name with pkg.
- src = bytes.Replace(src, []byte("main.pkg"), []byte("pkg"), -1)
- // Replace actual GOROOT with "/go".
- src = bytes.Replace(src, []byte(ctx.GOROOT), []byte("/go"), -1)
- // Add some line wrapping.
- src = bytes.Replace(src, []byte("}, "), []byte("},\n"), -1)
- src = bytes.Replace(src, []byte("true, "), []byte("true,\n"), -1)
-
- var err error
- src, err = format.Source(src)
- if err != nil {
- log.Fatal(err)
- }
-
- // Write out source file.
- err = ioutil.WriteFile("pkgindex.go", src, 0644)
- if err != nil {
- log.Fatal(err)
- }
-}
-
-const pkgIndexHead = `package imports
-
-func init() {
- pkgIndexOnce.Do(func() {
- pkgIndex.m = pkgIndexMaster
- })
- loadExports = func(dir string) map[string]bool {
- return exportsMaster[dir]
- }
-}
-`
-
-type pkg struct {
- importpath string // full pkg import path, e.g. "net/http"
- dir string // absolute file path to pkg directory e.g. "/usr/lib/go/src/fmt"
-}
-
-var fset = token.NewFileSet()
-
-func loadPkg(root, importpath string) {
- shortName := path.Base(importpath)
- if shortName == "testdata" {
- return
- }
-
- dir := filepath.Join(root, importpath)
- pkgIndex[shortName] = append(pkgIndex[shortName], pkg{
- importpath: importpath,
- dir: dir,
- })
-
- pkgDir, err := os.Open(dir)
- if err != nil {
- return
- }
- children, err := pkgDir.Readdir(-1)
- pkgDir.Close()
- if err != nil {
- return
- }
- for _, child := range children {
- name := child.Name()
- if name == "" {
- continue
- }
- if c := name[0]; c == '.' || ('0' <= c && c <= '9') {
- continue
- }
- if child.IsDir() {
- loadPkg(root, filepath.Join(importpath, name))
- }
- }
-}
-
-func loadExports(dir string) map[string]bool {
- exports := make(map[string]bool)
- buildPkg, err := build.ImportDir(dir, 0)
- if err != nil {
- if strings.Contains(err.Error(), "no buildable Go source files in") {
- return nil
- }
- log.Printf("could not import %q: %v", dir, err)
- return nil
- }
- for _, file := range buildPkg.GoFiles {
- f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0)
- if err != nil {
- log.Printf("could not parse %q: %v", file, err)
- continue
- }
- for name := range f.Scope.Objects {
- if ast.IsExported(name) {
- exports[name] = true
- }
- }
- }
- return exports
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/mkstdlib.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/mkstdlib.go
deleted file mode 100644
index c43d3255..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/mkstdlib.go
+++ /dev/null
@@ -1,90 +0,0 @@
-// +build ignore
-
-// mkstdlib generates the zstdlib.go file, containing the Go standard
-// library API symbols. It's baked into the binary to avoid scanning
-// GOPATH in the common case.
-package main
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "go/format"
- "io"
- "log"
- "os"
- "path"
- "path/filepath"
- "regexp"
- "sort"
- "strings"
-)
-
-func mustOpen(name string) io.Reader {
- f, err := os.Open(name)
- if err != nil {
- log.Fatal(err)
- }
- return f
-}
-
-func api(base string) string {
- return filepath.Join(os.Getenv("GOROOT"), "api", base)
-}
-
-var sym = regexp.MustCompile(`^pkg (\S+).*?, (?:var|func|type|const) ([A-Z]\w*)`)
-
-func main() {
- var buf bytes.Buffer
- outf := func(format string, args ...interface{}) {
- fmt.Fprintf(&buf, format, args...)
- }
- outf("// AUTO-GENERATED BY mkstdlib.go\n\n")
- outf("package imports\n")
- outf("var stdlib = map[string]string{\n")
- f := io.MultiReader(
- mustOpen(api("go1.txt")),
- mustOpen(api("go1.1.txt")),
- mustOpen(api("go1.2.txt")),
- )
- sc := bufio.NewScanner(f)
- fullImport := map[string]string{} // "zip.NewReader" => "archive/zip"
- ambiguous := map[string]bool{}
- var keys []string
- for sc.Scan() {
- l := sc.Text()
- has := func(v string) bool { return strings.Contains(l, v) }
- if has("struct, ") || has("interface, ") || has(", method (") {
- continue
- }
- if m := sym.FindStringSubmatch(l); m != nil {
- full := m[1]
- key := path.Base(full) + "." + m[2]
- if exist, ok := fullImport[key]; ok {
- if exist != full {
- ambiguous[key] = true
- }
- } else {
- fullImport[key] = full
- keys = append(keys, key)
- }
- }
- }
- if err := sc.Err(); err != nil {
- log.Fatal(err)
- }
- sort.Strings(keys)
- for _, key := range keys {
- if ambiguous[key] {
- outf("\t// %q is ambiguous\n", key)
- } else {
- outf("\t%q: %q,\n", key, fullImport[key])
- }
- }
- outf("}\n")
- fmtbuf, err := format.Source(buf.Bytes())
- if err != nil {
- log.Fatal(err)
- }
- os.Stdout.Write(fmtbuf)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/sortimports.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/sortimports.go
deleted file mode 100644
index 68b3dc4e..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/sortimports.go
+++ /dev/null
@@ -1,214 +0,0 @@
-// +build go1.2
-
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Hacked up copy of go/ast/import.go
-
-package imports
-
-import (
- "go/ast"
- "go/token"
- "sort"
- "strconv"
-)
-
-// sortImports sorts runs of consecutive import lines in import blocks in f.
-// It also removes duplicate imports when it is possible to do so without data loss.
-func sortImports(fset *token.FileSet, f *ast.File) {
- for i, d := range f.Decls {
- d, ok := d.(*ast.GenDecl)
- if !ok || d.Tok != token.IMPORT {
- // Not an import declaration, so we're done.
- // Imports are always first.
- break
- }
-
- if len(d.Specs) == 0 {
- // Empty import block, remove it.
- f.Decls = append(f.Decls[:i], f.Decls[i+1:]...)
- }
-
- if !d.Lparen.IsValid() {
- // Not a block: sorted by default.
- continue
- }
-
- // Identify and sort runs of specs on successive lines.
- i := 0
- specs := d.Specs[:0]
- for j, s := range d.Specs {
- if j > i && fset.Position(s.Pos()).Line > 1+fset.Position(d.Specs[j-1].End()).Line {
- // j begins a new run. End this one.
- specs = append(specs, sortSpecs(fset, f, d.Specs[i:j])...)
- i = j
- }
- }
- specs = append(specs, sortSpecs(fset, f, d.Specs[i:])...)
- d.Specs = specs
-
- // Deduping can leave a blank line before the rparen; clean that up.
- if len(d.Specs) > 0 {
- lastSpec := d.Specs[len(d.Specs)-1]
- lastLine := fset.Position(lastSpec.Pos()).Line
- if rParenLine := fset.Position(d.Rparen).Line; rParenLine > lastLine+1 {
- fset.File(d.Rparen).MergeLine(rParenLine - 1)
- }
- }
- }
-}
-
-func importPath(s ast.Spec) string {
- t, err := strconv.Unquote(s.(*ast.ImportSpec).Path.Value)
- if err == nil {
- return t
- }
- return ""
-}
-
-func importName(s ast.Spec) string {
- n := s.(*ast.ImportSpec).Name
- if n == nil {
- return ""
- }
- return n.Name
-}
-
-func importComment(s ast.Spec) string {
- c := s.(*ast.ImportSpec).Comment
- if c == nil {
- return ""
- }
- return c.Text()
-}
-
-// collapse indicates whether prev may be removed, leaving only next.
-func collapse(prev, next ast.Spec) bool {
- if importPath(next) != importPath(prev) || importName(next) != importName(prev) {
- return false
- }
- return prev.(*ast.ImportSpec).Comment == nil
-}
-
-type posSpan struct {
- Start token.Pos
- End token.Pos
-}
-
-func sortSpecs(fset *token.FileSet, f *ast.File, specs []ast.Spec) []ast.Spec {
- // Can't short-circuit here even if specs are already sorted,
- // since they might yet need deduplication.
- // A lone import, however, may be safely ignored.
- if len(specs) <= 1 {
- return specs
- }
-
- // Record positions for specs.
- pos := make([]posSpan, len(specs))
- for i, s := range specs {
- pos[i] = posSpan{s.Pos(), s.End()}
- }
-
- // Identify comments in this range.
- // Any comment from pos[0].Start to the final line counts.
- lastLine := fset.Position(pos[len(pos)-1].End).Line
- cstart := len(f.Comments)
- cend := len(f.Comments)
- for i, g := range f.Comments {
- if g.Pos() < pos[0].Start {
- continue
- }
- if i < cstart {
- cstart = i
- }
- if fset.Position(g.End()).Line > lastLine {
- cend = i
- break
- }
- }
- comments := f.Comments[cstart:cend]
-
- // Assign each comment to the import spec preceding it.
- importComment := map[*ast.ImportSpec][]*ast.CommentGroup{}
- specIndex := 0
- for _, g := range comments {
- for specIndex+1 < len(specs) && pos[specIndex+1].Start <= g.Pos() {
- specIndex++
- }
- s := specs[specIndex].(*ast.ImportSpec)
- importComment[s] = append(importComment[s], g)
- }
-
- // Sort the import specs by import path.
- // Remove duplicates, when possible without data loss.
- // Reassign the import paths to have the same position sequence.
- // Reassign each comment to abut the end of its spec.
- // Sort the comments by new position.
- sort.Sort(byImportSpec(specs))
-
- // Dedup. Thanks to our sorting, we can just consider
- // adjacent pairs of imports.
- deduped := specs[:0]
- for i, s := range specs {
- if i == len(specs)-1 || !collapse(s, specs[i+1]) {
- deduped = append(deduped, s)
- } else {
- p := s.Pos()
- fset.File(p).MergeLine(fset.Position(p).Line)
- }
- }
- specs = deduped
-
- // Fix up comment positions
- for i, s := range specs {
- s := s.(*ast.ImportSpec)
- if s.Name != nil {
- s.Name.NamePos = pos[i].Start
- }
- s.Path.ValuePos = pos[i].Start
- s.EndPos = pos[i].End
- for _, g := range importComment[s] {
- for _, c := range g.List {
- c.Slash = pos[i].End
- }
- }
- }
-
- sort.Sort(byCommentPos(comments))
-
- return specs
-}
-
-type byImportSpec []ast.Spec // slice of *ast.ImportSpec
-
-func (x byImportSpec) Len() int { return len(x) }
-func (x byImportSpec) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-func (x byImportSpec) Less(i, j int) bool {
- ipath := importPath(x[i])
- jpath := importPath(x[j])
-
- igroup := importGroup(ipath)
- jgroup := importGroup(jpath)
- if igroup != jgroup {
- return igroup < jgroup
- }
-
- if ipath != jpath {
- return ipath < jpath
- }
- iname := importName(x[i])
- jname := importName(x[j])
-
- if iname != jname {
- return iname < jname
- }
- return importComment(x[i]) < importComment(x[j])
-}
-
-type byCommentPos []*ast.CommentGroup
-
-func (x byCommentPos) Len() int { return len(x) }
-func (x byCommentPos) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-func (x byCommentPos) Less(i, j int) bool { return x[i].Pos() < x[j].Pos() }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/sortimports_compat.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/sortimports_compat.go
deleted file mode 100644
index 295f237a..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/sortimports_compat.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// +build !go1.2
-
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package imports
-
-import "go/ast"
-
-// Go 1.1 users don't get fancy package grouping.
-// But this is still gofmt-compliant:
-
-var sortImports = ast.SortImports
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/zstdlib.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/zstdlib.go
deleted file mode 100644
index 6cdc0334..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/imports/zstdlib.go
+++ /dev/null
@@ -1,8374 +0,0 @@
-// AUTO-GENERATED BY mkstdlib.go
-
-package imports
-
-var stdlib = map[string]string{
- "adler32.Checksum": "hash/adler32",
- "adler32.New": "hash/adler32",
- "adler32.Size": "hash/adler32",
- "aes.BlockSize": "crypto/aes",
- "aes.KeySizeError": "crypto/aes",
- "aes.NewCipher": "crypto/aes",
- "ascii85.CorruptInputError": "encoding/ascii85",
- "ascii85.Decode": "encoding/ascii85",
- "ascii85.Encode": "encoding/ascii85",
- "ascii85.MaxEncodedLen": "encoding/ascii85",
- "ascii85.NewDecoder": "encoding/ascii85",
- "ascii85.NewEncoder": "encoding/ascii85",
- "asn1.BitString": "encoding/asn1",
- "asn1.Enumerated": "encoding/asn1",
- "asn1.Flag": "encoding/asn1",
- "asn1.Marshal": "encoding/asn1",
- "asn1.ObjectIdentifier": "encoding/asn1",
- "asn1.RawContent": "encoding/asn1",
- "asn1.RawValue": "encoding/asn1",
- "asn1.StructuralError": "encoding/asn1",
- "asn1.SyntaxError": "encoding/asn1",
- "asn1.Unmarshal": "encoding/asn1",
- "asn1.UnmarshalWithParams": "encoding/asn1",
- "ast.ArrayType": "go/ast",
- "ast.AssignStmt": "go/ast",
- "ast.Bad": "go/ast",
- "ast.BadDecl": "go/ast",
- "ast.BadExpr": "go/ast",
- "ast.BadStmt": "go/ast",
- "ast.BasicLit": "go/ast",
- "ast.BinaryExpr": "go/ast",
- "ast.BlockStmt": "go/ast",
- "ast.BranchStmt": "go/ast",
- "ast.CallExpr": "go/ast",
- "ast.CaseClause": "go/ast",
- "ast.ChanDir": "go/ast",
- "ast.ChanType": "go/ast",
- "ast.CommClause": "go/ast",
- "ast.Comment": "go/ast",
- "ast.CommentGroup": "go/ast",
- "ast.CommentMap": "go/ast",
- "ast.CompositeLit": "go/ast",
- "ast.Con": "go/ast",
- "ast.DeclStmt": "go/ast",
- "ast.DeferStmt": "go/ast",
- "ast.Ellipsis": "go/ast",
- "ast.EmptyStmt": "go/ast",
- "ast.ExprStmt": "go/ast",
- "ast.Field": "go/ast",
- "ast.FieldFilter": "go/ast",
- "ast.FieldList": "go/ast",
- "ast.File": "go/ast",
- "ast.FileExports": "go/ast",
- "ast.Filter": "go/ast",
- "ast.FilterDecl": "go/ast",
- "ast.FilterFile": "go/ast",
- "ast.FilterFuncDuplicates": "go/ast",
- "ast.FilterImportDuplicates": "go/ast",
- "ast.FilterPackage": "go/ast",
- "ast.FilterUnassociatedComments": "go/ast",
- "ast.ForStmt": "go/ast",
- "ast.Fprint": "go/ast",
- "ast.Fun": "go/ast",
- "ast.FuncDecl": "go/ast",
- "ast.FuncLit": "go/ast",
- "ast.FuncType": "go/ast",
- "ast.GenDecl": "go/ast",
- "ast.GoStmt": "go/ast",
- "ast.Ident": "go/ast",
- "ast.IfStmt": "go/ast",
- "ast.ImportSpec": "go/ast",
- "ast.Importer": "go/ast",
- "ast.IncDecStmt": "go/ast",
- "ast.IndexExpr": "go/ast",
- "ast.Inspect": "go/ast",
- "ast.InterfaceType": "go/ast",
- "ast.IsExported": "go/ast",
- "ast.KeyValueExpr": "go/ast",
- "ast.LabeledStmt": "go/ast",
- "ast.Lbl": "go/ast",
- "ast.MapType": "go/ast",
- "ast.MergeMode": "go/ast",
- "ast.MergePackageFiles": "go/ast",
- "ast.NewCommentMap": "go/ast",
- "ast.NewIdent": "go/ast",
- "ast.NewObj": "go/ast",
- "ast.NewPackage": "go/ast",
- "ast.NewScope": "go/ast",
- "ast.Node": "go/ast",
- "ast.NotNilFilter": "go/ast",
- "ast.ObjKind": "go/ast",
- "ast.Object": "go/ast",
- "ast.Package": "go/ast",
- "ast.PackageExports": "go/ast",
- "ast.ParenExpr": "go/ast",
- "ast.Pkg": "go/ast",
- "ast.Print": "go/ast",
- "ast.RECV": "go/ast",
- "ast.RangeStmt": "go/ast",
- "ast.ReturnStmt": "go/ast",
- "ast.SEND": "go/ast",
- "ast.Scope": "go/ast",
- "ast.SelectStmt": "go/ast",
- "ast.SelectorExpr": "go/ast",
- "ast.SendStmt": "go/ast",
- "ast.SliceExpr": "go/ast",
- "ast.SortImports": "go/ast",
- "ast.StarExpr": "go/ast",
- "ast.StructType": "go/ast",
- "ast.SwitchStmt": "go/ast",
- "ast.Typ": "go/ast",
- "ast.TypeAssertExpr": "go/ast",
- "ast.TypeSpec": "go/ast",
- "ast.TypeSwitchStmt": "go/ast",
- "ast.UnaryExpr": "go/ast",
- "ast.ValueSpec": "go/ast",
- "ast.Var": "go/ast",
- "ast.Visitor": "go/ast",
- "ast.Walk": "go/ast",
- "atomic.AddInt32": "sync/atomic",
- "atomic.AddInt64": "sync/atomic",
- "atomic.AddUint32": "sync/atomic",
- "atomic.AddUint64": "sync/atomic",
- "atomic.AddUintptr": "sync/atomic",
- "atomic.CompareAndSwapInt32": "sync/atomic",
- "atomic.CompareAndSwapInt64": "sync/atomic",
- "atomic.CompareAndSwapPointer": "sync/atomic",
- "atomic.CompareAndSwapUint32": "sync/atomic",
- "atomic.CompareAndSwapUint64": "sync/atomic",
- "atomic.CompareAndSwapUintptr": "sync/atomic",
- "atomic.LoadInt32": "sync/atomic",
- "atomic.LoadInt64": "sync/atomic",
- "atomic.LoadPointer": "sync/atomic",
- "atomic.LoadUint32": "sync/atomic",
- "atomic.LoadUint64": "sync/atomic",
- "atomic.LoadUintptr": "sync/atomic",
- "atomic.StoreInt32": "sync/atomic",
- "atomic.StoreInt64": "sync/atomic",
- "atomic.StorePointer": "sync/atomic",
- "atomic.StoreUint32": "sync/atomic",
- "atomic.StoreUint64": "sync/atomic",
- "atomic.StoreUintptr": "sync/atomic",
- "atomic.SwapInt32": "sync/atomic",
- "atomic.SwapInt64": "sync/atomic",
- "atomic.SwapPointer": "sync/atomic",
- "atomic.SwapUint32": "sync/atomic",
- "atomic.SwapUint64": "sync/atomic",
- "atomic.SwapUintptr": "sync/atomic",
- "base32.CorruptInputError": "encoding/base32",
- "base32.Encoding": "encoding/base32",
- "base32.HexEncoding": "encoding/base32",
- "base32.NewDecoder": "encoding/base32",
- "base32.NewEncoder": "encoding/base32",
- "base32.NewEncoding": "encoding/base32",
- "base32.StdEncoding": "encoding/base32",
- "base64.CorruptInputError": "encoding/base64",
- "base64.Encoding": "encoding/base64",
- "base64.NewDecoder": "encoding/base64",
- "base64.NewEncoder": "encoding/base64",
- "base64.NewEncoding": "encoding/base64",
- "base64.StdEncoding": "encoding/base64",
- "base64.URLEncoding": "encoding/base64",
- "big.Int": "math/big",
- "big.MaxBase": "math/big",
- "big.NewInt": "math/big",
- "big.NewRat": "math/big",
- "big.Rat": "math/big",
- "big.Word": "math/big",
- "binary.BigEndian": "encoding/binary",
- "binary.ByteOrder": "encoding/binary",
- "binary.LittleEndian": "encoding/binary",
- "binary.MaxVarintLen16": "encoding/binary",
- "binary.MaxVarintLen32": "encoding/binary",
- "binary.MaxVarintLen64": "encoding/binary",
- "binary.PutUvarint": "encoding/binary",
- "binary.PutVarint": "encoding/binary",
- "binary.Read": "encoding/binary",
- "binary.ReadUvarint": "encoding/binary",
- "binary.ReadVarint": "encoding/binary",
- "binary.Size": "encoding/binary",
- "binary.Uvarint": "encoding/binary",
- "binary.Varint": "encoding/binary",
- "binary.Write": "encoding/binary",
- "bufio.ErrAdvanceTooFar": "bufio",
- "bufio.ErrBufferFull": "bufio",
- "bufio.ErrInvalidUnreadByte": "bufio",
- "bufio.ErrInvalidUnreadRune": "bufio",
- "bufio.ErrNegativeAdvance": "bufio",
- "bufio.ErrNegativeCount": "bufio",
- "bufio.ErrTooLong": "bufio",
- "bufio.MaxScanTokenSize": "bufio",
- "bufio.NewReadWriter": "bufio",
- "bufio.NewReader": "bufio",
- "bufio.NewReaderSize": "bufio",
- "bufio.NewScanner": "bufio",
- "bufio.NewWriter": "bufio",
- "bufio.NewWriterSize": "bufio",
- "bufio.ReadWriter": "bufio",
- "bufio.Reader": "bufio",
- "bufio.ScanBytes": "bufio",
- "bufio.ScanLines": "bufio",
- "bufio.ScanRunes": "bufio",
- "bufio.ScanWords": "bufio",
- "bufio.Scanner": "bufio",
- "bufio.SplitFunc": "bufio",
- "bufio.Writer": "bufio",
- "build.AllowBinary": "go/build",
- "build.ArchChar": "go/build",
- "build.Context": "go/build",
- "build.Default": "go/build",
- "build.FindOnly": "go/build",
- "build.Import": "go/build",
- "build.ImportDir": "go/build",
- "build.ImportMode": "go/build",
- "build.IsLocalImport": "go/build",
- "build.NoGoError": "go/build",
- "build.Package": "go/build",
- "build.ToolDir": "go/build",
- "bytes.Buffer": "bytes",
- "bytes.Compare": "bytes",
- "bytes.Contains": "bytes",
- "bytes.Count": "bytes",
- "bytes.Equal": "bytes",
- "bytes.EqualFold": "bytes",
- "bytes.ErrTooLarge": "bytes",
- "bytes.Fields": "bytes",
- "bytes.FieldsFunc": "bytes",
- "bytes.HasPrefix": "bytes",
- "bytes.HasSuffix": "bytes",
- "bytes.Index": "bytes",
- "bytes.IndexAny": "bytes",
- "bytes.IndexByte": "bytes",
- "bytes.IndexFunc": "bytes",
- "bytes.IndexRune": "bytes",
- "bytes.Join": "bytes",
- "bytes.LastIndex": "bytes",
- "bytes.LastIndexAny": "bytes",
- "bytes.LastIndexFunc": "bytes",
- "bytes.Map": "bytes",
- "bytes.MinRead": "bytes",
- "bytes.NewBuffer": "bytes",
- "bytes.NewBufferString": "bytes",
- "bytes.NewReader": "bytes",
- "bytes.Reader": "bytes",
- "bytes.Repeat": "bytes",
- "bytes.Replace": "bytes",
- "bytes.Runes": "bytes",
- "bytes.Split": "bytes",
- "bytes.SplitAfter": "bytes",
- "bytes.SplitAfterN": "bytes",
- "bytes.SplitN": "bytes",
- "bytes.Title": "bytes",
- "bytes.ToLower": "bytes",
- "bytes.ToLowerSpecial": "bytes",
- "bytes.ToTitle": "bytes",
- "bytes.ToTitleSpecial": "bytes",
- "bytes.ToUpper": "bytes",
- "bytes.ToUpperSpecial": "bytes",
- "bytes.Trim": "bytes",
- "bytes.TrimFunc": "bytes",
- "bytes.TrimLeft": "bytes",
- "bytes.TrimLeftFunc": "bytes",
- "bytes.TrimPrefix": "bytes",
- "bytes.TrimRight": "bytes",
- "bytes.TrimRightFunc": "bytes",
- "bytes.TrimSpace": "bytes",
- "bytes.TrimSuffix": "bytes",
- "bzip2.NewReader": "compress/bzip2",
- "bzip2.StructuralError": "compress/bzip2",
- "cgi.Handler": "net/http/cgi",
- "cgi.Request": "net/http/cgi",
- "cgi.RequestFromMap": "net/http/cgi",
- "cgi.Serve": "net/http/cgi",
- "cipher.AEAD": "crypto/cipher",
- "cipher.Block": "crypto/cipher",
- "cipher.BlockMode": "crypto/cipher",
- "cipher.NewCBCDecrypter": "crypto/cipher",
- "cipher.NewCBCEncrypter": "crypto/cipher",
- "cipher.NewCFBDecrypter": "crypto/cipher",
- "cipher.NewCFBEncrypter": "crypto/cipher",
- "cipher.NewCTR": "crypto/cipher",
- "cipher.NewGCM": "crypto/cipher",
- "cipher.NewOFB": "crypto/cipher",
- "cipher.Stream": "crypto/cipher",
- "cipher.StreamReader": "crypto/cipher",
- "cipher.StreamWriter": "crypto/cipher",
- "cmplx.Abs": "math/cmplx",
- "cmplx.Acos": "math/cmplx",
- "cmplx.Acosh": "math/cmplx",
- "cmplx.Asin": "math/cmplx",
- "cmplx.Asinh": "math/cmplx",
- "cmplx.Atan": "math/cmplx",
- "cmplx.Atanh": "math/cmplx",
- "cmplx.Conj": "math/cmplx",
- "cmplx.Cos": "math/cmplx",
- "cmplx.Cosh": "math/cmplx",
- "cmplx.Cot": "math/cmplx",
- "cmplx.Exp": "math/cmplx",
- "cmplx.Inf": "math/cmplx",
- "cmplx.IsInf": "math/cmplx",
- "cmplx.IsNaN": "math/cmplx",
- "cmplx.Log": "math/cmplx",
- "cmplx.Log10": "math/cmplx",
- "cmplx.NaN": "math/cmplx",
- "cmplx.Phase": "math/cmplx",
- "cmplx.Polar": "math/cmplx",
- "cmplx.Pow": "math/cmplx",
- "cmplx.Rect": "math/cmplx",
- "cmplx.Sin": "math/cmplx",
- "cmplx.Sinh": "math/cmplx",
- "cmplx.Sqrt": "math/cmplx",
- "cmplx.Tan": "math/cmplx",
- "cmplx.Tanh": "math/cmplx",
- "color.Alpha": "image/color",
- "color.Alpha16": "image/color",
- "color.Alpha16Model": "image/color",
- "color.AlphaModel": "image/color",
- "color.Black": "image/color",
- "color.Color": "image/color",
- "color.Gray": "image/color",
- "color.Gray16": "image/color",
- "color.Gray16Model": "image/color",
- "color.GrayModel": "image/color",
- "color.Model": "image/color",
- "color.ModelFunc": "image/color",
- "color.NRGBA": "image/color",
- "color.NRGBA64": "image/color",
- "color.NRGBA64Model": "image/color",
- "color.NRGBAModel": "image/color",
- "color.Opaque": "image/color",
- "color.Palette": "image/color",
- "color.RGBA": "image/color",
- "color.RGBA64": "image/color",
- "color.RGBA64Model": "image/color",
- "color.RGBAModel": "image/color",
- "color.RGBToYCbCr": "image/color",
- "color.Transparent": "image/color",
- "color.White": "image/color",
- "color.YCbCr": "image/color",
- "color.YCbCrModel": "image/color",
- "color.YCbCrToRGB": "image/color",
- "cookiejar.Jar": "net/http/cookiejar",
- "cookiejar.New": "net/http/cookiejar",
- "cookiejar.Options": "net/http/cookiejar",
- "cookiejar.PublicSuffixList": "net/http/cookiejar",
- "crc32.Castagnoli": "hash/crc32",
- "crc32.Checksum": "hash/crc32",
- "crc32.ChecksumIEEE": "hash/crc32",
- "crc32.IEEE": "hash/crc32",
- "crc32.IEEETable": "hash/crc32",
- "crc32.Koopman": "hash/crc32",
- "crc32.MakeTable": "hash/crc32",
- "crc32.New": "hash/crc32",
- "crc32.NewIEEE": "hash/crc32",
- "crc32.Size": "hash/crc32",
- "crc32.Table": "hash/crc32",
- "crc32.Update": "hash/crc32",
- "crc64.Checksum": "hash/crc64",
- "crc64.ECMA": "hash/crc64",
- "crc64.ISO": "hash/crc64",
- "crc64.MakeTable": "hash/crc64",
- "crc64.New": "hash/crc64",
- "crc64.Size": "hash/crc64",
- "crc64.Table": "hash/crc64",
- "crc64.Update": "hash/crc64",
- "crypto.Hash": "crypto",
- "crypto.MD4": "crypto",
- "crypto.MD5": "crypto",
- "crypto.MD5SHA1": "crypto",
- "crypto.PrivateKey": "crypto",
- "crypto.PublicKey": "crypto",
- "crypto.RIPEMD160": "crypto",
- "crypto.RegisterHash": "crypto",
- "crypto.SHA1": "crypto",
- "crypto.SHA224": "crypto",
- "crypto.SHA256": "crypto",
- "crypto.SHA384": "crypto",
- "crypto.SHA512": "crypto",
- "csv.ErrBareQuote": "encoding/csv",
- "csv.ErrFieldCount": "encoding/csv",
- "csv.ErrQuote": "encoding/csv",
- "csv.ErrTrailingComma": "encoding/csv",
- "csv.NewReader": "encoding/csv",
- "csv.NewWriter": "encoding/csv",
- "csv.ParseError": "encoding/csv",
- "csv.Reader": "encoding/csv",
- "csv.Writer": "encoding/csv",
- "debug.FreeOSMemory": "runtime/debug",
- "debug.GCStats": "runtime/debug",
- "debug.PrintStack": "runtime/debug",
- "debug.ReadGCStats": "runtime/debug",
- "debug.SetGCPercent": "runtime/debug",
- "debug.SetMaxStack": "runtime/debug",
- "debug.SetMaxThreads": "runtime/debug",
- "debug.Stack": "runtime/debug",
- "des.BlockSize": "crypto/des",
- "des.KeySizeError": "crypto/des",
- "des.NewCipher": "crypto/des",
- "des.NewTripleDESCipher": "crypto/des",
- "doc.AllDecls": "go/doc",
- "doc.AllMethods": "go/doc",
- "doc.Example": "go/doc",
- "doc.Examples": "go/doc",
- "doc.Filter": "go/doc",
- "doc.Func": "go/doc",
- "doc.IllegalPrefixes": "go/doc",
- "doc.Mode": "go/doc",
- "doc.New": "go/doc",
- "doc.Note": "go/doc",
- "doc.Package": "go/doc",
- "doc.Synopsis": "go/doc",
- "doc.ToHTML": "go/doc",
- "doc.ToText": "go/doc",
- "doc.Type": "go/doc",
- "doc.Value": "go/doc",
- "draw.Draw": "image/draw",
- "draw.DrawMask": "image/draw",
- "draw.Drawer": "image/draw",
- "draw.FloydSteinberg": "image/draw",
- "draw.Image": "image/draw",
- "draw.Op": "image/draw",
- "draw.Over": "image/draw",
- "draw.Quantizer": "image/draw",
- "draw.Src": "image/draw",
- "driver.Bool": "database/sql/driver",
- "driver.ColumnConverter": "database/sql/driver",
- "driver.Conn": "database/sql/driver",
- "driver.DefaultParameterConverter": "database/sql/driver",
- "driver.Driver": "database/sql/driver",
- "driver.ErrBadConn": "database/sql/driver",
- "driver.ErrSkip": "database/sql/driver",
- "driver.Execer": "database/sql/driver",
- "driver.Int32": "database/sql/driver",
- "driver.IsScanValue": "database/sql/driver",
- "driver.IsValue": "database/sql/driver",
- "driver.NotNull": "database/sql/driver",
- "driver.Null": "database/sql/driver",
- "driver.Queryer": "database/sql/driver",
- "driver.Result": "database/sql/driver",
- "driver.ResultNoRows": "database/sql/driver",
- "driver.Rows": "database/sql/driver",
- "driver.RowsAffected": "database/sql/driver",
- "driver.Stmt": "database/sql/driver",
- "driver.String": "database/sql/driver",
- "driver.Tx": "database/sql/driver",
- "driver.Value": "database/sql/driver",
- "driver.ValueConverter": "database/sql/driver",
- "driver.Valuer": "database/sql/driver",
- "dsa.ErrInvalidPublicKey": "crypto/dsa",
- "dsa.GenerateKey": "crypto/dsa",
- "dsa.GenerateParameters": "crypto/dsa",
- "dsa.L1024N160": "crypto/dsa",
- "dsa.L2048N224": "crypto/dsa",
- "dsa.L2048N256": "crypto/dsa",
- "dsa.L3072N256": "crypto/dsa",
- "dsa.ParameterSizes": "crypto/dsa",
- "dsa.Parameters": "crypto/dsa",
- "dsa.PrivateKey": "crypto/dsa",
- "dsa.PublicKey": "crypto/dsa",
- "dsa.Sign": "crypto/dsa",
- "dsa.Verify": "crypto/dsa",
- "dwarf.AddrType": "debug/dwarf",
- "dwarf.ArrayType": "debug/dwarf",
- "dwarf.Attr": "debug/dwarf",
- "dwarf.AttrAbstractOrigin": "debug/dwarf",
- "dwarf.AttrAccessibility": "debug/dwarf",
- "dwarf.AttrAddrClass": "debug/dwarf",
- "dwarf.AttrAllocated": "debug/dwarf",
- "dwarf.AttrArtificial": "debug/dwarf",
- "dwarf.AttrAssociated": "debug/dwarf",
- "dwarf.AttrBaseTypes": "debug/dwarf",
- "dwarf.AttrBitOffset": "debug/dwarf",
- "dwarf.AttrBitSize": "debug/dwarf",
- "dwarf.AttrByteSize": "debug/dwarf",
- "dwarf.AttrCallColumn": "debug/dwarf",
- "dwarf.AttrCallFile": "debug/dwarf",
- "dwarf.AttrCallLine": "debug/dwarf",
- "dwarf.AttrCalling": "debug/dwarf",
- "dwarf.AttrCommonRef": "debug/dwarf",
- "dwarf.AttrCompDir": "debug/dwarf",
- "dwarf.AttrConstValue": "debug/dwarf",
- "dwarf.AttrContainingType": "debug/dwarf",
- "dwarf.AttrCount": "debug/dwarf",
- "dwarf.AttrDataLocation": "debug/dwarf",
- "dwarf.AttrDataMemberLoc": "debug/dwarf",
- "dwarf.AttrDeclColumn": "debug/dwarf",
- "dwarf.AttrDeclFile": "debug/dwarf",
- "dwarf.AttrDeclLine": "debug/dwarf",
- "dwarf.AttrDeclaration": "debug/dwarf",
- "dwarf.AttrDefaultValue": "debug/dwarf",
- "dwarf.AttrDescription": "debug/dwarf",
- "dwarf.AttrDiscr": "debug/dwarf",
- "dwarf.AttrDiscrList": "debug/dwarf",
- "dwarf.AttrDiscrValue": "debug/dwarf",
- "dwarf.AttrEncoding": "debug/dwarf",
- "dwarf.AttrEntrypc": "debug/dwarf",
- "dwarf.AttrExtension": "debug/dwarf",
- "dwarf.AttrExternal": "debug/dwarf",
- "dwarf.AttrFrameBase": "debug/dwarf",
- "dwarf.AttrFriend": "debug/dwarf",
- "dwarf.AttrHighpc": "debug/dwarf",
- "dwarf.AttrIdentifierCase": "debug/dwarf",
- "dwarf.AttrImport": "debug/dwarf",
- "dwarf.AttrInline": "debug/dwarf",
- "dwarf.AttrIsOptional": "debug/dwarf",
- "dwarf.AttrLanguage": "debug/dwarf",
- "dwarf.AttrLocation": "debug/dwarf",
- "dwarf.AttrLowerBound": "debug/dwarf",
- "dwarf.AttrLowpc": "debug/dwarf",
- "dwarf.AttrMacroInfo": "debug/dwarf",
- "dwarf.AttrName": "debug/dwarf",
- "dwarf.AttrNamelistItem": "debug/dwarf",
- "dwarf.AttrOrdering": "debug/dwarf",
- "dwarf.AttrPriority": "debug/dwarf",
- "dwarf.AttrProducer": "debug/dwarf",
- "dwarf.AttrPrototyped": "debug/dwarf",
- "dwarf.AttrRanges": "debug/dwarf",
- "dwarf.AttrReturnAddr": "debug/dwarf",
- "dwarf.AttrSegment": "debug/dwarf",
- "dwarf.AttrSibling": "debug/dwarf",
- "dwarf.AttrSpecification": "debug/dwarf",
- "dwarf.AttrStartScope": "debug/dwarf",
- "dwarf.AttrStaticLink": "debug/dwarf",
- "dwarf.AttrStmtList": "debug/dwarf",
- "dwarf.AttrStride": "debug/dwarf",
- "dwarf.AttrStrideSize": "debug/dwarf",
- "dwarf.AttrStringLength": "debug/dwarf",
- "dwarf.AttrTrampoline": "debug/dwarf",
- "dwarf.AttrType": "debug/dwarf",
- "dwarf.AttrUpperBound": "debug/dwarf",
- "dwarf.AttrUseLocation": "debug/dwarf",
- "dwarf.AttrUseUTF8": "debug/dwarf",
- "dwarf.AttrVarParam": "debug/dwarf",
- "dwarf.AttrVirtuality": "debug/dwarf",
- "dwarf.AttrVisibility": "debug/dwarf",
- "dwarf.AttrVtableElemLoc": "debug/dwarf",
- "dwarf.BasicType": "debug/dwarf",
- "dwarf.BoolType": "debug/dwarf",
- "dwarf.CharType": "debug/dwarf",
- "dwarf.CommonType": "debug/dwarf",
- "dwarf.ComplexType": "debug/dwarf",
- "dwarf.Data": "debug/dwarf",
- "dwarf.DecodeError": "debug/dwarf",
- "dwarf.DotDotDotType": "debug/dwarf",
- "dwarf.Entry": "debug/dwarf",
- "dwarf.EnumType": "debug/dwarf",
- "dwarf.EnumValue": "debug/dwarf",
- "dwarf.Field": "debug/dwarf",
- "dwarf.FloatType": "debug/dwarf",
- "dwarf.FuncType": "debug/dwarf",
- "dwarf.IntType": "debug/dwarf",
- "dwarf.New": "debug/dwarf",
- "dwarf.Offset": "debug/dwarf",
- "dwarf.PtrType": "debug/dwarf",
- "dwarf.QualType": "debug/dwarf",
- "dwarf.Reader": "debug/dwarf",
- "dwarf.StructField": "debug/dwarf",
- "dwarf.StructType": "debug/dwarf",
- "dwarf.Tag": "debug/dwarf",
- "dwarf.TagAccessDeclaration": "debug/dwarf",
- "dwarf.TagArrayType": "debug/dwarf",
- "dwarf.TagBaseType": "debug/dwarf",
- "dwarf.TagCatchDwarfBlock": "debug/dwarf",
- "dwarf.TagClassType": "debug/dwarf",
- "dwarf.TagCommonDwarfBlock": "debug/dwarf",
- "dwarf.TagCommonInclusion": "debug/dwarf",
- "dwarf.TagCompileUnit": "debug/dwarf",
- "dwarf.TagConstType": "debug/dwarf",
- "dwarf.TagConstant": "debug/dwarf",
- "dwarf.TagDwarfProcedure": "debug/dwarf",
- "dwarf.TagEntryPoint": "debug/dwarf",
- "dwarf.TagEnumerationType": "debug/dwarf",
- "dwarf.TagEnumerator": "debug/dwarf",
- "dwarf.TagFileType": "debug/dwarf",
- "dwarf.TagFormalParameter": "debug/dwarf",
- "dwarf.TagFriend": "debug/dwarf",
- "dwarf.TagImportedDeclaration": "debug/dwarf",
- "dwarf.TagImportedModule": "debug/dwarf",
- "dwarf.TagImportedUnit": "debug/dwarf",
- "dwarf.TagInheritance": "debug/dwarf",
- "dwarf.TagInlinedSubroutine": "debug/dwarf",
- "dwarf.TagInterfaceType": "debug/dwarf",
- "dwarf.TagLabel": "debug/dwarf",
- "dwarf.TagLexDwarfBlock": "debug/dwarf",
- "dwarf.TagMember": "debug/dwarf",
- "dwarf.TagModule": "debug/dwarf",
- "dwarf.TagMutableType": "debug/dwarf",
- "dwarf.TagNamelist": "debug/dwarf",
- "dwarf.TagNamelistItem": "debug/dwarf",
- "dwarf.TagNamespace": "debug/dwarf",
- "dwarf.TagPackedType": "debug/dwarf",
- "dwarf.TagPartialUnit": "debug/dwarf",
- "dwarf.TagPointerType": "debug/dwarf",
- "dwarf.TagPtrToMemberType": "debug/dwarf",
- "dwarf.TagReferenceType": "debug/dwarf",
- "dwarf.TagRestrictType": "debug/dwarf",
- "dwarf.TagSetType": "debug/dwarf",
- "dwarf.TagStringType": "debug/dwarf",
- "dwarf.TagStructType": "debug/dwarf",
- "dwarf.TagSubprogram": "debug/dwarf",
- "dwarf.TagSubrangeType": "debug/dwarf",
- "dwarf.TagSubroutineType": "debug/dwarf",
- "dwarf.TagTemplateTypeParameter": "debug/dwarf",
- "dwarf.TagTemplateValueParameter": "debug/dwarf",
- "dwarf.TagThrownType": "debug/dwarf",
- "dwarf.TagTryDwarfBlock": "debug/dwarf",
- "dwarf.TagTypedef": "debug/dwarf",
- "dwarf.TagUnionType": "debug/dwarf",
- "dwarf.TagUnspecifiedParameters": "debug/dwarf",
- "dwarf.TagUnspecifiedType": "debug/dwarf",
- "dwarf.TagVariable": "debug/dwarf",
- "dwarf.TagVariant": "debug/dwarf",
- "dwarf.TagVariantPart": "debug/dwarf",
- "dwarf.TagVolatileType": "debug/dwarf",
- "dwarf.TagWithStmt": "debug/dwarf",
- "dwarf.Type": "debug/dwarf",
- "dwarf.TypedefType": "debug/dwarf",
- "dwarf.UcharType": "debug/dwarf",
- "dwarf.UintType": "debug/dwarf",
- "dwarf.VoidType": "debug/dwarf",
- "ecdsa.GenerateKey": "crypto/ecdsa",
- "ecdsa.PrivateKey": "crypto/ecdsa",
- "ecdsa.PublicKey": "crypto/ecdsa",
- "ecdsa.Sign": "crypto/ecdsa",
- "ecdsa.Verify": "crypto/ecdsa",
- "elf.ARM_MAGIC_TRAMP_NUMBER": "debug/elf",
- "elf.Class": "debug/elf",
- "elf.DF_BIND_NOW": "debug/elf",
- "elf.DF_ORIGIN": "debug/elf",
- "elf.DF_STATIC_TLS": "debug/elf",
- "elf.DF_SYMBOLIC": "debug/elf",
- "elf.DF_TEXTREL": "debug/elf",
- "elf.DT_BIND_NOW": "debug/elf",
- "elf.DT_DEBUG": "debug/elf",
- "elf.DT_ENCODING": "debug/elf",
- "elf.DT_FINI": "debug/elf",
- "elf.DT_FINI_ARRAY": "debug/elf",
- "elf.DT_FINI_ARRAYSZ": "debug/elf",
- "elf.DT_FLAGS": "debug/elf",
- "elf.DT_HASH": "debug/elf",
- "elf.DT_HIOS": "debug/elf",
- "elf.DT_HIPROC": "debug/elf",
- "elf.DT_INIT": "debug/elf",
- "elf.DT_INIT_ARRAY": "debug/elf",
- "elf.DT_INIT_ARRAYSZ": "debug/elf",
- "elf.DT_JMPREL": "debug/elf",
- "elf.DT_LOOS": "debug/elf",
- "elf.DT_LOPROC": "debug/elf",
- "elf.DT_NEEDED": "debug/elf",
- "elf.DT_NULL": "debug/elf",
- "elf.DT_PLTGOT": "debug/elf",
- "elf.DT_PLTREL": "debug/elf",
- "elf.DT_PLTRELSZ": "debug/elf",
- "elf.DT_PREINIT_ARRAY": "debug/elf",
- "elf.DT_PREINIT_ARRAYSZ": "debug/elf",
- "elf.DT_REL": "debug/elf",
- "elf.DT_RELA": "debug/elf",
- "elf.DT_RELAENT": "debug/elf",
- "elf.DT_RELASZ": "debug/elf",
- "elf.DT_RELENT": "debug/elf",
- "elf.DT_RELSZ": "debug/elf",
- "elf.DT_RPATH": "debug/elf",
- "elf.DT_RUNPATH": "debug/elf",
- "elf.DT_SONAME": "debug/elf",
- "elf.DT_STRSZ": "debug/elf",
- "elf.DT_STRTAB": "debug/elf",
- "elf.DT_SYMBOLIC": "debug/elf",
- "elf.DT_SYMENT": "debug/elf",
- "elf.DT_SYMTAB": "debug/elf",
- "elf.DT_TEXTREL": "debug/elf",
- "elf.DT_VERNEED": "debug/elf",
- "elf.DT_VERNEEDNUM": "debug/elf",
- "elf.DT_VERSYM": "debug/elf",
- "elf.Data": "debug/elf",
- "elf.Dyn32": "debug/elf",
- "elf.Dyn64": "debug/elf",
- "elf.DynFlag": "debug/elf",
- "elf.DynTag": "debug/elf",
- "elf.EI_ABIVERSION": "debug/elf",
- "elf.EI_CLASS": "debug/elf",
- "elf.EI_DATA": "debug/elf",
- "elf.EI_NIDENT": "debug/elf",
- "elf.EI_OSABI": "debug/elf",
- "elf.EI_PAD": "debug/elf",
- "elf.EI_VERSION": "debug/elf",
- "elf.ELFCLASS32": "debug/elf",
- "elf.ELFCLASS64": "debug/elf",
- "elf.ELFCLASSNONE": "debug/elf",
- "elf.ELFDATA2LSB": "debug/elf",
- "elf.ELFDATA2MSB": "debug/elf",
- "elf.ELFDATANONE": "debug/elf",
- "elf.ELFMAG": "debug/elf",
- "elf.ELFOSABI_86OPEN": "debug/elf",
- "elf.ELFOSABI_AIX": "debug/elf",
- "elf.ELFOSABI_ARM": "debug/elf",
- "elf.ELFOSABI_FREEBSD": "debug/elf",
- "elf.ELFOSABI_HPUX": "debug/elf",
- "elf.ELFOSABI_HURD": "debug/elf",
- "elf.ELFOSABI_IRIX": "debug/elf",
- "elf.ELFOSABI_LINUX": "debug/elf",
- "elf.ELFOSABI_MODESTO": "debug/elf",
- "elf.ELFOSABI_NETBSD": "debug/elf",
- "elf.ELFOSABI_NONE": "debug/elf",
- "elf.ELFOSABI_NSK": "debug/elf",
- "elf.ELFOSABI_OPENBSD": "debug/elf",
- "elf.ELFOSABI_OPENVMS": "debug/elf",
- "elf.ELFOSABI_SOLARIS": "debug/elf",
- "elf.ELFOSABI_STANDALONE": "debug/elf",
- "elf.ELFOSABI_TRU64": "debug/elf",
- "elf.EM_386": "debug/elf",
- "elf.EM_486": "debug/elf",
- "elf.EM_68HC12": "debug/elf",
- "elf.EM_68K": "debug/elf",
- "elf.EM_860": "debug/elf",
- "elf.EM_88K": "debug/elf",
- "elf.EM_960": "debug/elf",
- "elf.EM_ALPHA": "debug/elf",
- "elf.EM_ALPHA_STD": "debug/elf",
- "elf.EM_ARC": "debug/elf",
- "elf.EM_ARM": "debug/elf",
- "elf.EM_COLDFIRE": "debug/elf",
- "elf.EM_FR20": "debug/elf",
- "elf.EM_H8S": "debug/elf",
- "elf.EM_H8_300": "debug/elf",
- "elf.EM_H8_300H": "debug/elf",
- "elf.EM_H8_500": "debug/elf",
- "elf.EM_IA_64": "debug/elf",
- "elf.EM_M32": "debug/elf",
- "elf.EM_ME16": "debug/elf",
- "elf.EM_MIPS": "debug/elf",
- "elf.EM_MIPS_RS3_LE": "debug/elf",
- "elf.EM_MIPS_RS4_BE": "debug/elf",
- "elf.EM_MIPS_X": "debug/elf",
- "elf.EM_MMA": "debug/elf",
- "elf.EM_NCPU": "debug/elf",
- "elf.EM_NDR1": "debug/elf",
- "elf.EM_NONE": "debug/elf",
- "elf.EM_PARISC": "debug/elf",
- "elf.EM_PCP": "debug/elf",
- "elf.EM_PPC": "debug/elf",
- "elf.EM_PPC64": "debug/elf",
- "elf.EM_RCE": "debug/elf",
- "elf.EM_RH32": "debug/elf",
- "elf.EM_S370": "debug/elf",
- "elf.EM_S390": "debug/elf",
- "elf.EM_SH": "debug/elf",
- "elf.EM_SPARC": "debug/elf",
- "elf.EM_SPARC32PLUS": "debug/elf",
- "elf.EM_SPARCV9": "debug/elf",
- "elf.EM_ST100": "debug/elf",
- "elf.EM_STARCORE": "debug/elf",
- "elf.EM_TINYJ": "debug/elf",
- "elf.EM_TRICORE": "debug/elf",
- "elf.EM_V800": "debug/elf",
- "elf.EM_VPP500": "debug/elf",
- "elf.EM_X86_64": "debug/elf",
- "elf.ET_CORE": "debug/elf",
- "elf.ET_DYN": "debug/elf",
- "elf.ET_EXEC": "debug/elf",
- "elf.ET_HIOS": "debug/elf",
- "elf.ET_HIPROC": "debug/elf",
- "elf.ET_LOOS": "debug/elf",
- "elf.ET_LOPROC": "debug/elf",
- "elf.ET_NONE": "debug/elf",
- "elf.ET_REL": "debug/elf",
- "elf.EV_CURRENT": "debug/elf",
- "elf.EV_NONE": "debug/elf",
- "elf.File": "debug/elf",
- "elf.FileHeader": "debug/elf",
- "elf.FormatError": "debug/elf",
- "elf.Header32": "debug/elf",
- "elf.Header64": "debug/elf",
- "elf.ImportedSymbol": "debug/elf",
- "elf.Machine": "debug/elf",
- "elf.NT_FPREGSET": "debug/elf",
- "elf.NT_PRPSINFO": "debug/elf",
- "elf.NT_PRSTATUS": "debug/elf",
- "elf.NType": "debug/elf",
- "elf.NewFile": "debug/elf",
- "elf.OSABI": "debug/elf",
- "elf.Open": "debug/elf",
- "elf.PF_MASKOS": "debug/elf",
- "elf.PF_MASKPROC": "debug/elf",
- "elf.PF_R": "debug/elf",
- "elf.PF_W": "debug/elf",
- "elf.PF_X": "debug/elf",
- "elf.PT_DYNAMIC": "debug/elf",
- "elf.PT_HIOS": "debug/elf",
- "elf.PT_HIPROC": "debug/elf",
- "elf.PT_INTERP": "debug/elf",
- "elf.PT_LOAD": "debug/elf",
- "elf.PT_LOOS": "debug/elf",
- "elf.PT_LOPROC": "debug/elf",
- "elf.PT_NOTE": "debug/elf",
- "elf.PT_NULL": "debug/elf",
- "elf.PT_PHDR": "debug/elf",
- "elf.PT_SHLIB": "debug/elf",
- "elf.PT_TLS": "debug/elf",
- "elf.Prog": "debug/elf",
- "elf.Prog32": "debug/elf",
- "elf.Prog64": "debug/elf",
- "elf.ProgFlag": "debug/elf",
- "elf.ProgHeader": "debug/elf",
- "elf.ProgType": "debug/elf",
- "elf.R_386": "debug/elf",
- "elf.R_386_32": "debug/elf",
- "elf.R_386_COPY": "debug/elf",
- "elf.R_386_GLOB_DAT": "debug/elf",
- "elf.R_386_GOT32": "debug/elf",
- "elf.R_386_GOTOFF": "debug/elf",
- "elf.R_386_GOTPC": "debug/elf",
- "elf.R_386_JMP_SLOT": "debug/elf",
- "elf.R_386_NONE": "debug/elf",
- "elf.R_386_PC32": "debug/elf",
- "elf.R_386_PLT32": "debug/elf",
- "elf.R_386_RELATIVE": "debug/elf",
- "elf.R_386_TLS_DTPMOD32": "debug/elf",
- "elf.R_386_TLS_DTPOFF32": "debug/elf",
- "elf.R_386_TLS_GD": "debug/elf",
- "elf.R_386_TLS_GD_32": "debug/elf",
- "elf.R_386_TLS_GD_CALL": "debug/elf",
- "elf.R_386_TLS_GD_POP": "debug/elf",
- "elf.R_386_TLS_GD_PUSH": "debug/elf",
- "elf.R_386_TLS_GOTIE": "debug/elf",
- "elf.R_386_TLS_IE": "debug/elf",
- "elf.R_386_TLS_IE_32": "debug/elf",
- "elf.R_386_TLS_LDM": "debug/elf",
- "elf.R_386_TLS_LDM_32": "debug/elf",
- "elf.R_386_TLS_LDM_CALL": "debug/elf",
- "elf.R_386_TLS_LDM_POP": "debug/elf",
- "elf.R_386_TLS_LDM_PUSH": "debug/elf",
- "elf.R_386_TLS_LDO_32": "debug/elf",
- "elf.R_386_TLS_LE": "debug/elf",
- "elf.R_386_TLS_LE_32": "debug/elf",
- "elf.R_386_TLS_TPOFF": "debug/elf",
- "elf.R_386_TLS_TPOFF32": "debug/elf",
- "elf.R_ALPHA": "debug/elf",
- "elf.R_ALPHA_BRADDR": "debug/elf",
- "elf.R_ALPHA_COPY": "debug/elf",
- "elf.R_ALPHA_GLOB_DAT": "debug/elf",
- "elf.R_ALPHA_GPDISP": "debug/elf",
- "elf.R_ALPHA_GPREL32": "debug/elf",
- "elf.R_ALPHA_GPRELHIGH": "debug/elf",
- "elf.R_ALPHA_GPRELLOW": "debug/elf",
- "elf.R_ALPHA_GPVALUE": "debug/elf",
- "elf.R_ALPHA_HINT": "debug/elf",
- "elf.R_ALPHA_IMMED_BR_HI32": "debug/elf",
- "elf.R_ALPHA_IMMED_GP_16": "debug/elf",
- "elf.R_ALPHA_IMMED_GP_HI32": "debug/elf",
- "elf.R_ALPHA_IMMED_LO32": "debug/elf",
- "elf.R_ALPHA_IMMED_SCN_HI32": "debug/elf",
- "elf.R_ALPHA_JMP_SLOT": "debug/elf",
- "elf.R_ALPHA_LITERAL": "debug/elf",
- "elf.R_ALPHA_LITUSE": "debug/elf",
- "elf.R_ALPHA_NONE": "debug/elf",
- "elf.R_ALPHA_OP_PRSHIFT": "debug/elf",
- "elf.R_ALPHA_OP_PSUB": "debug/elf",
- "elf.R_ALPHA_OP_PUSH": "debug/elf",
- "elf.R_ALPHA_OP_STORE": "debug/elf",
- "elf.R_ALPHA_REFLONG": "debug/elf",
- "elf.R_ALPHA_REFQUAD": "debug/elf",
- "elf.R_ALPHA_RELATIVE": "debug/elf",
- "elf.R_ALPHA_SREL16": "debug/elf",
- "elf.R_ALPHA_SREL32": "debug/elf",
- "elf.R_ALPHA_SREL64": "debug/elf",
- "elf.R_ARM": "debug/elf",
- "elf.R_ARM_ABS12": "debug/elf",
- "elf.R_ARM_ABS16": "debug/elf",
- "elf.R_ARM_ABS32": "debug/elf",
- "elf.R_ARM_ABS8": "debug/elf",
- "elf.R_ARM_AMP_VCALL9": "debug/elf",
- "elf.R_ARM_COPY": "debug/elf",
- "elf.R_ARM_GLOB_DAT": "debug/elf",
- "elf.R_ARM_GNU_VTENTRY": "debug/elf",
- "elf.R_ARM_GNU_VTINHERIT": "debug/elf",
- "elf.R_ARM_GOT32": "debug/elf",
- "elf.R_ARM_GOTOFF": "debug/elf",
- "elf.R_ARM_GOTPC": "debug/elf",
- "elf.R_ARM_JUMP_SLOT": "debug/elf",
- "elf.R_ARM_NONE": "debug/elf",
- "elf.R_ARM_PC13": "debug/elf",
- "elf.R_ARM_PC24": "debug/elf",
- "elf.R_ARM_PLT32": "debug/elf",
- "elf.R_ARM_RABS32": "debug/elf",
- "elf.R_ARM_RBASE": "debug/elf",
- "elf.R_ARM_REL32": "debug/elf",
- "elf.R_ARM_RELATIVE": "debug/elf",
- "elf.R_ARM_RPC24": "debug/elf",
- "elf.R_ARM_RREL32": "debug/elf",
- "elf.R_ARM_RSBREL32": "debug/elf",
- "elf.R_ARM_SBREL32": "debug/elf",
- "elf.R_ARM_SWI24": "debug/elf",
- "elf.R_ARM_THM_ABS5": "debug/elf",
- "elf.R_ARM_THM_PC22": "debug/elf",
- "elf.R_ARM_THM_PC8": "debug/elf",
- "elf.R_ARM_THM_RPC22": "debug/elf",
- "elf.R_ARM_THM_SWI8": "debug/elf",
- "elf.R_ARM_THM_XPC22": "debug/elf",
- "elf.R_ARM_XPC25": "debug/elf",
- "elf.R_INFO": "debug/elf",
- "elf.R_INFO32": "debug/elf",
- "elf.R_PPC": "debug/elf",
- "elf.R_PPC_ADDR14": "debug/elf",
- "elf.R_PPC_ADDR14_BRNTAKEN": "debug/elf",
- "elf.R_PPC_ADDR14_BRTAKEN": "debug/elf",
- "elf.R_PPC_ADDR16": "debug/elf",
- "elf.R_PPC_ADDR16_HA": "debug/elf",
- "elf.R_PPC_ADDR16_HI": "debug/elf",
- "elf.R_PPC_ADDR16_LO": "debug/elf",
- "elf.R_PPC_ADDR24": "debug/elf",
- "elf.R_PPC_ADDR32": "debug/elf",
- "elf.R_PPC_COPY": "debug/elf",
- "elf.R_PPC_DTPMOD32": "debug/elf",
- "elf.R_PPC_DTPREL16": "debug/elf",
- "elf.R_PPC_DTPREL16_HA": "debug/elf",
- "elf.R_PPC_DTPREL16_HI": "debug/elf",
- "elf.R_PPC_DTPREL16_LO": "debug/elf",
- "elf.R_PPC_DTPREL32": "debug/elf",
- "elf.R_PPC_EMB_BIT_FLD": "debug/elf",
- "elf.R_PPC_EMB_MRKREF": "debug/elf",
- "elf.R_PPC_EMB_NADDR16": "debug/elf",
- "elf.R_PPC_EMB_NADDR16_HA": "debug/elf",
- "elf.R_PPC_EMB_NADDR16_HI": "debug/elf",
- "elf.R_PPC_EMB_NADDR16_LO": "debug/elf",
- "elf.R_PPC_EMB_NADDR32": "debug/elf",
- "elf.R_PPC_EMB_RELSDA": "debug/elf",
- "elf.R_PPC_EMB_RELSEC16": "debug/elf",
- "elf.R_PPC_EMB_RELST_HA": "debug/elf",
- "elf.R_PPC_EMB_RELST_HI": "debug/elf",
- "elf.R_PPC_EMB_RELST_LO": "debug/elf",
- "elf.R_PPC_EMB_SDA21": "debug/elf",
- "elf.R_PPC_EMB_SDA2I16": "debug/elf",
- "elf.R_PPC_EMB_SDA2REL": "debug/elf",
- "elf.R_PPC_EMB_SDAI16": "debug/elf",
- "elf.R_PPC_GLOB_DAT": "debug/elf",
- "elf.R_PPC_GOT16": "debug/elf",
- "elf.R_PPC_GOT16_HA": "debug/elf",
- "elf.R_PPC_GOT16_HI": "debug/elf",
- "elf.R_PPC_GOT16_LO": "debug/elf",
- "elf.R_PPC_GOT_TLSGD16": "debug/elf",
- "elf.R_PPC_GOT_TLSGD16_HA": "debug/elf",
- "elf.R_PPC_GOT_TLSGD16_HI": "debug/elf",
- "elf.R_PPC_GOT_TLSGD16_LO": "debug/elf",
- "elf.R_PPC_GOT_TLSLD16": "debug/elf",
- "elf.R_PPC_GOT_TLSLD16_HA": "debug/elf",
- "elf.R_PPC_GOT_TLSLD16_HI": "debug/elf",
- "elf.R_PPC_GOT_TLSLD16_LO": "debug/elf",
- "elf.R_PPC_GOT_TPREL16": "debug/elf",
- "elf.R_PPC_GOT_TPREL16_HA": "debug/elf",
- "elf.R_PPC_GOT_TPREL16_HI": "debug/elf",
- "elf.R_PPC_GOT_TPREL16_LO": "debug/elf",
- "elf.R_PPC_JMP_SLOT": "debug/elf",
- "elf.R_PPC_LOCAL24PC": "debug/elf",
- "elf.R_PPC_NONE": "debug/elf",
- "elf.R_PPC_PLT16_HA": "debug/elf",
- "elf.R_PPC_PLT16_HI": "debug/elf",
- "elf.R_PPC_PLT16_LO": "debug/elf",
- "elf.R_PPC_PLT32": "debug/elf",
- "elf.R_PPC_PLTREL24": "debug/elf",
- "elf.R_PPC_PLTREL32": "debug/elf",
- "elf.R_PPC_REL14": "debug/elf",
- "elf.R_PPC_REL14_BRNTAKEN": "debug/elf",
- "elf.R_PPC_REL14_BRTAKEN": "debug/elf",
- "elf.R_PPC_REL24": "debug/elf",
- "elf.R_PPC_REL32": "debug/elf",
- "elf.R_PPC_RELATIVE": "debug/elf",
- "elf.R_PPC_SDAREL16": "debug/elf",
- "elf.R_PPC_SECTOFF": "debug/elf",
- "elf.R_PPC_SECTOFF_HA": "debug/elf",
- "elf.R_PPC_SECTOFF_HI": "debug/elf",
- "elf.R_PPC_SECTOFF_LO": "debug/elf",
- "elf.R_PPC_TLS": "debug/elf",
- "elf.R_PPC_TPREL16": "debug/elf",
- "elf.R_PPC_TPREL16_HA": "debug/elf",
- "elf.R_PPC_TPREL16_HI": "debug/elf",
- "elf.R_PPC_TPREL16_LO": "debug/elf",
- "elf.R_PPC_TPREL32": "debug/elf",
- "elf.R_PPC_UADDR16": "debug/elf",
- "elf.R_PPC_UADDR32": "debug/elf",
- "elf.R_SPARC": "debug/elf",
- "elf.R_SPARC_10": "debug/elf",
- "elf.R_SPARC_11": "debug/elf",
- "elf.R_SPARC_13": "debug/elf",
- "elf.R_SPARC_16": "debug/elf",
- "elf.R_SPARC_22": "debug/elf",
- "elf.R_SPARC_32": "debug/elf",
- "elf.R_SPARC_5": "debug/elf",
- "elf.R_SPARC_6": "debug/elf",
- "elf.R_SPARC_64": "debug/elf",
- "elf.R_SPARC_7": "debug/elf",
- "elf.R_SPARC_8": "debug/elf",
- "elf.R_SPARC_COPY": "debug/elf",
- "elf.R_SPARC_DISP16": "debug/elf",
- "elf.R_SPARC_DISP32": "debug/elf",
- "elf.R_SPARC_DISP64": "debug/elf",
- "elf.R_SPARC_DISP8": "debug/elf",
- "elf.R_SPARC_GLOB_DAT": "debug/elf",
- "elf.R_SPARC_GLOB_JMP": "debug/elf",
- "elf.R_SPARC_GOT10": "debug/elf",
- "elf.R_SPARC_GOT13": "debug/elf",
- "elf.R_SPARC_GOT22": "debug/elf",
- "elf.R_SPARC_H44": "debug/elf",
- "elf.R_SPARC_HH22": "debug/elf",
- "elf.R_SPARC_HI22": "debug/elf",
- "elf.R_SPARC_HIPLT22": "debug/elf",
- "elf.R_SPARC_HIX22": "debug/elf",
- "elf.R_SPARC_HM10": "debug/elf",
- "elf.R_SPARC_JMP_SLOT": "debug/elf",
- "elf.R_SPARC_L44": "debug/elf",
- "elf.R_SPARC_LM22": "debug/elf",
- "elf.R_SPARC_LO10": "debug/elf",
- "elf.R_SPARC_LOPLT10": "debug/elf",
- "elf.R_SPARC_LOX10": "debug/elf",
- "elf.R_SPARC_M44": "debug/elf",
- "elf.R_SPARC_NONE": "debug/elf",
- "elf.R_SPARC_OLO10": "debug/elf",
- "elf.R_SPARC_PC10": "debug/elf",
- "elf.R_SPARC_PC22": "debug/elf",
- "elf.R_SPARC_PCPLT10": "debug/elf",
- "elf.R_SPARC_PCPLT22": "debug/elf",
- "elf.R_SPARC_PCPLT32": "debug/elf",
- "elf.R_SPARC_PC_HH22": "debug/elf",
- "elf.R_SPARC_PC_HM10": "debug/elf",
- "elf.R_SPARC_PC_LM22": "debug/elf",
- "elf.R_SPARC_PLT32": "debug/elf",
- "elf.R_SPARC_PLT64": "debug/elf",
- "elf.R_SPARC_REGISTER": "debug/elf",
- "elf.R_SPARC_RELATIVE": "debug/elf",
- "elf.R_SPARC_UA16": "debug/elf",
- "elf.R_SPARC_UA32": "debug/elf",
- "elf.R_SPARC_UA64": "debug/elf",
- "elf.R_SPARC_WDISP16": "debug/elf",
- "elf.R_SPARC_WDISP19": "debug/elf",
- "elf.R_SPARC_WDISP22": "debug/elf",
- "elf.R_SPARC_WDISP30": "debug/elf",
- "elf.R_SPARC_WPLT30": "debug/elf",
- "elf.R_SYM32": "debug/elf",
- "elf.R_SYM64": "debug/elf",
- "elf.R_TYPE32": "debug/elf",
- "elf.R_TYPE64": "debug/elf",
- "elf.R_X86_64": "debug/elf",
- "elf.R_X86_64_16": "debug/elf",
- "elf.R_X86_64_32": "debug/elf",
- "elf.R_X86_64_32S": "debug/elf",
- "elf.R_X86_64_64": "debug/elf",
- "elf.R_X86_64_8": "debug/elf",
- "elf.R_X86_64_COPY": "debug/elf",
- "elf.R_X86_64_DTPMOD64": "debug/elf",
- "elf.R_X86_64_DTPOFF32": "debug/elf",
- "elf.R_X86_64_DTPOFF64": "debug/elf",
- "elf.R_X86_64_GLOB_DAT": "debug/elf",
- "elf.R_X86_64_GOT32": "debug/elf",
- "elf.R_X86_64_GOTPCREL": "debug/elf",
- "elf.R_X86_64_GOTTPOFF": "debug/elf",
- "elf.R_X86_64_JMP_SLOT": "debug/elf",
- "elf.R_X86_64_NONE": "debug/elf",
- "elf.R_X86_64_PC16": "debug/elf",
- "elf.R_X86_64_PC32": "debug/elf",
- "elf.R_X86_64_PC8": "debug/elf",
- "elf.R_X86_64_PLT32": "debug/elf",
- "elf.R_X86_64_RELATIVE": "debug/elf",
- "elf.R_X86_64_TLSGD": "debug/elf",
- "elf.R_X86_64_TLSLD": "debug/elf",
- "elf.R_X86_64_TPOFF32": "debug/elf",
- "elf.R_X86_64_TPOFF64": "debug/elf",
- "elf.Rel32": "debug/elf",
- "elf.Rel64": "debug/elf",
- "elf.Rela32": "debug/elf",
- "elf.Rela64": "debug/elf",
- "elf.SHF_ALLOC": "debug/elf",
- "elf.SHF_EXECINSTR": "debug/elf",
- "elf.SHF_GROUP": "debug/elf",
- "elf.SHF_INFO_LINK": "debug/elf",
- "elf.SHF_LINK_ORDER": "debug/elf",
- "elf.SHF_MASKOS": "debug/elf",
- "elf.SHF_MASKPROC": "debug/elf",
- "elf.SHF_MERGE": "debug/elf",
- "elf.SHF_OS_NONCONFORMING": "debug/elf",
- "elf.SHF_STRINGS": "debug/elf",
- "elf.SHF_TLS": "debug/elf",
- "elf.SHF_WRITE": "debug/elf",
- "elf.SHN_ABS": "debug/elf",
- "elf.SHN_COMMON": "debug/elf",
- "elf.SHN_HIOS": "debug/elf",
- "elf.SHN_HIPROC": "debug/elf",
- "elf.SHN_HIRESERVE": "debug/elf",
- "elf.SHN_LOOS": "debug/elf",
- "elf.SHN_LOPROC": "debug/elf",
- "elf.SHN_LORESERVE": "debug/elf",
- "elf.SHN_UNDEF": "debug/elf",
- "elf.SHN_XINDEX": "debug/elf",
- "elf.SHT_DYNAMIC": "debug/elf",
- "elf.SHT_DYNSYM": "debug/elf",
- "elf.SHT_FINI_ARRAY": "debug/elf",
- "elf.SHT_GNU_ATTRIBUTES": "debug/elf",
- "elf.SHT_GNU_HASH": "debug/elf",
- "elf.SHT_GNU_LIBLIST": "debug/elf",
- "elf.SHT_GNU_VERDEF": "debug/elf",
- "elf.SHT_GNU_VERNEED": "debug/elf",
- "elf.SHT_GNU_VERSYM": "debug/elf",
- "elf.SHT_GROUP": "debug/elf",
- "elf.SHT_HASH": "debug/elf",
- "elf.SHT_HIOS": "debug/elf",
- "elf.SHT_HIPROC": "debug/elf",
- "elf.SHT_HIUSER": "debug/elf",
- "elf.SHT_INIT_ARRAY": "debug/elf",
- "elf.SHT_LOOS": "debug/elf",
- "elf.SHT_LOPROC": "debug/elf",
- "elf.SHT_LOUSER": "debug/elf",
- "elf.SHT_NOBITS": "debug/elf",
- "elf.SHT_NOTE": "debug/elf",
- "elf.SHT_NULL": "debug/elf",
- "elf.SHT_PREINIT_ARRAY": "debug/elf",
- "elf.SHT_PROGBITS": "debug/elf",
- "elf.SHT_REL": "debug/elf",
- "elf.SHT_RELA": "debug/elf",
- "elf.SHT_SHLIB": "debug/elf",
- "elf.SHT_STRTAB": "debug/elf",
- "elf.SHT_SYMTAB": "debug/elf",
- "elf.SHT_SYMTAB_SHNDX": "debug/elf",
- "elf.STB_GLOBAL": "debug/elf",
- "elf.STB_HIOS": "debug/elf",
- "elf.STB_HIPROC": "debug/elf",
- "elf.STB_LOCAL": "debug/elf",
- "elf.STB_LOOS": "debug/elf",
- "elf.STB_LOPROC": "debug/elf",
- "elf.STB_WEAK": "debug/elf",
- "elf.STT_COMMON": "debug/elf",
- "elf.STT_FILE": "debug/elf",
- "elf.STT_FUNC": "debug/elf",
- "elf.STT_HIOS": "debug/elf",
- "elf.STT_HIPROC": "debug/elf",
- "elf.STT_LOOS": "debug/elf",
- "elf.STT_LOPROC": "debug/elf",
- "elf.STT_NOTYPE": "debug/elf",
- "elf.STT_OBJECT": "debug/elf",
- "elf.STT_SECTION": "debug/elf",
- "elf.STT_TLS": "debug/elf",
- "elf.STV_DEFAULT": "debug/elf",
- "elf.STV_HIDDEN": "debug/elf",
- "elf.STV_INTERNAL": "debug/elf",
- "elf.STV_PROTECTED": "debug/elf",
- "elf.ST_BIND": "debug/elf",
- "elf.ST_INFO": "debug/elf",
- "elf.ST_TYPE": "debug/elf",
- "elf.ST_VISIBILITY": "debug/elf",
- "elf.Section": "debug/elf",
- "elf.Section32": "debug/elf",
- "elf.Section64": "debug/elf",
- "elf.SectionFlag": "debug/elf",
- "elf.SectionHeader": "debug/elf",
- "elf.SectionIndex": "debug/elf",
- "elf.SectionType": "debug/elf",
- "elf.Sym32": "debug/elf",
- "elf.Sym32Size": "debug/elf",
- "elf.Sym64": "debug/elf",
- "elf.Sym64Size": "debug/elf",
- "elf.SymBind": "debug/elf",
- "elf.SymType": "debug/elf",
- "elf.SymVis": "debug/elf",
- "elf.Symbol": "debug/elf",
- "elf.Type": "debug/elf",
- "elf.Version": "debug/elf",
- "elliptic.Curve": "crypto/elliptic",
- "elliptic.CurveParams": "crypto/elliptic",
- "elliptic.GenerateKey": "crypto/elliptic",
- "elliptic.Marshal": "crypto/elliptic",
- "elliptic.P224": "crypto/elliptic",
- "elliptic.P256": "crypto/elliptic",
- "elliptic.P384": "crypto/elliptic",
- "elliptic.P521": "crypto/elliptic",
- "elliptic.Unmarshal": "crypto/elliptic",
- "encoding.BinaryMarshaler": "encoding",
- "encoding.BinaryUnmarshaler": "encoding",
- "encoding.TextMarshaler": "encoding",
- "encoding.TextUnmarshaler": "encoding",
- "errors.New": "errors",
- "exec.Cmd": "os/exec",
- "exec.Command": "os/exec",
- "exec.ErrNotFound": "os/exec",
- "exec.Error": "os/exec",
- "exec.ExitError": "os/exec",
- "exec.LookPath": "os/exec",
- "expvar.Do": "expvar",
- "expvar.Float": "expvar",
- "expvar.Func": "expvar",
- "expvar.Get": "expvar",
- "expvar.Int": "expvar",
- "expvar.KeyValue": "expvar",
- "expvar.Map": "expvar",
- "expvar.NewFloat": "expvar",
- "expvar.NewInt": "expvar",
- "expvar.NewMap": "expvar",
- "expvar.NewString": "expvar",
- "expvar.Publish": "expvar",
- "expvar.String": "expvar",
- "expvar.Var": "expvar",
- "fcgi.Serve": "net/http/fcgi",
- "filepath.Abs": "path/filepath",
- "filepath.Base": "path/filepath",
- "filepath.Clean": "path/filepath",
- "filepath.Dir": "path/filepath",
- "filepath.ErrBadPattern": "path/filepath",
- "filepath.EvalSymlinks": "path/filepath",
- "filepath.Ext": "path/filepath",
- "filepath.FromSlash": "path/filepath",
- "filepath.Glob": "path/filepath",
- "filepath.HasPrefix": "path/filepath",
- "filepath.IsAbs": "path/filepath",
- "filepath.Join": "path/filepath",
- "filepath.ListSeparator": "path/filepath",
- "filepath.Match": "path/filepath",
- "filepath.Rel": "path/filepath",
- "filepath.Separator": "path/filepath",
- "filepath.SkipDir": "path/filepath",
- "filepath.Split": "path/filepath",
- "filepath.SplitList": "path/filepath",
- "filepath.ToSlash": "path/filepath",
- "filepath.VolumeName": "path/filepath",
- "filepath.Walk": "path/filepath",
- "filepath.WalkFunc": "path/filepath",
- "flag.Arg": "flag",
- "flag.Args": "flag",
- "flag.Bool": "flag",
- "flag.BoolVar": "flag",
- "flag.CommandLine": "flag",
- "flag.ContinueOnError": "flag",
- "flag.Duration": "flag",
- "flag.DurationVar": "flag",
- "flag.ErrHelp": "flag",
- "flag.ErrorHandling": "flag",
- "flag.ExitOnError": "flag",
- "flag.Flag": "flag",
- "flag.FlagSet": "flag",
- "flag.Float64": "flag",
- "flag.Float64Var": "flag",
- "flag.Getter": "flag",
- "flag.Int": "flag",
- "flag.Int64": "flag",
- "flag.Int64Var": "flag",
- "flag.IntVar": "flag",
- "flag.Lookup": "flag",
- "flag.NArg": "flag",
- "flag.NFlag": "flag",
- "flag.NewFlagSet": "flag",
- "flag.PanicOnError": "flag",
- "flag.Parse": "flag",
- "flag.Parsed": "flag",
- "flag.PrintDefaults": "flag",
- "flag.Set": "flag",
- "flag.String": "flag",
- "flag.StringVar": "flag",
- "flag.Uint": "flag",
- "flag.Uint64": "flag",
- "flag.Uint64Var": "flag",
- "flag.UintVar": "flag",
- "flag.Usage": "flag",
- "flag.Value": "flag",
- "flag.Var": "flag",
- "flag.Visit": "flag",
- "flag.VisitAll": "flag",
- "flate.BestCompression": "compress/flate",
- "flate.BestSpeed": "compress/flate",
- "flate.CorruptInputError": "compress/flate",
- "flate.DefaultCompression": "compress/flate",
- "flate.InternalError": "compress/flate",
- "flate.NewReader": "compress/flate",
- "flate.NewReaderDict": "compress/flate",
- "flate.NewWriter": "compress/flate",
- "flate.NewWriterDict": "compress/flate",
- "flate.NoCompression": "compress/flate",
- "flate.ReadError": "compress/flate",
- "flate.Reader": "compress/flate",
- "flate.WriteError": "compress/flate",
- "flate.Writer": "compress/flate",
- "fmt.Errorf": "fmt",
- "fmt.Formatter": "fmt",
- "fmt.Fprint": "fmt",
- "fmt.Fprintf": "fmt",
- "fmt.Fprintln": "fmt",
- "fmt.Fscan": "fmt",
- "fmt.Fscanf": "fmt",
- "fmt.Fscanln": "fmt",
- "fmt.GoStringer": "fmt",
- "fmt.Print": "fmt",
- "fmt.Printf": "fmt",
- "fmt.Println": "fmt",
- "fmt.Scan": "fmt",
- "fmt.ScanState": "fmt",
- "fmt.Scanf": "fmt",
- "fmt.Scanln": "fmt",
- "fmt.Scanner": "fmt",
- "fmt.Sprint": "fmt",
- "fmt.Sprintf": "fmt",
- "fmt.Sprintln": "fmt",
- "fmt.Sscan": "fmt",
- "fmt.Sscanf": "fmt",
- "fmt.Sscanln": "fmt",
- "fmt.State": "fmt",
- "fmt.Stringer": "fmt",
- "fnv.New32": "hash/fnv",
- "fnv.New32a": "hash/fnv",
- "fnv.New64": "hash/fnv",
- "fnv.New64a": "hash/fnv",
- "format.Node": "go/format",
- "format.Source": "go/format",
- "gif.Decode": "image/gif",
- "gif.DecodeAll": "image/gif",
- "gif.DecodeConfig": "image/gif",
- "gif.Encode": "image/gif",
- "gif.EncodeAll": "image/gif",
- "gif.GIF": "image/gif",
- "gif.Options": "image/gif",
- "gob.CommonType": "encoding/gob",
- "gob.Decoder": "encoding/gob",
- "gob.Encoder": "encoding/gob",
- "gob.GobDecoder": "encoding/gob",
- "gob.GobEncoder": "encoding/gob",
- "gob.NewDecoder": "encoding/gob",
- "gob.NewEncoder": "encoding/gob",
- "gob.Register": "encoding/gob",
- "gob.RegisterName": "encoding/gob",
- "gosym.DecodingError": "debug/gosym",
- "gosym.Func": "debug/gosym",
- "gosym.LineTable": "debug/gosym",
- "gosym.NewLineTable": "debug/gosym",
- "gosym.NewTable": "debug/gosym",
- "gosym.Obj": "debug/gosym",
- "gosym.Sym": "debug/gosym",
- "gosym.Table": "debug/gosym",
- "gosym.UnknownFileError": "debug/gosym",
- "gosym.UnknownLineError": "debug/gosym",
- "gzip.BestCompression": "compress/gzip",
- "gzip.BestSpeed": "compress/gzip",
- "gzip.DefaultCompression": "compress/gzip",
- "gzip.ErrChecksum": "compress/gzip",
- "gzip.ErrHeader": "compress/gzip",
- "gzip.Header": "compress/gzip",
- "gzip.NewReader": "compress/gzip",
- "gzip.NewWriter": "compress/gzip",
- "gzip.NewWriterLevel": "compress/gzip",
- "gzip.NoCompression": "compress/gzip",
- "gzip.Reader": "compress/gzip",
- "gzip.Writer": "compress/gzip",
- "hash.Hash": "hash",
- "hash.Hash32": "hash",
- "hash.Hash64": "hash",
- "heap.Fix": "container/heap",
- "heap.Init": "container/heap",
- "heap.Interface": "container/heap",
- "heap.Pop": "container/heap",
- "heap.Push": "container/heap",
- "heap.Remove": "container/heap",
- "hex.Decode": "encoding/hex",
- "hex.DecodeString": "encoding/hex",
- "hex.DecodedLen": "encoding/hex",
- "hex.Dump": "encoding/hex",
- "hex.Dumper": "encoding/hex",
- "hex.Encode": "encoding/hex",
- "hex.EncodeToString": "encoding/hex",
- "hex.EncodedLen": "encoding/hex",
- "hex.ErrLength": "encoding/hex",
- "hex.InvalidByteError": "encoding/hex",
- "hmac.Equal": "crypto/hmac",
- "hmac.New": "crypto/hmac",
- "html.EscapeString": "html",
- "html.UnescapeString": "html",
- "http.CanonicalHeaderKey": "net/http",
- "http.Client": "net/http",
- "http.CloseNotifier": "net/http",
- "http.Cookie": "net/http",
- "http.CookieJar": "net/http",
- "http.DefaultClient": "net/http",
- "http.DefaultMaxHeaderBytes": "net/http",
- "http.DefaultMaxIdleConnsPerHost": "net/http",
- "http.DefaultServeMux": "net/http",
- "http.DefaultTransport": "net/http",
- "http.DetectContentType": "net/http",
- "http.Dir": "net/http",
- "http.ErrBodyNotAllowed": "net/http",
- "http.ErrBodyReadAfterClose": "net/http",
- "http.ErrContentLength": "net/http",
- "http.ErrHandlerTimeout": "net/http",
- "http.ErrHeaderTooLong": "net/http",
- "http.ErrHijacked": "net/http",
- "http.ErrLineTooLong": "net/http",
- "http.ErrMissingBoundary": "net/http",
- "http.ErrMissingContentLength": "net/http",
- "http.ErrMissingFile": "net/http",
- "http.ErrNoCookie": "net/http",
- "http.ErrNoLocation": "net/http",
- "http.ErrNotMultipart": "net/http",
- "http.ErrNotSupported": "net/http",
- "http.ErrShortBody": "net/http",
- "http.ErrUnexpectedTrailer": "net/http",
- "http.ErrWriteAfterFlush": "net/http",
- "http.Error": "net/http",
- "http.File": "net/http",
- "http.FileServer": "net/http",
- "http.FileSystem": "net/http",
- "http.Flusher": "net/http",
- "http.Get": "net/http",
- "http.Handle": "net/http",
- "http.HandleFunc": "net/http",
- "http.Handler": "net/http",
- "http.HandlerFunc": "net/http",
- "http.Head": "net/http",
- "http.Header": "net/http",
- "http.Hijacker": "net/http",
- "http.ListenAndServe": "net/http",
- "http.ListenAndServeTLS": "net/http",
- "http.MaxBytesReader": "net/http",
- "http.NewFileTransport": "net/http",
- "http.NewRequest": "net/http",
- "http.NewServeMux": "net/http",
- "http.NotFound": "net/http",
- "http.NotFoundHandler": "net/http",
- "http.ParseHTTPVersion": "net/http",
- "http.ParseTime": "net/http",
- "http.Post": "net/http",
- "http.PostForm": "net/http",
- "http.ProtocolError": "net/http",
- "http.ProxyFromEnvironment": "net/http",
- "http.ProxyURL": "net/http",
- "http.ReadRequest": "net/http",
- "http.ReadResponse": "net/http",
- "http.Redirect": "net/http",
- "http.RedirectHandler": "net/http",
- "http.Request": "net/http",
- "http.Response": "net/http",
- "http.ResponseWriter": "net/http",
- "http.RoundTripper": "net/http",
- "http.Serve": "net/http",
- "http.ServeContent": "net/http",
- "http.ServeFile": "net/http",
- "http.ServeMux": "net/http",
- "http.Server": "net/http",
- "http.SetCookie": "net/http",
- "http.StatusAccepted": "net/http",
- "http.StatusBadGateway": "net/http",
- "http.StatusBadRequest": "net/http",
- "http.StatusConflict": "net/http",
- "http.StatusContinue": "net/http",
- "http.StatusCreated": "net/http",
- "http.StatusExpectationFailed": "net/http",
- "http.StatusForbidden": "net/http",
- "http.StatusFound": "net/http",
- "http.StatusGatewayTimeout": "net/http",
- "http.StatusGone": "net/http",
- "http.StatusHTTPVersionNotSupported": "net/http",
- "http.StatusInternalServerError": "net/http",
- "http.StatusLengthRequired": "net/http",
- "http.StatusMethodNotAllowed": "net/http",
- "http.StatusMovedPermanently": "net/http",
- "http.StatusMultipleChoices": "net/http",
- "http.StatusNoContent": "net/http",
- "http.StatusNonAuthoritativeInfo": "net/http",
- "http.StatusNotAcceptable": "net/http",
- "http.StatusNotFound": "net/http",
- "http.StatusNotImplemented": "net/http",
- "http.StatusNotModified": "net/http",
- "http.StatusOK": "net/http",
- "http.StatusPartialContent": "net/http",
- "http.StatusPaymentRequired": "net/http",
- "http.StatusPreconditionFailed": "net/http",
- "http.StatusProxyAuthRequired": "net/http",
- "http.StatusRequestEntityTooLarge": "net/http",
- "http.StatusRequestTimeout": "net/http",
- "http.StatusRequestURITooLong": "net/http",
- "http.StatusRequestedRangeNotSatisfiable": "net/http",
- "http.StatusResetContent": "net/http",
- "http.StatusSeeOther": "net/http",
- "http.StatusServiceUnavailable": "net/http",
- "http.StatusSwitchingProtocols": "net/http",
- "http.StatusTeapot": "net/http",
- "http.StatusTemporaryRedirect": "net/http",
- "http.StatusText": "net/http",
- "http.StatusUnauthorized": "net/http",
- "http.StatusUnsupportedMediaType": "net/http",
- "http.StatusUseProxy": "net/http",
- "http.StripPrefix": "net/http",
- "http.TimeFormat": "net/http",
- "http.TimeoutHandler": "net/http",
- "http.Transport": "net/http",
- "httptest.DefaultRemoteAddr": "net/http/httptest",
- "httptest.NewRecorder": "net/http/httptest",
- "httptest.NewServer": "net/http/httptest",
- "httptest.NewTLSServer": "net/http/httptest",
- "httptest.NewUnstartedServer": "net/http/httptest",
- "httptest.ResponseRecorder": "net/http/httptest",
- "httptest.Server": "net/http/httptest",
- "httputil.ClientConn": "net/http/httputil",
- "httputil.DumpRequest": "net/http/httputil",
- "httputil.DumpRequestOut": "net/http/httputil",
- "httputil.DumpResponse": "net/http/httputil",
- "httputil.ErrClosed": "net/http/httputil",
- "httputil.ErrLineTooLong": "net/http/httputil",
- "httputil.ErrPersistEOF": "net/http/httputil",
- "httputil.ErrPipeline": "net/http/httputil",
- "httputil.NewChunkedReader": "net/http/httputil",
- "httputil.NewChunkedWriter": "net/http/httputil",
- "httputil.NewClientConn": "net/http/httputil",
- "httputil.NewProxyClientConn": "net/http/httputil",
- "httputil.NewServerConn": "net/http/httputil",
- "httputil.NewSingleHostReverseProxy": "net/http/httputil",
- "httputil.ReverseProxy": "net/http/httputil",
- "httputil.ServerConn": "net/http/httputil",
- "image.Alpha": "image",
- "image.Alpha16": "image",
- "image.Black": "image",
- "image.Config": "image",
- "image.Decode": "image",
- "image.DecodeConfig": "image",
- "image.ErrFormat": "image",
- "image.Gray": "image",
- "image.Gray16": "image",
- "image.Image": "image",
- "image.NRGBA": "image",
- "image.NRGBA64": "image",
- "image.NewAlpha": "image",
- "image.NewAlpha16": "image",
- "image.NewGray": "image",
- "image.NewGray16": "image",
- "image.NewNRGBA": "image",
- "image.NewNRGBA64": "image",
- "image.NewPaletted": "image",
- "image.NewRGBA": "image",
- "image.NewRGBA64": "image",
- "image.NewUniform": "image",
- "image.NewYCbCr": "image",
- "image.Opaque": "image",
- "image.Paletted": "image",
- "image.PalettedImage": "image",
- "image.Point": "image",
- "image.Pt": "image",
- "image.RGBA": "image",
- "image.RGBA64": "image",
- "image.Rect": "image",
- "image.Rectangle": "image",
- "image.RegisterFormat": "image",
- "image.Transparent": "image",
- "image.Uniform": "image",
- "image.White": "image",
- "image.YCbCr": "image",
- "image.YCbCrSubsampleRatio": "image",
- "image.YCbCrSubsampleRatio420": "image",
- "image.YCbCrSubsampleRatio422": "image",
- "image.YCbCrSubsampleRatio440": "image",
- "image.YCbCrSubsampleRatio444": "image",
- "image.ZP": "image",
- "image.ZR": "image",
- "io.ByteReader": "io",
- "io.ByteScanner": "io",
- "io.ByteWriter": "io",
- "io.Closer": "io",
- "io.Copy": "io",
- "io.CopyN": "io",
- "io.EOF": "io",
- "io.ErrClosedPipe": "io",
- "io.ErrNoProgress": "io",
- "io.ErrShortBuffer": "io",
- "io.ErrShortWrite": "io",
- "io.ErrUnexpectedEOF": "io",
- "io.LimitReader": "io",
- "io.LimitedReader": "io",
- "io.MultiReader": "io",
- "io.MultiWriter": "io",
- "io.NewSectionReader": "io",
- "io.Pipe": "io",
- "io.PipeReader": "io",
- "io.PipeWriter": "io",
- "io.ReadAtLeast": "io",
- "io.ReadCloser": "io",
- "io.ReadFull": "io",
- "io.ReadSeeker": "io",
- "io.ReadWriteCloser": "io",
- "io.ReadWriteSeeker": "io",
- "io.ReadWriter": "io",
- "io.Reader": "io",
- "io.ReaderAt": "io",
- "io.ReaderFrom": "io",
- "io.RuneReader": "io",
- "io.RuneScanner": "io",
- "io.SectionReader": "io",
- "io.Seeker": "io",
- "io.TeeReader": "io",
- "io.WriteCloser": "io",
- "io.WriteSeeker": "io",
- "io.WriteString": "io",
- "io.Writer": "io",
- "io.WriterAt": "io",
- "io.WriterTo": "io",
- "iotest.DataErrReader": "testing/iotest",
- "iotest.ErrTimeout": "testing/iotest",
- "iotest.HalfReader": "testing/iotest",
- "iotest.NewReadLogger": "testing/iotest",
- "iotest.NewWriteLogger": "testing/iotest",
- "iotest.OneByteReader": "testing/iotest",
- "iotest.TimeoutReader": "testing/iotest",
- "iotest.TruncateWriter": "testing/iotest",
- "ioutil.Discard": "io/ioutil",
- "ioutil.NopCloser": "io/ioutil",
- "ioutil.ReadAll": "io/ioutil",
- "ioutil.ReadDir": "io/ioutil",
- "ioutil.ReadFile": "io/ioutil",
- "ioutil.TempDir": "io/ioutil",
- "ioutil.TempFile": "io/ioutil",
- "ioutil.WriteFile": "io/ioutil",
- "jpeg.Decode": "image/jpeg",
- "jpeg.DecodeConfig": "image/jpeg",
- "jpeg.DefaultQuality": "image/jpeg",
- "jpeg.Encode": "image/jpeg",
- "jpeg.FormatError": "image/jpeg",
- "jpeg.Options": "image/jpeg",
- "jpeg.Reader": "image/jpeg",
- "jpeg.UnsupportedError": "image/jpeg",
- "json.Compact": "encoding/json",
- "json.Decoder": "encoding/json",
- "json.Encoder": "encoding/json",
- "json.HTMLEscape": "encoding/json",
- "json.Indent": "encoding/json",
- "json.InvalidUTF8Error": "encoding/json",
- "json.InvalidUnmarshalError": "encoding/json",
- "json.Marshal": "encoding/json",
- "json.MarshalIndent": "encoding/json",
- "json.Marshaler": "encoding/json",
- "json.MarshalerError": "encoding/json",
- "json.NewDecoder": "encoding/json",
- "json.NewEncoder": "encoding/json",
- "json.Number": "encoding/json",
- "json.RawMessage": "encoding/json",
- "json.SyntaxError": "encoding/json",
- "json.Unmarshal": "encoding/json",
- "json.UnmarshalFieldError": "encoding/json",
- "json.UnmarshalTypeError": "encoding/json",
- "json.Unmarshaler": "encoding/json",
- "json.UnsupportedTypeError": "encoding/json",
- "json.UnsupportedValueError": "encoding/json",
- "jsonrpc.Dial": "net/rpc/jsonrpc",
- "jsonrpc.NewClient": "net/rpc/jsonrpc",
- "jsonrpc.NewClientCodec": "net/rpc/jsonrpc",
- "jsonrpc.NewServerCodec": "net/rpc/jsonrpc",
- "jsonrpc.ServeConn": "net/rpc/jsonrpc",
- "list.Element": "container/list",
- "list.List": "container/list",
- "list.New": "container/list",
- "log.Fatal": "log",
- "log.Fatalf": "log",
- "log.Fatalln": "log",
- "log.Flags": "log",
- "log.Ldate": "log",
- "log.Llongfile": "log",
- "log.Lmicroseconds": "log",
- "log.Logger": "log",
- "log.Lshortfile": "log",
- "log.LstdFlags": "log",
- "log.Ltime": "log",
- "log.New": "log",
- "log.Panic": "log",
- "log.Panicf": "log",
- "log.Panicln": "log",
- "log.Prefix": "log",
- "log.Print": "log",
- "log.Printf": "log",
- "log.Println": "log",
- "log.SetFlags": "log",
- "log.SetOutput": "log",
- "log.SetPrefix": "log",
- "lzw.LSB": "compress/lzw",
- "lzw.MSB": "compress/lzw",
- "lzw.NewReader": "compress/lzw",
- "lzw.NewWriter": "compress/lzw",
- "lzw.Order": "compress/lzw",
- "macho.Cpu": "debug/macho",
- "macho.Cpu386": "debug/macho",
- "macho.CpuAmd64": "debug/macho",
- "macho.Dylib": "debug/macho",
- "macho.DylibCmd": "debug/macho",
- "macho.Dysymtab": "debug/macho",
- "macho.DysymtabCmd": "debug/macho",
- "macho.File": "debug/macho",
- "macho.FileHeader": "debug/macho",
- "macho.FormatError": "debug/macho",
- "macho.Load": "debug/macho",
- "macho.LoadBytes": "debug/macho",
- "macho.LoadCmd": "debug/macho",
- "macho.LoadCmdDylib": "debug/macho",
- "macho.LoadCmdDylinker": "debug/macho",
- "macho.LoadCmdDysymtab": "debug/macho",
- "macho.LoadCmdSegment": "debug/macho",
- "macho.LoadCmdSegment64": "debug/macho",
- "macho.LoadCmdSymtab": "debug/macho",
- "macho.LoadCmdThread": "debug/macho",
- "macho.LoadCmdUnixThread": "debug/macho",
- "macho.Magic32": "debug/macho",
- "macho.Magic64": "debug/macho",
- "macho.NewFile": "debug/macho",
- "macho.Nlist32": "debug/macho",
- "macho.Nlist64": "debug/macho",
- "macho.Open": "debug/macho",
- "macho.Regs386": "debug/macho",
- "macho.RegsAMD64": "debug/macho",
- "macho.Section": "debug/macho",
- "macho.Section32": "debug/macho",
- "macho.Section64": "debug/macho",
- "macho.SectionHeader": "debug/macho",
- "macho.Segment": "debug/macho",
- "macho.Segment32": "debug/macho",
- "macho.Segment64": "debug/macho",
- "macho.SegmentHeader": "debug/macho",
- "macho.Symbol": "debug/macho",
- "macho.Symtab": "debug/macho",
- "macho.SymtabCmd": "debug/macho",
- "macho.Thread": "debug/macho",
- "macho.Type": "debug/macho",
- "macho.TypeExec": "debug/macho",
- "macho.TypeObj": "debug/macho",
- "mail.Address": "net/mail",
- "mail.ErrHeaderNotPresent": "net/mail",
- "mail.Header": "net/mail",
- "mail.Message": "net/mail",
- "mail.ParseAddress": "net/mail",
- "mail.ParseAddressList": "net/mail",
- "mail.ReadMessage": "net/mail",
- "math.Abs": "math",
- "math.Acos": "math",
- "math.Acosh": "math",
- "math.Asin": "math",
- "math.Asinh": "math",
- "math.Atan": "math",
- "math.Atan2": "math",
- "math.Atanh": "math",
- "math.Cbrt": "math",
- "math.Ceil": "math",
- "math.Copysign": "math",
- "math.Cos": "math",
- "math.Cosh": "math",
- "math.Dim": "math",
- "math.E": "math",
- "math.Erf": "math",
- "math.Erfc": "math",
- "math.Exp": "math",
- "math.Exp2": "math",
- "math.Expm1": "math",
- "math.Float32bits": "math",
- "math.Float32frombits": "math",
- "math.Float64bits": "math",
- "math.Float64frombits": "math",
- "math.Floor": "math",
- "math.Frexp": "math",
- "math.Gamma": "math",
- "math.Hypot": "math",
- "math.Ilogb": "math",
- "math.Inf": "math",
- "math.IsInf": "math",
- "math.IsNaN": "math",
- "math.J0": "math",
- "math.J1": "math",
- "math.Jn": "math",
- "math.Ldexp": "math",
- "math.Lgamma": "math",
- "math.Ln10": "math",
- "math.Ln2": "math",
- "math.Log": "math",
- "math.Log10": "math",
- "math.Log10E": "math",
- "math.Log1p": "math",
- "math.Log2": "math",
- "math.Log2E": "math",
- "math.Logb": "math",
- "math.Max": "math",
- "math.MaxFloat32": "math",
- "math.MaxFloat64": "math",
- "math.MaxInt16": "math",
- "math.MaxInt32": "math",
- "math.MaxInt64": "math",
- "math.MaxInt8": "math",
- "math.MaxUint16": "math",
- "math.MaxUint32": "math",
- "math.MaxUint64": "math",
- "math.MaxUint8": "math",
- "math.Min": "math",
- "math.MinInt16": "math",
- "math.MinInt32": "math",
- "math.MinInt64": "math",
- "math.MinInt8": "math",
- "math.Mod": "math",
- "math.Modf": "math",
- "math.NaN": "math",
- "math.Nextafter": "math",
- "math.Phi": "math",
- "math.Pi": "math",
- "math.Pow": "math",
- "math.Pow10": "math",
- "math.Remainder": "math",
- "math.Signbit": "math",
- "math.Sin": "math",
- "math.Sincos": "math",
- "math.Sinh": "math",
- "math.SmallestNonzeroFloat32": "math",
- "math.SmallestNonzeroFloat64": "math",
- "math.Sqrt": "math",
- "math.Sqrt2": "math",
- "math.SqrtE": "math",
- "math.SqrtPhi": "math",
- "math.SqrtPi": "math",
- "math.Tan": "math",
- "math.Tanh": "math",
- "math.Trunc": "math",
- "math.Y0": "math",
- "math.Y1": "math",
- "math.Yn": "math",
- "md5.BlockSize": "crypto/md5",
- "md5.New": "crypto/md5",
- "md5.Size": "crypto/md5",
- "md5.Sum": "crypto/md5",
- "mime.AddExtensionType": "mime",
- "mime.FormatMediaType": "mime",
- "mime.ParseMediaType": "mime",
- "mime.TypeByExtension": "mime",
- "multipart.File": "mime/multipart",
- "multipart.FileHeader": "mime/multipart",
- "multipart.Form": "mime/multipart",
- "multipart.NewReader": "mime/multipart",
- "multipart.NewWriter": "mime/multipart",
- "multipart.Part": "mime/multipart",
- "multipart.Reader": "mime/multipart",
- "multipart.Writer": "mime/multipart",
- "net.Addr": "net",
- "net.AddrError": "net",
- "net.CIDRMask": "net",
- "net.Conn": "net",
- "net.DNSConfigError": "net",
- "net.DNSError": "net",
- "net.Dial": "net",
- "net.DialIP": "net",
- "net.DialTCP": "net",
- "net.DialTimeout": "net",
- "net.DialUDP": "net",
- "net.DialUnix": "net",
- "net.Dialer": "net",
- "net.ErrWriteToConnected": "net",
- "net.Error": "net",
- "net.FileConn": "net",
- "net.FileListener": "net",
- "net.FilePacketConn": "net",
- "net.FlagBroadcast": "net",
- "net.FlagLoopback": "net",
- "net.FlagMulticast": "net",
- "net.FlagPointToPoint": "net",
- "net.FlagUp": "net",
- "net.Flags": "net",
- "net.HardwareAddr": "net",
- "net.IP": "net",
- "net.IPAddr": "net",
- "net.IPConn": "net",
- "net.IPMask": "net",
- "net.IPNet": "net",
- "net.IPv4": "net",
- "net.IPv4Mask": "net",
- "net.IPv4allrouter": "net",
- "net.IPv4allsys": "net",
- "net.IPv4bcast": "net",
- "net.IPv4len": "net",
- "net.IPv4zero": "net",
- "net.IPv6interfacelocalallnodes": "net",
- "net.IPv6len": "net",
- "net.IPv6linklocalallnodes": "net",
- "net.IPv6linklocalallrouters": "net",
- "net.IPv6loopback": "net",
- "net.IPv6unspecified": "net",
- "net.IPv6zero": "net",
- "net.Interface": "net",
- "net.InterfaceAddrs": "net",
- "net.InterfaceByIndex": "net",
- "net.InterfaceByName": "net",
- "net.Interfaces": "net",
- "net.InvalidAddrError": "net",
- "net.JoinHostPort": "net",
- "net.Listen": "net",
- "net.ListenIP": "net",
- "net.ListenMulticastUDP": "net",
- "net.ListenPacket": "net",
- "net.ListenTCP": "net",
- "net.ListenUDP": "net",
- "net.ListenUnix": "net",
- "net.ListenUnixgram": "net",
- "net.Listener": "net",
- "net.LookupAddr": "net",
- "net.LookupCNAME": "net",
- "net.LookupHost": "net",
- "net.LookupIP": "net",
- "net.LookupMX": "net",
- "net.LookupNS": "net",
- "net.LookupPort": "net",
- "net.LookupSRV": "net",
- "net.LookupTXT": "net",
- "net.MX": "net",
- "net.NS": "net",
- "net.OpError": "net",
- "net.PacketConn": "net",
- "net.ParseCIDR": "net",
- "net.ParseError": "net",
- "net.ParseIP": "net",
- "net.ParseMAC": "net",
- "net.Pipe": "net",
- "net.ResolveIPAddr": "net",
- "net.ResolveTCPAddr": "net",
- "net.ResolveUDPAddr": "net",
- "net.ResolveUnixAddr": "net",
- "net.SRV": "net",
- "net.SplitHostPort": "net",
- "net.TCPAddr": "net",
- "net.TCPConn": "net",
- "net.TCPListener": "net",
- "net.UDPAddr": "net",
- "net.UDPConn": "net",
- "net.UnixAddr": "net",
- "net.UnixConn": "net",
- "net.UnixListener": "net",
- "net.UnknownNetworkError": "net",
- "os.Args": "os",
- "os.Chdir": "os",
- "os.Chmod": "os",
- "os.Chown": "os",
- "os.Chtimes": "os",
- "os.Clearenv": "os",
- "os.Create": "os",
- "os.DevNull": "os",
- "os.Environ": "os",
- "os.ErrExist": "os",
- "os.ErrInvalid": "os",
- "os.ErrNotExist": "os",
- "os.ErrPermission": "os",
- "os.Exit": "os",
- "os.Expand": "os",
- "os.ExpandEnv": "os",
- "os.File": "os",
- "os.FileInfo": "os",
- "os.FileMode": "os",
- "os.FindProcess": "os",
- "os.Getegid": "os",
- "os.Getenv": "os",
- "os.Geteuid": "os",
- "os.Getgid": "os",
- "os.Getgroups": "os",
- "os.Getpagesize": "os",
- "os.Getpid": "os",
- "os.Getppid": "os",
- "os.Getuid": "os",
- "os.Getwd": "os",
- "os.Hostname": "os",
- "os.Interrupt": "os",
- "os.IsExist": "os",
- "os.IsNotExist": "os",
- "os.IsPathSeparator": "os",
- "os.IsPermission": "os",
- "os.Kill": "os",
- "os.Lchown": "os",
- "os.Link": "os",
- "os.LinkError": "os",
- "os.Lstat": "os",
- "os.Mkdir": "os",
- "os.MkdirAll": "os",
- "os.ModeAppend": "os",
- "os.ModeCharDevice": "os",
- "os.ModeDevice": "os",
- "os.ModeDir": "os",
- "os.ModeExclusive": "os",
- "os.ModeNamedPipe": "os",
- "os.ModePerm": "os",
- "os.ModeSetgid": "os",
- "os.ModeSetuid": "os",
- "os.ModeSocket": "os",
- "os.ModeSticky": "os",
- "os.ModeSymlink": "os",
- "os.ModeTemporary": "os",
- "os.ModeType": "os",
- "os.NewFile": "os",
- "os.NewSyscallError": "os",
- "os.O_APPEND": "os",
- "os.O_CREATE": "os",
- "os.O_EXCL": "os",
- "os.O_RDONLY": "os",
- "os.O_RDWR": "os",
- "os.O_SYNC": "os",
- "os.O_TRUNC": "os",
- "os.O_WRONLY": "os",
- "os.Open": "os",
- "os.OpenFile": "os",
- "os.PathError": "os",
- "os.PathListSeparator": "os",
- "os.PathSeparator": "os",
- "os.Pipe": "os",
- "os.ProcAttr": "os",
- "os.Process": "os",
- "os.ProcessState": "os",
- "os.Readlink": "os",
- "os.Remove": "os",
- "os.RemoveAll": "os",
- "os.Rename": "os",
- "os.SEEK_CUR": "os",
- "os.SEEK_END": "os",
- "os.SEEK_SET": "os",
- "os.SameFile": "os",
- "os.Setenv": "os",
- "os.Signal": "os",
- "os.StartProcess": "os",
- "os.Stat": "os",
- "os.Stderr": "os",
- "os.Stdin": "os",
- "os.Stdout": "os",
- "os.Symlink": "os",
- "os.SyscallError": "os",
- "os.TempDir": "os",
- "os.Truncate": "os",
- "palette.Plan9": "image/color/palette",
- "palette.WebSafe": "image/color/palette",
- "parse.ActionNode": "text/template/parse",
- "parse.BoolNode": "text/template/parse",
- "parse.BranchNode": "text/template/parse",
- "parse.ChainNode": "text/template/parse",
- "parse.CommandNode": "text/template/parse",
- "parse.DotNode": "text/template/parse",
- "parse.FieldNode": "text/template/parse",
- "parse.IdentifierNode": "text/template/parse",
- "parse.IfNode": "text/template/parse",
- "parse.IsEmptyTree": "text/template/parse",
- "parse.ListNode": "text/template/parse",
- "parse.New": "text/template/parse",
- "parse.NewIdentifier": "text/template/parse",
- "parse.NilNode": "text/template/parse",
- "parse.Node": "text/template/parse",
- "parse.NodeAction": "text/template/parse",
- "parse.NodeBool": "text/template/parse",
- "parse.NodeChain": "text/template/parse",
- "parse.NodeCommand": "text/template/parse",
- "parse.NodeDot": "text/template/parse",
- "parse.NodeField": "text/template/parse",
- "parse.NodeIdentifier": "text/template/parse",
- "parse.NodeIf": "text/template/parse",
- "parse.NodeList": "text/template/parse",
- "parse.NodeNil": "text/template/parse",
- "parse.NodeNumber": "text/template/parse",
- "parse.NodePipe": "text/template/parse",
- "parse.NodeRange": "text/template/parse",
- "parse.NodeString": "text/template/parse",
- "parse.NodeTemplate": "text/template/parse",
- "parse.NodeText": "text/template/parse",
- "parse.NodeType": "text/template/parse",
- "parse.NodeVariable": "text/template/parse",
- "parse.NodeWith": "text/template/parse",
- "parse.NumberNode": "text/template/parse",
- "parse.Parse": "text/template/parse",
- "parse.PipeNode": "text/template/parse",
- "parse.Pos": "text/template/parse",
- "parse.RangeNode": "text/template/parse",
- "parse.StringNode": "text/template/parse",
- "parse.TemplateNode": "text/template/parse",
- "parse.TextNode": "text/template/parse",
- "parse.Tree": "text/template/parse",
- "parse.VariableNode": "text/template/parse",
- "parse.WithNode": "text/template/parse",
- "parser.AllErrors": "go/parser",
- "parser.DeclarationErrors": "go/parser",
- "parser.ImportsOnly": "go/parser",
- "parser.Mode": "go/parser",
- "parser.PackageClauseOnly": "go/parser",
- "parser.ParseComments": "go/parser",
- "parser.ParseDir": "go/parser",
- "parser.ParseExpr": "go/parser",
- "parser.ParseFile": "go/parser",
- "parser.SpuriousErrors": "go/parser",
- "parser.Trace": "go/parser",
- "path.Base": "path",
- "path.Clean": "path",
- "path.Dir": "path",
- "path.ErrBadPattern": "path",
- "path.Ext": "path",
- "path.IsAbs": "path",
- "path.Join": "path",
- "path.Match": "path",
- "path.Split": "path",
- "pe.COFFSymbol": "debug/pe",
- "pe.COFFSymbolSize": "debug/pe",
- "pe.File": "debug/pe",
- "pe.FileHeader": "debug/pe",
- "pe.FormatError": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_AM33": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_AMD64": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_ARM": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_EBC": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_I386": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_IA64": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_M32R": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_MIPS16": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_MIPSFPU": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_MIPSFPU16": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_POWERPC": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_POWERPCFP": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_R4000": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_SH3": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_SH3DSP": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_SH4": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_SH5": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_THUMB": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_UNKNOWN": "debug/pe",
- "pe.IMAGE_FILE_MACHINE_WCEMIPSV2": "debug/pe",
- "pe.ImportDirectory": "debug/pe",
- "pe.NewFile": "debug/pe",
- "pe.Open": "debug/pe",
- "pe.Section": "debug/pe",
- "pe.SectionHeader": "debug/pe",
- "pe.SectionHeader32": "debug/pe",
- "pe.Symbol": "debug/pe",
- "pem.Block": "encoding/pem",
- "pem.Decode": "encoding/pem",
- "pem.Encode": "encoding/pem",
- "pem.EncodeToMemory": "encoding/pem",
- "pkix.AlgorithmIdentifier": "crypto/x509/pkix",
- "pkix.AttributeTypeAndValue": "crypto/x509/pkix",
- "pkix.CertificateList": "crypto/x509/pkix",
- "pkix.Extension": "crypto/x509/pkix",
- "pkix.Name": "crypto/x509/pkix",
- "pkix.RDNSequence": "crypto/x509/pkix",
- "pkix.RelativeDistinguishedNameSET": "crypto/x509/pkix",
- "pkix.RevokedCertificate": "crypto/x509/pkix",
- "pkix.TBSCertificateList": "crypto/x509/pkix",
- "png.Decode": "image/png",
- "png.DecodeConfig": "image/png",
- "png.Encode": "image/png",
- "png.FormatError": "image/png",
- "png.UnsupportedError": "image/png",
- "pprof.Cmdline": "net/http/pprof",
- "pprof.Handler": "net/http/pprof",
- "pprof.Index": "net/http/pprof",
- "pprof.Lookup": "runtime/pprof",
- "pprof.NewProfile": "runtime/pprof",
- // "pprof.Profile" is ambiguous
- "pprof.Profiles": "runtime/pprof",
- "pprof.StartCPUProfile": "runtime/pprof",
- "pprof.StopCPUProfile": "runtime/pprof",
- "pprof.Symbol": "net/http/pprof",
- "pprof.WriteHeapProfile": "runtime/pprof",
- "printer.CommentedNode": "go/printer",
- "printer.Config": "go/printer",
- "printer.Fprint": "go/printer",
- "printer.Mode": "go/printer",
- "printer.RawFormat": "go/printer",
- "printer.SourcePos": "go/printer",
- "printer.TabIndent": "go/printer",
- "printer.UseSpaces": "go/printer",
- "quick.Check": "testing/quick",
- "quick.CheckEqual": "testing/quick",
- "quick.CheckEqualError": "testing/quick",
- "quick.CheckError": "testing/quick",
- "quick.Config": "testing/quick",
- "quick.Generator": "testing/quick",
- "quick.SetupError": "testing/quick",
- "quick.Value": "testing/quick",
- "rand.ExpFloat64": "math/rand",
- "rand.Float32": "math/rand",
- "rand.Float64": "math/rand",
- // "rand.Int" is ambiguous
- "rand.Int31": "math/rand",
- "rand.Int31n": "math/rand",
- "rand.Int63": "math/rand",
- "rand.Int63n": "math/rand",
- "rand.Intn": "math/rand",
- "rand.New": "math/rand",
- "rand.NewSource": "math/rand",
- "rand.NewZipf": "math/rand",
- "rand.NormFloat64": "math/rand",
- "rand.Perm": "math/rand",
- "rand.Prime": "crypto/rand",
- "rand.Rand": "math/rand",
- "rand.Read": "crypto/rand",
- "rand.Reader": "crypto/rand",
- "rand.Seed": "math/rand",
- "rand.Source": "math/rand",
- "rand.Uint32": "math/rand",
- "rand.Zipf": "math/rand",
- "rc4.Cipher": "crypto/rc4",
- "rc4.KeySizeError": "crypto/rc4",
- "rc4.NewCipher": "crypto/rc4",
- "reflect.Append": "reflect",
- "reflect.AppendSlice": "reflect",
- "reflect.Array": "reflect",
- "reflect.Bool": "reflect",
- "reflect.BothDir": "reflect",
- "reflect.Chan": "reflect",
- "reflect.ChanDir": "reflect",
- "reflect.ChanOf": "reflect",
- "reflect.Complex128": "reflect",
- "reflect.Complex64": "reflect",
- "reflect.Copy": "reflect",
- "reflect.DeepEqual": "reflect",
- "reflect.Float32": "reflect",
- "reflect.Float64": "reflect",
- "reflect.Func": "reflect",
- "reflect.Indirect": "reflect",
- "reflect.Int": "reflect",
- "reflect.Int16": "reflect",
- "reflect.Int32": "reflect",
- "reflect.Int64": "reflect",
- "reflect.Int8": "reflect",
- "reflect.Interface": "reflect",
- "reflect.Invalid": "reflect",
- "reflect.Kind": "reflect",
- "reflect.MakeChan": "reflect",
- "reflect.MakeFunc": "reflect",
- "reflect.MakeMap": "reflect",
- "reflect.MakeSlice": "reflect",
- "reflect.Map": "reflect",
- "reflect.MapOf": "reflect",
- "reflect.Method": "reflect",
- "reflect.New": "reflect",
- "reflect.NewAt": "reflect",
- "reflect.Ptr": "reflect",
- "reflect.PtrTo": "reflect",
- "reflect.RecvDir": "reflect",
- "reflect.Select": "reflect",
- "reflect.SelectCase": "reflect",
- "reflect.SelectDefault": "reflect",
- "reflect.SelectDir": "reflect",
- "reflect.SelectRecv": "reflect",
- "reflect.SelectSend": "reflect",
- "reflect.SendDir": "reflect",
- "reflect.Slice": "reflect",
- "reflect.SliceHeader": "reflect",
- "reflect.SliceOf": "reflect",
- "reflect.String": "reflect",
- "reflect.StringHeader": "reflect",
- "reflect.Struct": "reflect",
- "reflect.StructField": "reflect",
- "reflect.StructTag": "reflect",
- "reflect.TypeOf": "reflect",
- "reflect.Uint": "reflect",
- "reflect.Uint16": "reflect",
- "reflect.Uint32": "reflect",
- "reflect.Uint64": "reflect",
- "reflect.Uint8": "reflect",
- "reflect.Uintptr": "reflect",
- "reflect.UnsafePointer": "reflect",
- "reflect.Value": "reflect",
- "reflect.ValueError": "reflect",
- "reflect.ValueOf": "reflect",
- "reflect.Zero": "reflect",
- "regexp.Compile": "regexp",
- "regexp.CompilePOSIX": "regexp",
- "regexp.Match": "regexp",
- "regexp.MatchReader": "regexp",
- "regexp.MatchString": "regexp",
- "regexp.MustCompile": "regexp",
- "regexp.MustCompilePOSIX": "regexp",
- "regexp.QuoteMeta": "regexp",
- "regexp.Regexp": "regexp",
- "ring.New": "container/ring",
- "ring.Ring": "container/ring",
- "rpc.Accept": "net/rpc",
- "rpc.Call": "net/rpc",
- "rpc.Client": "net/rpc",
- "rpc.ClientCodec": "net/rpc",
- "rpc.DefaultDebugPath": "net/rpc",
- "rpc.DefaultRPCPath": "net/rpc",
- "rpc.DefaultServer": "net/rpc",
- "rpc.Dial": "net/rpc",
- "rpc.DialHTTP": "net/rpc",
- "rpc.DialHTTPPath": "net/rpc",
- "rpc.ErrShutdown": "net/rpc",
- "rpc.HandleHTTP": "net/rpc",
- "rpc.NewClient": "net/rpc",
- "rpc.NewClientWithCodec": "net/rpc",
- "rpc.NewServer": "net/rpc",
- "rpc.Register": "net/rpc",
- "rpc.RegisterName": "net/rpc",
- "rpc.Request": "net/rpc",
- "rpc.Response": "net/rpc",
- "rpc.ServeCodec": "net/rpc",
- "rpc.ServeConn": "net/rpc",
- "rpc.ServeRequest": "net/rpc",
- "rpc.Server": "net/rpc",
- "rpc.ServerCodec": "net/rpc",
- "rpc.ServerError": "net/rpc",
- "rsa.CRTValue": "crypto/rsa",
- "rsa.DecryptOAEP": "crypto/rsa",
- "rsa.DecryptPKCS1v15": "crypto/rsa",
- "rsa.DecryptPKCS1v15SessionKey": "crypto/rsa",
- "rsa.EncryptOAEP": "crypto/rsa",
- "rsa.EncryptPKCS1v15": "crypto/rsa",
- "rsa.ErrDecryption": "crypto/rsa",
- "rsa.ErrMessageTooLong": "crypto/rsa",
- "rsa.ErrVerification": "crypto/rsa",
- "rsa.GenerateKey": "crypto/rsa",
- "rsa.GenerateMultiPrimeKey": "crypto/rsa",
- "rsa.PSSOptions": "crypto/rsa",
- "rsa.PSSSaltLengthAuto": "crypto/rsa",
- "rsa.PSSSaltLengthEqualsHash": "crypto/rsa",
- "rsa.PrecomputedValues": "crypto/rsa",
- "rsa.PrivateKey": "crypto/rsa",
- "rsa.PublicKey": "crypto/rsa",
- "rsa.SignPKCS1v15": "crypto/rsa",
- "rsa.SignPSS": "crypto/rsa",
- "rsa.VerifyPKCS1v15": "crypto/rsa",
- "rsa.VerifyPSS": "crypto/rsa",
- "runtime.BlockProfile": "runtime",
- "runtime.BlockProfileRecord": "runtime",
- "runtime.Breakpoint": "runtime",
- "runtime.CPUProfile": "runtime",
- "runtime.Caller": "runtime",
- "runtime.Callers": "runtime",
- "runtime.Compiler": "runtime",
- "runtime.Error": "runtime",
- "runtime.Func": "runtime",
- "runtime.FuncForPC": "runtime",
- "runtime.GC": "runtime",
- "runtime.GOARCH": "runtime",
- "runtime.GOMAXPROCS": "runtime",
- "runtime.GOOS": "runtime",
- "runtime.GOROOT": "runtime",
- "runtime.Goexit": "runtime",
- "runtime.GoroutineProfile": "runtime",
- "runtime.Gosched": "runtime",
- "runtime.LockOSThread": "runtime",
- "runtime.MemProfile": "runtime",
- "runtime.MemProfileRate": "runtime",
- "runtime.MemProfileRecord": "runtime",
- "runtime.MemStats": "runtime",
- "runtime.NumCPU": "runtime",
- "runtime.NumCgoCall": "runtime",
- "runtime.NumGoroutine": "runtime",
- "runtime.ReadMemStats": "runtime",
- "runtime.SetBlockProfileRate": "runtime",
- "runtime.SetCPUProfileRate": "runtime",
- "runtime.SetFinalizer": "runtime",
- "runtime.Stack": "runtime",
- "runtime.StackRecord": "runtime",
- "runtime.ThreadCreateProfile": "runtime",
- "runtime.TypeAssertionError": "runtime",
- "runtime.UnlockOSThread": "runtime",
- "runtime.Version": "runtime",
- "scanner.Char": "text/scanner",
- "scanner.Comment": "text/scanner",
- "scanner.EOF": "text/scanner",
- "scanner.Error": "go/scanner",
- "scanner.ErrorHandler": "go/scanner",
- "scanner.ErrorList": "go/scanner",
- "scanner.Float": "text/scanner",
- "scanner.GoTokens": "text/scanner",
- "scanner.GoWhitespace": "text/scanner",
- "scanner.Ident": "text/scanner",
- "scanner.Int": "text/scanner",
- "scanner.Mode": "go/scanner",
- "scanner.Position": "text/scanner",
- "scanner.PrintError": "go/scanner",
- "scanner.RawString": "text/scanner",
- "scanner.ScanChars": "text/scanner",
- // "scanner.ScanComments" is ambiguous
- "scanner.ScanFloats": "text/scanner",
- "scanner.ScanIdents": "text/scanner",
- "scanner.ScanInts": "text/scanner",
- "scanner.ScanRawStrings": "text/scanner",
- "scanner.ScanStrings": "text/scanner",
- // "scanner.Scanner" is ambiguous
- "scanner.SkipComments": "text/scanner",
- "scanner.String": "text/scanner",
- "scanner.TokenString": "text/scanner",
- "sha1.BlockSize": "crypto/sha1",
- "sha1.New": "crypto/sha1",
- "sha1.Size": "crypto/sha1",
- "sha1.Sum": "crypto/sha1",
- "sha256.BlockSize": "crypto/sha256",
- "sha256.New": "crypto/sha256",
- "sha256.New224": "crypto/sha256",
- "sha256.Size": "crypto/sha256",
- "sha256.Size224": "crypto/sha256",
- "sha256.Sum224": "crypto/sha256",
- "sha256.Sum256": "crypto/sha256",
- "sha512.BlockSize": "crypto/sha512",
- "sha512.New": "crypto/sha512",
- "sha512.New384": "crypto/sha512",
- "sha512.Size": "crypto/sha512",
- "sha512.Size384": "crypto/sha512",
- "sha512.Sum384": "crypto/sha512",
- "sha512.Sum512": "crypto/sha512",
- "signal.Notify": "os/signal",
- "signal.Stop": "os/signal",
- "smtp.Auth": "net/smtp",
- "smtp.CRAMMD5Auth": "net/smtp",
- "smtp.Client": "net/smtp",
- "smtp.Dial": "net/smtp",
- "smtp.NewClient": "net/smtp",
- "smtp.PlainAuth": "net/smtp",
- "smtp.SendMail": "net/smtp",
- "smtp.ServerInfo": "net/smtp",
- "sort.Float64Slice": "sort",
- "sort.Float64s": "sort",
- "sort.Float64sAreSorted": "sort",
- "sort.IntSlice": "sort",
- "sort.Interface": "sort",
- "sort.Ints": "sort",
- "sort.IntsAreSorted": "sort",
- "sort.IsSorted": "sort",
- "sort.Reverse": "sort",
- "sort.Search": "sort",
- "sort.SearchFloat64s": "sort",
- "sort.SearchInts": "sort",
- "sort.SearchStrings": "sort",
- "sort.Sort": "sort",
- "sort.Stable": "sort",
- "sort.StringSlice": "sort",
- "sort.Strings": "sort",
- "sort.StringsAreSorted": "sort",
- "sql.DB": "database/sql",
- "sql.ErrNoRows": "database/sql",
- "sql.ErrTxDone": "database/sql",
- "sql.NullBool": "database/sql",
- "sql.NullFloat64": "database/sql",
- "sql.NullInt64": "database/sql",
- "sql.NullString": "database/sql",
- "sql.Open": "database/sql",
- "sql.RawBytes": "database/sql",
- "sql.Register": "database/sql",
- "sql.Result": "database/sql",
- "sql.Row": "database/sql",
- "sql.Rows": "database/sql",
- "sql.Scanner": "database/sql",
- "sql.Stmt": "database/sql",
- "sql.Tx": "database/sql",
- "strconv.AppendBool": "strconv",
- "strconv.AppendFloat": "strconv",
- "strconv.AppendInt": "strconv",
- "strconv.AppendQuote": "strconv",
- "strconv.AppendQuoteRune": "strconv",
- "strconv.AppendQuoteRuneToASCII": "strconv",
- "strconv.AppendQuoteToASCII": "strconv",
- "strconv.AppendUint": "strconv",
- "strconv.Atoi": "strconv",
- "strconv.CanBackquote": "strconv",
- "strconv.ErrRange": "strconv",
- "strconv.ErrSyntax": "strconv",
- "strconv.FormatBool": "strconv",
- "strconv.FormatFloat": "strconv",
- "strconv.FormatInt": "strconv",
- "strconv.FormatUint": "strconv",
- "strconv.IntSize": "strconv",
- "strconv.IsPrint": "strconv",
- "strconv.Itoa": "strconv",
- "strconv.NumError": "strconv",
- "strconv.ParseBool": "strconv",
- "strconv.ParseFloat": "strconv",
- "strconv.ParseInt": "strconv",
- "strconv.ParseUint": "strconv",
- "strconv.Quote": "strconv",
- "strconv.QuoteRune": "strconv",
- "strconv.QuoteRuneToASCII": "strconv",
- "strconv.QuoteToASCII": "strconv",
- "strconv.Unquote": "strconv",
- "strconv.UnquoteChar": "strconv",
- "strings.Contains": "strings",
- "strings.ContainsAny": "strings",
- "strings.ContainsRune": "strings",
- "strings.Count": "strings",
- "strings.EqualFold": "strings",
- "strings.Fields": "strings",
- "strings.FieldsFunc": "strings",
- "strings.HasPrefix": "strings",
- "strings.HasSuffix": "strings",
- "strings.Index": "strings",
- "strings.IndexAny": "strings",
- "strings.IndexByte": "strings",
- "strings.IndexFunc": "strings",
- "strings.IndexRune": "strings",
- "strings.Join": "strings",
- "strings.LastIndex": "strings",
- "strings.LastIndexAny": "strings",
- "strings.LastIndexFunc": "strings",
- "strings.Map": "strings",
- "strings.NewReader": "strings",
- "strings.NewReplacer": "strings",
- "strings.Reader": "strings",
- "strings.Repeat": "strings",
- "strings.Replace": "strings",
- "strings.Replacer": "strings",
- "strings.Split": "strings",
- "strings.SplitAfter": "strings",
- "strings.SplitAfterN": "strings",
- "strings.SplitN": "strings",
- "strings.Title": "strings",
- "strings.ToLower": "strings",
- "strings.ToLowerSpecial": "strings",
- "strings.ToTitle": "strings",
- "strings.ToTitleSpecial": "strings",
- "strings.ToUpper": "strings",
- "strings.ToUpperSpecial": "strings",
- "strings.Trim": "strings",
- "strings.TrimFunc": "strings",
- "strings.TrimLeft": "strings",
- "strings.TrimLeftFunc": "strings",
- "strings.TrimPrefix": "strings",
- "strings.TrimRight": "strings",
- "strings.TrimRightFunc": "strings",
- "strings.TrimSpace": "strings",
- "strings.TrimSuffix": "strings",
- "subtle.ConstantTimeByteEq": "crypto/subtle",
- "subtle.ConstantTimeCompare": "crypto/subtle",
- "subtle.ConstantTimeCopy": "crypto/subtle",
- "subtle.ConstantTimeEq": "crypto/subtle",
- "subtle.ConstantTimeLessOrEq": "crypto/subtle",
- "subtle.ConstantTimeSelect": "crypto/subtle",
- "suffixarray.Index": "index/suffixarray",
- "suffixarray.New": "index/suffixarray",
- "sync.Cond": "sync",
- "sync.Locker": "sync",
- "sync.Mutex": "sync",
- "sync.NewCond": "sync",
- "sync.Once": "sync",
- "sync.RWMutex": "sync",
- "sync.WaitGroup": "sync",
- "syntax.ClassNL": "regexp/syntax",
- "syntax.Compile": "regexp/syntax",
- "syntax.DotNL": "regexp/syntax",
- "syntax.EmptyBeginLine": "regexp/syntax",
- "syntax.EmptyBeginText": "regexp/syntax",
- "syntax.EmptyEndLine": "regexp/syntax",
- "syntax.EmptyEndText": "regexp/syntax",
- "syntax.EmptyNoWordBoundary": "regexp/syntax",
- "syntax.EmptyOp": "regexp/syntax",
- "syntax.EmptyOpContext": "regexp/syntax",
- "syntax.EmptyWordBoundary": "regexp/syntax",
- "syntax.ErrInternalError": "regexp/syntax",
- "syntax.ErrInvalidCharClass": "regexp/syntax",
- "syntax.ErrInvalidCharRange": "regexp/syntax",
- "syntax.ErrInvalidEscape": "regexp/syntax",
- "syntax.ErrInvalidNamedCapture": "regexp/syntax",
- "syntax.ErrInvalidPerlOp": "regexp/syntax",
- "syntax.ErrInvalidRepeatOp": "regexp/syntax",
- "syntax.ErrInvalidRepeatSize": "regexp/syntax",
- "syntax.ErrInvalidUTF8": "regexp/syntax",
- "syntax.ErrMissingBracket": "regexp/syntax",
- "syntax.ErrMissingParen": "regexp/syntax",
- "syntax.ErrMissingRepeatArgument": "regexp/syntax",
- "syntax.ErrTrailingBackslash": "regexp/syntax",
- "syntax.ErrUnexpectedParen": "regexp/syntax",
- "syntax.Error": "regexp/syntax",
- "syntax.ErrorCode": "regexp/syntax",
- "syntax.Flags": "regexp/syntax",
- "syntax.FoldCase": "regexp/syntax",
- "syntax.Inst": "regexp/syntax",
- "syntax.InstAlt": "regexp/syntax",
- "syntax.InstAltMatch": "regexp/syntax",
- "syntax.InstCapture": "regexp/syntax",
- "syntax.InstEmptyWidth": "regexp/syntax",
- "syntax.InstFail": "regexp/syntax",
- "syntax.InstMatch": "regexp/syntax",
- "syntax.InstNop": "regexp/syntax",
- "syntax.InstOp": "regexp/syntax",
- "syntax.InstRune": "regexp/syntax",
- "syntax.InstRune1": "regexp/syntax",
- "syntax.InstRuneAny": "regexp/syntax",
- "syntax.InstRuneAnyNotNL": "regexp/syntax",
- "syntax.IsWordChar": "regexp/syntax",
- "syntax.Literal": "regexp/syntax",
- "syntax.MatchNL": "regexp/syntax",
- "syntax.NonGreedy": "regexp/syntax",
- "syntax.OneLine": "regexp/syntax",
- "syntax.Op": "regexp/syntax",
- "syntax.OpAlternate": "regexp/syntax",
- "syntax.OpAnyChar": "regexp/syntax",
- "syntax.OpAnyCharNotNL": "regexp/syntax",
- "syntax.OpBeginLine": "regexp/syntax",
- "syntax.OpBeginText": "regexp/syntax",
- "syntax.OpCapture": "regexp/syntax",
- "syntax.OpCharClass": "regexp/syntax",
- "syntax.OpConcat": "regexp/syntax",
- "syntax.OpEmptyMatch": "regexp/syntax",
- "syntax.OpEndLine": "regexp/syntax",
- "syntax.OpEndText": "regexp/syntax",
- "syntax.OpLiteral": "regexp/syntax",
- "syntax.OpNoMatch": "regexp/syntax",
- "syntax.OpNoWordBoundary": "regexp/syntax",
- "syntax.OpPlus": "regexp/syntax",
- "syntax.OpQuest": "regexp/syntax",
- "syntax.OpRepeat": "regexp/syntax",
- "syntax.OpStar": "regexp/syntax",
- "syntax.OpWordBoundary": "regexp/syntax",
- "syntax.POSIX": "regexp/syntax",
- "syntax.Parse": "regexp/syntax",
- "syntax.Perl": "regexp/syntax",
- "syntax.PerlX": "regexp/syntax",
- "syntax.Prog": "regexp/syntax",
- "syntax.Regexp": "regexp/syntax",
- "syntax.Simple": "regexp/syntax",
- "syntax.UnicodeGroups": "regexp/syntax",
- "syntax.WasDollar": "regexp/syntax",
- "syscall.AF_ALG": "syscall",
- "syscall.AF_APPLETALK": "syscall",
- "syscall.AF_ARP": "syscall",
- "syscall.AF_ASH": "syscall",
- "syscall.AF_ATM": "syscall",
- "syscall.AF_ATMPVC": "syscall",
- "syscall.AF_ATMSVC": "syscall",
- "syscall.AF_AX25": "syscall",
- "syscall.AF_BLUETOOTH": "syscall",
- "syscall.AF_BRIDGE": "syscall",
- "syscall.AF_CAIF": "syscall",
- "syscall.AF_CAN": "syscall",
- "syscall.AF_CCITT": "syscall",
- "syscall.AF_CHAOS": "syscall",
- "syscall.AF_CNT": "syscall",
- "syscall.AF_COIP": "syscall",
- "syscall.AF_DATAKIT": "syscall",
- "syscall.AF_DECnet": "syscall",
- "syscall.AF_DLI": "syscall",
- "syscall.AF_E164": "syscall",
- "syscall.AF_ECMA": "syscall",
- "syscall.AF_ECONET": "syscall",
- "syscall.AF_ENCAP": "syscall",
- "syscall.AF_FILE": "syscall",
- "syscall.AF_HYLINK": "syscall",
- "syscall.AF_IEEE80211": "syscall",
- "syscall.AF_IEEE802154": "syscall",
- "syscall.AF_IMPLINK": "syscall",
- "syscall.AF_INET": "syscall",
- "syscall.AF_INET6": "syscall",
- "syscall.AF_IPX": "syscall",
- "syscall.AF_IRDA": "syscall",
- "syscall.AF_ISDN": "syscall",
- "syscall.AF_ISO": "syscall",
- "syscall.AF_IUCV": "syscall",
- "syscall.AF_KEY": "syscall",
- "syscall.AF_LAT": "syscall",
- "syscall.AF_LINK": "syscall",
- "syscall.AF_LLC": "syscall",
- "syscall.AF_LOCAL": "syscall",
- "syscall.AF_MAX": "syscall",
- "syscall.AF_MPLS": "syscall",
- "syscall.AF_NATM": "syscall",
- "syscall.AF_NDRV": "syscall",
- "syscall.AF_NETBEUI": "syscall",
- "syscall.AF_NETBIOS": "syscall",
- "syscall.AF_NETGRAPH": "syscall",
- "syscall.AF_NETLINK": "syscall",
- "syscall.AF_NETROM": "syscall",
- "syscall.AF_NS": "syscall",
- "syscall.AF_OROUTE": "syscall",
- "syscall.AF_OSI": "syscall",
- "syscall.AF_PACKET": "syscall",
- "syscall.AF_PHONET": "syscall",
- "syscall.AF_PPP": "syscall",
- "syscall.AF_PPPOX": "syscall",
- "syscall.AF_PUP": "syscall",
- "syscall.AF_RDS": "syscall",
- "syscall.AF_RESERVED_36": "syscall",
- "syscall.AF_ROSE": "syscall",
- "syscall.AF_ROUTE": "syscall",
- "syscall.AF_RXRPC": "syscall",
- "syscall.AF_SCLUSTER": "syscall",
- "syscall.AF_SECURITY": "syscall",
- "syscall.AF_SIP": "syscall",
- "syscall.AF_SLOW": "syscall",
- "syscall.AF_SNA": "syscall",
- "syscall.AF_SYSTEM": "syscall",
- "syscall.AF_TIPC": "syscall",
- "syscall.AF_UNIX": "syscall",
- "syscall.AF_UNSPEC": "syscall",
- "syscall.AF_VENDOR00": "syscall",
- "syscall.AF_VENDOR01": "syscall",
- "syscall.AF_VENDOR02": "syscall",
- "syscall.AF_VENDOR03": "syscall",
- "syscall.AF_VENDOR04": "syscall",
- "syscall.AF_VENDOR05": "syscall",
- "syscall.AF_VENDOR06": "syscall",
- "syscall.AF_VENDOR07": "syscall",
- "syscall.AF_VENDOR08": "syscall",
- "syscall.AF_VENDOR09": "syscall",
- "syscall.AF_VENDOR10": "syscall",
- "syscall.AF_VENDOR11": "syscall",
- "syscall.AF_VENDOR12": "syscall",
- "syscall.AF_VENDOR13": "syscall",
- "syscall.AF_VENDOR14": "syscall",
- "syscall.AF_VENDOR15": "syscall",
- "syscall.AF_VENDOR16": "syscall",
- "syscall.AF_VENDOR17": "syscall",
- "syscall.AF_VENDOR18": "syscall",
- "syscall.AF_VENDOR19": "syscall",
- "syscall.AF_VENDOR20": "syscall",
- "syscall.AF_VENDOR21": "syscall",
- "syscall.AF_VENDOR22": "syscall",
- "syscall.AF_VENDOR23": "syscall",
- "syscall.AF_VENDOR24": "syscall",
- "syscall.AF_VENDOR25": "syscall",
- "syscall.AF_VENDOR26": "syscall",
- "syscall.AF_VENDOR27": "syscall",
- "syscall.AF_VENDOR28": "syscall",
- "syscall.AF_VENDOR29": "syscall",
- "syscall.AF_VENDOR30": "syscall",
- "syscall.AF_VENDOR31": "syscall",
- "syscall.AF_VENDOR32": "syscall",
- "syscall.AF_VENDOR33": "syscall",
- "syscall.AF_VENDOR34": "syscall",
- "syscall.AF_VENDOR35": "syscall",
- "syscall.AF_VENDOR36": "syscall",
- "syscall.AF_VENDOR37": "syscall",
- "syscall.AF_VENDOR38": "syscall",
- "syscall.AF_VENDOR39": "syscall",
- "syscall.AF_VENDOR40": "syscall",
- "syscall.AF_VENDOR41": "syscall",
- "syscall.AF_VENDOR42": "syscall",
- "syscall.AF_VENDOR43": "syscall",
- "syscall.AF_VENDOR44": "syscall",
- "syscall.AF_VENDOR45": "syscall",
- "syscall.AF_VENDOR46": "syscall",
- "syscall.AF_VENDOR47": "syscall",
- "syscall.AF_WANPIPE": "syscall",
- "syscall.AF_X25": "syscall",
- "syscall.AI_CANONNAME": "syscall",
- "syscall.AI_NUMERICHOST": "syscall",
- "syscall.AI_PASSIVE": "syscall",
- "syscall.APPLICATION_ERROR": "syscall",
- "syscall.ARPHRD_ADAPT": "syscall",
- "syscall.ARPHRD_APPLETLK": "syscall",
- "syscall.ARPHRD_ARCNET": "syscall",
- "syscall.ARPHRD_ASH": "syscall",
- "syscall.ARPHRD_ATM": "syscall",
- "syscall.ARPHRD_AX25": "syscall",
- "syscall.ARPHRD_BIF": "syscall",
- "syscall.ARPHRD_CHAOS": "syscall",
- "syscall.ARPHRD_CISCO": "syscall",
- "syscall.ARPHRD_CSLIP": "syscall",
- "syscall.ARPHRD_CSLIP6": "syscall",
- "syscall.ARPHRD_DDCMP": "syscall",
- "syscall.ARPHRD_DLCI": "syscall",
- "syscall.ARPHRD_ECONET": "syscall",
- "syscall.ARPHRD_EETHER": "syscall",
- "syscall.ARPHRD_ETHER": "syscall",
- "syscall.ARPHRD_EUI64": "syscall",
- "syscall.ARPHRD_FCAL": "syscall",
- "syscall.ARPHRD_FCFABRIC": "syscall",
- "syscall.ARPHRD_FCPL": "syscall",
- "syscall.ARPHRD_FCPP": "syscall",
- "syscall.ARPHRD_FDDI": "syscall",
- "syscall.ARPHRD_FRAD": "syscall",
- "syscall.ARPHRD_FRELAY": "syscall",
- "syscall.ARPHRD_HDLC": "syscall",
- "syscall.ARPHRD_HIPPI": "syscall",
- "syscall.ARPHRD_HWX25": "syscall",
- "syscall.ARPHRD_IEEE1394": "syscall",
- "syscall.ARPHRD_IEEE802": "syscall",
- "syscall.ARPHRD_IEEE80211": "syscall",
- "syscall.ARPHRD_IEEE80211_PRISM": "syscall",
- "syscall.ARPHRD_IEEE80211_RADIOTAP": "syscall",
- "syscall.ARPHRD_IEEE802154": "syscall",
- "syscall.ARPHRD_IEEE802154_PHY": "syscall",
- "syscall.ARPHRD_IEEE802_TR": "syscall",
- "syscall.ARPHRD_INFINIBAND": "syscall",
- "syscall.ARPHRD_IPDDP": "syscall",
- "syscall.ARPHRD_IPGRE": "syscall",
- "syscall.ARPHRD_IRDA": "syscall",
- "syscall.ARPHRD_LAPB": "syscall",
- "syscall.ARPHRD_LOCALTLK": "syscall",
- "syscall.ARPHRD_LOOPBACK": "syscall",
- "syscall.ARPHRD_METRICOM": "syscall",
- "syscall.ARPHRD_NETROM": "syscall",
- "syscall.ARPHRD_NONE": "syscall",
- "syscall.ARPHRD_PIMREG": "syscall",
- "syscall.ARPHRD_PPP": "syscall",
- "syscall.ARPHRD_PRONET": "syscall",
- "syscall.ARPHRD_RAWHDLC": "syscall",
- "syscall.ARPHRD_ROSE": "syscall",
- "syscall.ARPHRD_RSRVD": "syscall",
- "syscall.ARPHRD_SIT": "syscall",
- "syscall.ARPHRD_SKIP": "syscall",
- "syscall.ARPHRD_SLIP": "syscall",
- "syscall.ARPHRD_SLIP6": "syscall",
- "syscall.ARPHRD_STRIP": "syscall",
- "syscall.ARPHRD_TUNNEL": "syscall",
- "syscall.ARPHRD_TUNNEL6": "syscall",
- "syscall.ARPHRD_VOID": "syscall",
- "syscall.ARPHRD_X25": "syscall",
- "syscall.AUTHTYPE_CLIENT": "syscall",
- "syscall.AUTHTYPE_SERVER": "syscall",
- "syscall.Accept": "syscall",
- "syscall.Accept4": "syscall",
- "syscall.AcceptEx": "syscall",
- "syscall.Access": "syscall",
- "syscall.Acct": "syscall",
- "syscall.AddrinfoW": "syscall",
- "syscall.Adjtime": "syscall",
- "syscall.Adjtimex": "syscall",
- "syscall.AttachLsf": "syscall",
- "syscall.B0": "syscall",
- "syscall.B1000000": "syscall",
- "syscall.B110": "syscall",
- "syscall.B115200": "syscall",
- "syscall.B1152000": "syscall",
- "syscall.B1200": "syscall",
- "syscall.B134": "syscall",
- "syscall.B14400": "syscall",
- "syscall.B150": "syscall",
- "syscall.B1500000": "syscall",
- "syscall.B1800": "syscall",
- "syscall.B19200": "syscall",
- "syscall.B200": "syscall",
- "syscall.B2000000": "syscall",
- "syscall.B230400": "syscall",
- "syscall.B2400": "syscall",
- "syscall.B2500000": "syscall",
- "syscall.B28800": "syscall",
- "syscall.B300": "syscall",
- "syscall.B3000000": "syscall",
- "syscall.B3500000": "syscall",
- "syscall.B38400": "syscall",
- "syscall.B4000000": "syscall",
- "syscall.B460800": "syscall",
- "syscall.B4800": "syscall",
- "syscall.B50": "syscall",
- "syscall.B500000": "syscall",
- "syscall.B57600": "syscall",
- "syscall.B576000": "syscall",
- "syscall.B600": "syscall",
- "syscall.B7200": "syscall",
- "syscall.B75": "syscall",
- "syscall.B76800": "syscall",
- "syscall.B921600": "syscall",
- "syscall.B9600": "syscall",
- "syscall.BASE_PROTOCOL": "syscall",
- "syscall.BIOCFEEDBACK": "syscall",
- "syscall.BIOCFLUSH": "syscall",
- "syscall.BIOCGBLEN": "syscall",
- "syscall.BIOCGDIRECTION": "syscall",
- "syscall.BIOCGDIRFILT": "syscall",
- "syscall.BIOCGDLT": "syscall",
- "syscall.BIOCGDLTLIST": "syscall",
- "syscall.BIOCGETBUFMODE": "syscall",
- "syscall.BIOCGETIF": "syscall",
- "syscall.BIOCGETZMAX": "syscall",
- "syscall.BIOCGFEEDBACK": "syscall",
- "syscall.BIOCGFILDROP": "syscall",
- "syscall.BIOCGHDRCMPLT": "syscall",
- "syscall.BIOCGRSIG": "syscall",
- "syscall.BIOCGRTIMEOUT": "syscall",
- "syscall.BIOCGSEESENT": "syscall",
- "syscall.BIOCGSTATS": "syscall",
- "syscall.BIOCGSTATSOLD": "syscall",
- "syscall.BIOCGTSTAMP": "syscall",
- "syscall.BIOCIMMEDIATE": "syscall",
- "syscall.BIOCLOCK": "syscall",
- "syscall.BIOCPROMISC": "syscall",
- "syscall.BIOCROTZBUF": "syscall",
- "syscall.BIOCSBLEN": "syscall",
- "syscall.BIOCSDIRECTION": "syscall",
- "syscall.BIOCSDIRFILT": "syscall",
- "syscall.BIOCSDLT": "syscall",
- "syscall.BIOCSETBUFMODE": "syscall",
- "syscall.BIOCSETF": "syscall",
- "syscall.BIOCSETFNR": "syscall",
- "syscall.BIOCSETIF": "syscall",
- "syscall.BIOCSETWF": "syscall",
- "syscall.BIOCSETZBUF": "syscall",
- "syscall.BIOCSFEEDBACK": "syscall",
- "syscall.BIOCSFILDROP": "syscall",
- "syscall.BIOCSHDRCMPLT": "syscall",
- "syscall.BIOCSRSIG": "syscall",
- "syscall.BIOCSRTIMEOUT": "syscall",
- "syscall.BIOCSSEESENT": "syscall",
- "syscall.BIOCSTCPF": "syscall",
- "syscall.BIOCSTSTAMP": "syscall",
- "syscall.BIOCSUDPF": "syscall",
- "syscall.BIOCVERSION": "syscall",
- "syscall.BPF_A": "syscall",
- "syscall.BPF_ABS": "syscall",
- "syscall.BPF_ADD": "syscall",
- "syscall.BPF_ALIGNMENT": "syscall",
- "syscall.BPF_ALIGNMENT32": "syscall",
- "syscall.BPF_ALU": "syscall",
- "syscall.BPF_AND": "syscall",
- "syscall.BPF_B": "syscall",
- "syscall.BPF_BUFMODE_BUFFER": "syscall",
- "syscall.BPF_BUFMODE_ZBUF": "syscall",
- "syscall.BPF_DFLTBUFSIZE": "syscall",
- "syscall.BPF_DIRECTION_IN": "syscall",
- "syscall.BPF_DIRECTION_OUT": "syscall",
- "syscall.BPF_DIV": "syscall",
- "syscall.BPF_H": "syscall",
- "syscall.BPF_IMM": "syscall",
- "syscall.BPF_IND": "syscall",
- "syscall.BPF_JA": "syscall",
- "syscall.BPF_JEQ": "syscall",
- "syscall.BPF_JGE": "syscall",
- "syscall.BPF_JGT": "syscall",
- "syscall.BPF_JMP": "syscall",
- "syscall.BPF_JSET": "syscall",
- "syscall.BPF_K": "syscall",
- "syscall.BPF_LD": "syscall",
- "syscall.BPF_LDX": "syscall",
- "syscall.BPF_LEN": "syscall",
- "syscall.BPF_LSH": "syscall",
- "syscall.BPF_MAJOR_VERSION": "syscall",
- "syscall.BPF_MAXBUFSIZE": "syscall",
- "syscall.BPF_MAXINSNS": "syscall",
- "syscall.BPF_MEM": "syscall",
- "syscall.BPF_MEMWORDS": "syscall",
- "syscall.BPF_MINBUFSIZE": "syscall",
- "syscall.BPF_MINOR_VERSION": "syscall",
- "syscall.BPF_MISC": "syscall",
- "syscall.BPF_MSH": "syscall",
- "syscall.BPF_MUL": "syscall",
- "syscall.BPF_NEG": "syscall",
- "syscall.BPF_OR": "syscall",
- "syscall.BPF_RELEASE": "syscall",
- "syscall.BPF_RET": "syscall",
- "syscall.BPF_RSH": "syscall",
- "syscall.BPF_ST": "syscall",
- "syscall.BPF_STX": "syscall",
- "syscall.BPF_SUB": "syscall",
- "syscall.BPF_TAX": "syscall",
- "syscall.BPF_TXA": "syscall",
- "syscall.BPF_T_BINTIME": "syscall",
- "syscall.BPF_T_BINTIME_FAST": "syscall",
- "syscall.BPF_T_BINTIME_MONOTONIC": "syscall",
- "syscall.BPF_T_BINTIME_MONOTONIC_FAST": "syscall",
- "syscall.BPF_T_FAST": "syscall",
- "syscall.BPF_T_FLAG_MASK": "syscall",
- "syscall.BPF_T_FORMAT_MASK": "syscall",
- "syscall.BPF_T_MICROTIME": "syscall",
- "syscall.BPF_T_MICROTIME_FAST": "syscall",
- "syscall.BPF_T_MICROTIME_MONOTONIC": "syscall",
- "syscall.BPF_T_MICROTIME_MONOTONIC_FAST": "syscall",
- "syscall.BPF_T_MONOTONIC": "syscall",
- "syscall.BPF_T_MONOTONIC_FAST": "syscall",
- "syscall.BPF_T_NANOTIME": "syscall",
- "syscall.BPF_T_NANOTIME_FAST": "syscall",
- "syscall.BPF_T_NANOTIME_MONOTONIC": "syscall",
- "syscall.BPF_T_NANOTIME_MONOTONIC_FAST": "syscall",
- "syscall.BPF_T_NONE": "syscall",
- "syscall.BPF_T_NORMAL": "syscall",
- "syscall.BPF_W": "syscall",
- "syscall.BPF_X": "syscall",
- "syscall.BRKINT": "syscall",
- "syscall.Bind": "syscall",
- "syscall.BindToDevice": "syscall",
- "syscall.BpfBuflen": "syscall",
- "syscall.BpfDatalink": "syscall",
- "syscall.BpfHdr": "syscall",
- "syscall.BpfHeadercmpl": "syscall",
- "syscall.BpfInsn": "syscall",
- "syscall.BpfInterface": "syscall",
- "syscall.BpfJump": "syscall",
- "syscall.BpfProgram": "syscall",
- "syscall.BpfStat": "syscall",
- "syscall.BpfStats": "syscall",
- "syscall.BpfStmt": "syscall",
- "syscall.BpfTimeout": "syscall",
- "syscall.BpfTimeval": "syscall",
- "syscall.BpfVersion": "syscall",
- "syscall.BpfZbuf": "syscall",
- "syscall.BpfZbufHeader": "syscall",
- "syscall.ByHandleFileInformation": "syscall",
- "syscall.BytePtrFromString": "syscall",
- "syscall.ByteSliceFromString": "syscall",
- "syscall.CCR0_FLUSH": "syscall",
- "syscall.CERT_CHAIN_POLICY_AUTHENTICODE": "syscall",
- "syscall.CERT_CHAIN_POLICY_AUTHENTICODE_TS": "syscall",
- "syscall.CERT_CHAIN_POLICY_BASE": "syscall",
- "syscall.CERT_CHAIN_POLICY_BASIC_CONSTRAINTS": "syscall",
- "syscall.CERT_CHAIN_POLICY_EV": "syscall",
- "syscall.CERT_CHAIN_POLICY_MICROSOFT_ROOT": "syscall",
- "syscall.CERT_CHAIN_POLICY_NT_AUTH": "syscall",
- "syscall.CERT_CHAIN_POLICY_SSL": "syscall",
- "syscall.CERT_E_CN_NO_MATCH": "syscall",
- "syscall.CERT_E_EXPIRED": "syscall",
- "syscall.CERT_E_PURPOSE": "syscall",
- "syscall.CERT_E_ROLE": "syscall",
- "syscall.CERT_E_UNTRUSTEDROOT": "syscall",
- "syscall.CERT_STORE_ADD_ALWAYS": "syscall",
- "syscall.CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG": "syscall",
- "syscall.CERT_STORE_PROV_MEMORY": "syscall",
- "syscall.CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT": "syscall",
- "syscall.CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT": "syscall",
- "syscall.CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT": "syscall",
- "syscall.CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT": "syscall",
- "syscall.CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT": "syscall",
- "syscall.CERT_TRUST_INVALID_BASIC_CONSTRAINTS": "syscall",
- "syscall.CERT_TRUST_INVALID_EXTENSION": "syscall",
- "syscall.CERT_TRUST_INVALID_NAME_CONSTRAINTS": "syscall",
- "syscall.CERT_TRUST_INVALID_POLICY_CONSTRAINTS": "syscall",
- "syscall.CERT_TRUST_IS_CYCLIC": "syscall",
- "syscall.CERT_TRUST_IS_EXPLICIT_DISTRUST": "syscall",
- "syscall.CERT_TRUST_IS_NOT_SIGNATURE_VALID": "syscall",
- "syscall.CERT_TRUST_IS_NOT_TIME_VALID": "syscall",
- "syscall.CERT_TRUST_IS_NOT_VALID_FOR_USAGE": "syscall",
- "syscall.CERT_TRUST_IS_OFFLINE_REVOCATION": "syscall",
- "syscall.CERT_TRUST_IS_REVOKED": "syscall",
- "syscall.CERT_TRUST_IS_UNTRUSTED_ROOT": "syscall",
- "syscall.CERT_TRUST_NO_ERROR": "syscall",
- "syscall.CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY": "syscall",
- "syscall.CERT_TRUST_REVOCATION_STATUS_UNKNOWN": "syscall",
- "syscall.CFLUSH": "syscall",
- "syscall.CLOCAL": "syscall",
- "syscall.CLONE_CHILD_CLEARTID": "syscall",
- "syscall.CLONE_CHILD_SETTID": "syscall",
- "syscall.CLONE_DETACHED": "syscall",
- "syscall.CLONE_FILES": "syscall",
- "syscall.CLONE_FS": "syscall",
- "syscall.CLONE_IO": "syscall",
- "syscall.CLONE_NEWIPC": "syscall",
- "syscall.CLONE_NEWNET": "syscall",
- "syscall.CLONE_NEWNS": "syscall",
- "syscall.CLONE_NEWPID": "syscall",
- "syscall.CLONE_NEWUSER": "syscall",
- "syscall.CLONE_NEWUTS": "syscall",
- "syscall.CLONE_PARENT": "syscall",
- "syscall.CLONE_PARENT_SETTID": "syscall",
- "syscall.CLONE_PTRACE": "syscall",
- "syscall.CLONE_SETTLS": "syscall",
- "syscall.CLONE_SIGHAND": "syscall",
- "syscall.CLONE_SYSVSEM": "syscall",
- "syscall.CLONE_THREAD": "syscall",
- "syscall.CLONE_UNTRACED": "syscall",
- "syscall.CLONE_VFORK": "syscall",
- "syscall.CLONE_VM": "syscall",
- "syscall.CPUID_CFLUSH": "syscall",
- "syscall.CREAD": "syscall",
- "syscall.CREATE_ALWAYS": "syscall",
- "syscall.CREATE_NEW": "syscall",
- "syscall.CREATE_NEW_PROCESS_GROUP": "syscall",
- "syscall.CREATE_UNICODE_ENVIRONMENT": "syscall",
- "syscall.CRYPT_DEFAULT_CONTAINER_OPTIONAL": "syscall",
- "syscall.CRYPT_DELETEKEYSET": "syscall",
- "syscall.CRYPT_MACHINE_KEYSET": "syscall",
- "syscall.CRYPT_NEWKEYSET": "syscall",
- "syscall.CRYPT_SILENT": "syscall",
- "syscall.CRYPT_VERIFYCONTEXT": "syscall",
- "syscall.CS5": "syscall",
- "syscall.CS6": "syscall",
- "syscall.CS7": "syscall",
- "syscall.CS8": "syscall",
- "syscall.CSIZE": "syscall",
- "syscall.CSTART": "syscall",
- "syscall.CSTATUS": "syscall",
- "syscall.CSTOP": "syscall",
- "syscall.CSTOPB": "syscall",
- "syscall.CSUSP": "syscall",
- "syscall.CTL_MAXNAME": "syscall",
- "syscall.CTL_NET": "syscall",
- "syscall.CTL_QUERY": "syscall",
- "syscall.CTRL_BREAK_EVENT": "syscall",
- "syscall.CTRL_C_EVENT": "syscall",
- "syscall.CancelIo": "syscall",
- "syscall.CancelIoEx": "syscall",
- "syscall.CertAddCertificateContextToStore": "syscall",
- "syscall.CertChainContext": "syscall",
- "syscall.CertChainElement": "syscall",
- "syscall.CertChainPara": "syscall",
- "syscall.CertChainPolicyPara": "syscall",
- "syscall.CertChainPolicyStatus": "syscall",
- "syscall.CertCloseStore": "syscall",
- "syscall.CertContext": "syscall",
- "syscall.CertCreateCertificateContext": "syscall",
- "syscall.CertEnhKeyUsage": "syscall",
- "syscall.CertEnumCertificatesInStore": "syscall",
- "syscall.CertFreeCertificateChain": "syscall",
- "syscall.CertFreeCertificateContext": "syscall",
- "syscall.CertGetCertificateChain": "syscall",
- "syscall.CertOpenStore": "syscall",
- "syscall.CertOpenSystemStore": "syscall",
- "syscall.CertRevocationInfo": "syscall",
- "syscall.CertSimpleChain": "syscall",
- "syscall.CertTrustStatus": "syscall",
- "syscall.CertUsageMatch": "syscall",
- "syscall.CertVerifyCertificateChainPolicy": "syscall",
- "syscall.Chdir": "syscall",
- "syscall.CheckBpfVersion": "syscall",
- "syscall.Chflags": "syscall",
- "syscall.Chmod": "syscall",
- "syscall.Chown": "syscall",
- "syscall.Chroot": "syscall",
- "syscall.Clearenv": "syscall",
- "syscall.Close": "syscall",
- "syscall.CloseHandle": "syscall",
- "syscall.CloseOnExec": "syscall",
- "syscall.Closesocket": "syscall",
- "syscall.CmsgLen": "syscall",
- "syscall.CmsgSpace": "syscall",
- "syscall.Cmsghdr": "syscall",
- "syscall.CommandLineToArgv": "syscall",
- "syscall.ComputerName": "syscall",
- "syscall.Connect": "syscall",
- "syscall.ConnectEx": "syscall",
- "syscall.ConvertSidToStringSid": "syscall",
- "syscall.ConvertStringSidToSid": "syscall",
- "syscall.CopySid": "syscall",
- "syscall.Creat": "syscall",
- "syscall.CreateDirectory": "syscall",
- "syscall.CreateFile": "syscall",
- "syscall.CreateFileMapping": "syscall",
- "syscall.CreateIoCompletionPort": "syscall",
- "syscall.CreatePipe": "syscall",
- "syscall.CreateProcess": "syscall",
- "syscall.Credential": "syscall",
- "syscall.CryptAcquireContext": "syscall",
- "syscall.CryptGenRandom": "syscall",
- "syscall.CryptReleaseContext": "syscall",
- "syscall.DIOCBSFLUSH": "syscall",
- "syscall.DIOCOSFPFLUSH": "syscall",
- "syscall.DLL": "syscall",
- "syscall.DLLError": "syscall",
- "syscall.DLT_A429": "syscall",
- "syscall.DLT_A653_ICM": "syscall",
- "syscall.DLT_AIRONET_HEADER": "syscall",
- "syscall.DLT_AOS": "syscall",
- "syscall.DLT_APPLE_IP_OVER_IEEE1394": "syscall",
- "syscall.DLT_ARCNET": "syscall",
- "syscall.DLT_ARCNET_LINUX": "syscall",
- "syscall.DLT_ATM_CLIP": "syscall",
- "syscall.DLT_ATM_RFC1483": "syscall",
- "syscall.DLT_AURORA": "syscall",
- "syscall.DLT_AX25": "syscall",
- "syscall.DLT_AX25_KISS": "syscall",
- "syscall.DLT_BACNET_MS_TP": "syscall",
- "syscall.DLT_BLUETOOTH_HCI_H4": "syscall",
- "syscall.DLT_BLUETOOTH_HCI_H4_WITH_PHDR": "syscall",
- "syscall.DLT_CAN20B": "syscall",
- "syscall.DLT_CAN_SOCKETCAN": "syscall",
- "syscall.DLT_CHAOS": "syscall",
- "syscall.DLT_CHDLC": "syscall",
- "syscall.DLT_CISCO_IOS": "syscall",
- "syscall.DLT_C_HDLC": "syscall",
- "syscall.DLT_C_HDLC_WITH_DIR": "syscall",
- "syscall.DLT_DBUS": "syscall",
- "syscall.DLT_DECT": "syscall",
- "syscall.DLT_DOCSIS": "syscall",
- "syscall.DLT_DVB_CI": "syscall",
- "syscall.DLT_ECONET": "syscall",
- "syscall.DLT_EN10MB": "syscall",
- "syscall.DLT_EN3MB": "syscall",
- "syscall.DLT_ENC": "syscall",
- "syscall.DLT_ERF": "syscall",
- "syscall.DLT_ERF_ETH": "syscall",
- "syscall.DLT_ERF_POS": "syscall",
- "syscall.DLT_FC_2": "syscall",
- "syscall.DLT_FC_2_WITH_FRAME_DELIMS": "syscall",
- "syscall.DLT_FDDI": "syscall",
- "syscall.DLT_FLEXRAY": "syscall",
- "syscall.DLT_FRELAY": "syscall",
- "syscall.DLT_FRELAY_WITH_DIR": "syscall",
- "syscall.DLT_GCOM_SERIAL": "syscall",
- "syscall.DLT_GCOM_T1E1": "syscall",
- "syscall.DLT_GPF_F": "syscall",
- "syscall.DLT_GPF_T": "syscall",
- "syscall.DLT_GPRS_LLC": "syscall",
- "syscall.DLT_GSMTAP_ABIS": "syscall",
- "syscall.DLT_GSMTAP_UM": "syscall",
- "syscall.DLT_HDLC": "syscall",
- "syscall.DLT_HHDLC": "syscall",
- "syscall.DLT_HIPPI": "syscall",
- "syscall.DLT_IBM_SN": "syscall",
- "syscall.DLT_IBM_SP": "syscall",
- "syscall.DLT_IEEE802": "syscall",
- "syscall.DLT_IEEE802_11": "syscall",
- "syscall.DLT_IEEE802_11_RADIO": "syscall",
- "syscall.DLT_IEEE802_11_RADIO_AVS": "syscall",
- "syscall.DLT_IEEE802_15_4": "syscall",
- "syscall.DLT_IEEE802_15_4_LINUX": "syscall",
- "syscall.DLT_IEEE802_15_4_NOFCS": "syscall",
- "syscall.DLT_IEEE802_15_4_NONASK_PHY": "syscall",
- "syscall.DLT_IEEE802_16_MAC_CPS": "syscall",
- "syscall.DLT_IEEE802_16_MAC_CPS_RADIO": "syscall",
- "syscall.DLT_IPFILTER": "syscall",
- "syscall.DLT_IPMB": "syscall",
- "syscall.DLT_IPMB_LINUX": "syscall",
- "syscall.DLT_IPNET": "syscall",
- "syscall.DLT_IPOIB": "syscall",
- "syscall.DLT_IPV4": "syscall",
- "syscall.DLT_IPV6": "syscall",
- "syscall.DLT_IP_OVER_FC": "syscall",
- "syscall.DLT_JUNIPER_ATM1": "syscall",
- "syscall.DLT_JUNIPER_ATM2": "syscall",
- "syscall.DLT_JUNIPER_ATM_CEMIC": "syscall",
- "syscall.DLT_JUNIPER_CHDLC": "syscall",
- "syscall.DLT_JUNIPER_ES": "syscall",
- "syscall.DLT_JUNIPER_ETHER": "syscall",
- "syscall.DLT_JUNIPER_FIBRECHANNEL": "syscall",
- "syscall.DLT_JUNIPER_FRELAY": "syscall",
- "syscall.DLT_JUNIPER_GGSN": "syscall",
- "syscall.DLT_JUNIPER_ISM": "syscall",
- "syscall.DLT_JUNIPER_MFR": "syscall",
- "syscall.DLT_JUNIPER_MLFR": "syscall",
- "syscall.DLT_JUNIPER_MLPPP": "syscall",
- "syscall.DLT_JUNIPER_MONITOR": "syscall",
- "syscall.DLT_JUNIPER_PIC_PEER": "syscall",
- "syscall.DLT_JUNIPER_PPP": "syscall",
- "syscall.DLT_JUNIPER_PPPOE": "syscall",
- "syscall.DLT_JUNIPER_PPPOE_ATM": "syscall",
- "syscall.DLT_JUNIPER_SERVICES": "syscall",
- "syscall.DLT_JUNIPER_SRX_E2E": "syscall",
- "syscall.DLT_JUNIPER_ST": "syscall",
- "syscall.DLT_JUNIPER_VP": "syscall",
- "syscall.DLT_JUNIPER_VS": "syscall",
- "syscall.DLT_LAPB_WITH_DIR": "syscall",
- "syscall.DLT_LAPD": "syscall",
- "syscall.DLT_LIN": "syscall",
- "syscall.DLT_LINUX_EVDEV": "syscall",
- "syscall.DLT_LINUX_IRDA": "syscall",
- "syscall.DLT_LINUX_LAPD": "syscall",
- "syscall.DLT_LINUX_PPP_WITHDIRECTION": "syscall",
- "syscall.DLT_LINUX_SLL": "syscall",
- "syscall.DLT_LOOP": "syscall",
- "syscall.DLT_LTALK": "syscall",
- "syscall.DLT_MATCHING_MAX": "syscall",
- "syscall.DLT_MATCHING_MIN": "syscall",
- "syscall.DLT_MFR": "syscall",
- "syscall.DLT_MOST": "syscall",
- "syscall.DLT_MPEG_2_TS": "syscall",
- "syscall.DLT_MPLS": "syscall",
- "syscall.DLT_MTP2": "syscall",
- "syscall.DLT_MTP2_WITH_PHDR": "syscall",
- "syscall.DLT_MTP3": "syscall",
- "syscall.DLT_MUX27010": "syscall",
- "syscall.DLT_NETANALYZER": "syscall",
- "syscall.DLT_NETANALYZER_TRANSPARENT": "syscall",
- "syscall.DLT_NFC_LLCP": "syscall",
- "syscall.DLT_NFLOG": "syscall",
- "syscall.DLT_NG40": "syscall",
- "syscall.DLT_NULL": "syscall",
- "syscall.DLT_PCI_EXP": "syscall",
- "syscall.DLT_PFLOG": "syscall",
- "syscall.DLT_PFSYNC": "syscall",
- "syscall.DLT_PPI": "syscall",
- "syscall.DLT_PPP": "syscall",
- "syscall.DLT_PPP_BSDOS": "syscall",
- "syscall.DLT_PPP_ETHER": "syscall",
- "syscall.DLT_PPP_PPPD": "syscall",
- "syscall.DLT_PPP_SERIAL": "syscall",
- "syscall.DLT_PPP_WITH_DIR": "syscall",
- "syscall.DLT_PPP_WITH_DIRECTION": "syscall",
- "syscall.DLT_PRISM_HEADER": "syscall",
- "syscall.DLT_PRONET": "syscall",
- "syscall.DLT_RAIF1": "syscall",
- "syscall.DLT_RAW": "syscall",
- "syscall.DLT_RAWAF_MASK": "syscall",
- "syscall.DLT_RIO": "syscall",
- "syscall.DLT_SCCP": "syscall",
- "syscall.DLT_SITA": "syscall",
- "syscall.DLT_SLIP": "syscall",
- "syscall.DLT_SLIP_BSDOS": "syscall",
- "syscall.DLT_STANAG_5066_D_PDU": "syscall",
- "syscall.DLT_SUNATM": "syscall",
- "syscall.DLT_SYMANTEC_FIREWALL": "syscall",
- "syscall.DLT_TZSP": "syscall",
- "syscall.DLT_USB": "syscall",
- "syscall.DLT_USB_LINUX": "syscall",
- "syscall.DLT_USB_LINUX_MMAPPED": "syscall",
- "syscall.DLT_USER0": "syscall",
- "syscall.DLT_USER1": "syscall",
- "syscall.DLT_USER10": "syscall",
- "syscall.DLT_USER11": "syscall",
- "syscall.DLT_USER12": "syscall",
- "syscall.DLT_USER13": "syscall",
- "syscall.DLT_USER14": "syscall",
- "syscall.DLT_USER15": "syscall",
- "syscall.DLT_USER2": "syscall",
- "syscall.DLT_USER3": "syscall",
- "syscall.DLT_USER4": "syscall",
- "syscall.DLT_USER5": "syscall",
- "syscall.DLT_USER6": "syscall",
- "syscall.DLT_USER7": "syscall",
- "syscall.DLT_USER8": "syscall",
- "syscall.DLT_USER9": "syscall",
- "syscall.DLT_WIHART": "syscall",
- "syscall.DLT_X2E_SERIAL": "syscall",
- "syscall.DLT_X2E_XORAYA": "syscall",
- "syscall.DNSMXData": "syscall",
- "syscall.DNSPTRData": "syscall",
- "syscall.DNSRecord": "syscall",
- "syscall.DNSSRVData": "syscall",
- "syscall.DNSTXTData": "syscall",
- "syscall.DNS_TYPE_A": "syscall",
- "syscall.DNS_TYPE_A6": "syscall",
- "syscall.DNS_TYPE_AAAA": "syscall",
- "syscall.DNS_TYPE_ADDRS": "syscall",
- "syscall.DNS_TYPE_AFSDB": "syscall",
- "syscall.DNS_TYPE_ALL": "syscall",
- "syscall.DNS_TYPE_ANY": "syscall",
- "syscall.DNS_TYPE_ATMA": "syscall",
- "syscall.DNS_TYPE_AXFR": "syscall",
- "syscall.DNS_TYPE_CERT": "syscall",
- "syscall.DNS_TYPE_CNAME": "syscall",
- "syscall.DNS_TYPE_DHCID": "syscall",
- "syscall.DNS_TYPE_DNAME": "syscall",
- "syscall.DNS_TYPE_DNSKEY": "syscall",
- "syscall.DNS_TYPE_DS": "syscall",
- "syscall.DNS_TYPE_EID": "syscall",
- "syscall.DNS_TYPE_GID": "syscall",
- "syscall.DNS_TYPE_GPOS": "syscall",
- "syscall.DNS_TYPE_HINFO": "syscall",
- "syscall.DNS_TYPE_ISDN": "syscall",
- "syscall.DNS_TYPE_IXFR": "syscall",
- "syscall.DNS_TYPE_KEY": "syscall",
- "syscall.DNS_TYPE_KX": "syscall",
- "syscall.DNS_TYPE_LOC": "syscall",
- "syscall.DNS_TYPE_MAILA": "syscall",
- "syscall.DNS_TYPE_MAILB": "syscall",
- "syscall.DNS_TYPE_MB": "syscall",
- "syscall.DNS_TYPE_MD": "syscall",
- "syscall.DNS_TYPE_MF": "syscall",
- "syscall.DNS_TYPE_MG": "syscall",
- "syscall.DNS_TYPE_MINFO": "syscall",
- "syscall.DNS_TYPE_MR": "syscall",
- "syscall.DNS_TYPE_MX": "syscall",
- "syscall.DNS_TYPE_NAPTR": "syscall",
- "syscall.DNS_TYPE_NBSTAT": "syscall",
- "syscall.DNS_TYPE_NIMLOC": "syscall",
- "syscall.DNS_TYPE_NS": "syscall",
- "syscall.DNS_TYPE_NSAP": "syscall",
- "syscall.DNS_TYPE_NSAPPTR": "syscall",
- "syscall.DNS_TYPE_NSEC": "syscall",
- "syscall.DNS_TYPE_NULL": "syscall",
- "syscall.DNS_TYPE_NXT": "syscall",
- "syscall.DNS_TYPE_OPT": "syscall",
- "syscall.DNS_TYPE_PTR": "syscall",
- "syscall.DNS_TYPE_PX": "syscall",
- "syscall.DNS_TYPE_RP": "syscall",
- "syscall.DNS_TYPE_RRSIG": "syscall",
- "syscall.DNS_TYPE_RT": "syscall",
- "syscall.DNS_TYPE_SIG": "syscall",
- "syscall.DNS_TYPE_SINK": "syscall",
- "syscall.DNS_TYPE_SOA": "syscall",
- "syscall.DNS_TYPE_SRV": "syscall",
- "syscall.DNS_TYPE_TEXT": "syscall",
- "syscall.DNS_TYPE_TKEY": "syscall",
- "syscall.DNS_TYPE_TSIG": "syscall",
- "syscall.DNS_TYPE_UID": "syscall",
- "syscall.DNS_TYPE_UINFO": "syscall",
- "syscall.DNS_TYPE_UNSPEC": "syscall",
- "syscall.DNS_TYPE_WINS": "syscall",
- "syscall.DNS_TYPE_WINSR": "syscall",
- "syscall.DNS_TYPE_WKS": "syscall",
- "syscall.DNS_TYPE_X25": "syscall",
- "syscall.DT_BLK": "syscall",
- "syscall.DT_CHR": "syscall",
- "syscall.DT_DIR": "syscall",
- "syscall.DT_FIFO": "syscall",
- "syscall.DT_LNK": "syscall",
- "syscall.DT_REG": "syscall",
- "syscall.DT_SOCK": "syscall",
- "syscall.DT_UNKNOWN": "syscall",
- "syscall.DT_WHT": "syscall",
- "syscall.DUPLICATE_CLOSE_SOURCE": "syscall",
- "syscall.DUPLICATE_SAME_ACCESS": "syscall",
- "syscall.DeleteFile": "syscall",
- "syscall.DetachLsf": "syscall",
- "syscall.Dirent": "syscall",
- "syscall.DnsQuery": "syscall",
- "syscall.DnsRecordListFree": "syscall",
- "syscall.Dup": "syscall",
- "syscall.Dup2": "syscall",
- "syscall.Dup3": "syscall",
- "syscall.DuplicateHandle": "syscall",
- "syscall.E2BIG": "syscall",
- "syscall.EACCES": "syscall",
- "syscall.EADDRINUSE": "syscall",
- "syscall.EADDRNOTAVAIL": "syscall",
- "syscall.EADV": "syscall",
- "syscall.EAFNOSUPPORT": "syscall",
- "syscall.EAGAIN": "syscall",
- "syscall.EALREADY": "syscall",
- "syscall.EAUTH": "syscall",
- "syscall.EBADARCH": "syscall",
- "syscall.EBADE": "syscall",
- "syscall.EBADEXEC": "syscall",
- "syscall.EBADF": "syscall",
- "syscall.EBADFD": "syscall",
- "syscall.EBADMACHO": "syscall",
- "syscall.EBADMSG": "syscall",
- "syscall.EBADR": "syscall",
- "syscall.EBADRPC": "syscall",
- "syscall.EBADRQC": "syscall",
- "syscall.EBADSLT": "syscall",
- "syscall.EBFONT": "syscall",
- "syscall.EBUSY": "syscall",
- "syscall.ECANCELED": "syscall",
- "syscall.ECAPMODE": "syscall",
- "syscall.ECHILD": "syscall",
- "syscall.ECHO": "syscall",
- "syscall.ECHOCTL": "syscall",
- "syscall.ECHOE": "syscall",
- "syscall.ECHOK": "syscall",
- "syscall.ECHOKE": "syscall",
- "syscall.ECHONL": "syscall",
- "syscall.ECHOPRT": "syscall",
- "syscall.ECHRNG": "syscall",
- "syscall.ECOMM": "syscall",
- "syscall.ECONNABORTED": "syscall",
- "syscall.ECONNREFUSED": "syscall",
- "syscall.ECONNRESET": "syscall",
- "syscall.EDEADLK": "syscall",
- "syscall.EDEADLOCK": "syscall",
- "syscall.EDESTADDRREQ": "syscall",
- "syscall.EDEVERR": "syscall",
- "syscall.EDOM": "syscall",
- "syscall.EDOOFUS": "syscall",
- "syscall.EDOTDOT": "syscall",
- "syscall.EDQUOT": "syscall",
- "syscall.EEXIST": "syscall",
- "syscall.EFAULT": "syscall",
- "syscall.EFBIG": "syscall",
- "syscall.EFER_LMA": "syscall",
- "syscall.EFER_LME": "syscall",
- "syscall.EFER_NXE": "syscall",
- "syscall.EFER_SCE": "syscall",
- "syscall.EFTYPE": "syscall",
- "syscall.EHOSTDOWN": "syscall",
- "syscall.EHOSTUNREACH": "syscall",
- "syscall.EHWPOISON": "syscall",
- "syscall.EIDRM": "syscall",
- "syscall.EILSEQ": "syscall",
- "syscall.EINPROGRESS": "syscall",
- "syscall.EINTR": "syscall",
- "syscall.EINVAL": "syscall",
- "syscall.EIO": "syscall",
- "syscall.EIPSEC": "syscall",
- "syscall.EISCONN": "syscall",
- "syscall.EISDIR": "syscall",
- "syscall.EISNAM": "syscall",
- "syscall.EKEYEXPIRED": "syscall",
- "syscall.EKEYREJECTED": "syscall",
- "syscall.EKEYREVOKED": "syscall",
- "syscall.EL2HLT": "syscall",
- "syscall.EL2NSYNC": "syscall",
- "syscall.EL3HLT": "syscall",
- "syscall.EL3RST": "syscall",
- "syscall.ELAST": "syscall",
- "syscall.ELF_NGREG": "syscall",
- "syscall.ELF_PRARGSZ": "syscall",
- "syscall.ELIBACC": "syscall",
- "syscall.ELIBBAD": "syscall",
- "syscall.ELIBEXEC": "syscall",
- "syscall.ELIBMAX": "syscall",
- "syscall.ELIBSCN": "syscall",
- "syscall.ELNRNG": "syscall",
- "syscall.ELOOP": "syscall",
- "syscall.EMEDIUMTYPE": "syscall",
- "syscall.EMFILE": "syscall",
- "syscall.EMLINK": "syscall",
- "syscall.EMSGSIZE": "syscall",
- "syscall.EMT_TAGOVF": "syscall",
- "syscall.EMULTIHOP": "syscall",
- "syscall.EMUL_ENABLED": "syscall",
- "syscall.EMUL_LINUX": "syscall",
- "syscall.EMUL_LINUX32": "syscall",
- "syscall.EMUL_MAXID": "syscall",
- "syscall.EMUL_NATIVE": "syscall",
- "syscall.ENAMETOOLONG": "syscall",
- "syscall.ENAVAIL": "syscall",
- "syscall.ENDRUNDISC": "syscall",
- "syscall.ENEEDAUTH": "syscall",
- "syscall.ENETDOWN": "syscall",
- "syscall.ENETRESET": "syscall",
- "syscall.ENETUNREACH": "syscall",
- "syscall.ENFILE": "syscall",
- "syscall.ENOANO": "syscall",
- "syscall.ENOATTR": "syscall",
- "syscall.ENOBUFS": "syscall",
- "syscall.ENOCSI": "syscall",
- "syscall.ENODATA": "syscall",
- "syscall.ENODEV": "syscall",
- "syscall.ENOENT": "syscall",
- "syscall.ENOEXEC": "syscall",
- "syscall.ENOKEY": "syscall",
- "syscall.ENOLCK": "syscall",
- "syscall.ENOLINK": "syscall",
- "syscall.ENOMEDIUM": "syscall",
- "syscall.ENOMEM": "syscall",
- "syscall.ENOMSG": "syscall",
- "syscall.ENONET": "syscall",
- "syscall.ENOPKG": "syscall",
- "syscall.ENOPOLICY": "syscall",
- "syscall.ENOPROTOOPT": "syscall",
- "syscall.ENOSPC": "syscall",
- "syscall.ENOSR": "syscall",
- "syscall.ENOSTR": "syscall",
- "syscall.ENOSYS": "syscall",
- "syscall.ENOTBLK": "syscall",
- "syscall.ENOTCAPABLE": "syscall",
- "syscall.ENOTCONN": "syscall",
- "syscall.ENOTDIR": "syscall",
- "syscall.ENOTEMPTY": "syscall",
- "syscall.ENOTNAM": "syscall",
- "syscall.ENOTRECOVERABLE": "syscall",
- "syscall.ENOTSOCK": "syscall",
- "syscall.ENOTSUP": "syscall",
- "syscall.ENOTTY": "syscall",
- "syscall.ENOTUNIQ": "syscall",
- "syscall.ENXIO": "syscall",
- "syscall.EN_SW_CTL_INF": "syscall",
- "syscall.EN_SW_CTL_PREC": "syscall",
- "syscall.EN_SW_CTL_ROUND": "syscall",
- "syscall.EN_SW_DATACHAIN": "syscall",
- "syscall.EN_SW_DENORM": "syscall",
- "syscall.EN_SW_INVOP": "syscall",
- "syscall.EN_SW_OVERFLOW": "syscall",
- "syscall.EN_SW_PRECLOSS": "syscall",
- "syscall.EN_SW_UNDERFLOW": "syscall",
- "syscall.EN_SW_ZERODIV": "syscall",
- "syscall.EOPNOTSUPP": "syscall",
- "syscall.EOVERFLOW": "syscall",
- "syscall.EOWNERDEAD": "syscall",
- "syscall.EPERM": "syscall",
- "syscall.EPFNOSUPPORT": "syscall",
- "syscall.EPIPE": "syscall",
- "syscall.EPOLLERR": "syscall",
- "syscall.EPOLLET": "syscall",
- "syscall.EPOLLHUP": "syscall",
- "syscall.EPOLLIN": "syscall",
- "syscall.EPOLLMSG": "syscall",
- "syscall.EPOLLONESHOT": "syscall",
- "syscall.EPOLLOUT": "syscall",
- "syscall.EPOLLPRI": "syscall",
- "syscall.EPOLLRDBAND": "syscall",
- "syscall.EPOLLRDHUP": "syscall",
- "syscall.EPOLLRDNORM": "syscall",
- "syscall.EPOLLWRBAND": "syscall",
- "syscall.EPOLLWRNORM": "syscall",
- "syscall.EPOLL_CLOEXEC": "syscall",
- "syscall.EPOLL_CTL_ADD": "syscall",
- "syscall.EPOLL_CTL_DEL": "syscall",
- "syscall.EPOLL_CTL_MOD": "syscall",
- "syscall.EPOLL_NONBLOCK": "syscall",
- "syscall.EPROCLIM": "syscall",
- "syscall.EPROCUNAVAIL": "syscall",
- "syscall.EPROGMISMATCH": "syscall",
- "syscall.EPROGUNAVAIL": "syscall",
- "syscall.EPROTO": "syscall",
- "syscall.EPROTONOSUPPORT": "syscall",
- "syscall.EPROTOTYPE": "syscall",
- "syscall.EPWROFF": "syscall",
- "syscall.ERANGE": "syscall",
- "syscall.EREMCHG": "syscall",
- "syscall.EREMOTE": "syscall",
- "syscall.EREMOTEIO": "syscall",
- "syscall.ERESTART": "syscall",
- "syscall.ERFKILL": "syscall",
- "syscall.EROFS": "syscall",
- "syscall.ERPCMISMATCH": "syscall",
- "syscall.ERROR_ACCESS_DENIED": "syscall",
- "syscall.ERROR_ALREADY_EXISTS": "syscall",
- "syscall.ERROR_BROKEN_PIPE": "syscall",
- "syscall.ERROR_BUFFER_OVERFLOW": "syscall",
- "syscall.ERROR_ENVVAR_NOT_FOUND": "syscall",
- "syscall.ERROR_FILE_EXISTS": "syscall",
- "syscall.ERROR_FILE_NOT_FOUND": "syscall",
- "syscall.ERROR_HANDLE_EOF": "syscall",
- "syscall.ERROR_INSUFFICIENT_BUFFER": "syscall",
- "syscall.ERROR_IO_PENDING": "syscall",
- "syscall.ERROR_MOD_NOT_FOUND": "syscall",
- "syscall.ERROR_NOT_FOUND": "syscall",
- "syscall.ERROR_NO_MORE_FILES": "syscall",
- "syscall.ERROR_OPERATION_ABORTED": "syscall",
- "syscall.ERROR_PATH_NOT_FOUND": "syscall",
- "syscall.ERROR_PROC_NOT_FOUND": "syscall",
- "syscall.ESHLIBVERS": "syscall",
- "syscall.ESHUTDOWN": "syscall",
- "syscall.ESOCKTNOSUPPORT": "syscall",
- "syscall.ESPIPE": "syscall",
- "syscall.ESRCH": "syscall",
- "syscall.ESRMNT": "syscall",
- "syscall.ESTALE": "syscall",
- "syscall.ESTRPIPE": "syscall",
- "syscall.ETHERCAP_JUMBO_MTU": "syscall",
- "syscall.ETHERCAP_VLAN_HWTAGGING": "syscall",
- "syscall.ETHERCAP_VLAN_MTU": "syscall",
- "syscall.ETHERMIN": "syscall",
- "syscall.ETHERMTU": "syscall",
- "syscall.ETHERMTU_JUMBO": "syscall",
- "syscall.ETHERTYPE_8023": "syscall",
- "syscall.ETHERTYPE_AARP": "syscall",
- "syscall.ETHERTYPE_ACCTON": "syscall",
- "syscall.ETHERTYPE_AEONIC": "syscall",
- "syscall.ETHERTYPE_ALPHA": "syscall",
- "syscall.ETHERTYPE_AMBER": "syscall",
- "syscall.ETHERTYPE_AMOEBA": "syscall",
- "syscall.ETHERTYPE_AOE": "syscall",
- "syscall.ETHERTYPE_APOLLO": "syscall",
- "syscall.ETHERTYPE_APOLLODOMAIN": "syscall",
- "syscall.ETHERTYPE_APPLETALK": "syscall",
- "syscall.ETHERTYPE_APPLITEK": "syscall",
- "syscall.ETHERTYPE_ARGONAUT": "syscall",
- "syscall.ETHERTYPE_ARP": "syscall",
- "syscall.ETHERTYPE_AT": "syscall",
- "syscall.ETHERTYPE_ATALK": "syscall",
- "syscall.ETHERTYPE_ATOMIC": "syscall",
- "syscall.ETHERTYPE_ATT": "syscall",
- "syscall.ETHERTYPE_ATTSTANFORD": "syscall",
- "syscall.ETHERTYPE_AUTOPHON": "syscall",
- "syscall.ETHERTYPE_AXIS": "syscall",
- "syscall.ETHERTYPE_BCLOOP": "syscall",
- "syscall.ETHERTYPE_BOFL": "syscall",
- "syscall.ETHERTYPE_CABLETRON": "syscall",
- "syscall.ETHERTYPE_CHAOS": "syscall",
- "syscall.ETHERTYPE_COMDESIGN": "syscall",
- "syscall.ETHERTYPE_COMPUGRAPHIC": "syscall",
- "syscall.ETHERTYPE_COUNTERPOINT": "syscall",
- "syscall.ETHERTYPE_CRONUS": "syscall",
- "syscall.ETHERTYPE_CRONUSVLN": "syscall",
- "syscall.ETHERTYPE_DCA": "syscall",
- "syscall.ETHERTYPE_DDE": "syscall",
- "syscall.ETHERTYPE_DEBNI": "syscall",
- "syscall.ETHERTYPE_DECAM": "syscall",
- "syscall.ETHERTYPE_DECCUST": "syscall",
- "syscall.ETHERTYPE_DECDIAG": "syscall",
- "syscall.ETHERTYPE_DECDNS": "syscall",
- "syscall.ETHERTYPE_DECDTS": "syscall",
- "syscall.ETHERTYPE_DECEXPER": "syscall",
- "syscall.ETHERTYPE_DECLAST": "syscall",
- "syscall.ETHERTYPE_DECLTM": "syscall",
- "syscall.ETHERTYPE_DECMUMPS": "syscall",
- "syscall.ETHERTYPE_DECNETBIOS": "syscall",
- "syscall.ETHERTYPE_DELTACON": "syscall",
- "syscall.ETHERTYPE_DIDDLE": "syscall",
- "syscall.ETHERTYPE_DLOG1": "syscall",
- "syscall.ETHERTYPE_DLOG2": "syscall",
- "syscall.ETHERTYPE_DN": "syscall",
- "syscall.ETHERTYPE_DOGFIGHT": "syscall",
- "syscall.ETHERTYPE_DSMD": "syscall",
- "syscall.ETHERTYPE_ECMA": "syscall",
- "syscall.ETHERTYPE_ENCRYPT": "syscall",
- "syscall.ETHERTYPE_ES": "syscall",
- "syscall.ETHERTYPE_EXCELAN": "syscall",
- "syscall.ETHERTYPE_EXPERDATA": "syscall",
- "syscall.ETHERTYPE_FLIP": "syscall",
- "syscall.ETHERTYPE_FLOWCONTROL": "syscall",
- "syscall.ETHERTYPE_FRARP": "syscall",
- "syscall.ETHERTYPE_GENDYN": "syscall",
- "syscall.ETHERTYPE_HAYES": "syscall",
- "syscall.ETHERTYPE_HIPPI_FP": "syscall",
- "syscall.ETHERTYPE_HITACHI": "syscall",
- "syscall.ETHERTYPE_HP": "syscall",
- "syscall.ETHERTYPE_IEEEPUP": "syscall",
- "syscall.ETHERTYPE_IEEEPUPAT": "syscall",
- "syscall.ETHERTYPE_IMLBL": "syscall",
- "syscall.ETHERTYPE_IMLBLDIAG": "syscall",
- "syscall.ETHERTYPE_IP": "syscall",
- "syscall.ETHERTYPE_IPAS": "syscall",
- "syscall.ETHERTYPE_IPV6": "syscall",
- "syscall.ETHERTYPE_IPX": "syscall",
- "syscall.ETHERTYPE_IPXNEW": "syscall",
- "syscall.ETHERTYPE_KALPANA": "syscall",
- "syscall.ETHERTYPE_LANBRIDGE": "syscall",
- "syscall.ETHERTYPE_LANPROBE": "syscall",
- "syscall.ETHERTYPE_LAT": "syscall",
- "syscall.ETHERTYPE_LBACK": "syscall",
- "syscall.ETHERTYPE_LITTLE": "syscall",
- "syscall.ETHERTYPE_LLDP": "syscall",
- "syscall.ETHERTYPE_LOGICRAFT": "syscall",
- "syscall.ETHERTYPE_LOOPBACK": "syscall",
- "syscall.ETHERTYPE_MATRA": "syscall",
- "syscall.ETHERTYPE_MAX": "syscall",
- "syscall.ETHERTYPE_MERIT": "syscall",
- "syscall.ETHERTYPE_MICP": "syscall",
- "syscall.ETHERTYPE_MOPDL": "syscall",
- "syscall.ETHERTYPE_MOPRC": "syscall",
- "syscall.ETHERTYPE_MOTOROLA": "syscall",
- "syscall.ETHERTYPE_MPLS": "syscall",
- "syscall.ETHERTYPE_MPLS_MCAST": "syscall",
- "syscall.ETHERTYPE_MUMPS": "syscall",
- "syscall.ETHERTYPE_NBPCC": "syscall",
- "syscall.ETHERTYPE_NBPCLAIM": "syscall",
- "syscall.ETHERTYPE_NBPCLREQ": "syscall",
- "syscall.ETHERTYPE_NBPCLRSP": "syscall",
- "syscall.ETHERTYPE_NBPCREQ": "syscall",
- "syscall.ETHERTYPE_NBPCRSP": "syscall",
- "syscall.ETHERTYPE_NBPDG": "syscall",
- "syscall.ETHERTYPE_NBPDGB": "syscall",
- "syscall.ETHERTYPE_NBPDLTE": "syscall",
- "syscall.ETHERTYPE_NBPRAR": "syscall",
- "syscall.ETHERTYPE_NBPRAS": "syscall",
- "syscall.ETHERTYPE_NBPRST": "syscall",
- "syscall.ETHERTYPE_NBPSCD": "syscall",
- "syscall.ETHERTYPE_NBPVCD": "syscall",
- "syscall.ETHERTYPE_NBS": "syscall",
- "syscall.ETHERTYPE_NCD": "syscall",
- "syscall.ETHERTYPE_NESTAR": "syscall",
- "syscall.ETHERTYPE_NETBEUI": "syscall",
- "syscall.ETHERTYPE_NOVELL": "syscall",
- "syscall.ETHERTYPE_NS": "syscall",
- "syscall.ETHERTYPE_NSAT": "syscall",
- "syscall.ETHERTYPE_NSCOMPAT": "syscall",
- "syscall.ETHERTYPE_NTRAILER": "syscall",
- "syscall.ETHERTYPE_OS9": "syscall",
- "syscall.ETHERTYPE_OS9NET": "syscall",
- "syscall.ETHERTYPE_PACER": "syscall",
- "syscall.ETHERTYPE_PAE": "syscall",
- "syscall.ETHERTYPE_PCS": "syscall",
- "syscall.ETHERTYPE_PLANNING": "syscall",
- "syscall.ETHERTYPE_PPP": "syscall",
- "syscall.ETHERTYPE_PPPOE": "syscall",
- "syscall.ETHERTYPE_PPPOEDISC": "syscall",
- "syscall.ETHERTYPE_PRIMENTS": "syscall",
- "syscall.ETHERTYPE_PUP": "syscall",
- "syscall.ETHERTYPE_PUPAT": "syscall",
- "syscall.ETHERTYPE_QINQ": "syscall",
- "syscall.ETHERTYPE_RACAL": "syscall",
- "syscall.ETHERTYPE_RATIONAL": "syscall",
- "syscall.ETHERTYPE_RAWFR": "syscall",
- "syscall.ETHERTYPE_RCL": "syscall",
- "syscall.ETHERTYPE_RDP": "syscall",
- "syscall.ETHERTYPE_RETIX": "syscall",
- "syscall.ETHERTYPE_REVARP": "syscall",
- "syscall.ETHERTYPE_SCA": "syscall",
- "syscall.ETHERTYPE_SECTRA": "syscall",
- "syscall.ETHERTYPE_SECUREDATA": "syscall",
- "syscall.ETHERTYPE_SGITW": "syscall",
- "syscall.ETHERTYPE_SG_BOUNCE": "syscall",
- "syscall.ETHERTYPE_SG_DIAG": "syscall",
- "syscall.ETHERTYPE_SG_NETGAMES": "syscall",
- "syscall.ETHERTYPE_SG_RESV": "syscall",
- "syscall.ETHERTYPE_SIMNET": "syscall",
- "syscall.ETHERTYPE_SLOW": "syscall",
- "syscall.ETHERTYPE_SLOWPROTOCOLS": "syscall",
- "syscall.ETHERTYPE_SNA": "syscall",
- "syscall.ETHERTYPE_SNMP": "syscall",
- "syscall.ETHERTYPE_SONIX": "syscall",
- "syscall.ETHERTYPE_SPIDER": "syscall",
- "syscall.ETHERTYPE_SPRITE": "syscall",
- "syscall.ETHERTYPE_STP": "syscall",
- "syscall.ETHERTYPE_TALARIS": "syscall",
- "syscall.ETHERTYPE_TALARISMC": "syscall",
- "syscall.ETHERTYPE_TCPCOMP": "syscall",
- "syscall.ETHERTYPE_TCPSM": "syscall",
- "syscall.ETHERTYPE_TEC": "syscall",
- "syscall.ETHERTYPE_TIGAN": "syscall",
- "syscall.ETHERTYPE_TRAIL": "syscall",
- "syscall.ETHERTYPE_TRANSETHER": "syscall",
- "syscall.ETHERTYPE_TYMSHARE": "syscall",
- "syscall.ETHERTYPE_UBBST": "syscall",
- "syscall.ETHERTYPE_UBDEBUG": "syscall",
- "syscall.ETHERTYPE_UBDIAGLOOP": "syscall",
- "syscall.ETHERTYPE_UBDL": "syscall",
- "syscall.ETHERTYPE_UBNIU": "syscall",
- "syscall.ETHERTYPE_UBNMC": "syscall",
- "syscall.ETHERTYPE_VALID": "syscall",
- "syscall.ETHERTYPE_VARIAN": "syscall",
- "syscall.ETHERTYPE_VAXELN": "syscall",
- "syscall.ETHERTYPE_VEECO": "syscall",
- "syscall.ETHERTYPE_VEXP": "syscall",
- "syscall.ETHERTYPE_VGLAB": "syscall",
- "syscall.ETHERTYPE_VINES": "syscall",
- "syscall.ETHERTYPE_VINESECHO": "syscall",
- "syscall.ETHERTYPE_VINESLOOP": "syscall",
- "syscall.ETHERTYPE_VITAL": "syscall",
- "syscall.ETHERTYPE_VLAN": "syscall",
- "syscall.ETHERTYPE_VLTLMAN": "syscall",
- "syscall.ETHERTYPE_VPROD": "syscall",
- "syscall.ETHERTYPE_VURESERVED": "syscall",
- "syscall.ETHERTYPE_WATERLOO": "syscall",
- "syscall.ETHERTYPE_WELLFLEET": "syscall",
- "syscall.ETHERTYPE_X25": "syscall",
- "syscall.ETHERTYPE_X75": "syscall",
- "syscall.ETHERTYPE_XNSSM": "syscall",
- "syscall.ETHERTYPE_XTP": "syscall",
- "syscall.ETHER_ADDR_LEN": "syscall",
- "syscall.ETHER_ALIGN": "syscall",
- "syscall.ETHER_CRC_LEN": "syscall",
- "syscall.ETHER_CRC_POLY_BE": "syscall",
- "syscall.ETHER_CRC_POLY_LE": "syscall",
- "syscall.ETHER_HDR_LEN": "syscall",
- "syscall.ETHER_MAX_DIX_LEN": "syscall",
- "syscall.ETHER_MAX_LEN": "syscall",
- "syscall.ETHER_MAX_LEN_JUMBO": "syscall",
- "syscall.ETHER_MIN_LEN": "syscall",
- "syscall.ETHER_PPPOE_ENCAP_LEN": "syscall",
- "syscall.ETHER_TYPE_LEN": "syscall",
- "syscall.ETHER_VLAN_ENCAP_LEN": "syscall",
- "syscall.ETH_P_1588": "syscall",
- "syscall.ETH_P_8021Q": "syscall",
- "syscall.ETH_P_802_2": "syscall",
- "syscall.ETH_P_802_3": "syscall",
- "syscall.ETH_P_AARP": "syscall",
- "syscall.ETH_P_ALL": "syscall",
- "syscall.ETH_P_AOE": "syscall",
- "syscall.ETH_P_ARCNET": "syscall",
- "syscall.ETH_P_ARP": "syscall",
- "syscall.ETH_P_ATALK": "syscall",
- "syscall.ETH_P_ATMFATE": "syscall",
- "syscall.ETH_P_ATMMPOA": "syscall",
- "syscall.ETH_P_AX25": "syscall",
- "syscall.ETH_P_BPQ": "syscall",
- "syscall.ETH_P_CAIF": "syscall",
- "syscall.ETH_P_CAN": "syscall",
- "syscall.ETH_P_CONTROL": "syscall",
- "syscall.ETH_P_CUST": "syscall",
- "syscall.ETH_P_DDCMP": "syscall",
- "syscall.ETH_P_DEC": "syscall",
- "syscall.ETH_P_DIAG": "syscall",
- "syscall.ETH_P_DNA_DL": "syscall",
- "syscall.ETH_P_DNA_RC": "syscall",
- "syscall.ETH_P_DNA_RT": "syscall",
- "syscall.ETH_P_DSA": "syscall",
- "syscall.ETH_P_ECONET": "syscall",
- "syscall.ETH_P_EDSA": "syscall",
- "syscall.ETH_P_FCOE": "syscall",
- "syscall.ETH_P_FIP": "syscall",
- "syscall.ETH_P_HDLC": "syscall",
- "syscall.ETH_P_IEEE802154": "syscall",
- "syscall.ETH_P_IEEEPUP": "syscall",
- "syscall.ETH_P_IEEEPUPAT": "syscall",
- "syscall.ETH_P_IP": "syscall",
- "syscall.ETH_P_IPV6": "syscall",
- "syscall.ETH_P_IPX": "syscall",
- "syscall.ETH_P_IRDA": "syscall",
- "syscall.ETH_P_LAT": "syscall",
- "syscall.ETH_P_LINK_CTL": "syscall",
- "syscall.ETH_P_LOCALTALK": "syscall",
- "syscall.ETH_P_LOOP": "syscall",
- "syscall.ETH_P_MOBITEX": "syscall",
- "syscall.ETH_P_MPLS_MC": "syscall",
- "syscall.ETH_P_MPLS_UC": "syscall",
- "syscall.ETH_P_PAE": "syscall",
- "syscall.ETH_P_PAUSE": "syscall",
- "syscall.ETH_P_PHONET": "syscall",
- "syscall.ETH_P_PPPTALK": "syscall",
- "syscall.ETH_P_PPP_DISC": "syscall",
- "syscall.ETH_P_PPP_MP": "syscall",
- "syscall.ETH_P_PPP_SES": "syscall",
- "syscall.ETH_P_PUP": "syscall",
- "syscall.ETH_P_PUPAT": "syscall",
- "syscall.ETH_P_RARP": "syscall",
- "syscall.ETH_P_SCA": "syscall",
- "syscall.ETH_P_SLOW": "syscall",
- "syscall.ETH_P_SNAP": "syscall",
- "syscall.ETH_P_TEB": "syscall",
- "syscall.ETH_P_TIPC": "syscall",
- "syscall.ETH_P_TRAILER": "syscall",
- "syscall.ETH_P_TR_802_2": "syscall",
- "syscall.ETH_P_WAN_PPP": "syscall",
- "syscall.ETH_P_WCCP": "syscall",
- "syscall.ETH_P_X25": "syscall",
- "syscall.ETIME": "syscall",
- "syscall.ETIMEDOUT": "syscall",
- "syscall.ETOOMANYREFS": "syscall",
- "syscall.ETXTBSY": "syscall",
- "syscall.EUCLEAN": "syscall",
- "syscall.EUNATCH": "syscall",
- "syscall.EUSERS": "syscall",
- "syscall.EVFILT_AIO": "syscall",
- "syscall.EVFILT_FS": "syscall",
- "syscall.EVFILT_LIO": "syscall",
- "syscall.EVFILT_MACHPORT": "syscall",
- "syscall.EVFILT_PROC": "syscall",
- "syscall.EVFILT_READ": "syscall",
- "syscall.EVFILT_SIGNAL": "syscall",
- "syscall.EVFILT_SYSCOUNT": "syscall",
- "syscall.EVFILT_THREADMARKER": "syscall",
- "syscall.EVFILT_TIMER": "syscall",
- "syscall.EVFILT_USER": "syscall",
- "syscall.EVFILT_VM": "syscall",
- "syscall.EVFILT_VNODE": "syscall",
- "syscall.EVFILT_WRITE": "syscall",
- "syscall.EV_ADD": "syscall",
- "syscall.EV_CLEAR": "syscall",
- "syscall.EV_DELETE": "syscall",
- "syscall.EV_DISABLE": "syscall",
- "syscall.EV_DISPATCH": "syscall",
- "syscall.EV_ENABLE": "syscall",
- "syscall.EV_EOF": "syscall",
- "syscall.EV_ERROR": "syscall",
- "syscall.EV_FLAG0": "syscall",
- "syscall.EV_FLAG1": "syscall",
- "syscall.EV_ONESHOT": "syscall",
- "syscall.EV_OOBAND": "syscall",
- "syscall.EV_POLL": "syscall",
- "syscall.EV_RECEIPT": "syscall",
- "syscall.EV_SYSFLAGS": "syscall",
- "syscall.EWINDOWS": "syscall",
- "syscall.EWOULDBLOCK": "syscall",
- "syscall.EXDEV": "syscall",
- "syscall.EXFULL": "syscall",
- "syscall.EXTA": "syscall",
- "syscall.EXTB": "syscall",
- "syscall.EXTPROC": "syscall",
- "syscall.Environ": "syscall",
- "syscall.EpollCreate": "syscall",
- "syscall.EpollCreate1": "syscall",
- "syscall.EpollCtl": "syscall",
- "syscall.EpollEvent": "syscall",
- "syscall.EpollWait": "syscall",
- "syscall.Errno": "syscall",
- "syscall.EscapeArg": "syscall",
- "syscall.Exchangedata": "syscall",
- "syscall.Exec": "syscall",
- "syscall.Exit": "syscall",
- "syscall.ExitProcess": "syscall",
- "syscall.FD_CLOEXEC": "syscall",
- "syscall.FD_SETSIZE": "syscall",
- "syscall.FILE_ACTION_ADDED": "syscall",
- "syscall.FILE_ACTION_MODIFIED": "syscall",
- "syscall.FILE_ACTION_REMOVED": "syscall",
- "syscall.FILE_ACTION_RENAMED_NEW_NAME": "syscall",
- "syscall.FILE_ACTION_RENAMED_OLD_NAME": "syscall",
- "syscall.FILE_APPEND_DATA": "syscall",
- "syscall.FILE_ATTRIBUTE_ARCHIVE": "syscall",
- "syscall.FILE_ATTRIBUTE_DIRECTORY": "syscall",
- "syscall.FILE_ATTRIBUTE_HIDDEN": "syscall",
- "syscall.FILE_ATTRIBUTE_NORMAL": "syscall",
- "syscall.FILE_ATTRIBUTE_READONLY": "syscall",
- "syscall.FILE_ATTRIBUTE_SYSTEM": "syscall",
- "syscall.FILE_BEGIN": "syscall",
- "syscall.FILE_CURRENT": "syscall",
- "syscall.FILE_END": "syscall",
- "syscall.FILE_FLAG_BACKUP_SEMANTICS": "syscall",
- "syscall.FILE_FLAG_OVERLAPPED": "syscall",
- "syscall.FILE_LIST_DIRECTORY": "syscall",
- "syscall.FILE_MAP_COPY": "syscall",
- "syscall.FILE_MAP_EXECUTE": "syscall",
- "syscall.FILE_MAP_READ": "syscall",
- "syscall.FILE_MAP_WRITE": "syscall",
- "syscall.FILE_NOTIFY_CHANGE_ATTRIBUTES": "syscall",
- "syscall.FILE_NOTIFY_CHANGE_CREATION": "syscall",
- "syscall.FILE_NOTIFY_CHANGE_DIR_NAME": "syscall",
- "syscall.FILE_NOTIFY_CHANGE_FILE_NAME": "syscall",
- "syscall.FILE_NOTIFY_CHANGE_LAST_ACCESS": "syscall",
- "syscall.FILE_NOTIFY_CHANGE_LAST_WRITE": "syscall",
- "syscall.FILE_NOTIFY_CHANGE_SIZE": "syscall",
- "syscall.FILE_SHARE_DELETE": "syscall",
- "syscall.FILE_SHARE_READ": "syscall",
- "syscall.FILE_SHARE_WRITE": "syscall",
- "syscall.FILE_SKIP_COMPLETION_PORT_ON_SUCCESS": "syscall",
- "syscall.FILE_SKIP_SET_EVENT_ON_HANDLE": "syscall",
- "syscall.FILE_TYPE_CHAR": "syscall",
- "syscall.FILE_TYPE_DISK": "syscall",
- "syscall.FILE_TYPE_PIPE": "syscall",
- "syscall.FILE_TYPE_REMOTE": "syscall",
- "syscall.FILE_TYPE_UNKNOWN": "syscall",
- "syscall.FILE_WRITE_ATTRIBUTES": "syscall",
- "syscall.FLUSHO": "syscall",
- "syscall.FORMAT_MESSAGE_ALLOCATE_BUFFER": "syscall",
- "syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY": "syscall",
- "syscall.FORMAT_MESSAGE_FROM_HMODULE": "syscall",
- "syscall.FORMAT_MESSAGE_FROM_STRING": "syscall",
- "syscall.FORMAT_MESSAGE_FROM_SYSTEM": "syscall",
- "syscall.FORMAT_MESSAGE_IGNORE_INSERTS": "syscall",
- "syscall.FORMAT_MESSAGE_MAX_WIDTH_MASK": "syscall",
- "syscall.F_ADDFILESIGS": "syscall",
- "syscall.F_ADDSIGS": "syscall",
- "syscall.F_ALLOCATEALL": "syscall",
- "syscall.F_ALLOCATECONTIG": "syscall",
- "syscall.F_CANCEL": "syscall",
- "syscall.F_CHKCLEAN": "syscall",
- "syscall.F_CLOSEM": "syscall",
- "syscall.F_DUP2FD": "syscall",
- "syscall.F_DUP2FD_CLOEXEC": "syscall",
- "syscall.F_DUPFD": "syscall",
- "syscall.F_DUPFD_CLOEXEC": "syscall",
- "syscall.F_EXLCK": "syscall",
- "syscall.F_FLUSH_DATA": "syscall",
- "syscall.F_FREEZE_FS": "syscall",
- "syscall.F_FSCTL": "syscall",
- "syscall.F_FSDIRMASK": "syscall",
- "syscall.F_FSIN": "syscall",
- "syscall.F_FSINOUT": "syscall",
- "syscall.F_FSOUT": "syscall",
- "syscall.F_FSPRIV": "syscall",
- "syscall.F_FSVOID": "syscall",
- "syscall.F_FULLFSYNC": "syscall",
- "syscall.F_GETFD": "syscall",
- "syscall.F_GETFL": "syscall",
- "syscall.F_GETLEASE": "syscall",
- "syscall.F_GETLK": "syscall",
- "syscall.F_GETLK64": "syscall",
- "syscall.F_GETLKPID": "syscall",
- "syscall.F_GETNOSIGPIPE": "syscall",
- "syscall.F_GETOWN": "syscall",
- "syscall.F_GETOWN_EX": "syscall",
- "syscall.F_GETPATH": "syscall",
- "syscall.F_GETPATH_MTMINFO": "syscall",
- "syscall.F_GETPIPE_SZ": "syscall",
- "syscall.F_GETPROTECTIONCLASS": "syscall",
- "syscall.F_GETSIG": "syscall",
- "syscall.F_GLOBAL_NOCACHE": "syscall",
- "syscall.F_LOCK": "syscall",
- "syscall.F_LOG2PHYS": "syscall",
- "syscall.F_LOG2PHYS_EXT": "syscall",
- "syscall.F_MARKDEPENDENCY": "syscall",
- "syscall.F_MAXFD": "syscall",
- "syscall.F_NOCACHE": "syscall",
- "syscall.F_NODIRECT": "syscall",
- "syscall.F_NOTIFY": "syscall",
- "syscall.F_OGETLK": "syscall",
- "syscall.F_OK": "syscall",
- "syscall.F_OSETLK": "syscall",
- "syscall.F_OSETLKW": "syscall",
- "syscall.F_PARAM_MASK": "syscall",
- "syscall.F_PARAM_MAX": "syscall",
- "syscall.F_PATHPKG_CHECK": "syscall",
- "syscall.F_PEOFPOSMODE": "syscall",
- "syscall.F_PREALLOCATE": "syscall",
- "syscall.F_RDADVISE": "syscall",
- "syscall.F_RDAHEAD": "syscall",
- "syscall.F_RDLCK": "syscall",
- "syscall.F_READAHEAD": "syscall",
- "syscall.F_READBOOTSTRAP": "syscall",
- "syscall.F_SETBACKINGSTORE": "syscall",
- "syscall.F_SETFD": "syscall",
- "syscall.F_SETFL": "syscall",
- "syscall.F_SETLEASE": "syscall",
- "syscall.F_SETLK": "syscall",
- "syscall.F_SETLK64": "syscall",
- "syscall.F_SETLKW": "syscall",
- "syscall.F_SETLKW64": "syscall",
- "syscall.F_SETLK_REMOTE": "syscall",
- "syscall.F_SETNOSIGPIPE": "syscall",
- "syscall.F_SETOWN": "syscall",
- "syscall.F_SETOWN_EX": "syscall",
- "syscall.F_SETPIPE_SZ": "syscall",
- "syscall.F_SETPROTECTIONCLASS": "syscall",
- "syscall.F_SETSIG": "syscall",
- "syscall.F_SETSIZE": "syscall",
- "syscall.F_SHLCK": "syscall",
- "syscall.F_TEST": "syscall",
- "syscall.F_THAW_FS": "syscall",
- "syscall.F_TLOCK": "syscall",
- "syscall.F_ULOCK": "syscall",
- "syscall.F_UNLCK": "syscall",
- "syscall.F_UNLCKSYS": "syscall",
- "syscall.F_VOLPOSMODE": "syscall",
- "syscall.F_WRITEBOOTSTRAP": "syscall",
- "syscall.F_WRLCK": "syscall",
- "syscall.Faccessat": "syscall",
- "syscall.Fallocate": "syscall",
- "syscall.Fbootstraptransfer_t": "syscall",
- "syscall.Fchdir": "syscall",
- "syscall.Fchflags": "syscall",
- "syscall.Fchmod": "syscall",
- "syscall.Fchmodat": "syscall",
- "syscall.Fchown": "syscall",
- "syscall.Fchownat": "syscall",
- "syscall.FdSet": "syscall",
- "syscall.Fdatasync": "syscall",
- "syscall.FileNotifyInformation": "syscall",
- "syscall.Filetime": "syscall",
- "syscall.FindClose": "syscall",
- "syscall.FindFirstFile": "syscall",
- "syscall.FindNextFile": "syscall",
- "syscall.Flock": "syscall",
- "syscall.Flock_t": "syscall",
- "syscall.FlushBpf": "syscall",
- "syscall.FlushFileBuffers": "syscall",
- "syscall.FlushViewOfFile": "syscall",
- "syscall.ForkExec": "syscall",
- "syscall.ForkLock": "syscall",
- "syscall.FormatMessage": "syscall",
- "syscall.Fpathconf": "syscall",
- "syscall.FreeAddrInfoW": "syscall",
- "syscall.FreeEnvironmentStrings": "syscall",
- "syscall.FreeLibrary": "syscall",
- "syscall.Fsid": "syscall",
- "syscall.Fstat": "syscall",
- "syscall.Fstatfs": "syscall",
- "syscall.Fstore_t": "syscall",
- "syscall.Fsync": "syscall",
- "syscall.Ftruncate": "syscall",
- "syscall.Futimes": "syscall",
- "syscall.Futimesat": "syscall",
- "syscall.GENERIC_ALL": "syscall",
- "syscall.GENERIC_EXECUTE": "syscall",
- "syscall.GENERIC_READ": "syscall",
- "syscall.GENERIC_WRITE": "syscall",
- "syscall.GUID": "syscall",
- "syscall.GetAcceptExSockaddrs": "syscall",
- "syscall.GetAdaptersInfo": "syscall",
- "syscall.GetAddrInfoW": "syscall",
- "syscall.GetCommandLine": "syscall",
- "syscall.GetComputerName": "syscall",
- "syscall.GetConsoleMode": "syscall",
- "syscall.GetCurrentDirectory": "syscall",
- "syscall.GetCurrentProcess": "syscall",
- "syscall.GetEnvironmentStrings": "syscall",
- "syscall.GetEnvironmentVariable": "syscall",
- "syscall.GetExitCodeProcess": "syscall",
- "syscall.GetFileAttributes": "syscall",
- "syscall.GetFileAttributesEx": "syscall",
- "syscall.GetFileExInfoStandard": "syscall",
- "syscall.GetFileExMaxInfoLevel": "syscall",
- "syscall.GetFileInformationByHandle": "syscall",
- "syscall.GetFileType": "syscall",
- "syscall.GetFullPathName": "syscall",
- "syscall.GetHostByName": "syscall",
- "syscall.GetIfEntry": "syscall",
- "syscall.GetLastError": "syscall",
- "syscall.GetLengthSid": "syscall",
- "syscall.GetLongPathName": "syscall",
- "syscall.GetProcAddress": "syscall",
- "syscall.GetProcessTimes": "syscall",
- "syscall.GetProtoByName": "syscall",
- "syscall.GetQueuedCompletionStatus": "syscall",
- "syscall.GetServByName": "syscall",
- "syscall.GetShortPathName": "syscall",
- "syscall.GetStartupInfo": "syscall",
- "syscall.GetStdHandle": "syscall",
- "syscall.GetSystemTimeAsFileTime": "syscall",
- "syscall.GetTempPath": "syscall",
- "syscall.GetTimeZoneInformation": "syscall",
- "syscall.GetTokenInformation": "syscall",
- "syscall.GetUserNameEx": "syscall",
- "syscall.GetUserProfileDirectory": "syscall",
- "syscall.GetVersion": "syscall",
- "syscall.Getcwd": "syscall",
- "syscall.Getdents": "syscall",
- "syscall.Getdirentries": "syscall",
- "syscall.Getdtablesize": "syscall",
- "syscall.Getegid": "syscall",
- "syscall.Getenv": "syscall",
- "syscall.Geteuid": "syscall",
- "syscall.Getfsstat": "syscall",
- "syscall.Getgid": "syscall",
- "syscall.Getgroups": "syscall",
- "syscall.Getpagesize": "syscall",
- "syscall.Getpeername": "syscall",
- "syscall.Getpgid": "syscall",
- "syscall.Getpgrp": "syscall",
- "syscall.Getpid": "syscall",
- "syscall.Getppid": "syscall",
- "syscall.Getpriority": "syscall",
- "syscall.Getrlimit": "syscall",
- "syscall.Getrusage": "syscall",
- "syscall.Getsid": "syscall",
- "syscall.Getsockname": "syscall",
- "syscall.Getsockopt": "syscall",
- "syscall.GetsockoptByte": "syscall",
- "syscall.GetsockoptICMPv6Filter": "syscall",
- "syscall.GetsockoptIPMreq": "syscall",
- "syscall.GetsockoptIPMreqn": "syscall",
- "syscall.GetsockoptIPv6MTUInfo": "syscall",
- "syscall.GetsockoptIPv6Mreq": "syscall",
- "syscall.GetsockoptInet4Addr": "syscall",
- "syscall.GetsockoptInt": "syscall",
- "syscall.GetsockoptUcred": "syscall",
- "syscall.Gettid": "syscall",
- "syscall.Gettimeofday": "syscall",
- "syscall.Getuid": "syscall",
- "syscall.Getwd": "syscall",
- "syscall.Getxattr": "syscall",
- "syscall.HANDLE_FLAG_INHERIT": "syscall",
- "syscall.HKEY_CLASSES_ROOT": "syscall",
- "syscall.HKEY_CURRENT_CONFIG": "syscall",
- "syscall.HKEY_CURRENT_USER": "syscall",
- "syscall.HKEY_DYN_DATA": "syscall",
- "syscall.HKEY_LOCAL_MACHINE": "syscall",
- "syscall.HKEY_PERFORMANCE_DATA": "syscall",
- "syscall.HKEY_USERS": "syscall",
- "syscall.HUPCL": "syscall",
- "syscall.Handle": "syscall",
- "syscall.Hostent": "syscall",
- "syscall.ICANON": "syscall",
- "syscall.ICMP6_FILTER": "syscall",
- "syscall.ICMPV6_FILTER": "syscall",
- "syscall.ICMPv6Filter": "syscall",
- "syscall.ICRNL": "syscall",
- "syscall.IEXTEN": "syscall",
- "syscall.IFAN_ARRIVAL": "syscall",
- "syscall.IFAN_DEPARTURE": "syscall",
- "syscall.IFA_ADDRESS": "syscall",
- "syscall.IFA_ANYCAST": "syscall",
- "syscall.IFA_BROADCAST": "syscall",
- "syscall.IFA_CACHEINFO": "syscall",
- "syscall.IFA_F_DADFAILED": "syscall",
- "syscall.IFA_F_DEPRECATED": "syscall",
- "syscall.IFA_F_HOMEADDRESS": "syscall",
- "syscall.IFA_F_NODAD": "syscall",
- "syscall.IFA_F_OPTIMISTIC": "syscall",
- "syscall.IFA_F_PERMANENT": "syscall",
- "syscall.IFA_F_SECONDARY": "syscall",
- "syscall.IFA_F_TEMPORARY": "syscall",
- "syscall.IFA_F_TENTATIVE": "syscall",
- "syscall.IFA_LABEL": "syscall",
- "syscall.IFA_LOCAL": "syscall",
- "syscall.IFA_MAX": "syscall",
- "syscall.IFA_MULTICAST": "syscall",
- "syscall.IFA_ROUTE": "syscall",
- "syscall.IFA_UNSPEC": "syscall",
- "syscall.IFF_ALLMULTI": "syscall",
- "syscall.IFF_ALTPHYS": "syscall",
- "syscall.IFF_AUTOMEDIA": "syscall",
- "syscall.IFF_BROADCAST": "syscall",
- "syscall.IFF_CANTCHANGE": "syscall",
- "syscall.IFF_CANTCONFIG": "syscall",
- "syscall.IFF_DEBUG": "syscall",
- "syscall.IFF_DRV_OACTIVE": "syscall",
- "syscall.IFF_DRV_RUNNING": "syscall",
- "syscall.IFF_DYING": "syscall",
- "syscall.IFF_DYNAMIC": "syscall",
- "syscall.IFF_LINK0": "syscall",
- "syscall.IFF_LINK1": "syscall",
- "syscall.IFF_LINK2": "syscall",
- "syscall.IFF_LOOPBACK": "syscall",
- "syscall.IFF_MASTER": "syscall",
- "syscall.IFF_MONITOR": "syscall",
- "syscall.IFF_MULTICAST": "syscall",
- "syscall.IFF_NOARP": "syscall",
- "syscall.IFF_NOTRAILERS": "syscall",
- "syscall.IFF_NO_PI": "syscall",
- "syscall.IFF_OACTIVE": "syscall",
- "syscall.IFF_ONE_QUEUE": "syscall",
- "syscall.IFF_POINTOPOINT": "syscall",
- "syscall.IFF_POINTTOPOINT": "syscall",
- "syscall.IFF_PORTSEL": "syscall",
- "syscall.IFF_PPROMISC": "syscall",
- "syscall.IFF_PROMISC": "syscall",
- "syscall.IFF_RENAMING": "syscall",
- "syscall.IFF_RUNNING": "syscall",
- "syscall.IFF_SIMPLEX": "syscall",
- "syscall.IFF_SLAVE": "syscall",
- "syscall.IFF_SMART": "syscall",
- "syscall.IFF_STATICARP": "syscall",
- "syscall.IFF_TAP": "syscall",
- "syscall.IFF_TUN": "syscall",
- "syscall.IFF_TUN_EXCL": "syscall",
- "syscall.IFF_UP": "syscall",
- "syscall.IFF_VNET_HDR": "syscall",
- "syscall.IFLA_ADDRESS": "syscall",
- "syscall.IFLA_BROADCAST": "syscall",
- "syscall.IFLA_COST": "syscall",
- "syscall.IFLA_IFALIAS": "syscall",
- "syscall.IFLA_IFNAME": "syscall",
- "syscall.IFLA_LINK": "syscall",
- "syscall.IFLA_LINKINFO": "syscall",
- "syscall.IFLA_LINKMODE": "syscall",
- "syscall.IFLA_MAP": "syscall",
- "syscall.IFLA_MASTER": "syscall",
- "syscall.IFLA_MAX": "syscall",
- "syscall.IFLA_MTU": "syscall",
- "syscall.IFLA_NET_NS_PID": "syscall",
- "syscall.IFLA_OPERSTATE": "syscall",
- "syscall.IFLA_PRIORITY": "syscall",
- "syscall.IFLA_PROTINFO": "syscall",
- "syscall.IFLA_QDISC": "syscall",
- "syscall.IFLA_STATS": "syscall",
- "syscall.IFLA_TXQLEN": "syscall",
- "syscall.IFLA_UNSPEC": "syscall",
- "syscall.IFLA_WEIGHT": "syscall",
- "syscall.IFLA_WIRELESS": "syscall",
- "syscall.IFNAMSIZ": "syscall",
- "syscall.IFT_1822": "syscall",
- "syscall.IFT_A12MPPSWITCH": "syscall",
- "syscall.IFT_AAL2": "syscall",
- "syscall.IFT_AAL5": "syscall",
- "syscall.IFT_ADSL": "syscall",
- "syscall.IFT_AFLANE8023": "syscall",
- "syscall.IFT_AFLANE8025": "syscall",
- "syscall.IFT_ARAP": "syscall",
- "syscall.IFT_ARCNET": "syscall",
- "syscall.IFT_ARCNETPLUS": "syscall",
- "syscall.IFT_ASYNC": "syscall",
- "syscall.IFT_ATM": "syscall",
- "syscall.IFT_ATMDXI": "syscall",
- "syscall.IFT_ATMFUNI": "syscall",
- "syscall.IFT_ATMIMA": "syscall",
- "syscall.IFT_ATMLOGICAL": "syscall",
- "syscall.IFT_ATMRADIO": "syscall",
- "syscall.IFT_ATMSUBINTERFACE": "syscall",
- "syscall.IFT_ATMVCIENDPT": "syscall",
- "syscall.IFT_ATMVIRTUAL": "syscall",
- "syscall.IFT_BGPPOLICYACCOUNTING": "syscall",
- "syscall.IFT_BLUETOOTH": "syscall",
- "syscall.IFT_BRIDGE": "syscall",
- "syscall.IFT_BSC": "syscall",
- "syscall.IFT_CARP": "syscall",
- "syscall.IFT_CCTEMUL": "syscall",
- "syscall.IFT_CELLULAR": "syscall",
- "syscall.IFT_CEPT": "syscall",
- "syscall.IFT_CES": "syscall",
- "syscall.IFT_CHANNEL": "syscall",
- "syscall.IFT_CNR": "syscall",
- "syscall.IFT_COFFEE": "syscall",
- "syscall.IFT_COMPOSITELINK": "syscall",
- "syscall.IFT_DCN": "syscall",
- "syscall.IFT_DIGITALPOWERLINE": "syscall",
- "syscall.IFT_DIGITALWRAPPEROVERHEADCHANNEL": "syscall",
- "syscall.IFT_DLSW": "syscall",
- "syscall.IFT_DOCSCABLEDOWNSTREAM": "syscall",
- "syscall.IFT_DOCSCABLEMACLAYER": "syscall",
- "syscall.IFT_DOCSCABLEUPSTREAM": "syscall",
- "syscall.IFT_DOCSCABLEUPSTREAMCHANNEL": "syscall",
- "syscall.IFT_DS0": "syscall",
- "syscall.IFT_DS0BUNDLE": "syscall",
- "syscall.IFT_DS1FDL": "syscall",
- "syscall.IFT_DS3": "syscall",
- "syscall.IFT_DTM": "syscall",
- "syscall.IFT_DUMMY": "syscall",
- "syscall.IFT_DVBASILN": "syscall",
- "syscall.IFT_DVBASIOUT": "syscall",
- "syscall.IFT_DVBRCCDOWNSTREAM": "syscall",
- "syscall.IFT_DVBRCCMACLAYER": "syscall",
- "syscall.IFT_DVBRCCUPSTREAM": "syscall",
- "syscall.IFT_ECONET": "syscall",
- "syscall.IFT_ENC": "syscall",
- "syscall.IFT_EON": "syscall",
- "syscall.IFT_EPLRS": "syscall",
- "syscall.IFT_ESCON": "syscall",
- "syscall.IFT_ETHER": "syscall",
- "syscall.IFT_FAITH": "syscall",
- "syscall.IFT_FAST": "syscall",
- "syscall.IFT_FASTETHER": "syscall",
- "syscall.IFT_FASTETHERFX": "syscall",
- "syscall.IFT_FDDI": "syscall",
- "syscall.IFT_FIBRECHANNEL": "syscall",
- "syscall.IFT_FRAMERELAYINTERCONNECT": "syscall",
- "syscall.IFT_FRAMERELAYMPI": "syscall",
- "syscall.IFT_FRDLCIENDPT": "syscall",
- "syscall.IFT_FRELAY": "syscall",
- "syscall.IFT_FRELAYDCE": "syscall",
- "syscall.IFT_FRF16MFRBUNDLE": "syscall",
- "syscall.IFT_FRFORWARD": "syscall",
- "syscall.IFT_G703AT2MB": "syscall",
- "syscall.IFT_G703AT64K": "syscall",
- "syscall.IFT_GIF": "syscall",
- "syscall.IFT_GIGABITETHERNET": "syscall",
- "syscall.IFT_GR303IDT": "syscall",
- "syscall.IFT_GR303RDT": "syscall",
- "syscall.IFT_H323GATEKEEPER": "syscall",
- "syscall.IFT_H323PROXY": "syscall",
- "syscall.IFT_HDH1822": "syscall",
- "syscall.IFT_HDLC": "syscall",
- "syscall.IFT_HDSL2": "syscall",
- "syscall.IFT_HIPERLAN2": "syscall",
- "syscall.IFT_HIPPI": "syscall",
- "syscall.IFT_HIPPIINTERFACE": "syscall",
- "syscall.IFT_HOSTPAD": "syscall",
- "syscall.IFT_HSSI": "syscall",
- "syscall.IFT_HY": "syscall",
- "syscall.IFT_IBM370PARCHAN": "syscall",
- "syscall.IFT_IDSL": "syscall",
- "syscall.IFT_IEEE1394": "syscall",
- "syscall.IFT_IEEE80211": "syscall",
- "syscall.IFT_IEEE80212": "syscall",
- "syscall.IFT_IEEE8023ADLAG": "syscall",
- "syscall.IFT_IFGSN": "syscall",
- "syscall.IFT_IMT": "syscall",
- "syscall.IFT_INFINIBAND": "syscall",
- "syscall.IFT_INTERLEAVE": "syscall",
- "syscall.IFT_IP": "syscall",
- "syscall.IFT_IPFORWARD": "syscall",
- "syscall.IFT_IPOVERATM": "syscall",
- "syscall.IFT_IPOVERCDLC": "syscall",
- "syscall.IFT_IPOVERCLAW": "syscall",
- "syscall.IFT_IPSWITCH": "syscall",
- "syscall.IFT_IPXIP": "syscall",
- "syscall.IFT_ISDN": "syscall",
- "syscall.IFT_ISDNBASIC": "syscall",
- "syscall.IFT_ISDNPRIMARY": "syscall",
- "syscall.IFT_ISDNS": "syscall",
- "syscall.IFT_ISDNU": "syscall",
- "syscall.IFT_ISO88022LLC": "syscall",
- "syscall.IFT_ISO88023": "syscall",
- "syscall.IFT_ISO88024": "syscall",
- "syscall.IFT_ISO88025": "syscall",
- "syscall.IFT_ISO88025CRFPINT": "syscall",
- "syscall.IFT_ISO88025DTR": "syscall",
- "syscall.IFT_ISO88025FIBER": "syscall",
- "syscall.IFT_ISO88026": "syscall",
- "syscall.IFT_ISUP": "syscall",
- "syscall.IFT_L2VLAN": "syscall",
- "syscall.IFT_L3IPVLAN": "syscall",
- "syscall.IFT_L3IPXVLAN": "syscall",
- "syscall.IFT_LAPB": "syscall",
- "syscall.IFT_LAPD": "syscall",
- "syscall.IFT_LAPF": "syscall",
- "syscall.IFT_LINEGROUP": "syscall",
- "syscall.IFT_LOCALTALK": "syscall",
- "syscall.IFT_LOOP": "syscall",
- "syscall.IFT_MEDIAMAILOVERIP": "syscall",
- "syscall.IFT_MFSIGLINK": "syscall",
- "syscall.IFT_MIOX25": "syscall",
- "syscall.IFT_MODEM": "syscall",
- "syscall.IFT_MPC": "syscall",
- "syscall.IFT_MPLS": "syscall",
- "syscall.IFT_MPLSTUNNEL": "syscall",
- "syscall.IFT_MSDSL": "syscall",
- "syscall.IFT_MVL": "syscall",
- "syscall.IFT_MYRINET": "syscall",
- "syscall.IFT_NFAS": "syscall",
- "syscall.IFT_NSIP": "syscall",
- "syscall.IFT_OPTICALCHANNEL": "syscall",
- "syscall.IFT_OPTICALTRANSPORT": "syscall",
- "syscall.IFT_OTHER": "syscall",
- "syscall.IFT_P10": "syscall",
- "syscall.IFT_P80": "syscall",
- "syscall.IFT_PARA": "syscall",
- "syscall.IFT_PDP": "syscall",
- "syscall.IFT_PFLOG": "syscall",
- "syscall.IFT_PFLOW": "syscall",
- "syscall.IFT_PFSYNC": "syscall",
- "syscall.IFT_PLC": "syscall",
- "syscall.IFT_PON155": "syscall",
- "syscall.IFT_PON622": "syscall",
- "syscall.IFT_POS": "syscall",
- "syscall.IFT_PPP": "syscall",
- "syscall.IFT_PPPMULTILINKBUNDLE": "syscall",
- "syscall.IFT_PROPATM": "syscall",
- "syscall.IFT_PROPBWAP2MP": "syscall",
- "syscall.IFT_PROPCNLS": "syscall",
- "syscall.IFT_PROPDOCSWIRELESSDOWNSTREAM": "syscall",
- "syscall.IFT_PROPDOCSWIRELESSMACLAYER": "syscall",
- "syscall.IFT_PROPDOCSWIRELESSUPSTREAM": "syscall",
- "syscall.IFT_PROPMUX": "syscall",
- "syscall.IFT_PROPVIRTUAL": "syscall",
- "syscall.IFT_PROPWIRELESSP2P": "syscall",
- "syscall.IFT_PTPSERIAL": "syscall",
- "syscall.IFT_PVC": "syscall",
- "syscall.IFT_Q2931": "syscall",
- "syscall.IFT_QLLC": "syscall",
- "syscall.IFT_RADIOMAC": "syscall",
- "syscall.IFT_RADSL": "syscall",
- "syscall.IFT_REACHDSL": "syscall",
- "syscall.IFT_RFC1483": "syscall",
- "syscall.IFT_RS232": "syscall",
- "syscall.IFT_RSRB": "syscall",
- "syscall.IFT_SDLC": "syscall",
- "syscall.IFT_SDSL": "syscall",
- "syscall.IFT_SHDSL": "syscall",
- "syscall.IFT_SIP": "syscall",
- "syscall.IFT_SIPSIG": "syscall",
- "syscall.IFT_SIPTG": "syscall",
- "syscall.IFT_SLIP": "syscall",
- "syscall.IFT_SMDSDXI": "syscall",
- "syscall.IFT_SMDSICIP": "syscall",
- "syscall.IFT_SONET": "syscall",
- "syscall.IFT_SONETOVERHEADCHANNEL": "syscall",
- "syscall.IFT_SONETPATH": "syscall",
- "syscall.IFT_SONETVT": "syscall",
- "syscall.IFT_SRP": "syscall",
- "syscall.IFT_SS7SIGLINK": "syscall",
- "syscall.IFT_STACKTOSTACK": "syscall",
- "syscall.IFT_STARLAN": "syscall",
- "syscall.IFT_STF": "syscall",
- "syscall.IFT_T1": "syscall",
- "syscall.IFT_TDLC": "syscall",
- "syscall.IFT_TELINK": "syscall",
- "syscall.IFT_TERMPAD": "syscall",
- "syscall.IFT_TR008": "syscall",
- "syscall.IFT_TRANSPHDLC": "syscall",
- "syscall.IFT_TUNNEL": "syscall",
- "syscall.IFT_ULTRA": "syscall",
- "syscall.IFT_USB": "syscall",
- "syscall.IFT_V11": "syscall",
- "syscall.IFT_V35": "syscall",
- "syscall.IFT_V36": "syscall",
- "syscall.IFT_V37": "syscall",
- "syscall.IFT_VDSL": "syscall",
- "syscall.IFT_VIRTUALIPADDRESS": "syscall",
- "syscall.IFT_VIRTUALTG": "syscall",
- "syscall.IFT_VOICEDID": "syscall",
- "syscall.IFT_VOICEEM": "syscall",
- "syscall.IFT_VOICEEMFGD": "syscall",
- "syscall.IFT_VOICEENCAP": "syscall",
- "syscall.IFT_VOICEFGDEANA": "syscall",
- "syscall.IFT_VOICEFXO": "syscall",
- "syscall.IFT_VOICEFXS": "syscall",
- "syscall.IFT_VOICEOVERATM": "syscall",
- "syscall.IFT_VOICEOVERCABLE": "syscall",
- "syscall.IFT_VOICEOVERFRAMERELAY": "syscall",
- "syscall.IFT_VOICEOVERIP": "syscall",
- "syscall.IFT_X213": "syscall",
- "syscall.IFT_X25": "syscall",
- "syscall.IFT_X25DDN": "syscall",
- "syscall.IFT_X25HUNTGROUP": "syscall",
- "syscall.IFT_X25MLP": "syscall",
- "syscall.IFT_X25PLE": "syscall",
- "syscall.IFT_XETHER": "syscall",
- "syscall.IGNBRK": "syscall",
- "syscall.IGNCR": "syscall",
- "syscall.IGNORE": "syscall",
- "syscall.IGNPAR": "syscall",
- "syscall.IMAXBEL": "syscall",
- "syscall.INFINITE": "syscall",
- "syscall.INLCR": "syscall",
- "syscall.INPCK": "syscall",
- "syscall.INVALID_FILE_ATTRIBUTES": "syscall",
- "syscall.IN_ACCESS": "syscall",
- "syscall.IN_ALL_EVENTS": "syscall",
- "syscall.IN_ATTRIB": "syscall",
- "syscall.IN_CLASSA_HOST": "syscall",
- "syscall.IN_CLASSA_MAX": "syscall",
- "syscall.IN_CLASSA_NET": "syscall",
- "syscall.IN_CLASSA_NSHIFT": "syscall",
- "syscall.IN_CLASSB_HOST": "syscall",
- "syscall.IN_CLASSB_MAX": "syscall",
- "syscall.IN_CLASSB_NET": "syscall",
- "syscall.IN_CLASSB_NSHIFT": "syscall",
- "syscall.IN_CLASSC_HOST": "syscall",
- "syscall.IN_CLASSC_NET": "syscall",
- "syscall.IN_CLASSC_NSHIFT": "syscall",
- "syscall.IN_CLASSD_HOST": "syscall",
- "syscall.IN_CLASSD_NET": "syscall",
- "syscall.IN_CLASSD_NSHIFT": "syscall",
- "syscall.IN_CLOEXEC": "syscall",
- "syscall.IN_CLOSE": "syscall",
- "syscall.IN_CLOSE_NOWRITE": "syscall",
- "syscall.IN_CLOSE_WRITE": "syscall",
- "syscall.IN_CREATE": "syscall",
- "syscall.IN_DELETE": "syscall",
- "syscall.IN_DELETE_SELF": "syscall",
- "syscall.IN_DONT_FOLLOW": "syscall",
- "syscall.IN_EXCL_UNLINK": "syscall",
- "syscall.IN_IGNORED": "syscall",
- "syscall.IN_ISDIR": "syscall",
- "syscall.IN_LINKLOCALNETNUM": "syscall",
- "syscall.IN_LOOPBACKNET": "syscall",
- "syscall.IN_MASK_ADD": "syscall",
- "syscall.IN_MODIFY": "syscall",
- "syscall.IN_MOVE": "syscall",
- "syscall.IN_MOVED_FROM": "syscall",
- "syscall.IN_MOVED_TO": "syscall",
- "syscall.IN_MOVE_SELF": "syscall",
- "syscall.IN_NONBLOCK": "syscall",
- "syscall.IN_ONESHOT": "syscall",
- "syscall.IN_ONLYDIR": "syscall",
- "syscall.IN_OPEN": "syscall",
- "syscall.IN_Q_OVERFLOW": "syscall",
- "syscall.IN_RFC3021_HOST": "syscall",
- "syscall.IN_RFC3021_MASK": "syscall",
- "syscall.IN_RFC3021_NET": "syscall",
- "syscall.IN_RFC3021_NSHIFT": "syscall",
- "syscall.IN_UNMOUNT": "syscall",
- "syscall.IOC_IN": "syscall",
- "syscall.IOC_INOUT": "syscall",
- "syscall.IOC_OUT": "syscall",
- "syscall.IOC_WS2": "syscall",
- "syscall.IPMreq": "syscall",
- "syscall.IPMreqn": "syscall",
- "syscall.IPPROTO_3PC": "syscall",
- "syscall.IPPROTO_ADFS": "syscall",
- "syscall.IPPROTO_AH": "syscall",
- "syscall.IPPROTO_AHIP": "syscall",
- "syscall.IPPROTO_APES": "syscall",
- "syscall.IPPROTO_ARGUS": "syscall",
- "syscall.IPPROTO_AX25": "syscall",
- "syscall.IPPROTO_BHA": "syscall",
- "syscall.IPPROTO_BLT": "syscall",
- "syscall.IPPROTO_BRSATMON": "syscall",
- "syscall.IPPROTO_CARP": "syscall",
- "syscall.IPPROTO_CFTP": "syscall",
- "syscall.IPPROTO_CHAOS": "syscall",
- "syscall.IPPROTO_CMTP": "syscall",
- "syscall.IPPROTO_COMP": "syscall",
- "syscall.IPPROTO_CPHB": "syscall",
- "syscall.IPPROTO_CPNX": "syscall",
- "syscall.IPPROTO_DCCP": "syscall",
- "syscall.IPPROTO_DDP": "syscall",
- "syscall.IPPROTO_DGP": "syscall",
- "syscall.IPPROTO_DIVERT": "syscall",
- "syscall.IPPROTO_DONE": "syscall",
- "syscall.IPPROTO_DSTOPTS": "syscall",
- "syscall.IPPROTO_EGP": "syscall",
- "syscall.IPPROTO_EMCON": "syscall",
- "syscall.IPPROTO_ENCAP": "syscall",
- "syscall.IPPROTO_EON": "syscall",
- "syscall.IPPROTO_ESP": "syscall",
- "syscall.IPPROTO_ETHERIP": "syscall",
- "syscall.IPPROTO_FRAGMENT": "syscall",
- "syscall.IPPROTO_GGP": "syscall",
- "syscall.IPPROTO_GMTP": "syscall",
- "syscall.IPPROTO_GRE": "syscall",
- "syscall.IPPROTO_HELLO": "syscall",
- "syscall.IPPROTO_HMP": "syscall",
- "syscall.IPPROTO_HOPOPTS": "syscall",
- "syscall.IPPROTO_ICMP": "syscall",
- "syscall.IPPROTO_ICMPV6": "syscall",
- "syscall.IPPROTO_IDP": "syscall",
- "syscall.IPPROTO_IDPR": "syscall",
- "syscall.IPPROTO_IDRP": "syscall",
- "syscall.IPPROTO_IGMP": "syscall",
- "syscall.IPPROTO_IGP": "syscall",
- "syscall.IPPROTO_IGRP": "syscall",
- "syscall.IPPROTO_IL": "syscall",
- "syscall.IPPROTO_INLSP": "syscall",
- "syscall.IPPROTO_INP": "syscall",
- "syscall.IPPROTO_IP": "syscall",
- "syscall.IPPROTO_IPCOMP": "syscall",
- "syscall.IPPROTO_IPCV": "syscall",
- "syscall.IPPROTO_IPEIP": "syscall",
- "syscall.IPPROTO_IPIP": "syscall",
- "syscall.IPPROTO_IPPC": "syscall",
- "syscall.IPPROTO_IPV4": "syscall",
- "syscall.IPPROTO_IPV6": "syscall",
- "syscall.IPPROTO_IPV6_ICMP": "syscall",
- "syscall.IPPROTO_IRTP": "syscall",
- "syscall.IPPROTO_KRYPTOLAN": "syscall",
- "syscall.IPPROTO_LARP": "syscall",
- "syscall.IPPROTO_LEAF1": "syscall",
- "syscall.IPPROTO_LEAF2": "syscall",
- "syscall.IPPROTO_MAX": "syscall",
- "syscall.IPPROTO_MAXID": "syscall",
- "syscall.IPPROTO_MEAS": "syscall",
- "syscall.IPPROTO_MH": "syscall",
- "syscall.IPPROTO_MHRP": "syscall",
- "syscall.IPPROTO_MICP": "syscall",
- "syscall.IPPROTO_MOBILE": "syscall",
- "syscall.IPPROTO_MPLS": "syscall",
- "syscall.IPPROTO_MTP": "syscall",
- "syscall.IPPROTO_MUX": "syscall",
- "syscall.IPPROTO_ND": "syscall",
- "syscall.IPPROTO_NHRP": "syscall",
- "syscall.IPPROTO_NONE": "syscall",
- "syscall.IPPROTO_NSP": "syscall",
- "syscall.IPPROTO_NVPII": "syscall",
- "syscall.IPPROTO_OLD_DIVERT": "syscall",
- "syscall.IPPROTO_OSPFIGP": "syscall",
- "syscall.IPPROTO_PFSYNC": "syscall",
- "syscall.IPPROTO_PGM": "syscall",
- "syscall.IPPROTO_PIGP": "syscall",
- "syscall.IPPROTO_PIM": "syscall",
- "syscall.IPPROTO_PRM": "syscall",
- "syscall.IPPROTO_PUP": "syscall",
- "syscall.IPPROTO_PVP": "syscall",
- "syscall.IPPROTO_RAW": "syscall",
- "syscall.IPPROTO_RCCMON": "syscall",
- "syscall.IPPROTO_RDP": "syscall",
- "syscall.IPPROTO_ROUTING": "syscall",
- "syscall.IPPROTO_RSVP": "syscall",
- "syscall.IPPROTO_RVD": "syscall",
- "syscall.IPPROTO_SATEXPAK": "syscall",
- "syscall.IPPROTO_SATMON": "syscall",
- "syscall.IPPROTO_SCCSP": "syscall",
- "syscall.IPPROTO_SCTP": "syscall",
- "syscall.IPPROTO_SDRP": "syscall",
- "syscall.IPPROTO_SEND": "syscall",
- "syscall.IPPROTO_SEP": "syscall",
- "syscall.IPPROTO_SKIP": "syscall",
- "syscall.IPPROTO_SPACER": "syscall",
- "syscall.IPPROTO_SRPC": "syscall",
- "syscall.IPPROTO_ST": "syscall",
- "syscall.IPPROTO_SVMTP": "syscall",
- "syscall.IPPROTO_SWIPE": "syscall",
- "syscall.IPPROTO_TCF": "syscall",
- "syscall.IPPROTO_TCP": "syscall",
- "syscall.IPPROTO_TLSP": "syscall",
- "syscall.IPPROTO_TP": "syscall",
- "syscall.IPPROTO_TPXX": "syscall",
- "syscall.IPPROTO_TRUNK1": "syscall",
- "syscall.IPPROTO_TRUNK2": "syscall",
- "syscall.IPPROTO_TTP": "syscall",
- "syscall.IPPROTO_UDP": "syscall",
- "syscall.IPPROTO_UDPLITE": "syscall",
- "syscall.IPPROTO_VINES": "syscall",
- "syscall.IPPROTO_VISA": "syscall",
- "syscall.IPPROTO_VMTP": "syscall",
- "syscall.IPPROTO_VRRP": "syscall",
- "syscall.IPPROTO_WBEXPAK": "syscall",
- "syscall.IPPROTO_WBMON": "syscall",
- "syscall.IPPROTO_WSN": "syscall",
- "syscall.IPPROTO_XNET": "syscall",
- "syscall.IPPROTO_XTP": "syscall",
- "syscall.IPV6_2292DSTOPTS": "syscall",
- "syscall.IPV6_2292HOPLIMIT": "syscall",
- "syscall.IPV6_2292HOPOPTS": "syscall",
- "syscall.IPV6_2292NEXTHOP": "syscall",
- "syscall.IPV6_2292PKTINFO": "syscall",
- "syscall.IPV6_2292PKTOPTIONS": "syscall",
- "syscall.IPV6_2292RTHDR": "syscall",
- "syscall.IPV6_ADDRFORM": "syscall",
- "syscall.IPV6_ADD_MEMBERSHIP": "syscall",
- "syscall.IPV6_AUTHHDR": "syscall",
- "syscall.IPV6_AUTH_LEVEL": "syscall",
- "syscall.IPV6_AUTOFLOWLABEL": "syscall",
- "syscall.IPV6_BINDANY": "syscall",
- "syscall.IPV6_BINDV6ONLY": "syscall",
- "syscall.IPV6_BOUND_IF": "syscall",
- "syscall.IPV6_CHECKSUM": "syscall",
- "syscall.IPV6_DEFAULT_MULTICAST_HOPS": "syscall",
- "syscall.IPV6_DEFAULT_MULTICAST_LOOP": "syscall",
- "syscall.IPV6_DEFHLIM": "syscall",
- "syscall.IPV6_DONTFRAG": "syscall",
- "syscall.IPV6_DROP_MEMBERSHIP": "syscall",
- "syscall.IPV6_DSTOPTS": "syscall",
- "syscall.IPV6_ESP_NETWORK_LEVEL": "syscall",
- "syscall.IPV6_ESP_TRANS_LEVEL": "syscall",
- "syscall.IPV6_FAITH": "syscall",
- "syscall.IPV6_FLOWINFO_MASK": "syscall",
- "syscall.IPV6_FLOWLABEL_MASK": "syscall",
- "syscall.IPV6_FRAGTTL": "syscall",
- "syscall.IPV6_FW_ADD": "syscall",
- "syscall.IPV6_FW_DEL": "syscall",
- "syscall.IPV6_FW_FLUSH": "syscall",
- "syscall.IPV6_FW_GET": "syscall",
- "syscall.IPV6_FW_ZERO": "syscall",
- "syscall.IPV6_HLIMDEC": "syscall",
- "syscall.IPV6_HOPLIMIT": "syscall",
- "syscall.IPV6_HOPOPTS": "syscall",
- "syscall.IPV6_IPCOMP_LEVEL": "syscall",
- "syscall.IPV6_IPSEC_POLICY": "syscall",
- "syscall.IPV6_JOIN_ANYCAST": "syscall",
- "syscall.IPV6_JOIN_GROUP": "syscall",
- "syscall.IPV6_LEAVE_ANYCAST": "syscall",
- "syscall.IPV6_LEAVE_GROUP": "syscall",
- "syscall.IPV6_MAXHLIM": "syscall",
- "syscall.IPV6_MAXOPTHDR": "syscall",
- "syscall.IPV6_MAXPACKET": "syscall",
- "syscall.IPV6_MAX_GROUP_SRC_FILTER": "syscall",
- "syscall.IPV6_MAX_MEMBERSHIPS": "syscall",
- "syscall.IPV6_MAX_SOCK_SRC_FILTER": "syscall",
- "syscall.IPV6_MIN_MEMBERSHIPS": "syscall",
- "syscall.IPV6_MMTU": "syscall",
- "syscall.IPV6_MSFILTER": "syscall",
- "syscall.IPV6_MTU": "syscall",
- "syscall.IPV6_MTU_DISCOVER": "syscall",
- "syscall.IPV6_MULTICAST_HOPS": "syscall",
- "syscall.IPV6_MULTICAST_IF": "syscall",
- "syscall.IPV6_MULTICAST_LOOP": "syscall",
- "syscall.IPV6_NEXTHOP": "syscall",
- "syscall.IPV6_OPTIONS": "syscall",
- "syscall.IPV6_PATHMTU": "syscall",
- "syscall.IPV6_PIPEX": "syscall",
- "syscall.IPV6_PKTINFO": "syscall",
- "syscall.IPV6_PMTUDISC_DO": "syscall",
- "syscall.IPV6_PMTUDISC_DONT": "syscall",
- "syscall.IPV6_PMTUDISC_PROBE": "syscall",
- "syscall.IPV6_PMTUDISC_WANT": "syscall",
- "syscall.IPV6_PORTRANGE": "syscall",
- "syscall.IPV6_PORTRANGE_DEFAULT": "syscall",
- "syscall.IPV6_PORTRANGE_HIGH": "syscall",
- "syscall.IPV6_PORTRANGE_LOW": "syscall",
- "syscall.IPV6_PREFER_TEMPADDR": "syscall",
- "syscall.IPV6_RECVDSTOPTS": "syscall",
- "syscall.IPV6_RECVERR": "syscall",
- "syscall.IPV6_RECVHOPLIMIT": "syscall",
- "syscall.IPV6_RECVHOPOPTS": "syscall",
- "syscall.IPV6_RECVPATHMTU": "syscall",
- "syscall.IPV6_RECVPKTINFO": "syscall",
- "syscall.IPV6_RECVRTHDR": "syscall",
- "syscall.IPV6_RECVTCLASS": "syscall",
- "syscall.IPV6_ROUTER_ALERT": "syscall",
- "syscall.IPV6_RTABLE": "syscall",
- "syscall.IPV6_RTHDR": "syscall",
- "syscall.IPV6_RTHDRDSTOPTS": "syscall",
- "syscall.IPV6_RTHDR_LOOSE": "syscall",
- "syscall.IPV6_RTHDR_STRICT": "syscall",
- "syscall.IPV6_RTHDR_TYPE_0": "syscall",
- "syscall.IPV6_RXDSTOPTS": "syscall",
- "syscall.IPV6_RXHOPOPTS": "syscall",
- "syscall.IPV6_SOCKOPT_RESERVED1": "syscall",
- "syscall.IPV6_TCLASS": "syscall",
- "syscall.IPV6_UNICAST_HOPS": "syscall",
- "syscall.IPV6_USE_MIN_MTU": "syscall",
- "syscall.IPV6_V6ONLY": "syscall",
- "syscall.IPV6_VERSION": "syscall",
- "syscall.IPV6_VERSION_MASK": "syscall",
- "syscall.IPV6_XFRM_POLICY": "syscall",
- "syscall.IP_ADD_MEMBERSHIP": "syscall",
- "syscall.IP_ADD_SOURCE_MEMBERSHIP": "syscall",
- "syscall.IP_AUTH_LEVEL": "syscall",
- "syscall.IP_BINDANY": "syscall",
- "syscall.IP_BLOCK_SOURCE": "syscall",
- "syscall.IP_BOUND_IF": "syscall",
- "syscall.IP_DEFAULT_MULTICAST_LOOP": "syscall",
- "syscall.IP_DEFAULT_MULTICAST_TTL": "syscall",
- "syscall.IP_DF": "syscall",
- "syscall.IP_DONTFRAG": "syscall",
- "syscall.IP_DROP_MEMBERSHIP": "syscall",
- "syscall.IP_DROP_SOURCE_MEMBERSHIP": "syscall",
- "syscall.IP_DUMMYNET3": "syscall",
- "syscall.IP_DUMMYNET_CONFIGURE": "syscall",
- "syscall.IP_DUMMYNET_DEL": "syscall",
- "syscall.IP_DUMMYNET_FLUSH": "syscall",
- "syscall.IP_DUMMYNET_GET": "syscall",
- "syscall.IP_EF": "syscall",
- "syscall.IP_ERRORMTU": "syscall",
- "syscall.IP_ESP_NETWORK_LEVEL": "syscall",
- "syscall.IP_ESP_TRANS_LEVEL": "syscall",
- "syscall.IP_FAITH": "syscall",
- "syscall.IP_FREEBIND": "syscall",
- "syscall.IP_FW3": "syscall",
- "syscall.IP_FW_ADD": "syscall",
- "syscall.IP_FW_DEL": "syscall",
- "syscall.IP_FW_FLUSH": "syscall",
- "syscall.IP_FW_GET": "syscall",
- "syscall.IP_FW_NAT_CFG": "syscall",
- "syscall.IP_FW_NAT_DEL": "syscall",
- "syscall.IP_FW_NAT_GET_CONFIG": "syscall",
- "syscall.IP_FW_NAT_GET_LOG": "syscall",
- "syscall.IP_FW_RESETLOG": "syscall",
- "syscall.IP_FW_TABLE_ADD": "syscall",
- "syscall.IP_FW_TABLE_DEL": "syscall",
- "syscall.IP_FW_TABLE_FLUSH": "syscall",
- "syscall.IP_FW_TABLE_GETSIZE": "syscall",
- "syscall.IP_FW_TABLE_LIST": "syscall",
- "syscall.IP_FW_ZERO": "syscall",
- "syscall.IP_HDRINCL": "syscall",
- "syscall.IP_IPCOMP_LEVEL": "syscall",
- "syscall.IP_IPSECFLOWINFO": "syscall",
- "syscall.IP_IPSEC_LOCAL_AUTH": "syscall",
- "syscall.IP_IPSEC_LOCAL_CRED": "syscall",
- "syscall.IP_IPSEC_LOCAL_ID": "syscall",
- "syscall.IP_IPSEC_POLICY": "syscall",
- "syscall.IP_IPSEC_REMOTE_AUTH": "syscall",
- "syscall.IP_IPSEC_REMOTE_CRED": "syscall",
- "syscall.IP_IPSEC_REMOTE_ID": "syscall",
- "syscall.IP_MAXPACKET": "syscall",
- "syscall.IP_MAX_GROUP_SRC_FILTER": "syscall",
- "syscall.IP_MAX_MEMBERSHIPS": "syscall",
- "syscall.IP_MAX_SOCK_MUTE_FILTER": "syscall",
- "syscall.IP_MAX_SOCK_SRC_FILTER": "syscall",
- "syscall.IP_MAX_SOURCE_FILTER": "syscall",
- "syscall.IP_MF": "syscall",
- "syscall.IP_MINFRAGSIZE": "syscall",
- "syscall.IP_MINTTL": "syscall",
- "syscall.IP_MIN_MEMBERSHIPS": "syscall",
- "syscall.IP_MSFILTER": "syscall",
- "syscall.IP_MSS": "syscall",
- "syscall.IP_MTU": "syscall",
- "syscall.IP_MTU_DISCOVER": "syscall",
- "syscall.IP_MULTICAST_IF": "syscall",
- "syscall.IP_MULTICAST_IFINDEX": "syscall",
- "syscall.IP_MULTICAST_LOOP": "syscall",
- "syscall.IP_MULTICAST_TTL": "syscall",
- "syscall.IP_MULTICAST_VIF": "syscall",
- "syscall.IP_NAT__XXX": "syscall",
- "syscall.IP_OFFMASK": "syscall",
- "syscall.IP_OLD_FW_ADD": "syscall",
- "syscall.IP_OLD_FW_DEL": "syscall",
- "syscall.IP_OLD_FW_FLUSH": "syscall",
- "syscall.IP_OLD_FW_GET": "syscall",
- "syscall.IP_OLD_FW_RESETLOG": "syscall",
- "syscall.IP_OLD_FW_ZERO": "syscall",
- "syscall.IP_ONESBCAST": "syscall",
- "syscall.IP_OPTIONS": "syscall",
- "syscall.IP_ORIGDSTADDR": "syscall",
- "syscall.IP_PASSSEC": "syscall",
- "syscall.IP_PIPEX": "syscall",
- "syscall.IP_PKTINFO": "syscall",
- "syscall.IP_PKTOPTIONS": "syscall",
- "syscall.IP_PMTUDISC": "syscall",
- "syscall.IP_PMTUDISC_DO": "syscall",
- "syscall.IP_PMTUDISC_DONT": "syscall",
- "syscall.IP_PMTUDISC_PROBE": "syscall",
- "syscall.IP_PMTUDISC_WANT": "syscall",
- "syscall.IP_PORTRANGE": "syscall",
- "syscall.IP_PORTRANGE_DEFAULT": "syscall",
- "syscall.IP_PORTRANGE_HIGH": "syscall",
- "syscall.IP_PORTRANGE_LOW": "syscall",
- "syscall.IP_RECVDSTADDR": "syscall",
- "syscall.IP_RECVDSTPORT": "syscall",
- "syscall.IP_RECVERR": "syscall",
- "syscall.IP_RECVIF": "syscall",
- "syscall.IP_RECVOPTS": "syscall",
- "syscall.IP_RECVORIGDSTADDR": "syscall",
- "syscall.IP_RECVPKTINFO": "syscall",
- "syscall.IP_RECVRETOPTS": "syscall",
- "syscall.IP_RECVRTABLE": "syscall",
- "syscall.IP_RECVTOS": "syscall",
- "syscall.IP_RECVTTL": "syscall",
- "syscall.IP_RETOPTS": "syscall",
- "syscall.IP_RF": "syscall",
- "syscall.IP_ROUTER_ALERT": "syscall",
- "syscall.IP_RSVP_OFF": "syscall",
- "syscall.IP_RSVP_ON": "syscall",
- "syscall.IP_RSVP_VIF_OFF": "syscall",
- "syscall.IP_RSVP_VIF_ON": "syscall",
- "syscall.IP_RTABLE": "syscall",
- "syscall.IP_SENDSRCADDR": "syscall",
- "syscall.IP_STRIPHDR": "syscall",
- "syscall.IP_TOS": "syscall",
- "syscall.IP_TRAFFIC_MGT_BACKGROUND": "syscall",
- "syscall.IP_TRANSPARENT": "syscall",
- "syscall.IP_TTL": "syscall",
- "syscall.IP_UNBLOCK_SOURCE": "syscall",
- "syscall.IP_XFRM_POLICY": "syscall",
- "syscall.IPv6MTUInfo": "syscall",
- "syscall.IPv6Mreq": "syscall",
- "syscall.ISIG": "syscall",
- "syscall.ISTRIP": "syscall",
- "syscall.IUCLC": "syscall",
- "syscall.IUTF8": "syscall",
- "syscall.IXANY": "syscall",
- "syscall.IXOFF": "syscall",
- "syscall.IXON": "syscall",
- "syscall.IfAddrmsg": "syscall",
- "syscall.IfAnnounceMsghdr": "syscall",
- "syscall.IfData": "syscall",
- "syscall.IfInfomsg": "syscall",
- "syscall.IfMsghdr": "syscall",
- "syscall.IfaMsghdr": "syscall",
- "syscall.IfmaMsghdr": "syscall",
- "syscall.IfmaMsghdr2": "syscall",
- "syscall.ImplementsGetwd": "syscall",
- "syscall.Inet4Pktinfo": "syscall",
- "syscall.Inet6Pktinfo": "syscall",
- "syscall.InotifyAddWatch": "syscall",
- "syscall.InotifyEvent": "syscall",
- "syscall.InotifyInit": "syscall",
- "syscall.InotifyInit1": "syscall",
- "syscall.InotifyRmWatch": "syscall",
- "syscall.InterfaceAddrMessage": "syscall",
- "syscall.InterfaceAnnounceMessage": "syscall",
- "syscall.InterfaceInfo": "syscall",
- "syscall.InterfaceMessage": "syscall",
- "syscall.InterfaceMulticastAddrMessage": "syscall",
- "syscall.InvalidHandle": "syscall",
- "syscall.Ioperm": "syscall",
- "syscall.Iopl": "syscall",
- "syscall.Iovec": "syscall",
- "syscall.IpAdapterInfo": "syscall",
- "syscall.IpAddrString": "syscall",
- "syscall.IpAddressString": "syscall",
- "syscall.IpMaskString": "syscall",
- "syscall.Issetugid": "syscall",
- "syscall.KEY_ALL_ACCESS": "syscall",
- "syscall.KEY_CREATE_LINK": "syscall",
- "syscall.KEY_CREATE_SUB_KEY": "syscall",
- "syscall.KEY_ENUMERATE_SUB_KEYS": "syscall",
- "syscall.KEY_EXECUTE": "syscall",
- "syscall.KEY_NOTIFY": "syscall",
- "syscall.KEY_QUERY_VALUE": "syscall",
- "syscall.KEY_READ": "syscall",
- "syscall.KEY_SET_VALUE": "syscall",
- "syscall.KEY_WOW64_32KEY": "syscall",
- "syscall.KEY_WOW64_64KEY": "syscall",
- "syscall.KEY_WRITE": "syscall",
- "syscall.Kevent": "syscall",
- "syscall.Kevent_t": "syscall",
- "syscall.Kill": "syscall",
- "syscall.Klogctl": "syscall",
- "syscall.Kqueue": "syscall",
- "syscall.LANG_ENGLISH": "syscall",
- "syscall.LAYERED_PROTOCOL": "syscall",
- "syscall.LCNT_OVERLOAD_FLUSH": "syscall",
- "syscall.LINUX_REBOOT_CMD_CAD_OFF": "syscall",
- "syscall.LINUX_REBOOT_CMD_CAD_ON": "syscall",
- "syscall.LINUX_REBOOT_CMD_HALT": "syscall",
- "syscall.LINUX_REBOOT_CMD_KEXEC": "syscall",
- "syscall.LINUX_REBOOT_CMD_POWER_OFF": "syscall",
- "syscall.LINUX_REBOOT_CMD_RESTART": "syscall",
- "syscall.LINUX_REBOOT_CMD_RESTART2": "syscall",
- "syscall.LINUX_REBOOT_CMD_SW_SUSPEND": "syscall",
- "syscall.LINUX_REBOOT_MAGIC1": "syscall",
- "syscall.LINUX_REBOOT_MAGIC2": "syscall",
- "syscall.LOCK_EX": "syscall",
- "syscall.LOCK_NB": "syscall",
- "syscall.LOCK_SH": "syscall",
- "syscall.LOCK_UN": "syscall",
- "syscall.LazyDLL": "syscall",
- "syscall.LazyProc": "syscall",
- "syscall.Lchown": "syscall",
- "syscall.Linger": "syscall",
- "syscall.Link": "syscall",
- "syscall.Listen": "syscall",
- "syscall.Listxattr": "syscall",
- "syscall.LoadCancelIoEx": "syscall",
- "syscall.LoadConnectEx": "syscall",
- "syscall.LoadDLL": "syscall",
- "syscall.LoadGetAddrInfo": "syscall",
- "syscall.LoadLibrary": "syscall",
- "syscall.LoadSetFileCompletionNotificationModes": "syscall",
- "syscall.LocalFree": "syscall",
- "syscall.Log2phys_t": "syscall",
- "syscall.LookupAccountName": "syscall",
- "syscall.LookupAccountSid": "syscall",
- "syscall.LookupSID": "syscall",
- "syscall.LsfJump": "syscall",
- "syscall.LsfSocket": "syscall",
- "syscall.LsfStmt": "syscall",
- "syscall.Lstat": "syscall",
- "syscall.MADV_AUTOSYNC": "syscall",
- "syscall.MADV_CAN_REUSE": "syscall",
- "syscall.MADV_CORE": "syscall",
- "syscall.MADV_DOFORK": "syscall",
- "syscall.MADV_DONTFORK": "syscall",
- "syscall.MADV_DONTNEED": "syscall",
- "syscall.MADV_FREE": "syscall",
- "syscall.MADV_FREE_REUSABLE": "syscall",
- "syscall.MADV_FREE_REUSE": "syscall",
- "syscall.MADV_HUGEPAGE": "syscall",
- "syscall.MADV_HWPOISON": "syscall",
- "syscall.MADV_MERGEABLE": "syscall",
- "syscall.MADV_NOCORE": "syscall",
- "syscall.MADV_NOHUGEPAGE": "syscall",
- "syscall.MADV_NORMAL": "syscall",
- "syscall.MADV_NOSYNC": "syscall",
- "syscall.MADV_PROTECT": "syscall",
- "syscall.MADV_RANDOM": "syscall",
- "syscall.MADV_REMOVE": "syscall",
- "syscall.MADV_SEQUENTIAL": "syscall",
- "syscall.MADV_UNMERGEABLE": "syscall",
- "syscall.MADV_WILLNEED": "syscall",
- "syscall.MADV_ZERO_WIRED_PAGES": "syscall",
- "syscall.MAP_32BIT": "syscall",
- "syscall.MAP_ANON": "syscall",
- "syscall.MAP_ANONYMOUS": "syscall",
- "syscall.MAP_COPY": "syscall",
- "syscall.MAP_DENYWRITE": "syscall",
- "syscall.MAP_EXECUTABLE": "syscall",
- "syscall.MAP_FILE": "syscall",
- "syscall.MAP_FIXED": "syscall",
- "syscall.MAP_GROWSDOWN": "syscall",
- "syscall.MAP_HASSEMAPHORE": "syscall",
- "syscall.MAP_HUGETLB": "syscall",
- "syscall.MAP_JIT": "syscall",
- "syscall.MAP_LOCKED": "syscall",
- "syscall.MAP_NOCACHE": "syscall",
- "syscall.MAP_NOCORE": "syscall",
- "syscall.MAP_NOEXTEND": "syscall",
- "syscall.MAP_NONBLOCK": "syscall",
- "syscall.MAP_NORESERVE": "syscall",
- "syscall.MAP_NOSYNC": "syscall",
- "syscall.MAP_POPULATE": "syscall",
- "syscall.MAP_PREFAULT_READ": "syscall",
- "syscall.MAP_PRIVATE": "syscall",
- "syscall.MAP_RENAME": "syscall",
- "syscall.MAP_RESERVED0080": "syscall",
- "syscall.MAP_RESERVED0100": "syscall",
- "syscall.MAP_SHARED": "syscall",
- "syscall.MAP_STACK": "syscall",
- "syscall.MAP_TYPE": "syscall",
- "syscall.MAXLEN_IFDESCR": "syscall",
- "syscall.MAXLEN_PHYSADDR": "syscall",
- "syscall.MAX_ADAPTER_ADDRESS_LENGTH": "syscall",
- "syscall.MAX_ADAPTER_DESCRIPTION_LENGTH": "syscall",
- "syscall.MAX_ADAPTER_NAME_LENGTH": "syscall",
- "syscall.MAX_COMPUTERNAME_LENGTH": "syscall",
- "syscall.MAX_INTERFACE_NAME_LEN": "syscall",
- "syscall.MAX_LONG_PATH": "syscall",
- "syscall.MAX_PATH": "syscall",
- "syscall.MAX_PROTOCOL_CHAIN": "syscall",
- "syscall.MCL_CURRENT": "syscall",
- "syscall.MCL_FUTURE": "syscall",
- "syscall.MNT_DETACH": "syscall",
- "syscall.MNT_EXPIRE": "syscall",
- "syscall.MNT_FORCE": "syscall",
- "syscall.MSG_BCAST": "syscall",
- "syscall.MSG_CMSG_CLOEXEC": "syscall",
- "syscall.MSG_COMPAT": "syscall",
- "syscall.MSG_CONFIRM": "syscall",
- "syscall.MSG_CONTROLMBUF": "syscall",
- "syscall.MSG_CTRUNC": "syscall",
- "syscall.MSG_DONTROUTE": "syscall",
- "syscall.MSG_DONTWAIT": "syscall",
- "syscall.MSG_EOF": "syscall",
- "syscall.MSG_EOR": "syscall",
- "syscall.MSG_ERRQUEUE": "syscall",
- "syscall.MSG_FASTOPEN": "syscall",
- "syscall.MSG_FIN": "syscall",
- "syscall.MSG_FLUSH": "syscall",
- "syscall.MSG_HAVEMORE": "syscall",
- "syscall.MSG_HOLD": "syscall",
- "syscall.MSG_IOVUSRSPACE": "syscall",
- "syscall.MSG_LENUSRSPACE": "syscall",
- "syscall.MSG_MCAST": "syscall",
- "syscall.MSG_MORE": "syscall",
- "syscall.MSG_NAMEMBUF": "syscall",
- "syscall.MSG_NBIO": "syscall",
- "syscall.MSG_NEEDSA": "syscall",
- "syscall.MSG_NOSIGNAL": "syscall",
- "syscall.MSG_NOTIFICATION": "syscall",
- "syscall.MSG_OOB": "syscall",
- "syscall.MSG_PEEK": "syscall",
- "syscall.MSG_PROXY": "syscall",
- "syscall.MSG_RCVMORE": "syscall",
- "syscall.MSG_RST": "syscall",
- "syscall.MSG_SEND": "syscall",
- "syscall.MSG_SYN": "syscall",
- "syscall.MSG_TRUNC": "syscall",
- "syscall.MSG_TRYHARD": "syscall",
- "syscall.MSG_USERFLAGS": "syscall",
- "syscall.MSG_WAITALL": "syscall",
- "syscall.MSG_WAITFORONE": "syscall",
- "syscall.MSG_WAITSTREAM": "syscall",
- "syscall.MS_ACTIVE": "syscall",
- "syscall.MS_ASYNC": "syscall",
- "syscall.MS_BIND": "syscall",
- "syscall.MS_DEACTIVATE": "syscall",
- "syscall.MS_DIRSYNC": "syscall",
- "syscall.MS_INVALIDATE": "syscall",
- "syscall.MS_I_VERSION": "syscall",
- "syscall.MS_KERNMOUNT": "syscall",
- "syscall.MS_KILLPAGES": "syscall",
- "syscall.MS_MANDLOCK": "syscall",
- "syscall.MS_MGC_MSK": "syscall",
- "syscall.MS_MGC_VAL": "syscall",
- "syscall.MS_MOVE": "syscall",
- "syscall.MS_NOATIME": "syscall",
- "syscall.MS_NODEV": "syscall",
- "syscall.MS_NODIRATIME": "syscall",
- "syscall.MS_NOEXEC": "syscall",
- "syscall.MS_NOSUID": "syscall",
- "syscall.MS_NOUSER": "syscall",
- "syscall.MS_POSIXACL": "syscall",
- "syscall.MS_PRIVATE": "syscall",
- "syscall.MS_RDONLY": "syscall",
- "syscall.MS_REC": "syscall",
- "syscall.MS_RELATIME": "syscall",
- "syscall.MS_REMOUNT": "syscall",
- "syscall.MS_RMT_MASK": "syscall",
- "syscall.MS_SHARED": "syscall",
- "syscall.MS_SILENT": "syscall",
- "syscall.MS_SLAVE": "syscall",
- "syscall.MS_STRICTATIME": "syscall",
- "syscall.MS_SYNC": "syscall",
- "syscall.MS_SYNCHRONOUS": "syscall",
- "syscall.MS_UNBINDABLE": "syscall",
- "syscall.Madvise": "syscall",
- "syscall.MapViewOfFile": "syscall",
- "syscall.MaxTokenInfoClass": "syscall",
- "syscall.Mclpool": "syscall",
- "syscall.MibIfRow": "syscall",
- "syscall.Mkdir": "syscall",
- "syscall.Mkdirat": "syscall",
- "syscall.Mkfifo": "syscall",
- "syscall.Mknod": "syscall",
- "syscall.Mknodat": "syscall",
- "syscall.Mlock": "syscall",
- "syscall.Mlockall": "syscall",
- "syscall.Mmap": "syscall",
- "syscall.Mount": "syscall",
- "syscall.MoveFile": "syscall",
- "syscall.Mprotect": "syscall",
- "syscall.Msghdr": "syscall",
- "syscall.Munlock": "syscall",
- "syscall.Munlockall": "syscall",
- "syscall.Munmap": "syscall",
- "syscall.MustLoadDLL": "syscall",
- "syscall.NAME_MAX": "syscall",
- "syscall.NETLINK_ADD_MEMBERSHIP": "syscall",
- "syscall.NETLINK_AUDIT": "syscall",
- "syscall.NETLINK_BROADCAST_ERROR": "syscall",
- "syscall.NETLINK_CONNECTOR": "syscall",
- "syscall.NETLINK_DNRTMSG": "syscall",
- "syscall.NETLINK_DROP_MEMBERSHIP": "syscall",
- "syscall.NETLINK_ECRYPTFS": "syscall",
- "syscall.NETLINK_FIB_LOOKUP": "syscall",
- "syscall.NETLINK_FIREWALL": "syscall",
- "syscall.NETLINK_GENERIC": "syscall",
- "syscall.NETLINK_INET_DIAG": "syscall",
- "syscall.NETLINK_IP6_FW": "syscall",
- "syscall.NETLINK_ISCSI": "syscall",
- "syscall.NETLINK_KOBJECT_UEVENT": "syscall",
- "syscall.NETLINK_NETFILTER": "syscall",
- "syscall.NETLINK_NFLOG": "syscall",
- "syscall.NETLINK_NO_ENOBUFS": "syscall",
- "syscall.NETLINK_PKTINFO": "syscall",
- "syscall.NETLINK_RDMA": "syscall",
- "syscall.NETLINK_ROUTE": "syscall",
- "syscall.NETLINK_SCSITRANSPORT": "syscall",
- "syscall.NETLINK_SELINUX": "syscall",
- "syscall.NETLINK_UNUSED": "syscall",
- "syscall.NETLINK_USERSOCK": "syscall",
- "syscall.NETLINK_XFRM": "syscall",
- "syscall.NET_RT_DUMP": "syscall",
- "syscall.NET_RT_DUMP2": "syscall",
- "syscall.NET_RT_FLAGS": "syscall",
- "syscall.NET_RT_IFLIST": "syscall",
- "syscall.NET_RT_IFLIST2": "syscall",
- "syscall.NET_RT_IFLISTL": "syscall",
- "syscall.NET_RT_IFMALIST": "syscall",
- "syscall.NET_RT_MAXID": "syscall",
- "syscall.NET_RT_OIFLIST": "syscall",
- "syscall.NET_RT_OOIFLIST": "syscall",
- "syscall.NET_RT_STAT": "syscall",
- "syscall.NET_RT_STATS": "syscall",
- "syscall.NET_RT_TABLE": "syscall",
- "syscall.NET_RT_TRASH": "syscall",
- "syscall.NLA_ALIGNTO": "syscall",
- "syscall.NLA_F_NESTED": "syscall",
- "syscall.NLA_F_NET_BYTEORDER": "syscall",
- "syscall.NLA_HDRLEN": "syscall",
- "syscall.NLMSG_ALIGNTO": "syscall",
- "syscall.NLMSG_DONE": "syscall",
- "syscall.NLMSG_ERROR": "syscall",
- "syscall.NLMSG_HDRLEN": "syscall",
- "syscall.NLMSG_MIN_TYPE": "syscall",
- "syscall.NLMSG_NOOP": "syscall",
- "syscall.NLMSG_OVERRUN": "syscall",
- "syscall.NLM_F_ACK": "syscall",
- "syscall.NLM_F_APPEND": "syscall",
- "syscall.NLM_F_ATOMIC": "syscall",
- "syscall.NLM_F_CREATE": "syscall",
- "syscall.NLM_F_DUMP": "syscall",
- "syscall.NLM_F_ECHO": "syscall",
- "syscall.NLM_F_EXCL": "syscall",
- "syscall.NLM_F_MATCH": "syscall",
- "syscall.NLM_F_MULTI": "syscall",
- "syscall.NLM_F_REPLACE": "syscall",
- "syscall.NLM_F_REQUEST": "syscall",
- "syscall.NLM_F_ROOT": "syscall",
- "syscall.NOFLSH": "syscall",
- "syscall.NOTE_ABSOLUTE": "syscall",
- "syscall.NOTE_ATTRIB": "syscall",
- "syscall.NOTE_CHILD": "syscall",
- "syscall.NOTE_DELETE": "syscall",
- "syscall.NOTE_EOF": "syscall",
- "syscall.NOTE_EXEC": "syscall",
- "syscall.NOTE_EXIT": "syscall",
- "syscall.NOTE_EXITSTATUS": "syscall",
- "syscall.NOTE_EXTEND": "syscall",
- "syscall.NOTE_FFAND": "syscall",
- "syscall.NOTE_FFCOPY": "syscall",
- "syscall.NOTE_FFCTRLMASK": "syscall",
- "syscall.NOTE_FFLAGSMASK": "syscall",
- "syscall.NOTE_FFNOP": "syscall",
- "syscall.NOTE_FFOR": "syscall",
- "syscall.NOTE_FORK": "syscall",
- "syscall.NOTE_LINK": "syscall",
- "syscall.NOTE_LOWAT": "syscall",
- "syscall.NOTE_NONE": "syscall",
- "syscall.NOTE_NSECONDS": "syscall",
- "syscall.NOTE_PCTRLMASK": "syscall",
- "syscall.NOTE_PDATAMASK": "syscall",
- "syscall.NOTE_REAP": "syscall",
- "syscall.NOTE_RENAME": "syscall",
- "syscall.NOTE_RESOURCEEND": "syscall",
- "syscall.NOTE_REVOKE": "syscall",
- "syscall.NOTE_SECONDS": "syscall",
- "syscall.NOTE_SIGNAL": "syscall",
- "syscall.NOTE_TRACK": "syscall",
- "syscall.NOTE_TRACKERR": "syscall",
- "syscall.NOTE_TRIGGER": "syscall",
- "syscall.NOTE_TRUNCATE": "syscall",
- "syscall.NOTE_USECONDS": "syscall",
- "syscall.NOTE_VM_ERROR": "syscall",
- "syscall.NOTE_VM_PRESSURE": "syscall",
- "syscall.NOTE_VM_PRESSURE_SUDDEN_TERMINATE": "syscall",
- "syscall.NOTE_VM_PRESSURE_TERMINATE": "syscall",
- "syscall.NOTE_WRITE": "syscall",
- "syscall.NameCanonical": "syscall",
- "syscall.NameCanonicalEx": "syscall",
- "syscall.NameDisplay": "syscall",
- "syscall.NameDnsDomain": "syscall",
- "syscall.NameFullyQualifiedDN": "syscall",
- "syscall.NameSamCompatible": "syscall",
- "syscall.NameServicePrincipal": "syscall",
- "syscall.NameUniqueId": "syscall",
- "syscall.NameUnknown": "syscall",
- "syscall.NameUserPrincipal": "syscall",
- "syscall.Nanosleep": "syscall",
- "syscall.NetApiBufferFree": "syscall",
- "syscall.NetGetJoinInformation": "syscall",
- "syscall.NetSetupDomainName": "syscall",
- "syscall.NetSetupUnjoined": "syscall",
- "syscall.NetSetupUnknownStatus": "syscall",
- "syscall.NetSetupWorkgroupName": "syscall",
- "syscall.NetUserGetInfo": "syscall",
- "syscall.NetlinkMessage": "syscall",
- "syscall.NetlinkRIB": "syscall",
- "syscall.NetlinkRouteAttr": "syscall",
- "syscall.NetlinkRouteRequest": "syscall",
- "syscall.NewCallback": "syscall",
- "syscall.NewLazyDLL": "syscall",
- "syscall.NlAttr": "syscall",
- "syscall.NlMsgerr": "syscall",
- "syscall.NlMsghdr": "syscall",
- "syscall.NsecToFiletime": "syscall",
- "syscall.NsecToTimespec": "syscall",
- "syscall.NsecToTimeval": "syscall",
- "syscall.Ntohs": "syscall",
- "syscall.OCRNL": "syscall",
- "syscall.OFDEL": "syscall",
- "syscall.OFILL": "syscall",
- "syscall.OFIOGETBMAP": "syscall",
- "syscall.OID_PKIX_KP_SERVER_AUTH": "syscall",
- "syscall.OID_SERVER_GATED_CRYPTO": "syscall",
- "syscall.OID_SGC_NETSCAPE": "syscall",
- "syscall.OLCUC": "syscall",
- "syscall.ONLCR": "syscall",
- "syscall.ONLRET": "syscall",
- "syscall.ONOCR": "syscall",
- "syscall.ONOEOT": "syscall",
- "syscall.OPEN_ALWAYS": "syscall",
- "syscall.OPEN_EXISTING": "syscall",
- "syscall.OPOST": "syscall",
- "syscall.O_ACCMODE": "syscall",
- "syscall.O_ALERT": "syscall",
- "syscall.O_ALT_IO": "syscall",
- "syscall.O_APPEND": "syscall",
- "syscall.O_ASYNC": "syscall",
- "syscall.O_CLOEXEC": "syscall",
- "syscall.O_CREAT": "syscall",
- "syscall.O_DIRECT": "syscall",
- "syscall.O_DIRECTORY": "syscall",
- "syscall.O_DSYNC": "syscall",
- "syscall.O_EVTONLY": "syscall",
- "syscall.O_EXCL": "syscall",
- "syscall.O_EXEC": "syscall",
- "syscall.O_EXLOCK": "syscall",
- "syscall.O_FSYNC": "syscall",
- "syscall.O_LARGEFILE": "syscall",
- "syscall.O_NDELAY": "syscall",
- "syscall.O_NOATIME": "syscall",
- "syscall.O_NOCTTY": "syscall",
- "syscall.O_NOFOLLOW": "syscall",
- "syscall.O_NONBLOCK": "syscall",
- "syscall.O_NOSIGPIPE": "syscall",
- "syscall.O_POPUP": "syscall",
- "syscall.O_RDONLY": "syscall",
- "syscall.O_RDWR": "syscall",
- "syscall.O_RSYNC": "syscall",
- "syscall.O_SHLOCK": "syscall",
- "syscall.O_SYMLINK": "syscall",
- "syscall.O_SYNC": "syscall",
- "syscall.O_TRUNC": "syscall",
- "syscall.O_TTY_INIT": "syscall",
- "syscall.O_WRONLY": "syscall",
- "syscall.Open": "syscall",
- "syscall.OpenCurrentProcessToken": "syscall",
- "syscall.OpenProcess": "syscall",
- "syscall.OpenProcessToken": "syscall",
- "syscall.Openat": "syscall",
- "syscall.Overlapped": "syscall",
- "syscall.PACKET_ADD_MEMBERSHIP": "syscall",
- "syscall.PACKET_BROADCAST": "syscall",
- "syscall.PACKET_DROP_MEMBERSHIP": "syscall",
- "syscall.PACKET_FASTROUTE": "syscall",
- "syscall.PACKET_HOST": "syscall",
- "syscall.PACKET_LOOPBACK": "syscall",
- "syscall.PACKET_MR_ALLMULTI": "syscall",
- "syscall.PACKET_MR_MULTICAST": "syscall",
- "syscall.PACKET_MR_PROMISC": "syscall",
- "syscall.PACKET_MULTICAST": "syscall",
- "syscall.PACKET_OTHERHOST": "syscall",
- "syscall.PACKET_OUTGOING": "syscall",
- "syscall.PACKET_RECV_OUTPUT": "syscall",
- "syscall.PACKET_RX_RING": "syscall",
- "syscall.PACKET_STATISTICS": "syscall",
- "syscall.PAGE_EXECUTE_READ": "syscall",
- "syscall.PAGE_EXECUTE_READWRITE": "syscall",
- "syscall.PAGE_EXECUTE_WRITECOPY": "syscall",
- "syscall.PAGE_READONLY": "syscall",
- "syscall.PAGE_READWRITE": "syscall",
- "syscall.PAGE_WRITECOPY": "syscall",
- "syscall.PARENB": "syscall",
- "syscall.PARMRK": "syscall",
- "syscall.PARODD": "syscall",
- "syscall.PENDIN": "syscall",
- "syscall.PFL_HIDDEN": "syscall",
- "syscall.PFL_MATCHES_PROTOCOL_ZERO": "syscall",
- "syscall.PFL_MULTIPLE_PROTO_ENTRIES": "syscall",
- "syscall.PFL_NETWORKDIRECT_PROVIDER": "syscall",
- "syscall.PFL_RECOMMENDED_PROTO_ENTRY": "syscall",
- "syscall.PF_FLUSH": "syscall",
- "syscall.PKCS_7_ASN_ENCODING": "syscall",
- "syscall.PMC5_PIPELINE_FLUSH": "syscall",
- "syscall.PRIO_PGRP": "syscall",
- "syscall.PRIO_PROCESS": "syscall",
- "syscall.PRIO_USER": "syscall",
- "syscall.PRI_IOFLUSH": "syscall",
- "syscall.PROCESS_QUERY_INFORMATION": "syscall",
- "syscall.PROCESS_TERMINATE": "syscall",
- "syscall.PROT_EXEC": "syscall",
- "syscall.PROT_GROWSDOWN": "syscall",
- "syscall.PROT_GROWSUP": "syscall",
- "syscall.PROT_NONE": "syscall",
- "syscall.PROT_READ": "syscall",
- "syscall.PROT_WRITE": "syscall",
- "syscall.PROV_DH_SCHANNEL": "syscall",
- "syscall.PROV_DSS": "syscall",
- "syscall.PROV_DSS_DH": "syscall",
- "syscall.PROV_EC_ECDSA_FULL": "syscall",
- "syscall.PROV_EC_ECDSA_SIG": "syscall",
- "syscall.PROV_EC_ECNRA_FULL": "syscall",
- "syscall.PROV_EC_ECNRA_SIG": "syscall",
- "syscall.PROV_FORTEZZA": "syscall",
- "syscall.PROV_INTEL_SEC": "syscall",
- "syscall.PROV_MS_EXCHANGE": "syscall",
- "syscall.PROV_REPLACE_OWF": "syscall",
- "syscall.PROV_RNG": "syscall",
- "syscall.PROV_RSA_AES": "syscall",
- "syscall.PROV_RSA_FULL": "syscall",
- "syscall.PROV_RSA_SCHANNEL": "syscall",
- "syscall.PROV_RSA_SIG": "syscall",
- "syscall.PROV_SPYRUS_LYNKS": "syscall",
- "syscall.PROV_SSL": "syscall",
- "syscall.PR_CAPBSET_DROP": "syscall",
- "syscall.PR_CAPBSET_READ": "syscall",
- "syscall.PR_CLEAR_SECCOMP_FILTER": "syscall",
- "syscall.PR_ENDIAN_BIG": "syscall",
- "syscall.PR_ENDIAN_LITTLE": "syscall",
- "syscall.PR_ENDIAN_PPC_LITTLE": "syscall",
- "syscall.PR_FPEMU_NOPRINT": "syscall",
- "syscall.PR_FPEMU_SIGFPE": "syscall",
- "syscall.PR_FP_EXC_ASYNC": "syscall",
- "syscall.PR_FP_EXC_DISABLED": "syscall",
- "syscall.PR_FP_EXC_DIV": "syscall",
- "syscall.PR_FP_EXC_INV": "syscall",
- "syscall.PR_FP_EXC_NONRECOV": "syscall",
- "syscall.PR_FP_EXC_OVF": "syscall",
- "syscall.PR_FP_EXC_PRECISE": "syscall",
- "syscall.PR_FP_EXC_RES": "syscall",
- "syscall.PR_FP_EXC_SW_ENABLE": "syscall",
- "syscall.PR_FP_EXC_UND": "syscall",
- "syscall.PR_GET_DUMPABLE": "syscall",
- "syscall.PR_GET_ENDIAN": "syscall",
- "syscall.PR_GET_FPEMU": "syscall",
- "syscall.PR_GET_FPEXC": "syscall",
- "syscall.PR_GET_KEEPCAPS": "syscall",
- "syscall.PR_GET_NAME": "syscall",
- "syscall.PR_GET_PDEATHSIG": "syscall",
- "syscall.PR_GET_SECCOMP": "syscall",
- "syscall.PR_GET_SECCOMP_FILTER": "syscall",
- "syscall.PR_GET_SECUREBITS": "syscall",
- "syscall.PR_GET_TIMERSLACK": "syscall",
- "syscall.PR_GET_TIMING": "syscall",
- "syscall.PR_GET_TSC": "syscall",
- "syscall.PR_GET_UNALIGN": "syscall",
- "syscall.PR_MCE_KILL": "syscall",
- "syscall.PR_MCE_KILL_CLEAR": "syscall",
- "syscall.PR_MCE_KILL_DEFAULT": "syscall",
- "syscall.PR_MCE_KILL_EARLY": "syscall",
- "syscall.PR_MCE_KILL_GET": "syscall",
- "syscall.PR_MCE_KILL_LATE": "syscall",
- "syscall.PR_MCE_KILL_SET": "syscall",
- "syscall.PR_SECCOMP_FILTER_EVENT": "syscall",
- "syscall.PR_SECCOMP_FILTER_SYSCALL": "syscall",
- "syscall.PR_SET_DUMPABLE": "syscall",
- "syscall.PR_SET_ENDIAN": "syscall",
- "syscall.PR_SET_FPEMU": "syscall",
- "syscall.PR_SET_FPEXC": "syscall",
- "syscall.PR_SET_KEEPCAPS": "syscall",
- "syscall.PR_SET_NAME": "syscall",
- "syscall.PR_SET_PDEATHSIG": "syscall",
- "syscall.PR_SET_PTRACER": "syscall",
- "syscall.PR_SET_SECCOMP": "syscall",
- "syscall.PR_SET_SECCOMP_FILTER": "syscall",
- "syscall.PR_SET_SECUREBITS": "syscall",
- "syscall.PR_SET_TIMERSLACK": "syscall",
- "syscall.PR_SET_TIMING": "syscall",
- "syscall.PR_SET_TSC": "syscall",
- "syscall.PR_SET_UNALIGN": "syscall",
- "syscall.PR_TASK_PERF_EVENTS_DISABLE": "syscall",
- "syscall.PR_TASK_PERF_EVENTS_ENABLE": "syscall",
- "syscall.PR_TIMING_STATISTICAL": "syscall",
- "syscall.PR_TIMING_TIMESTAMP": "syscall",
- "syscall.PR_TSC_ENABLE": "syscall",
- "syscall.PR_TSC_SIGSEGV": "syscall",
- "syscall.PR_UNALIGN_NOPRINT": "syscall",
- "syscall.PR_UNALIGN_SIGBUS": "syscall",
- "syscall.PTRACE_ARCH_PRCTL": "syscall",
- "syscall.PTRACE_ATTACH": "syscall",
- "syscall.PTRACE_CONT": "syscall",
- "syscall.PTRACE_DETACH": "syscall",
- "syscall.PTRACE_EVENT_CLONE": "syscall",
- "syscall.PTRACE_EVENT_EXEC": "syscall",
- "syscall.PTRACE_EVENT_EXIT": "syscall",
- "syscall.PTRACE_EVENT_FORK": "syscall",
- "syscall.PTRACE_EVENT_VFORK": "syscall",
- "syscall.PTRACE_EVENT_VFORK_DONE": "syscall",
- "syscall.PTRACE_GETCRUNCHREGS": "syscall",
- "syscall.PTRACE_GETEVENTMSG": "syscall",
- "syscall.PTRACE_GETFPREGS": "syscall",
- "syscall.PTRACE_GETFPXREGS": "syscall",
- "syscall.PTRACE_GETHBPREGS": "syscall",
- "syscall.PTRACE_GETREGS": "syscall",
- "syscall.PTRACE_GETREGSET": "syscall",
- "syscall.PTRACE_GETSIGINFO": "syscall",
- "syscall.PTRACE_GETVFPREGS": "syscall",
- "syscall.PTRACE_GETWMMXREGS": "syscall",
- "syscall.PTRACE_GET_THREAD_AREA": "syscall",
- "syscall.PTRACE_KILL": "syscall",
- "syscall.PTRACE_OLDSETOPTIONS": "syscall",
- "syscall.PTRACE_O_MASK": "syscall",
- "syscall.PTRACE_O_TRACECLONE": "syscall",
- "syscall.PTRACE_O_TRACEEXEC": "syscall",
- "syscall.PTRACE_O_TRACEEXIT": "syscall",
- "syscall.PTRACE_O_TRACEFORK": "syscall",
- "syscall.PTRACE_O_TRACESYSGOOD": "syscall",
- "syscall.PTRACE_O_TRACEVFORK": "syscall",
- "syscall.PTRACE_O_TRACEVFORKDONE": "syscall",
- "syscall.PTRACE_PEEKDATA": "syscall",
- "syscall.PTRACE_PEEKTEXT": "syscall",
- "syscall.PTRACE_PEEKUSR": "syscall",
- "syscall.PTRACE_POKEDATA": "syscall",
- "syscall.PTRACE_POKETEXT": "syscall",
- "syscall.PTRACE_POKEUSR": "syscall",
- "syscall.PTRACE_SETCRUNCHREGS": "syscall",
- "syscall.PTRACE_SETFPREGS": "syscall",
- "syscall.PTRACE_SETFPXREGS": "syscall",
- "syscall.PTRACE_SETHBPREGS": "syscall",
- "syscall.PTRACE_SETOPTIONS": "syscall",
- "syscall.PTRACE_SETREGS": "syscall",
- "syscall.PTRACE_SETREGSET": "syscall",
- "syscall.PTRACE_SETSIGINFO": "syscall",
- "syscall.PTRACE_SETVFPREGS": "syscall",
- "syscall.PTRACE_SETWMMXREGS": "syscall",
- "syscall.PTRACE_SET_SYSCALL": "syscall",
- "syscall.PTRACE_SET_THREAD_AREA": "syscall",
- "syscall.PTRACE_SINGLEBLOCK": "syscall",
- "syscall.PTRACE_SINGLESTEP": "syscall",
- "syscall.PTRACE_SYSCALL": "syscall",
- "syscall.PTRACE_SYSEMU": "syscall",
- "syscall.PTRACE_SYSEMU_SINGLESTEP": "syscall",
- "syscall.PTRACE_TRACEME": "syscall",
- "syscall.PT_ATTACH": "syscall",
- "syscall.PT_ATTACHEXC": "syscall",
- "syscall.PT_CONTINUE": "syscall",
- "syscall.PT_DATA_ADDR": "syscall",
- "syscall.PT_DENY_ATTACH": "syscall",
- "syscall.PT_DETACH": "syscall",
- "syscall.PT_FIRSTMACH": "syscall",
- "syscall.PT_FORCEQUOTA": "syscall",
- "syscall.PT_KILL": "syscall",
- "syscall.PT_MASK": "syscall",
- "syscall.PT_READ_D": "syscall",
- "syscall.PT_READ_I": "syscall",
- "syscall.PT_READ_U": "syscall",
- "syscall.PT_SIGEXC": "syscall",
- "syscall.PT_STEP": "syscall",
- "syscall.PT_TEXT_ADDR": "syscall",
- "syscall.PT_TEXT_END_ADDR": "syscall",
- "syscall.PT_THUPDATE": "syscall",
- "syscall.PT_TRACE_ME": "syscall",
- "syscall.PT_WRITE_D": "syscall",
- "syscall.PT_WRITE_I": "syscall",
- "syscall.PT_WRITE_U": "syscall",
- "syscall.ParseDirent": "syscall",
- "syscall.ParseNetlinkMessage": "syscall",
- "syscall.ParseNetlinkRouteAttr": "syscall",
- "syscall.ParseRoutingMessage": "syscall",
- "syscall.ParseRoutingSockaddr": "syscall",
- "syscall.ParseSocketControlMessage": "syscall",
- "syscall.ParseUnixCredentials": "syscall",
- "syscall.ParseUnixRights": "syscall",
- "syscall.PathMax": "syscall",
- "syscall.Pathconf": "syscall",
- "syscall.Pause": "syscall",
- "syscall.Pipe": "syscall",
- "syscall.Pipe2": "syscall",
- "syscall.PivotRoot": "syscall",
- "syscall.PostQueuedCompletionStatus": "syscall",
- "syscall.Pread": "syscall",
- "syscall.Proc": "syscall",
- "syscall.ProcAttr": "syscall",
- "syscall.ProcessInformation": "syscall",
- "syscall.Protoent": "syscall",
- "syscall.PtraceAttach": "syscall",
- "syscall.PtraceCont": "syscall",
- "syscall.PtraceDetach": "syscall",
- "syscall.PtraceGetEventMsg": "syscall",
- "syscall.PtraceGetRegs": "syscall",
- "syscall.PtracePeekData": "syscall",
- "syscall.PtracePeekText": "syscall",
- "syscall.PtracePokeData": "syscall",
- "syscall.PtracePokeText": "syscall",
- "syscall.PtraceRegs": "syscall",
- "syscall.PtraceSetOptions": "syscall",
- "syscall.PtraceSetRegs": "syscall",
- "syscall.PtraceSingleStep": "syscall",
- "syscall.PtraceSyscall": "syscall",
- "syscall.Pwrite": "syscall",
- "syscall.REG_BINARY": "syscall",
- "syscall.REG_DWORD": "syscall",
- "syscall.REG_DWORD_BIG_ENDIAN": "syscall",
- "syscall.REG_DWORD_LITTLE_ENDIAN": "syscall",
- "syscall.REG_EXPAND_SZ": "syscall",
- "syscall.REG_FULL_RESOURCE_DESCRIPTOR": "syscall",
- "syscall.REG_LINK": "syscall",
- "syscall.REG_MULTI_SZ": "syscall",
- "syscall.REG_NONE": "syscall",
- "syscall.REG_QWORD": "syscall",
- "syscall.REG_QWORD_LITTLE_ENDIAN": "syscall",
- "syscall.REG_RESOURCE_LIST": "syscall",
- "syscall.REG_RESOURCE_REQUIREMENTS_LIST": "syscall",
- "syscall.REG_SZ": "syscall",
- "syscall.RLIMIT_AS": "syscall",
- "syscall.RLIMIT_CORE": "syscall",
- "syscall.RLIMIT_CPU": "syscall",
- "syscall.RLIMIT_DATA": "syscall",
- "syscall.RLIMIT_FSIZE": "syscall",
- "syscall.RLIMIT_NOFILE": "syscall",
- "syscall.RLIMIT_STACK": "syscall",
- "syscall.RLIM_INFINITY": "syscall",
- "syscall.RTAX_ADVMSS": "syscall",
- "syscall.RTAX_AUTHOR": "syscall",
- "syscall.RTAX_BRD": "syscall",
- "syscall.RTAX_CWND": "syscall",
- "syscall.RTAX_DST": "syscall",
- "syscall.RTAX_FEATURES": "syscall",
- "syscall.RTAX_FEATURE_ALLFRAG": "syscall",
- "syscall.RTAX_FEATURE_ECN": "syscall",
- "syscall.RTAX_FEATURE_SACK": "syscall",
- "syscall.RTAX_FEATURE_TIMESTAMP": "syscall",
- "syscall.RTAX_GATEWAY": "syscall",
- "syscall.RTAX_GENMASK": "syscall",
- "syscall.RTAX_HOPLIMIT": "syscall",
- "syscall.RTAX_IFA": "syscall",
- "syscall.RTAX_IFP": "syscall",
- "syscall.RTAX_INITCWND": "syscall",
- "syscall.RTAX_INITRWND": "syscall",
- "syscall.RTAX_LABEL": "syscall",
- "syscall.RTAX_LOCK": "syscall",
- "syscall.RTAX_MAX": "syscall",
- "syscall.RTAX_MTU": "syscall",
- "syscall.RTAX_NETMASK": "syscall",
- "syscall.RTAX_REORDERING": "syscall",
- "syscall.RTAX_RTO_MIN": "syscall",
- "syscall.RTAX_RTT": "syscall",
- "syscall.RTAX_RTTVAR": "syscall",
- "syscall.RTAX_SRC": "syscall",
- "syscall.RTAX_SRCMASK": "syscall",
- "syscall.RTAX_SSTHRESH": "syscall",
- "syscall.RTAX_TAG": "syscall",
- "syscall.RTAX_UNSPEC": "syscall",
- "syscall.RTAX_WINDOW": "syscall",
- "syscall.RTA_ALIGNTO": "syscall",
- "syscall.RTA_AUTHOR": "syscall",
- "syscall.RTA_BRD": "syscall",
- "syscall.RTA_CACHEINFO": "syscall",
- "syscall.RTA_DST": "syscall",
- "syscall.RTA_FLOW": "syscall",
- "syscall.RTA_GATEWAY": "syscall",
- "syscall.RTA_GENMASK": "syscall",
- "syscall.RTA_IFA": "syscall",
- "syscall.RTA_IFP": "syscall",
- "syscall.RTA_IIF": "syscall",
- "syscall.RTA_LABEL": "syscall",
- "syscall.RTA_MAX": "syscall",
- "syscall.RTA_METRICS": "syscall",
- "syscall.RTA_MULTIPATH": "syscall",
- "syscall.RTA_NETMASK": "syscall",
- "syscall.RTA_OIF": "syscall",
- "syscall.RTA_PREFSRC": "syscall",
- "syscall.RTA_PRIORITY": "syscall",
- "syscall.RTA_SRC": "syscall",
- "syscall.RTA_SRCMASK": "syscall",
- "syscall.RTA_TABLE": "syscall",
- "syscall.RTA_TAG": "syscall",
- "syscall.RTA_UNSPEC": "syscall",
- "syscall.RTCF_DIRECTSRC": "syscall",
- "syscall.RTCF_DOREDIRECT": "syscall",
- "syscall.RTCF_LOG": "syscall",
- "syscall.RTCF_MASQ": "syscall",
- "syscall.RTCF_NAT": "syscall",
- "syscall.RTCF_VALVE": "syscall",
- "syscall.RTF_ADDRCLASSMASK": "syscall",
- "syscall.RTF_ADDRCONF": "syscall",
- "syscall.RTF_ALLONLINK": "syscall",
- "syscall.RTF_ANNOUNCE": "syscall",
- "syscall.RTF_BLACKHOLE": "syscall",
- "syscall.RTF_BROADCAST": "syscall",
- "syscall.RTF_CACHE": "syscall",
- "syscall.RTF_CLONED": "syscall",
- "syscall.RTF_CLONING": "syscall",
- "syscall.RTF_CONDEMNED": "syscall",
- "syscall.RTF_DEFAULT": "syscall",
- "syscall.RTF_DELCLONE": "syscall",
- "syscall.RTF_DONE": "syscall",
- "syscall.RTF_DYNAMIC": "syscall",
- "syscall.RTF_FLOW": "syscall",
- "syscall.RTF_FMASK": "syscall",
- "syscall.RTF_GATEWAY": "syscall",
- "syscall.RTF_HOST": "syscall",
- "syscall.RTF_IFREF": "syscall",
- "syscall.RTF_IFSCOPE": "syscall",
- "syscall.RTF_INTERFACE": "syscall",
- "syscall.RTF_IRTT": "syscall",
- "syscall.RTF_LINKRT": "syscall",
- "syscall.RTF_LLDATA": "syscall",
- "syscall.RTF_LLINFO": "syscall",
- "syscall.RTF_LOCAL": "syscall",
- "syscall.RTF_MASK": "syscall",
- "syscall.RTF_MODIFIED": "syscall",
- "syscall.RTF_MPATH": "syscall",
- "syscall.RTF_MPLS": "syscall",
- "syscall.RTF_MSS": "syscall",
- "syscall.RTF_MTU": "syscall",
- "syscall.RTF_MULTICAST": "syscall",
- "syscall.RTF_NAT": "syscall",
- "syscall.RTF_NOFORWARD": "syscall",
- "syscall.RTF_NONEXTHOP": "syscall",
- "syscall.RTF_NOPMTUDISC": "syscall",
- "syscall.RTF_PERMANENT_ARP": "syscall",
- "syscall.RTF_PINNED": "syscall",
- "syscall.RTF_POLICY": "syscall",
- "syscall.RTF_PRCLONING": "syscall",
- "syscall.RTF_PROTO1": "syscall",
- "syscall.RTF_PROTO2": "syscall",
- "syscall.RTF_PROTO3": "syscall",
- "syscall.RTF_REINSTATE": "syscall",
- "syscall.RTF_REJECT": "syscall",
- "syscall.RTF_RNH_LOCKED": "syscall",
- "syscall.RTF_SOURCE": "syscall",
- "syscall.RTF_SRC": "syscall",
- "syscall.RTF_STATIC": "syscall",
- "syscall.RTF_STICKY": "syscall",
- "syscall.RTF_THROW": "syscall",
- "syscall.RTF_TUNNEL": "syscall",
- "syscall.RTF_UP": "syscall",
- "syscall.RTF_USETRAILERS": "syscall",
- "syscall.RTF_WASCLONED": "syscall",
- "syscall.RTF_WINDOW": "syscall",
- "syscall.RTF_XRESOLVE": "syscall",
- "syscall.RTM_ADD": "syscall",
- "syscall.RTM_BASE": "syscall",
- "syscall.RTM_CHANGE": "syscall",
- "syscall.RTM_CHGADDR": "syscall",
- "syscall.RTM_DELACTION": "syscall",
- "syscall.RTM_DELADDR": "syscall",
- "syscall.RTM_DELADDRLABEL": "syscall",
- "syscall.RTM_DELETE": "syscall",
- "syscall.RTM_DELLINK": "syscall",
- "syscall.RTM_DELMADDR": "syscall",
- "syscall.RTM_DELNEIGH": "syscall",
- "syscall.RTM_DELQDISC": "syscall",
- "syscall.RTM_DELROUTE": "syscall",
- "syscall.RTM_DELRULE": "syscall",
- "syscall.RTM_DELTCLASS": "syscall",
- "syscall.RTM_DELTFILTER": "syscall",
- "syscall.RTM_DESYNC": "syscall",
- "syscall.RTM_F_CLONED": "syscall",
- "syscall.RTM_F_EQUALIZE": "syscall",
- "syscall.RTM_F_NOTIFY": "syscall",
- "syscall.RTM_F_PREFIX": "syscall",
- "syscall.RTM_GET": "syscall",
- "syscall.RTM_GET2": "syscall",
- "syscall.RTM_GETACTION": "syscall",
- "syscall.RTM_GETADDR": "syscall",
- "syscall.RTM_GETADDRLABEL": "syscall",
- "syscall.RTM_GETANYCAST": "syscall",
- "syscall.RTM_GETDCB": "syscall",
- "syscall.RTM_GETLINK": "syscall",
- "syscall.RTM_GETMULTICAST": "syscall",
- "syscall.RTM_GETNEIGH": "syscall",
- "syscall.RTM_GETNEIGHTBL": "syscall",
- "syscall.RTM_GETQDISC": "syscall",
- "syscall.RTM_GETROUTE": "syscall",
- "syscall.RTM_GETRULE": "syscall",
- "syscall.RTM_GETTCLASS": "syscall",
- "syscall.RTM_GETTFILTER": "syscall",
- "syscall.RTM_IEEE80211": "syscall",
- "syscall.RTM_IFANNOUNCE": "syscall",
- "syscall.RTM_IFINFO": "syscall",
- "syscall.RTM_IFINFO2": "syscall",
- "syscall.RTM_LLINFO_UPD": "syscall",
- "syscall.RTM_LOCK": "syscall",
- "syscall.RTM_LOSING": "syscall",
- "syscall.RTM_MAX": "syscall",
- "syscall.RTM_MAXSIZE": "syscall",
- "syscall.RTM_MISS": "syscall",
- "syscall.RTM_NEWACTION": "syscall",
- "syscall.RTM_NEWADDR": "syscall",
- "syscall.RTM_NEWADDRLABEL": "syscall",
- "syscall.RTM_NEWLINK": "syscall",
- "syscall.RTM_NEWMADDR": "syscall",
- "syscall.RTM_NEWMADDR2": "syscall",
- "syscall.RTM_NEWNDUSEROPT": "syscall",
- "syscall.RTM_NEWNEIGH": "syscall",
- "syscall.RTM_NEWNEIGHTBL": "syscall",
- "syscall.RTM_NEWPREFIX": "syscall",
- "syscall.RTM_NEWQDISC": "syscall",
- "syscall.RTM_NEWROUTE": "syscall",
- "syscall.RTM_NEWRULE": "syscall",
- "syscall.RTM_NEWTCLASS": "syscall",
- "syscall.RTM_NEWTFILTER": "syscall",
- "syscall.RTM_NR_FAMILIES": "syscall",
- "syscall.RTM_NR_MSGTYPES": "syscall",
- "syscall.RTM_OIFINFO": "syscall",
- "syscall.RTM_OLDADD": "syscall",
- "syscall.RTM_OLDDEL": "syscall",
- "syscall.RTM_OOIFINFO": "syscall",
- "syscall.RTM_REDIRECT": "syscall",
- "syscall.RTM_RESOLVE": "syscall",
- "syscall.RTM_RTTUNIT": "syscall",
- "syscall.RTM_SETDCB": "syscall",
- "syscall.RTM_SETGATE": "syscall",
- "syscall.RTM_SETLINK": "syscall",
- "syscall.RTM_SETNEIGHTBL": "syscall",
- "syscall.RTM_VERSION": "syscall",
- "syscall.RTNH_ALIGNTO": "syscall",
- "syscall.RTNH_F_DEAD": "syscall",
- "syscall.RTNH_F_ONLINK": "syscall",
- "syscall.RTNH_F_PERVASIVE": "syscall",
- "syscall.RTNLGRP_IPV4_IFADDR": "syscall",
- "syscall.RTNLGRP_IPV4_MROUTE": "syscall",
- "syscall.RTNLGRP_IPV4_ROUTE": "syscall",
- "syscall.RTNLGRP_IPV4_RULE": "syscall",
- "syscall.RTNLGRP_IPV6_IFADDR": "syscall",
- "syscall.RTNLGRP_IPV6_IFINFO": "syscall",
- "syscall.RTNLGRP_IPV6_MROUTE": "syscall",
- "syscall.RTNLGRP_IPV6_PREFIX": "syscall",
- "syscall.RTNLGRP_IPV6_ROUTE": "syscall",
- "syscall.RTNLGRP_IPV6_RULE": "syscall",
- "syscall.RTNLGRP_LINK": "syscall",
- "syscall.RTNLGRP_ND_USEROPT": "syscall",
- "syscall.RTNLGRP_NEIGH": "syscall",
- "syscall.RTNLGRP_NONE": "syscall",
- "syscall.RTNLGRP_NOTIFY": "syscall",
- "syscall.RTNLGRP_TC": "syscall",
- "syscall.RTN_ANYCAST": "syscall",
- "syscall.RTN_BLACKHOLE": "syscall",
- "syscall.RTN_BROADCAST": "syscall",
- "syscall.RTN_LOCAL": "syscall",
- "syscall.RTN_MAX": "syscall",
- "syscall.RTN_MULTICAST": "syscall",
- "syscall.RTN_NAT": "syscall",
- "syscall.RTN_PROHIBIT": "syscall",
- "syscall.RTN_THROW": "syscall",
- "syscall.RTN_UNICAST": "syscall",
- "syscall.RTN_UNREACHABLE": "syscall",
- "syscall.RTN_UNSPEC": "syscall",
- "syscall.RTN_XRESOLVE": "syscall",
- "syscall.RTPROT_BIRD": "syscall",
- "syscall.RTPROT_BOOT": "syscall",
- "syscall.RTPROT_DHCP": "syscall",
- "syscall.RTPROT_DNROUTED": "syscall",
- "syscall.RTPROT_GATED": "syscall",
- "syscall.RTPROT_KERNEL": "syscall",
- "syscall.RTPROT_MRT": "syscall",
- "syscall.RTPROT_NTK": "syscall",
- "syscall.RTPROT_RA": "syscall",
- "syscall.RTPROT_REDIRECT": "syscall",
- "syscall.RTPROT_STATIC": "syscall",
- "syscall.RTPROT_UNSPEC": "syscall",
- "syscall.RTPROT_XORP": "syscall",
- "syscall.RTPROT_ZEBRA": "syscall",
- "syscall.RTV_EXPIRE": "syscall",
- "syscall.RTV_HOPCOUNT": "syscall",
- "syscall.RTV_MTU": "syscall",
- "syscall.RTV_RPIPE": "syscall",
- "syscall.RTV_RTT": "syscall",
- "syscall.RTV_RTTVAR": "syscall",
- "syscall.RTV_SPIPE": "syscall",
- "syscall.RTV_SSTHRESH": "syscall",
- "syscall.RTV_WEIGHT": "syscall",
- "syscall.RT_CACHING_CONTEXT": "syscall",
- "syscall.RT_CLASS_DEFAULT": "syscall",
- "syscall.RT_CLASS_LOCAL": "syscall",
- "syscall.RT_CLASS_MAIN": "syscall",
- "syscall.RT_CLASS_MAX": "syscall",
- "syscall.RT_CLASS_UNSPEC": "syscall",
- "syscall.RT_DEFAULT_FIB": "syscall",
- "syscall.RT_NORTREF": "syscall",
- "syscall.RT_SCOPE_HOST": "syscall",
- "syscall.RT_SCOPE_LINK": "syscall",
- "syscall.RT_SCOPE_NOWHERE": "syscall",
- "syscall.RT_SCOPE_SITE": "syscall",
- "syscall.RT_SCOPE_UNIVERSE": "syscall",
- "syscall.RT_TABLEID_MAX": "syscall",
- "syscall.RT_TABLE_COMPAT": "syscall",
- "syscall.RT_TABLE_DEFAULT": "syscall",
- "syscall.RT_TABLE_LOCAL": "syscall",
- "syscall.RT_TABLE_MAIN": "syscall",
- "syscall.RT_TABLE_MAX": "syscall",
- "syscall.RT_TABLE_UNSPEC": "syscall",
- "syscall.RUSAGE_CHILDREN": "syscall",
- "syscall.RUSAGE_SELF": "syscall",
- "syscall.RUSAGE_THREAD": "syscall",
- "syscall.Radvisory_t": "syscall",
- "syscall.RawSockaddr": "syscall",
- "syscall.RawSockaddrAny": "syscall",
- "syscall.RawSockaddrDatalink": "syscall",
- "syscall.RawSockaddrInet4": "syscall",
- "syscall.RawSockaddrInet6": "syscall",
- "syscall.RawSockaddrLinklayer": "syscall",
- "syscall.RawSockaddrNetlink": "syscall",
- "syscall.RawSockaddrUnix": "syscall",
- "syscall.RawSyscall": "syscall",
- "syscall.RawSyscall6": "syscall",
- "syscall.Read": "syscall",
- "syscall.ReadConsole": "syscall",
- "syscall.ReadDirectoryChanges": "syscall",
- "syscall.ReadDirent": "syscall",
- "syscall.ReadFile": "syscall",
- "syscall.Readlink": "syscall",
- "syscall.Reboot": "syscall",
- "syscall.Recvfrom": "syscall",
- "syscall.Recvmsg": "syscall",
- "syscall.RegCloseKey": "syscall",
- "syscall.RegEnumKeyEx": "syscall",
- "syscall.RegOpenKeyEx": "syscall",
- "syscall.RegQueryInfoKey": "syscall",
- "syscall.RegQueryValueEx": "syscall",
- "syscall.RemoveDirectory": "syscall",
- "syscall.Removexattr": "syscall",
- "syscall.Rename": "syscall",
- "syscall.Renameat": "syscall",
- "syscall.Revoke": "syscall",
- "syscall.Rlimit": "syscall",
- "syscall.Rmdir": "syscall",
- "syscall.RouteMessage": "syscall",
- "syscall.RouteRIB": "syscall",
- "syscall.RtAttr": "syscall",
- "syscall.RtGenmsg": "syscall",
- "syscall.RtMetrics": "syscall",
- "syscall.RtMsg": "syscall",
- "syscall.RtMsghdr": "syscall",
- "syscall.RtNexthop": "syscall",
- "syscall.Rusage": "syscall",
- "syscall.SCM_BINTIME": "syscall",
- "syscall.SCM_CREDENTIALS": "syscall",
- "syscall.SCM_CREDS": "syscall",
- "syscall.SCM_RIGHTS": "syscall",
- "syscall.SCM_TIMESTAMP": "syscall",
- "syscall.SCM_TIMESTAMPING": "syscall",
- "syscall.SCM_TIMESTAMPNS": "syscall",
- "syscall.SCM_TIMESTAMP_MONOTONIC": "syscall",
- "syscall.SHUT_RD": "syscall",
- "syscall.SHUT_RDWR": "syscall",
- "syscall.SHUT_WR": "syscall",
- "syscall.SID": "syscall",
- "syscall.SIDAndAttributes": "syscall",
- "syscall.SIGABRT": "syscall",
- "syscall.SIGALRM": "syscall",
- "syscall.SIGBUS": "syscall",
- "syscall.SIGCHLD": "syscall",
- "syscall.SIGCLD": "syscall",
- "syscall.SIGCONT": "syscall",
- "syscall.SIGEMT": "syscall",
- "syscall.SIGFPE": "syscall",
- "syscall.SIGHUP": "syscall",
- "syscall.SIGILL": "syscall",
- "syscall.SIGINFO": "syscall",
- "syscall.SIGINT": "syscall",
- "syscall.SIGIO": "syscall",
- "syscall.SIGIOT": "syscall",
- "syscall.SIGKILL": "syscall",
- "syscall.SIGLIBRT": "syscall",
- "syscall.SIGLWP": "syscall",
- "syscall.SIGPIPE": "syscall",
- "syscall.SIGPOLL": "syscall",
- "syscall.SIGPROF": "syscall",
- "syscall.SIGPWR": "syscall",
- "syscall.SIGQUIT": "syscall",
- "syscall.SIGSEGV": "syscall",
- "syscall.SIGSTKFLT": "syscall",
- "syscall.SIGSTOP": "syscall",
- "syscall.SIGSYS": "syscall",
- "syscall.SIGTERM": "syscall",
- "syscall.SIGTHR": "syscall",
- "syscall.SIGTRAP": "syscall",
- "syscall.SIGTSTP": "syscall",
- "syscall.SIGTTIN": "syscall",
- "syscall.SIGTTOU": "syscall",
- "syscall.SIGUNUSED": "syscall",
- "syscall.SIGURG": "syscall",
- "syscall.SIGUSR1": "syscall",
- "syscall.SIGUSR2": "syscall",
- "syscall.SIGVTALRM": "syscall",
- "syscall.SIGWINCH": "syscall",
- "syscall.SIGXCPU": "syscall",
- "syscall.SIGXFSZ": "syscall",
- "syscall.SIOCADDDLCI": "syscall",
- "syscall.SIOCADDMULTI": "syscall",
- "syscall.SIOCADDRT": "syscall",
- "syscall.SIOCAIFADDR": "syscall",
- "syscall.SIOCAIFGROUP": "syscall",
- "syscall.SIOCALIFADDR": "syscall",
- "syscall.SIOCARPIPLL": "syscall",
- "syscall.SIOCATMARK": "syscall",
- "syscall.SIOCAUTOADDR": "syscall",
- "syscall.SIOCAUTONETMASK": "syscall",
- "syscall.SIOCBRDGADD": "syscall",
- "syscall.SIOCBRDGADDS": "syscall",
- "syscall.SIOCBRDGARL": "syscall",
- "syscall.SIOCBRDGDADDR": "syscall",
- "syscall.SIOCBRDGDEL": "syscall",
- "syscall.SIOCBRDGDELS": "syscall",
- "syscall.SIOCBRDGFLUSH": "syscall",
- "syscall.SIOCBRDGFRL": "syscall",
- "syscall.SIOCBRDGGCACHE": "syscall",
- "syscall.SIOCBRDGGFD": "syscall",
- "syscall.SIOCBRDGGHT": "syscall",
- "syscall.SIOCBRDGGIFFLGS": "syscall",
- "syscall.SIOCBRDGGMA": "syscall",
- "syscall.SIOCBRDGGPARAM": "syscall",
- "syscall.SIOCBRDGGPRI": "syscall",
- "syscall.SIOCBRDGGRL": "syscall",
- "syscall.SIOCBRDGGSIFS": "syscall",
- "syscall.SIOCBRDGGTO": "syscall",
- "syscall.SIOCBRDGIFS": "syscall",
- "syscall.SIOCBRDGRTS": "syscall",
- "syscall.SIOCBRDGSADDR": "syscall",
- "syscall.SIOCBRDGSCACHE": "syscall",
- "syscall.SIOCBRDGSFD": "syscall",
- "syscall.SIOCBRDGSHT": "syscall",
- "syscall.SIOCBRDGSIFCOST": "syscall",
- "syscall.SIOCBRDGSIFFLGS": "syscall",
- "syscall.SIOCBRDGSIFPRIO": "syscall",
- "syscall.SIOCBRDGSMA": "syscall",
- "syscall.SIOCBRDGSPRI": "syscall",
- "syscall.SIOCBRDGSPROTO": "syscall",
- "syscall.SIOCBRDGSTO": "syscall",
- "syscall.SIOCBRDGSTXHC": "syscall",
- "syscall.SIOCDARP": "syscall",
- "syscall.SIOCDELDLCI": "syscall",
- "syscall.SIOCDELMULTI": "syscall",
- "syscall.SIOCDELRT": "syscall",
- "syscall.SIOCDEVPRIVATE": "syscall",
- "syscall.SIOCDIFADDR": "syscall",
- "syscall.SIOCDIFGROUP": "syscall",
- "syscall.SIOCDIFPHYADDR": "syscall",
- "syscall.SIOCDLIFADDR": "syscall",
- "syscall.SIOCDRARP": "syscall",
- "syscall.SIOCGARP": "syscall",
- "syscall.SIOCGDRVSPEC": "syscall",
- "syscall.SIOCGETKALIVE": "syscall",
- "syscall.SIOCGETLABEL": "syscall",
- "syscall.SIOCGETPFLOW": "syscall",
- "syscall.SIOCGETPFSYNC": "syscall",
- "syscall.SIOCGETSGCNT": "syscall",
- "syscall.SIOCGETVIFCNT": "syscall",
- "syscall.SIOCGETVLAN": "syscall",
- "syscall.SIOCGHIWAT": "syscall",
- "syscall.SIOCGIFADDR": "syscall",
- "syscall.SIOCGIFADDRPREF": "syscall",
- "syscall.SIOCGIFALIAS": "syscall",
- "syscall.SIOCGIFALTMTU": "syscall",
- "syscall.SIOCGIFASYNCMAP": "syscall",
- "syscall.SIOCGIFBOND": "syscall",
- "syscall.SIOCGIFBR": "syscall",
- "syscall.SIOCGIFBRDADDR": "syscall",
- "syscall.SIOCGIFCAP": "syscall",
- "syscall.SIOCGIFCONF": "syscall",
- "syscall.SIOCGIFCOUNT": "syscall",
- "syscall.SIOCGIFDATA": "syscall",
- "syscall.SIOCGIFDESCR": "syscall",
- "syscall.SIOCGIFDEVMTU": "syscall",
- "syscall.SIOCGIFDLT": "syscall",
- "syscall.SIOCGIFDSTADDR": "syscall",
- "syscall.SIOCGIFENCAP": "syscall",
- "syscall.SIOCGIFFIB": "syscall",
- "syscall.SIOCGIFFLAGS": "syscall",
- "syscall.SIOCGIFGATTR": "syscall",
- "syscall.SIOCGIFGENERIC": "syscall",
- "syscall.SIOCGIFGMEMB": "syscall",
- "syscall.SIOCGIFGROUP": "syscall",
- "syscall.SIOCGIFHWADDR": "syscall",
- "syscall.SIOCGIFINDEX": "syscall",
- "syscall.SIOCGIFKPI": "syscall",
- "syscall.SIOCGIFMAC": "syscall",
- "syscall.SIOCGIFMAP": "syscall",
- "syscall.SIOCGIFMEDIA": "syscall",
- "syscall.SIOCGIFMEM": "syscall",
- "syscall.SIOCGIFMETRIC": "syscall",
- "syscall.SIOCGIFMTU": "syscall",
- "syscall.SIOCGIFNAME": "syscall",
- "syscall.SIOCGIFNETMASK": "syscall",
- "syscall.SIOCGIFPDSTADDR": "syscall",
- "syscall.SIOCGIFPFLAGS": "syscall",
- "syscall.SIOCGIFPHYS": "syscall",
- "syscall.SIOCGIFPRIORITY": "syscall",
- "syscall.SIOCGIFPSRCADDR": "syscall",
- "syscall.SIOCGIFRDOMAIN": "syscall",
- "syscall.SIOCGIFRTLABEL": "syscall",
- "syscall.SIOCGIFSLAVE": "syscall",
- "syscall.SIOCGIFSTATUS": "syscall",
- "syscall.SIOCGIFTIMESLOT": "syscall",
- "syscall.SIOCGIFTXQLEN": "syscall",
- "syscall.SIOCGIFVLAN": "syscall",
- "syscall.SIOCGIFWAKEFLAGS": "syscall",
- "syscall.SIOCGIFXFLAGS": "syscall",
- "syscall.SIOCGLIFADDR": "syscall",
- "syscall.SIOCGLIFPHYADDR": "syscall",
- "syscall.SIOCGLIFPHYRTABLE": "syscall",
- "syscall.SIOCGLINKSTR": "syscall",
- "syscall.SIOCGLOWAT": "syscall",
- "syscall.SIOCGPGRP": "syscall",
- "syscall.SIOCGPRIVATE_0": "syscall",
- "syscall.SIOCGPRIVATE_1": "syscall",
- "syscall.SIOCGRARP": "syscall",
- "syscall.SIOCGSTAMP": "syscall",
- "syscall.SIOCGSTAMPNS": "syscall",
- "syscall.SIOCGVH": "syscall",
- "syscall.SIOCIFCREATE": "syscall",
- "syscall.SIOCIFCREATE2": "syscall",
- "syscall.SIOCIFDESTROY": "syscall",
- "syscall.SIOCIFGCLONERS": "syscall",
- "syscall.SIOCINITIFADDR": "syscall",
- "syscall.SIOCPROTOPRIVATE": "syscall",
- "syscall.SIOCRSLVMULTI": "syscall",
- "syscall.SIOCRTMSG": "syscall",
- "syscall.SIOCSARP": "syscall",
- "syscall.SIOCSDRVSPEC": "syscall",
- "syscall.SIOCSETKALIVE": "syscall",
- "syscall.SIOCSETLABEL": "syscall",
- "syscall.SIOCSETPFLOW": "syscall",
- "syscall.SIOCSETPFSYNC": "syscall",
- "syscall.SIOCSETVLAN": "syscall",
- "syscall.SIOCSHIWAT": "syscall",
- "syscall.SIOCSIFADDR": "syscall",
- "syscall.SIOCSIFADDRPREF": "syscall",
- "syscall.SIOCSIFALTMTU": "syscall",
- "syscall.SIOCSIFASYNCMAP": "syscall",
- "syscall.SIOCSIFBOND": "syscall",
- "syscall.SIOCSIFBR": "syscall",
- "syscall.SIOCSIFBRDADDR": "syscall",
- "syscall.SIOCSIFCAP": "syscall",
- "syscall.SIOCSIFDESCR": "syscall",
- "syscall.SIOCSIFDSTADDR": "syscall",
- "syscall.SIOCSIFENCAP": "syscall",
- "syscall.SIOCSIFFIB": "syscall",
- "syscall.SIOCSIFFLAGS": "syscall",
- "syscall.SIOCSIFGATTR": "syscall",
- "syscall.SIOCSIFGENERIC": "syscall",
- "syscall.SIOCSIFHWADDR": "syscall",
- "syscall.SIOCSIFHWBROADCAST": "syscall",
- "syscall.SIOCSIFKPI": "syscall",
- "syscall.SIOCSIFLINK": "syscall",
- "syscall.SIOCSIFLLADDR": "syscall",
- "syscall.SIOCSIFMAC": "syscall",
- "syscall.SIOCSIFMAP": "syscall",
- "syscall.SIOCSIFMEDIA": "syscall",
- "syscall.SIOCSIFMEM": "syscall",
- "syscall.SIOCSIFMETRIC": "syscall",
- "syscall.SIOCSIFMTU": "syscall",
- "syscall.SIOCSIFNAME": "syscall",
- "syscall.SIOCSIFNETMASK": "syscall",
- "syscall.SIOCSIFPFLAGS": "syscall",
- "syscall.SIOCSIFPHYADDR": "syscall",
- "syscall.SIOCSIFPHYS": "syscall",
- "syscall.SIOCSIFPRIORITY": "syscall",
- "syscall.SIOCSIFRDOMAIN": "syscall",
- "syscall.SIOCSIFRTLABEL": "syscall",
- "syscall.SIOCSIFRVNET": "syscall",
- "syscall.SIOCSIFSLAVE": "syscall",
- "syscall.SIOCSIFTIMESLOT": "syscall",
- "syscall.SIOCSIFTXQLEN": "syscall",
- "syscall.SIOCSIFVLAN": "syscall",
- "syscall.SIOCSIFVNET": "syscall",
- "syscall.SIOCSIFXFLAGS": "syscall",
- "syscall.SIOCSLIFPHYADDR": "syscall",
- "syscall.SIOCSLIFPHYRTABLE": "syscall",
- "syscall.SIOCSLINKSTR": "syscall",
- "syscall.SIOCSLOWAT": "syscall",
- "syscall.SIOCSPGRP": "syscall",
- "syscall.SIOCSRARP": "syscall",
- "syscall.SIOCSVH": "syscall",
- "syscall.SIOCZIFDATA": "syscall",
- "syscall.SIO_GET_EXTENSION_FUNCTION_POINTER": "syscall",
- "syscall.SIO_GET_INTERFACE_LIST": "syscall",
- "syscall.SOCK_CLOEXEC": "syscall",
- "syscall.SOCK_DCCP": "syscall",
- "syscall.SOCK_DGRAM": "syscall",
- "syscall.SOCK_FLAGS_MASK": "syscall",
- "syscall.SOCK_MAXADDRLEN": "syscall",
- "syscall.SOCK_NONBLOCK": "syscall",
- "syscall.SOCK_NOSIGPIPE": "syscall",
- "syscall.SOCK_PACKET": "syscall",
- "syscall.SOCK_RAW": "syscall",
- "syscall.SOCK_RDM": "syscall",
- "syscall.SOCK_SEQPACKET": "syscall",
- "syscall.SOCK_STREAM": "syscall",
- "syscall.SOL_AAL": "syscall",
- "syscall.SOL_ATM": "syscall",
- "syscall.SOL_DECNET": "syscall",
- "syscall.SOL_ICMPV6": "syscall",
- "syscall.SOL_IP": "syscall",
- "syscall.SOL_IPV6": "syscall",
- "syscall.SOL_IRDA": "syscall",
- "syscall.SOL_PACKET": "syscall",
- "syscall.SOL_RAW": "syscall",
- "syscall.SOL_SOCKET": "syscall",
- "syscall.SOL_TCP": "syscall",
- "syscall.SOL_X25": "syscall",
- "syscall.SOMAXCONN": "syscall",
- "syscall.SO_ACCEPTCONN": "syscall",
- "syscall.SO_ACCEPTFILTER": "syscall",
- "syscall.SO_ATTACH_FILTER": "syscall",
- "syscall.SO_BINDANY": "syscall",
- "syscall.SO_BINDTODEVICE": "syscall",
- "syscall.SO_BINTIME": "syscall",
- "syscall.SO_BROADCAST": "syscall",
- "syscall.SO_BSDCOMPAT": "syscall",
- "syscall.SO_DEBUG": "syscall",
- "syscall.SO_DETACH_FILTER": "syscall",
- "syscall.SO_DOMAIN": "syscall",
- "syscall.SO_DONTROUTE": "syscall",
- "syscall.SO_DONTTRUNC": "syscall",
- "syscall.SO_ERROR": "syscall",
- "syscall.SO_KEEPALIVE": "syscall",
- "syscall.SO_LABEL": "syscall",
- "syscall.SO_LINGER": "syscall",
- "syscall.SO_LINGER_SEC": "syscall",
- "syscall.SO_LISTENINCQLEN": "syscall",
- "syscall.SO_LISTENQLEN": "syscall",
- "syscall.SO_LISTENQLIMIT": "syscall",
- "syscall.SO_MARK": "syscall",
- "syscall.SO_NETPROC": "syscall",
- "syscall.SO_NKE": "syscall",
- "syscall.SO_NOADDRERR": "syscall",
- "syscall.SO_NOHEADER": "syscall",
- "syscall.SO_NOSIGPIPE": "syscall",
- "syscall.SO_NOTIFYCONFLICT": "syscall",
- "syscall.SO_NO_CHECK": "syscall",
- "syscall.SO_NO_DDP": "syscall",
- "syscall.SO_NO_OFFLOAD": "syscall",
- "syscall.SO_NP_EXTENSIONS": "syscall",
- "syscall.SO_NREAD": "syscall",
- "syscall.SO_NWRITE": "syscall",
- "syscall.SO_OOBINLINE": "syscall",
- "syscall.SO_OVERFLOWED": "syscall",
- "syscall.SO_PASSCRED": "syscall",
- "syscall.SO_PASSSEC": "syscall",
- "syscall.SO_PEERCRED": "syscall",
- "syscall.SO_PEERLABEL": "syscall",
- "syscall.SO_PEERNAME": "syscall",
- "syscall.SO_PEERSEC": "syscall",
- "syscall.SO_PRIORITY": "syscall",
- "syscall.SO_PROTOCOL": "syscall",
- "syscall.SO_PROTOTYPE": "syscall",
- "syscall.SO_RANDOMPORT": "syscall",
- "syscall.SO_RCVBUF": "syscall",
- "syscall.SO_RCVBUFFORCE": "syscall",
- "syscall.SO_RCVLOWAT": "syscall",
- "syscall.SO_RCVTIMEO": "syscall",
- "syscall.SO_RESTRICTIONS": "syscall",
- "syscall.SO_RESTRICT_DENYIN": "syscall",
- "syscall.SO_RESTRICT_DENYOUT": "syscall",
- "syscall.SO_RESTRICT_DENYSET": "syscall",
- "syscall.SO_REUSEADDR": "syscall",
- "syscall.SO_REUSEPORT": "syscall",
- "syscall.SO_REUSESHAREUID": "syscall",
- "syscall.SO_RTABLE": "syscall",
- "syscall.SO_RXQ_OVFL": "syscall",
- "syscall.SO_SECURITY_AUTHENTICATION": "syscall",
- "syscall.SO_SECURITY_ENCRYPTION_NETWORK": "syscall",
- "syscall.SO_SECURITY_ENCRYPTION_TRANSPORT": "syscall",
- "syscall.SO_SETFIB": "syscall",
- "syscall.SO_SNDBUF": "syscall",
- "syscall.SO_SNDBUFFORCE": "syscall",
- "syscall.SO_SNDLOWAT": "syscall",
- "syscall.SO_SNDTIMEO": "syscall",
- "syscall.SO_SPLICE": "syscall",
- "syscall.SO_TIMESTAMP": "syscall",
- "syscall.SO_TIMESTAMPING": "syscall",
- "syscall.SO_TIMESTAMPNS": "syscall",
- "syscall.SO_TIMESTAMP_MONOTONIC": "syscall",
- "syscall.SO_TYPE": "syscall",
- "syscall.SO_UPCALLCLOSEWAIT": "syscall",
- "syscall.SO_UPDATE_ACCEPT_CONTEXT": "syscall",
- "syscall.SO_UPDATE_CONNECT_CONTEXT": "syscall",
- "syscall.SO_USELOOPBACK": "syscall",
- "syscall.SO_USER_COOKIE": "syscall",
- "syscall.SO_WANTMORE": "syscall",
- "syscall.SO_WANTOOBFLAG": "syscall",
- "syscall.SSLExtraCertChainPolicyPara": "syscall",
- "syscall.STANDARD_RIGHTS_ALL": "syscall",
- "syscall.STANDARD_RIGHTS_EXECUTE": "syscall",
- "syscall.STANDARD_RIGHTS_READ": "syscall",
- "syscall.STANDARD_RIGHTS_REQUIRED": "syscall",
- "syscall.STANDARD_RIGHTS_WRITE": "syscall",
- "syscall.STARTF_USESHOWWINDOW": "syscall",
- "syscall.STARTF_USESTDHANDLES": "syscall",
- "syscall.STD_ERROR_HANDLE": "syscall",
- "syscall.STD_INPUT_HANDLE": "syscall",
- "syscall.STD_OUTPUT_HANDLE": "syscall",
- "syscall.SUBLANG_ENGLISH_US": "syscall",
- "syscall.SW_FORCEMINIMIZE": "syscall",
- "syscall.SW_HIDE": "syscall",
- "syscall.SW_MAXIMIZE": "syscall",
- "syscall.SW_MINIMIZE": "syscall",
- "syscall.SW_NORMAL": "syscall",
- "syscall.SW_RESTORE": "syscall",
- "syscall.SW_SHOW": "syscall",
- "syscall.SW_SHOWDEFAULT": "syscall",
- "syscall.SW_SHOWMAXIMIZED": "syscall",
- "syscall.SW_SHOWMINIMIZED": "syscall",
- "syscall.SW_SHOWMINNOACTIVE": "syscall",
- "syscall.SW_SHOWNA": "syscall",
- "syscall.SW_SHOWNOACTIVATE": "syscall",
- "syscall.SW_SHOWNORMAL": "syscall",
- "syscall.SYNCHRONIZE": "syscall",
- "syscall.SYSCTL_VERSION": "syscall",
- "syscall.SYSCTL_VERS_0": "syscall",
- "syscall.SYSCTL_VERS_1": "syscall",
- "syscall.SYSCTL_VERS_MASK": "syscall",
- "syscall.SYS_ABORT2": "syscall",
- "syscall.SYS_ACCEPT": "syscall",
- "syscall.SYS_ACCEPT4": "syscall",
- "syscall.SYS_ACCEPT_NOCANCEL": "syscall",
- "syscall.SYS_ACCESS": "syscall",
- "syscall.SYS_ACCESS_EXTENDED": "syscall",
- "syscall.SYS_ACCT": "syscall",
- "syscall.SYS_ADD_KEY": "syscall",
- "syscall.SYS_ADD_PROFIL": "syscall",
- "syscall.SYS_ADJFREQ": "syscall",
- "syscall.SYS_ADJTIME": "syscall",
- "syscall.SYS_ADJTIMEX": "syscall",
- "syscall.SYS_AFS_SYSCALL": "syscall",
- "syscall.SYS_AIO_CANCEL": "syscall",
- "syscall.SYS_AIO_ERROR": "syscall",
- "syscall.SYS_AIO_FSYNC": "syscall",
- "syscall.SYS_AIO_READ": "syscall",
- "syscall.SYS_AIO_RETURN": "syscall",
- "syscall.SYS_AIO_SUSPEND": "syscall",
- "syscall.SYS_AIO_SUSPEND_NOCANCEL": "syscall",
- "syscall.SYS_AIO_WRITE": "syscall",
- "syscall.SYS_ALARM": "syscall",
- "syscall.SYS_ARCH_PRCTL": "syscall",
- "syscall.SYS_ARM_FADVISE64_64": "syscall",
- "syscall.SYS_ARM_SYNC_FILE_RANGE": "syscall",
- "syscall.SYS_ATGETMSG": "syscall",
- "syscall.SYS_ATPGETREQ": "syscall",
- "syscall.SYS_ATPGETRSP": "syscall",
- "syscall.SYS_ATPSNDREQ": "syscall",
- "syscall.SYS_ATPSNDRSP": "syscall",
- "syscall.SYS_ATPUTMSG": "syscall",
- "syscall.SYS_ATSOCKET": "syscall",
- "syscall.SYS_AUDIT": "syscall",
- "syscall.SYS_AUDITCTL": "syscall",
- "syscall.SYS_AUDITON": "syscall",
- "syscall.SYS_AUDIT_SESSION_JOIN": "syscall",
- "syscall.SYS_AUDIT_SESSION_PORT": "syscall",
- "syscall.SYS_AUDIT_SESSION_SELF": "syscall",
- "syscall.SYS_BDFLUSH": "syscall",
- "syscall.SYS_BIND": "syscall",
- "syscall.SYS_BREAK": "syscall",
- "syscall.SYS_BRK": "syscall",
- "syscall.SYS_BSDTHREAD_CREATE": "syscall",
- "syscall.SYS_BSDTHREAD_REGISTER": "syscall",
- "syscall.SYS_BSDTHREAD_TERMINATE": "syscall",
- "syscall.SYS_CAPGET": "syscall",
- "syscall.SYS_CAPSET": "syscall",
- "syscall.SYS_CAP_ENTER": "syscall",
- "syscall.SYS_CAP_FCNTLS_GET": "syscall",
- "syscall.SYS_CAP_FCNTLS_LIMIT": "syscall",
- "syscall.SYS_CAP_GETMODE": "syscall",
- "syscall.SYS_CAP_GETRIGHTS": "syscall",
- "syscall.SYS_CAP_IOCTLS_GET": "syscall",
- "syscall.SYS_CAP_IOCTLS_LIMIT": "syscall",
- "syscall.SYS_CAP_NEW": "syscall",
- "syscall.SYS_CAP_RIGHTS_GET": "syscall",
- "syscall.SYS_CAP_RIGHTS_LIMIT": "syscall",
- "syscall.SYS_CHDIR": "syscall",
- "syscall.SYS_CHFLAGS": "syscall",
- "syscall.SYS_CHMOD": "syscall",
- "syscall.SYS_CHMOD_EXTENDED": "syscall",
- "syscall.SYS_CHOWN": "syscall",
- "syscall.SYS_CHOWN32": "syscall",
- "syscall.SYS_CHROOT": "syscall",
- "syscall.SYS_CHUD": "syscall",
- "syscall.SYS_CLOCK_ADJTIME": "syscall",
- "syscall.SYS_CLOCK_GETCPUCLOCKID2": "syscall",
- "syscall.SYS_CLOCK_GETRES": "syscall",
- "syscall.SYS_CLOCK_GETTIME": "syscall",
- "syscall.SYS_CLOCK_NANOSLEEP": "syscall",
- "syscall.SYS_CLOCK_SETTIME": "syscall",
- "syscall.SYS_CLONE": "syscall",
- "syscall.SYS_CLOSE": "syscall",
- "syscall.SYS_CLOSEFROM": "syscall",
- "syscall.SYS_CLOSE_NOCANCEL": "syscall",
- "syscall.SYS_CONNECT": "syscall",
- "syscall.SYS_CONNECT_NOCANCEL": "syscall",
- "syscall.SYS_COPYFILE": "syscall",
- "syscall.SYS_CPUSET": "syscall",
- "syscall.SYS_CPUSET_GETAFFINITY": "syscall",
- "syscall.SYS_CPUSET_GETID": "syscall",
- "syscall.SYS_CPUSET_SETAFFINITY": "syscall",
- "syscall.SYS_CPUSET_SETID": "syscall",
- "syscall.SYS_CREAT": "syscall",
- "syscall.SYS_CREATE_MODULE": "syscall",
- "syscall.SYS_CSOPS": "syscall",
- "syscall.SYS_DELETE": "syscall",
- "syscall.SYS_DELETE_MODULE": "syscall",
- "syscall.SYS_DUP": "syscall",
- "syscall.SYS_DUP2": "syscall",
- "syscall.SYS_DUP3": "syscall",
- "syscall.SYS_EACCESS": "syscall",
- "syscall.SYS_EPOLL_CREATE": "syscall",
- "syscall.SYS_EPOLL_CREATE1": "syscall",
- "syscall.SYS_EPOLL_CTL": "syscall",
- "syscall.SYS_EPOLL_CTL_OLD": "syscall",
- "syscall.SYS_EPOLL_PWAIT": "syscall",
- "syscall.SYS_EPOLL_WAIT": "syscall",
- "syscall.SYS_EPOLL_WAIT_OLD": "syscall",
- "syscall.SYS_EVENTFD": "syscall",
- "syscall.SYS_EVENTFD2": "syscall",
- "syscall.SYS_EXCHANGEDATA": "syscall",
- "syscall.SYS_EXECVE": "syscall",
- "syscall.SYS_EXIT": "syscall",
- "syscall.SYS_EXIT_GROUP": "syscall",
- "syscall.SYS_EXTATTRCTL": "syscall",
- "syscall.SYS_EXTATTR_DELETE_FD": "syscall",
- "syscall.SYS_EXTATTR_DELETE_FILE": "syscall",
- "syscall.SYS_EXTATTR_DELETE_LINK": "syscall",
- "syscall.SYS_EXTATTR_GET_FD": "syscall",
- "syscall.SYS_EXTATTR_GET_FILE": "syscall",
- "syscall.SYS_EXTATTR_GET_LINK": "syscall",
- "syscall.SYS_EXTATTR_LIST_FD": "syscall",
- "syscall.SYS_EXTATTR_LIST_FILE": "syscall",
- "syscall.SYS_EXTATTR_LIST_LINK": "syscall",
- "syscall.SYS_EXTATTR_SET_FD": "syscall",
- "syscall.SYS_EXTATTR_SET_FILE": "syscall",
- "syscall.SYS_EXTATTR_SET_LINK": "syscall",
- "syscall.SYS_FACCESSAT": "syscall",
- "syscall.SYS_FADVISE64": "syscall",
- "syscall.SYS_FADVISE64_64": "syscall",
- "syscall.SYS_FALLOCATE": "syscall",
- "syscall.SYS_FANOTIFY_INIT": "syscall",
- "syscall.SYS_FANOTIFY_MARK": "syscall",
- "syscall.SYS_FCHDIR": "syscall",
- "syscall.SYS_FCHFLAGS": "syscall",
- "syscall.SYS_FCHMOD": "syscall",
- "syscall.SYS_FCHMODAT": "syscall",
- "syscall.SYS_FCHMOD_EXTENDED": "syscall",
- "syscall.SYS_FCHOWN": "syscall",
- "syscall.SYS_FCHOWN32": "syscall",
- "syscall.SYS_FCHOWNAT": "syscall",
- "syscall.SYS_FCHROOT": "syscall",
- "syscall.SYS_FCNTL": "syscall",
- "syscall.SYS_FCNTL64": "syscall",
- "syscall.SYS_FCNTL_NOCANCEL": "syscall",
- "syscall.SYS_FDATASYNC": "syscall",
- "syscall.SYS_FEXECVE": "syscall",
- "syscall.SYS_FFCLOCK_GETCOUNTER": "syscall",
- "syscall.SYS_FFCLOCK_GETESTIMATE": "syscall",
- "syscall.SYS_FFCLOCK_SETESTIMATE": "syscall",
- "syscall.SYS_FFSCTL": "syscall",
- "syscall.SYS_FGETATTRLIST": "syscall",
- "syscall.SYS_FGETXATTR": "syscall",
- "syscall.SYS_FHOPEN": "syscall",
- "syscall.SYS_FHSTAT": "syscall",
- "syscall.SYS_FHSTATFS": "syscall",
- "syscall.SYS_FILEPORT_MAKEFD": "syscall",
- "syscall.SYS_FILEPORT_MAKEPORT": "syscall",
- "syscall.SYS_FKTRACE": "syscall",
- "syscall.SYS_FLISTXATTR": "syscall",
- "syscall.SYS_FLOCK": "syscall",
- "syscall.SYS_FORK": "syscall",
- "syscall.SYS_FPATHCONF": "syscall",
- "syscall.SYS_FREEBSD6_FTRUNCATE": "syscall",
- "syscall.SYS_FREEBSD6_LSEEK": "syscall",
- "syscall.SYS_FREEBSD6_MMAP": "syscall",
- "syscall.SYS_FREEBSD6_PREAD": "syscall",
- "syscall.SYS_FREEBSD6_PWRITE": "syscall",
- "syscall.SYS_FREEBSD6_TRUNCATE": "syscall",
- "syscall.SYS_FREMOVEXATTR": "syscall",
- "syscall.SYS_FSCTL": "syscall",
- "syscall.SYS_FSETATTRLIST": "syscall",
- "syscall.SYS_FSETXATTR": "syscall",
- "syscall.SYS_FSGETPATH": "syscall",
- "syscall.SYS_FSTAT": "syscall",
- "syscall.SYS_FSTAT64": "syscall",
- "syscall.SYS_FSTAT64_EXTENDED": "syscall",
- "syscall.SYS_FSTATAT": "syscall",
- "syscall.SYS_FSTATAT64": "syscall",
- "syscall.SYS_FSTATFS": "syscall",
- "syscall.SYS_FSTATFS64": "syscall",
- "syscall.SYS_FSTATV": "syscall",
- "syscall.SYS_FSTATVFS1": "syscall",
- "syscall.SYS_FSTAT_EXTENDED": "syscall",
- "syscall.SYS_FSYNC": "syscall",
- "syscall.SYS_FSYNC_NOCANCEL": "syscall",
- "syscall.SYS_FSYNC_RANGE": "syscall",
- "syscall.SYS_FTIME": "syscall",
- "syscall.SYS_FTRUNCATE": "syscall",
- "syscall.SYS_FTRUNCATE64": "syscall",
- "syscall.SYS_FUTEX": "syscall",
- "syscall.SYS_FUTIMENS": "syscall",
- "syscall.SYS_FUTIMES": "syscall",
- "syscall.SYS_FUTIMESAT": "syscall",
- "syscall.SYS_GETATTRLIST": "syscall",
- "syscall.SYS_GETAUDIT": "syscall",
- "syscall.SYS_GETAUDIT_ADDR": "syscall",
- "syscall.SYS_GETAUID": "syscall",
- "syscall.SYS_GETCONTEXT": "syscall",
- "syscall.SYS_GETCPU": "syscall",
- "syscall.SYS_GETCWD": "syscall",
- "syscall.SYS_GETDENTS": "syscall",
- "syscall.SYS_GETDENTS64": "syscall",
- "syscall.SYS_GETDIRENTRIES": "syscall",
- "syscall.SYS_GETDIRENTRIES64": "syscall",
- "syscall.SYS_GETDIRENTRIESATTR": "syscall",
- "syscall.SYS_GETDTABLECOUNT": "syscall",
- "syscall.SYS_GETDTABLESIZE": "syscall",
- "syscall.SYS_GETEGID": "syscall",
- "syscall.SYS_GETEGID32": "syscall",
- "syscall.SYS_GETEUID": "syscall",
- "syscall.SYS_GETEUID32": "syscall",
- "syscall.SYS_GETFH": "syscall",
- "syscall.SYS_GETFSSTAT": "syscall",
- "syscall.SYS_GETFSSTAT64": "syscall",
- "syscall.SYS_GETGID": "syscall",
- "syscall.SYS_GETGID32": "syscall",
- "syscall.SYS_GETGROUPS": "syscall",
- "syscall.SYS_GETGROUPS32": "syscall",
- "syscall.SYS_GETHOSTUUID": "syscall",
- "syscall.SYS_GETITIMER": "syscall",
- "syscall.SYS_GETLCID": "syscall",
- "syscall.SYS_GETLOGIN": "syscall",
- "syscall.SYS_GETLOGINCLASS": "syscall",
- "syscall.SYS_GETPEERNAME": "syscall",
- "syscall.SYS_GETPGID": "syscall",
- "syscall.SYS_GETPGRP": "syscall",
- "syscall.SYS_GETPID": "syscall",
- "syscall.SYS_GETPMSG": "syscall",
- "syscall.SYS_GETPPID": "syscall",
- "syscall.SYS_GETPRIORITY": "syscall",
- "syscall.SYS_GETRESGID": "syscall",
- "syscall.SYS_GETRESGID32": "syscall",
- "syscall.SYS_GETRESUID": "syscall",
- "syscall.SYS_GETRESUID32": "syscall",
- "syscall.SYS_GETRLIMIT": "syscall",
- "syscall.SYS_GETRTABLE": "syscall",
- "syscall.SYS_GETRUSAGE": "syscall",
- "syscall.SYS_GETSGROUPS": "syscall",
- "syscall.SYS_GETSID": "syscall",
- "syscall.SYS_GETSOCKNAME": "syscall",
- "syscall.SYS_GETSOCKOPT": "syscall",
- "syscall.SYS_GETTHRID": "syscall",
- "syscall.SYS_GETTID": "syscall",
- "syscall.SYS_GETTIMEOFDAY": "syscall",
- "syscall.SYS_GETUID": "syscall",
- "syscall.SYS_GETUID32": "syscall",
- "syscall.SYS_GETVFSSTAT": "syscall",
- "syscall.SYS_GETWGROUPS": "syscall",
- "syscall.SYS_GETXATTR": "syscall",
- "syscall.SYS_GET_KERNEL_SYMS": "syscall",
- "syscall.SYS_GET_MEMPOLICY": "syscall",
- "syscall.SYS_GET_ROBUST_LIST": "syscall",
- "syscall.SYS_GET_THREAD_AREA": "syscall",
- "syscall.SYS_GTTY": "syscall",
- "syscall.SYS_IDENTITYSVC": "syscall",
- "syscall.SYS_IDLE": "syscall",
- "syscall.SYS_INITGROUPS": "syscall",
- "syscall.SYS_INIT_MODULE": "syscall",
- "syscall.SYS_INOTIFY_ADD_WATCH": "syscall",
- "syscall.SYS_INOTIFY_INIT": "syscall",
- "syscall.SYS_INOTIFY_INIT1": "syscall",
- "syscall.SYS_INOTIFY_RM_WATCH": "syscall",
- "syscall.SYS_IOCTL": "syscall",
- "syscall.SYS_IOPERM": "syscall",
- "syscall.SYS_IOPL": "syscall",
- "syscall.SYS_IOPOLICYSYS": "syscall",
- "syscall.SYS_IOPRIO_GET": "syscall",
- "syscall.SYS_IOPRIO_SET": "syscall",
- "syscall.SYS_IO_CANCEL": "syscall",
- "syscall.SYS_IO_DESTROY": "syscall",
- "syscall.SYS_IO_GETEVENTS": "syscall",
- "syscall.SYS_IO_SETUP": "syscall",
- "syscall.SYS_IO_SUBMIT": "syscall",
- "syscall.SYS_IPC": "syscall",
- "syscall.SYS_ISSETUGID": "syscall",
- "syscall.SYS_JAIL": "syscall",
- "syscall.SYS_JAIL_ATTACH": "syscall",
- "syscall.SYS_JAIL_GET": "syscall",
- "syscall.SYS_JAIL_REMOVE": "syscall",
- "syscall.SYS_JAIL_SET": "syscall",
- "syscall.SYS_KDEBUG_TRACE": "syscall",
- "syscall.SYS_KENV": "syscall",
- "syscall.SYS_KEVENT": "syscall",
- "syscall.SYS_KEVENT64": "syscall",
- "syscall.SYS_KEXEC_LOAD": "syscall",
- "syscall.SYS_KEYCTL": "syscall",
- "syscall.SYS_KILL": "syscall",
- "syscall.SYS_KLDFIND": "syscall",
- "syscall.SYS_KLDFIRSTMOD": "syscall",
- "syscall.SYS_KLDLOAD": "syscall",
- "syscall.SYS_KLDNEXT": "syscall",
- "syscall.SYS_KLDSTAT": "syscall",
- "syscall.SYS_KLDSYM": "syscall",
- "syscall.SYS_KLDUNLOAD": "syscall",
- "syscall.SYS_KLDUNLOADF": "syscall",
- "syscall.SYS_KQUEUE": "syscall",
- "syscall.SYS_KQUEUE1": "syscall",
- "syscall.SYS_KTIMER_CREATE": "syscall",
- "syscall.SYS_KTIMER_DELETE": "syscall",
- "syscall.SYS_KTIMER_GETOVERRUN": "syscall",
- "syscall.SYS_KTIMER_GETTIME": "syscall",
- "syscall.SYS_KTIMER_SETTIME": "syscall",
- "syscall.SYS_KTRACE": "syscall",
- "syscall.SYS_LCHFLAGS": "syscall",
- "syscall.SYS_LCHMOD": "syscall",
- "syscall.SYS_LCHOWN": "syscall",
- "syscall.SYS_LCHOWN32": "syscall",
- "syscall.SYS_LGETFH": "syscall",
- "syscall.SYS_LGETXATTR": "syscall",
- "syscall.SYS_LINK": "syscall",
- "syscall.SYS_LINKAT": "syscall",
- "syscall.SYS_LIO_LISTIO": "syscall",
- "syscall.SYS_LISTEN": "syscall",
- "syscall.SYS_LISTXATTR": "syscall",
- "syscall.SYS_LLISTXATTR": "syscall",
- "syscall.SYS_LOCK": "syscall",
- "syscall.SYS_LOOKUP_DCOOKIE": "syscall",
- "syscall.SYS_LPATHCONF": "syscall",
- "syscall.SYS_LREMOVEXATTR": "syscall",
- "syscall.SYS_LSEEK": "syscall",
- "syscall.SYS_LSETXATTR": "syscall",
- "syscall.SYS_LSTAT": "syscall",
- "syscall.SYS_LSTAT64": "syscall",
- "syscall.SYS_LSTAT64_EXTENDED": "syscall",
- "syscall.SYS_LSTATV": "syscall",
- "syscall.SYS_LSTAT_EXTENDED": "syscall",
- "syscall.SYS_LUTIMES": "syscall",
- "syscall.SYS_MAC_SYSCALL": "syscall",
- "syscall.SYS_MADVISE": "syscall",
- "syscall.SYS_MADVISE1": "syscall",
- "syscall.SYS_MAXSYSCALL": "syscall",
- "syscall.SYS_MBIND": "syscall",
- "syscall.SYS_MIGRATE_PAGES": "syscall",
- "syscall.SYS_MINCORE": "syscall",
- "syscall.SYS_MINHERIT": "syscall",
- "syscall.SYS_MKCOMPLEX": "syscall",
- "syscall.SYS_MKDIR": "syscall",
- "syscall.SYS_MKDIRAT": "syscall",
- "syscall.SYS_MKDIR_EXTENDED": "syscall",
- "syscall.SYS_MKFIFO": "syscall",
- "syscall.SYS_MKFIFOAT": "syscall",
- "syscall.SYS_MKFIFO_EXTENDED": "syscall",
- "syscall.SYS_MKNOD": "syscall",
- "syscall.SYS_MKNODAT": "syscall",
- "syscall.SYS_MLOCK": "syscall",
- "syscall.SYS_MLOCKALL": "syscall",
- "syscall.SYS_MMAP": "syscall",
- "syscall.SYS_MMAP2": "syscall",
- "syscall.SYS_MODCTL": "syscall",
- "syscall.SYS_MODFIND": "syscall",
- "syscall.SYS_MODFNEXT": "syscall",
- "syscall.SYS_MODIFY_LDT": "syscall",
- "syscall.SYS_MODNEXT": "syscall",
- "syscall.SYS_MODSTAT": "syscall",
- "syscall.SYS_MODWATCH": "syscall",
- "syscall.SYS_MOUNT": "syscall",
- "syscall.SYS_MOVE_PAGES": "syscall",
- "syscall.SYS_MPROTECT": "syscall",
- "syscall.SYS_MPX": "syscall",
- "syscall.SYS_MQUERY": "syscall",
- "syscall.SYS_MQ_GETSETATTR": "syscall",
- "syscall.SYS_MQ_NOTIFY": "syscall",
- "syscall.SYS_MQ_OPEN": "syscall",
- "syscall.SYS_MQ_TIMEDRECEIVE": "syscall",
- "syscall.SYS_MQ_TIMEDSEND": "syscall",
- "syscall.SYS_MQ_UNLINK": "syscall",
- "syscall.SYS_MREMAP": "syscall",
- "syscall.SYS_MSGCTL": "syscall",
- "syscall.SYS_MSGGET": "syscall",
- "syscall.SYS_MSGRCV": "syscall",
- "syscall.SYS_MSGRCV_NOCANCEL": "syscall",
- "syscall.SYS_MSGSND": "syscall",
- "syscall.SYS_MSGSND_NOCANCEL": "syscall",
- "syscall.SYS_MSGSYS": "syscall",
- "syscall.SYS_MSYNC": "syscall",
- "syscall.SYS_MSYNC_NOCANCEL": "syscall",
- "syscall.SYS_MUNLOCK": "syscall",
- "syscall.SYS_MUNLOCKALL": "syscall",
- "syscall.SYS_MUNMAP": "syscall",
- "syscall.SYS_NAME_TO_HANDLE_AT": "syscall",
- "syscall.SYS_NANOSLEEP": "syscall",
- "syscall.SYS_NEWFSTATAT": "syscall",
- "syscall.SYS_NFSCLNT": "syscall",
- "syscall.SYS_NFSSERVCTL": "syscall",
- "syscall.SYS_NFSSVC": "syscall",
- "syscall.SYS_NFSTAT": "syscall",
- "syscall.SYS_NICE": "syscall",
- "syscall.SYS_NLSTAT": "syscall",
- "syscall.SYS_NMOUNT": "syscall",
- "syscall.SYS_NSTAT": "syscall",
- "syscall.SYS_NTP_ADJTIME": "syscall",
- "syscall.SYS_NTP_GETTIME": "syscall",
- "syscall.SYS_OABI_SYSCALL_BASE": "syscall",
- "syscall.SYS_OBREAK": "syscall",
- "syscall.SYS_OLDFSTAT": "syscall",
- "syscall.SYS_OLDLSTAT": "syscall",
- "syscall.SYS_OLDOLDUNAME": "syscall",
- "syscall.SYS_OLDSTAT": "syscall",
- "syscall.SYS_OLDUNAME": "syscall",
- "syscall.SYS_OPEN": "syscall",
- "syscall.SYS_OPENAT": "syscall",
- "syscall.SYS_OPENBSD_POLL": "syscall",
- "syscall.SYS_OPEN_BY_HANDLE_AT": "syscall",
- "syscall.SYS_OPEN_EXTENDED": "syscall",
- "syscall.SYS_OPEN_NOCANCEL": "syscall",
- "syscall.SYS_OVADVISE": "syscall",
- "syscall.SYS_PACCEPT": "syscall",
- "syscall.SYS_PATHCONF": "syscall",
- "syscall.SYS_PAUSE": "syscall",
- "syscall.SYS_PCICONFIG_IOBASE": "syscall",
- "syscall.SYS_PCICONFIG_READ": "syscall",
- "syscall.SYS_PCICONFIG_WRITE": "syscall",
- "syscall.SYS_PDFORK": "syscall",
- "syscall.SYS_PDGETPID": "syscall",
- "syscall.SYS_PDKILL": "syscall",
- "syscall.SYS_PERF_EVENT_OPEN": "syscall",
- "syscall.SYS_PERSONALITY": "syscall",
- "syscall.SYS_PID_HIBERNATE": "syscall",
- "syscall.SYS_PID_RESUME": "syscall",
- "syscall.SYS_PID_SHUTDOWN_SOCKETS": "syscall",
- "syscall.SYS_PID_SUSPEND": "syscall",
- "syscall.SYS_PIPE": "syscall",
- "syscall.SYS_PIPE2": "syscall",
- "syscall.SYS_PIVOT_ROOT": "syscall",
- "syscall.SYS_PMC_CONTROL": "syscall",
- "syscall.SYS_PMC_GET_INFO": "syscall",
- "syscall.SYS_POLL": "syscall",
- "syscall.SYS_POLLTS": "syscall",
- "syscall.SYS_POLL_NOCANCEL": "syscall",
- "syscall.SYS_POSIX_FADVISE": "syscall",
- "syscall.SYS_POSIX_FALLOCATE": "syscall",
- "syscall.SYS_POSIX_OPENPT": "syscall",
- "syscall.SYS_POSIX_SPAWN": "syscall",
- "syscall.SYS_PPOLL": "syscall",
- "syscall.SYS_PRCTL": "syscall",
- "syscall.SYS_PREAD": "syscall",
- "syscall.SYS_PREAD64": "syscall",
- "syscall.SYS_PREADV": "syscall",
- "syscall.SYS_PREAD_NOCANCEL": "syscall",
- "syscall.SYS_PRLIMIT64": "syscall",
- "syscall.SYS_PROCESS_POLICY": "syscall",
- "syscall.SYS_PROCESS_VM_READV": "syscall",
- "syscall.SYS_PROCESS_VM_WRITEV": "syscall",
- "syscall.SYS_PROC_INFO": "syscall",
- "syscall.SYS_PROF": "syscall",
- "syscall.SYS_PROFIL": "syscall",
- "syscall.SYS_PSELECT": "syscall",
- "syscall.SYS_PSELECT6": "syscall",
- "syscall.SYS_PSET_ASSIGN": "syscall",
- "syscall.SYS_PSET_CREATE": "syscall",
- "syscall.SYS_PSET_DESTROY": "syscall",
- "syscall.SYS_PSYNCH_CVBROAD": "syscall",
- "syscall.SYS_PSYNCH_CVCLRPREPOST": "syscall",
- "syscall.SYS_PSYNCH_CVSIGNAL": "syscall",
- "syscall.SYS_PSYNCH_CVWAIT": "syscall",
- "syscall.SYS_PSYNCH_MUTEXDROP": "syscall",
- "syscall.SYS_PSYNCH_MUTEXWAIT": "syscall",
- "syscall.SYS_PSYNCH_RW_DOWNGRADE": "syscall",
- "syscall.SYS_PSYNCH_RW_LONGRDLOCK": "syscall",
- "syscall.SYS_PSYNCH_RW_RDLOCK": "syscall",
- "syscall.SYS_PSYNCH_RW_UNLOCK": "syscall",
- "syscall.SYS_PSYNCH_RW_UNLOCK2": "syscall",
- "syscall.SYS_PSYNCH_RW_UPGRADE": "syscall",
- "syscall.SYS_PSYNCH_RW_WRLOCK": "syscall",
- "syscall.SYS_PSYNCH_RW_YIELDWRLOCK": "syscall",
- "syscall.SYS_PTRACE": "syscall",
- "syscall.SYS_PUTPMSG": "syscall",
- "syscall.SYS_PWRITE": "syscall",
- "syscall.SYS_PWRITE64": "syscall",
- "syscall.SYS_PWRITEV": "syscall",
- "syscall.SYS_PWRITE_NOCANCEL": "syscall",
- "syscall.SYS_QUERY_MODULE": "syscall",
- "syscall.SYS_QUOTACTL": "syscall",
- "syscall.SYS_RASCTL": "syscall",
- "syscall.SYS_RCTL_ADD_RULE": "syscall",
- "syscall.SYS_RCTL_GET_LIMITS": "syscall",
- "syscall.SYS_RCTL_GET_RACCT": "syscall",
- "syscall.SYS_RCTL_GET_RULES": "syscall",
- "syscall.SYS_RCTL_REMOVE_RULE": "syscall",
- "syscall.SYS_READ": "syscall",
- "syscall.SYS_READAHEAD": "syscall",
- "syscall.SYS_READDIR": "syscall",
- "syscall.SYS_READLINK": "syscall",
- "syscall.SYS_READLINKAT": "syscall",
- "syscall.SYS_READV": "syscall",
- "syscall.SYS_READV_NOCANCEL": "syscall",
- "syscall.SYS_READ_NOCANCEL": "syscall",
- "syscall.SYS_REBOOT": "syscall",
- "syscall.SYS_RECV": "syscall",
- "syscall.SYS_RECVFROM": "syscall",
- "syscall.SYS_RECVFROM_NOCANCEL": "syscall",
- "syscall.SYS_RECVMMSG": "syscall",
- "syscall.SYS_RECVMSG": "syscall",
- "syscall.SYS_RECVMSG_NOCANCEL": "syscall",
- "syscall.SYS_REMAP_FILE_PAGES": "syscall",
- "syscall.SYS_REMOVEXATTR": "syscall",
- "syscall.SYS_RENAME": "syscall",
- "syscall.SYS_RENAMEAT": "syscall",
- "syscall.SYS_REQUEST_KEY": "syscall",
- "syscall.SYS_RESTART_SYSCALL": "syscall",
- "syscall.SYS_REVOKE": "syscall",
- "syscall.SYS_RFORK": "syscall",
- "syscall.SYS_RMDIR": "syscall",
- "syscall.SYS_RTPRIO": "syscall",
- "syscall.SYS_RTPRIO_THREAD": "syscall",
- "syscall.SYS_RT_SIGACTION": "syscall",
- "syscall.SYS_RT_SIGPENDING": "syscall",
- "syscall.SYS_RT_SIGPROCMASK": "syscall",
- "syscall.SYS_RT_SIGQUEUEINFO": "syscall",
- "syscall.SYS_RT_SIGRETURN": "syscall",
- "syscall.SYS_RT_SIGSUSPEND": "syscall",
- "syscall.SYS_RT_SIGTIMEDWAIT": "syscall",
- "syscall.SYS_RT_TGSIGQUEUEINFO": "syscall",
- "syscall.SYS_SBRK": "syscall",
- "syscall.SYS_SCHED_GETAFFINITY": "syscall",
- "syscall.SYS_SCHED_GETPARAM": "syscall",
- "syscall.SYS_SCHED_GETSCHEDULER": "syscall",
- "syscall.SYS_SCHED_GET_PRIORITY_MAX": "syscall",
- "syscall.SYS_SCHED_GET_PRIORITY_MIN": "syscall",
- "syscall.SYS_SCHED_RR_GET_INTERVAL": "syscall",
- "syscall.SYS_SCHED_SETAFFINITY": "syscall",
- "syscall.SYS_SCHED_SETPARAM": "syscall",
- "syscall.SYS_SCHED_SETSCHEDULER": "syscall",
- "syscall.SYS_SCHED_YIELD": "syscall",
- "syscall.SYS_SCTP_GENERIC_RECVMSG": "syscall",
- "syscall.SYS_SCTP_GENERIC_SENDMSG": "syscall",
- "syscall.SYS_SCTP_GENERIC_SENDMSG_IOV": "syscall",
- "syscall.SYS_SCTP_PEELOFF": "syscall",
- "syscall.SYS_SEARCHFS": "syscall",
- "syscall.SYS_SECURITY": "syscall",
- "syscall.SYS_SELECT": "syscall",
- "syscall.SYS_SELECT_NOCANCEL": "syscall",
- "syscall.SYS_SEMCONFIG": "syscall",
- "syscall.SYS_SEMCTL": "syscall",
- "syscall.SYS_SEMGET": "syscall",
- "syscall.SYS_SEMOP": "syscall",
- "syscall.SYS_SEMSYS": "syscall",
- "syscall.SYS_SEMTIMEDOP": "syscall",
- "syscall.SYS_SEM_CLOSE": "syscall",
- "syscall.SYS_SEM_DESTROY": "syscall",
- "syscall.SYS_SEM_GETVALUE": "syscall",
- "syscall.SYS_SEM_INIT": "syscall",
- "syscall.SYS_SEM_OPEN": "syscall",
- "syscall.SYS_SEM_POST": "syscall",
- "syscall.SYS_SEM_TRYWAIT": "syscall",
- "syscall.SYS_SEM_UNLINK": "syscall",
- "syscall.SYS_SEM_WAIT": "syscall",
- "syscall.SYS_SEM_WAIT_NOCANCEL": "syscall",
- "syscall.SYS_SEND": "syscall",
- "syscall.SYS_SENDFILE": "syscall",
- "syscall.SYS_SENDFILE64": "syscall",
- "syscall.SYS_SENDMMSG": "syscall",
- "syscall.SYS_SENDMSG": "syscall",
- "syscall.SYS_SENDMSG_NOCANCEL": "syscall",
- "syscall.SYS_SENDTO": "syscall",
- "syscall.SYS_SENDTO_NOCANCEL": "syscall",
- "syscall.SYS_SETATTRLIST": "syscall",
- "syscall.SYS_SETAUDIT": "syscall",
- "syscall.SYS_SETAUDIT_ADDR": "syscall",
- "syscall.SYS_SETAUID": "syscall",
- "syscall.SYS_SETCONTEXT": "syscall",
- "syscall.SYS_SETDOMAINNAME": "syscall",
- "syscall.SYS_SETEGID": "syscall",
- "syscall.SYS_SETEUID": "syscall",
- "syscall.SYS_SETFIB": "syscall",
- "syscall.SYS_SETFSGID": "syscall",
- "syscall.SYS_SETFSGID32": "syscall",
- "syscall.SYS_SETFSUID": "syscall",
- "syscall.SYS_SETFSUID32": "syscall",
- "syscall.SYS_SETGID": "syscall",
- "syscall.SYS_SETGID32": "syscall",
- "syscall.SYS_SETGROUPS": "syscall",
- "syscall.SYS_SETGROUPS32": "syscall",
- "syscall.SYS_SETHOSTNAME": "syscall",
- "syscall.SYS_SETITIMER": "syscall",
- "syscall.SYS_SETLCID": "syscall",
- "syscall.SYS_SETLOGIN": "syscall",
- "syscall.SYS_SETLOGINCLASS": "syscall",
- "syscall.SYS_SETNS": "syscall",
- "syscall.SYS_SETPGID": "syscall",
- "syscall.SYS_SETPRIORITY": "syscall",
- "syscall.SYS_SETPRIVEXEC": "syscall",
- "syscall.SYS_SETREGID": "syscall",
- "syscall.SYS_SETREGID32": "syscall",
- "syscall.SYS_SETRESGID": "syscall",
- "syscall.SYS_SETRESGID32": "syscall",
- "syscall.SYS_SETRESUID": "syscall",
- "syscall.SYS_SETRESUID32": "syscall",
- "syscall.SYS_SETREUID": "syscall",
- "syscall.SYS_SETREUID32": "syscall",
- "syscall.SYS_SETRLIMIT": "syscall",
- "syscall.SYS_SETRTABLE": "syscall",
- "syscall.SYS_SETSGROUPS": "syscall",
- "syscall.SYS_SETSID": "syscall",
- "syscall.SYS_SETSOCKOPT": "syscall",
- "syscall.SYS_SETTID": "syscall",
- "syscall.SYS_SETTID_WITH_PID": "syscall",
- "syscall.SYS_SETTIMEOFDAY": "syscall",
- "syscall.SYS_SETUID": "syscall",
- "syscall.SYS_SETUID32": "syscall",
- "syscall.SYS_SETWGROUPS": "syscall",
- "syscall.SYS_SETXATTR": "syscall",
- "syscall.SYS_SET_MEMPOLICY": "syscall",
- "syscall.SYS_SET_ROBUST_LIST": "syscall",
- "syscall.SYS_SET_THREAD_AREA": "syscall",
- "syscall.SYS_SET_TID_ADDRESS": "syscall",
- "syscall.SYS_SGETMASK": "syscall",
- "syscall.SYS_SHARED_REGION_CHECK_NP": "syscall",
- "syscall.SYS_SHARED_REGION_MAP_AND_SLIDE_NP": "syscall",
- "syscall.SYS_SHMAT": "syscall",
- "syscall.SYS_SHMCTL": "syscall",
- "syscall.SYS_SHMDT": "syscall",
- "syscall.SYS_SHMGET": "syscall",
- "syscall.SYS_SHMSYS": "syscall",
- "syscall.SYS_SHM_OPEN": "syscall",
- "syscall.SYS_SHM_UNLINK": "syscall",
- "syscall.SYS_SHUTDOWN": "syscall",
- "syscall.SYS_SIGACTION": "syscall",
- "syscall.SYS_SIGALTSTACK": "syscall",
- "syscall.SYS_SIGNAL": "syscall",
- "syscall.SYS_SIGNALFD": "syscall",
- "syscall.SYS_SIGNALFD4": "syscall",
- "syscall.SYS_SIGPENDING": "syscall",
- "syscall.SYS_SIGPROCMASK": "syscall",
- "syscall.SYS_SIGQUEUE": "syscall",
- "syscall.SYS_SIGQUEUEINFO": "syscall",
- "syscall.SYS_SIGRETURN": "syscall",
- "syscall.SYS_SIGSUSPEND": "syscall",
- "syscall.SYS_SIGSUSPEND_NOCANCEL": "syscall",
- "syscall.SYS_SIGTIMEDWAIT": "syscall",
- "syscall.SYS_SIGWAIT": "syscall",
- "syscall.SYS_SIGWAITINFO": "syscall",
- "syscall.SYS_SOCKET": "syscall",
- "syscall.SYS_SOCKETCALL": "syscall",
- "syscall.SYS_SOCKETPAIR": "syscall",
- "syscall.SYS_SPLICE": "syscall",
- "syscall.SYS_SSETMASK": "syscall",
- "syscall.SYS_SSTK": "syscall",
- "syscall.SYS_STACK_SNAPSHOT": "syscall",
- "syscall.SYS_STAT": "syscall",
- "syscall.SYS_STAT64": "syscall",
- "syscall.SYS_STAT64_EXTENDED": "syscall",
- "syscall.SYS_STATFS": "syscall",
- "syscall.SYS_STATFS64": "syscall",
- "syscall.SYS_STATV": "syscall",
- "syscall.SYS_STATVFS1": "syscall",
- "syscall.SYS_STAT_EXTENDED": "syscall",
- "syscall.SYS_STIME": "syscall",
- "syscall.SYS_STTY": "syscall",
- "syscall.SYS_SWAPCONTEXT": "syscall",
- "syscall.SYS_SWAPCTL": "syscall",
- "syscall.SYS_SWAPOFF": "syscall",
- "syscall.SYS_SWAPON": "syscall",
- "syscall.SYS_SYMLINK": "syscall",
- "syscall.SYS_SYMLINKAT": "syscall",
- "syscall.SYS_SYNC": "syscall",
- "syscall.SYS_SYNCFS": "syscall",
- "syscall.SYS_SYNC_FILE_RANGE": "syscall",
- "syscall.SYS_SYSARCH": "syscall",
- "syscall.SYS_SYSCALL": "syscall",
- "syscall.SYS_SYSCALL_BASE": "syscall",
- "syscall.SYS_SYSFS": "syscall",
- "syscall.SYS_SYSINFO": "syscall",
- "syscall.SYS_SYSLOG": "syscall",
- "syscall.SYS_TEE": "syscall",
- "syscall.SYS_TGKILL": "syscall",
- "syscall.SYS_THREAD_SELFID": "syscall",
- "syscall.SYS_THR_CREATE": "syscall",
- "syscall.SYS_THR_EXIT": "syscall",
- "syscall.SYS_THR_KILL": "syscall",
- "syscall.SYS_THR_KILL2": "syscall",
- "syscall.SYS_THR_NEW": "syscall",
- "syscall.SYS_THR_SELF": "syscall",
- "syscall.SYS_THR_SET_NAME": "syscall",
- "syscall.SYS_THR_SUSPEND": "syscall",
- "syscall.SYS_THR_WAKE": "syscall",
- "syscall.SYS_TIME": "syscall",
- "syscall.SYS_TIMERFD_CREATE": "syscall",
- "syscall.SYS_TIMERFD_GETTIME": "syscall",
- "syscall.SYS_TIMERFD_SETTIME": "syscall",
- "syscall.SYS_TIMER_CREATE": "syscall",
- "syscall.SYS_TIMER_DELETE": "syscall",
- "syscall.SYS_TIMER_GETOVERRUN": "syscall",
- "syscall.SYS_TIMER_GETTIME": "syscall",
- "syscall.SYS_TIMER_SETTIME": "syscall",
- "syscall.SYS_TIMES": "syscall",
- "syscall.SYS_TKILL": "syscall",
- "syscall.SYS_TRUNCATE": "syscall",
- "syscall.SYS_TRUNCATE64": "syscall",
- "syscall.SYS_TUXCALL": "syscall",
- "syscall.SYS_UGETRLIMIT": "syscall",
- "syscall.SYS_ULIMIT": "syscall",
- "syscall.SYS_UMASK": "syscall",
- "syscall.SYS_UMASK_EXTENDED": "syscall",
- "syscall.SYS_UMOUNT": "syscall",
- "syscall.SYS_UMOUNT2": "syscall",
- "syscall.SYS_UNAME": "syscall",
- "syscall.SYS_UNDELETE": "syscall",
- "syscall.SYS_UNLINK": "syscall",
- "syscall.SYS_UNLINKAT": "syscall",
- "syscall.SYS_UNMOUNT": "syscall",
- "syscall.SYS_UNSHARE": "syscall",
- "syscall.SYS_USELIB": "syscall",
- "syscall.SYS_USTAT": "syscall",
- "syscall.SYS_UTIME": "syscall",
- "syscall.SYS_UTIMENSAT": "syscall",
- "syscall.SYS_UTIMES": "syscall",
- "syscall.SYS_UTRACE": "syscall",
- "syscall.SYS_UUIDGEN": "syscall",
- "syscall.SYS_VADVISE": "syscall",
- "syscall.SYS_VFORK": "syscall",
- "syscall.SYS_VHANGUP": "syscall",
- "syscall.SYS_VM86": "syscall",
- "syscall.SYS_VM86OLD": "syscall",
- "syscall.SYS_VMSPLICE": "syscall",
- "syscall.SYS_VM_PRESSURE_MONITOR": "syscall",
- "syscall.SYS_VSERVER": "syscall",
- "syscall.SYS_WAIT4": "syscall",
- "syscall.SYS_WAIT4_NOCANCEL": "syscall",
- "syscall.SYS_WAIT6": "syscall",
- "syscall.SYS_WAITEVENT": "syscall",
- "syscall.SYS_WAITID": "syscall",
- "syscall.SYS_WAITID_NOCANCEL": "syscall",
- "syscall.SYS_WAITPID": "syscall",
- "syscall.SYS_WATCHEVENT": "syscall",
- "syscall.SYS_WORKQ_KERNRETURN": "syscall",
- "syscall.SYS_WORKQ_OPEN": "syscall",
- "syscall.SYS_WRITE": "syscall",
- "syscall.SYS_WRITEV": "syscall",
- "syscall.SYS_WRITEV_NOCANCEL": "syscall",
- "syscall.SYS_WRITE_NOCANCEL": "syscall",
- "syscall.SYS_YIELD": "syscall",
- "syscall.SYS__LLSEEK": "syscall",
- "syscall.SYS__LWP_CONTINUE": "syscall",
- "syscall.SYS__LWP_CREATE": "syscall",
- "syscall.SYS__LWP_CTL": "syscall",
- "syscall.SYS__LWP_DETACH": "syscall",
- "syscall.SYS__LWP_EXIT": "syscall",
- "syscall.SYS__LWP_GETNAME": "syscall",
- "syscall.SYS__LWP_GETPRIVATE": "syscall",
- "syscall.SYS__LWP_KILL": "syscall",
- "syscall.SYS__LWP_PARK": "syscall",
- "syscall.SYS__LWP_SELF": "syscall",
- "syscall.SYS__LWP_SETNAME": "syscall",
- "syscall.SYS__LWP_SETPRIVATE": "syscall",
- "syscall.SYS__LWP_SUSPEND": "syscall",
- "syscall.SYS__LWP_UNPARK": "syscall",
- "syscall.SYS__LWP_UNPARK_ALL": "syscall",
- "syscall.SYS__LWP_WAIT": "syscall",
- "syscall.SYS__LWP_WAKEUP": "syscall",
- "syscall.SYS__NEWSELECT": "syscall",
- "syscall.SYS__PSET_BIND": "syscall",
- "syscall.SYS__SCHED_GETAFFINITY": "syscall",
- "syscall.SYS__SCHED_GETPARAM": "syscall",
- "syscall.SYS__SCHED_SETAFFINITY": "syscall",
- "syscall.SYS__SCHED_SETPARAM": "syscall",
- "syscall.SYS__SYSCTL": "syscall",
- "syscall.SYS__UMTX_LOCK": "syscall",
- "syscall.SYS__UMTX_OP": "syscall",
- "syscall.SYS__UMTX_UNLOCK": "syscall",
- "syscall.SYS___ACL_ACLCHECK_FD": "syscall",
- "syscall.SYS___ACL_ACLCHECK_FILE": "syscall",
- "syscall.SYS___ACL_ACLCHECK_LINK": "syscall",
- "syscall.SYS___ACL_DELETE_FD": "syscall",
- "syscall.SYS___ACL_DELETE_FILE": "syscall",
- "syscall.SYS___ACL_DELETE_LINK": "syscall",
- "syscall.SYS___ACL_GET_FD": "syscall",
- "syscall.SYS___ACL_GET_FILE": "syscall",
- "syscall.SYS___ACL_GET_LINK": "syscall",
- "syscall.SYS___ACL_SET_FD": "syscall",
- "syscall.SYS___ACL_SET_FILE": "syscall",
- "syscall.SYS___ACL_SET_LINK": "syscall",
- "syscall.SYS___CLONE": "syscall",
- "syscall.SYS___DISABLE_THREADSIGNAL": "syscall",
- "syscall.SYS___GETCWD": "syscall",
- "syscall.SYS___GETLOGIN": "syscall",
- "syscall.SYS___GET_TCB": "syscall",
- "syscall.SYS___MAC_EXECVE": "syscall",
- "syscall.SYS___MAC_GETFSSTAT": "syscall",
- "syscall.SYS___MAC_GET_FD": "syscall",
- "syscall.SYS___MAC_GET_FILE": "syscall",
- "syscall.SYS___MAC_GET_LCID": "syscall",
- "syscall.SYS___MAC_GET_LCTX": "syscall",
- "syscall.SYS___MAC_GET_LINK": "syscall",
- "syscall.SYS___MAC_GET_MOUNT": "syscall",
- "syscall.SYS___MAC_GET_PID": "syscall",
- "syscall.SYS___MAC_GET_PROC": "syscall",
- "syscall.SYS___MAC_MOUNT": "syscall",
- "syscall.SYS___MAC_SET_FD": "syscall",
- "syscall.SYS___MAC_SET_FILE": "syscall",
- "syscall.SYS___MAC_SET_LCTX": "syscall",
- "syscall.SYS___MAC_SET_LINK": "syscall",
- "syscall.SYS___MAC_SET_PROC": "syscall",
- "syscall.SYS___MAC_SYSCALL": "syscall",
- "syscall.SYS___OLD_SEMWAIT_SIGNAL": "syscall",
- "syscall.SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL": "syscall",
- "syscall.SYS___POSIX_CHOWN": "syscall",
- "syscall.SYS___POSIX_FCHOWN": "syscall",
- "syscall.SYS___POSIX_LCHOWN": "syscall",
- "syscall.SYS___POSIX_RENAME": "syscall",
- "syscall.SYS___PTHREAD_CANCELED": "syscall",
- "syscall.SYS___PTHREAD_CHDIR": "syscall",
- "syscall.SYS___PTHREAD_FCHDIR": "syscall",
- "syscall.SYS___PTHREAD_KILL": "syscall",
- "syscall.SYS___PTHREAD_MARKCANCEL": "syscall",
- "syscall.SYS___PTHREAD_SIGMASK": "syscall",
- "syscall.SYS___QUOTACTL": "syscall",
- "syscall.SYS___SEMCTL": "syscall",
- "syscall.SYS___SEMWAIT_SIGNAL": "syscall",
- "syscall.SYS___SEMWAIT_SIGNAL_NOCANCEL": "syscall",
- "syscall.SYS___SETLOGIN": "syscall",
- "syscall.SYS___SETUGID": "syscall",
- "syscall.SYS___SET_TCB": "syscall",
- "syscall.SYS___SIGACTION_SIGTRAMP": "syscall",
- "syscall.SYS___SIGTIMEDWAIT": "syscall",
- "syscall.SYS___SIGWAIT": "syscall",
- "syscall.SYS___SIGWAIT_NOCANCEL": "syscall",
- "syscall.SYS___SYSCTL": "syscall",
- "syscall.SYS___TFORK": "syscall",
- "syscall.SYS___THREXIT": "syscall",
- "syscall.SYS___THRSIGDIVERT": "syscall",
- "syscall.SYS___THRSLEEP": "syscall",
- "syscall.SYS___THRWAKEUP": "syscall",
- "syscall.S_ARCH1": "syscall",
- "syscall.S_ARCH2": "syscall",
- "syscall.S_BLKSIZE": "syscall",
- "syscall.S_IEXEC": "syscall",
- "syscall.S_IFBLK": "syscall",
- "syscall.S_IFCHR": "syscall",
- "syscall.S_IFDIR": "syscall",
- "syscall.S_IFIFO": "syscall",
- "syscall.S_IFLNK": "syscall",
- "syscall.S_IFMT": "syscall",
- "syscall.S_IFREG": "syscall",
- "syscall.S_IFSOCK": "syscall",
- "syscall.S_IFWHT": "syscall",
- "syscall.S_IREAD": "syscall",
- "syscall.S_IRGRP": "syscall",
- "syscall.S_IROTH": "syscall",
- "syscall.S_IRUSR": "syscall",
- "syscall.S_IRWXG": "syscall",
- "syscall.S_IRWXO": "syscall",
- "syscall.S_IRWXU": "syscall",
- "syscall.S_ISGID": "syscall",
- "syscall.S_ISTXT": "syscall",
- "syscall.S_ISUID": "syscall",
- "syscall.S_ISVTX": "syscall",
- "syscall.S_IWGRP": "syscall",
- "syscall.S_IWOTH": "syscall",
- "syscall.S_IWRITE": "syscall",
- "syscall.S_IWUSR": "syscall",
- "syscall.S_IXGRP": "syscall",
- "syscall.S_IXOTH": "syscall",
- "syscall.S_IXUSR": "syscall",
- "syscall.S_LOGIN_SET": "syscall",
- "syscall.SecurityAttributes": "syscall",
- "syscall.Seek": "syscall",
- "syscall.Select": "syscall",
- "syscall.Sendfile": "syscall",
- "syscall.Sendmsg": "syscall",
- "syscall.Sendto": "syscall",
- "syscall.Servent": "syscall",
- "syscall.SetBpf": "syscall",
- "syscall.SetBpfBuflen": "syscall",
- "syscall.SetBpfDatalink": "syscall",
- "syscall.SetBpfHeadercmpl": "syscall",
- "syscall.SetBpfImmediate": "syscall",
- "syscall.SetBpfInterface": "syscall",
- "syscall.SetBpfPromisc": "syscall",
- "syscall.SetBpfTimeout": "syscall",
- "syscall.SetCurrentDirectory": "syscall",
- "syscall.SetEndOfFile": "syscall",
- "syscall.SetEnvironmentVariable": "syscall",
- "syscall.SetFileAttributes": "syscall",
- "syscall.SetFileCompletionNotificationModes": "syscall",
- "syscall.SetFilePointer": "syscall",
- "syscall.SetFileTime": "syscall",
- "syscall.SetHandleInformation": "syscall",
- "syscall.SetKevent": "syscall",
- "syscall.SetLsfPromisc": "syscall",
- "syscall.SetNonblock": "syscall",
- "syscall.Setdomainname": "syscall",
- "syscall.Setegid": "syscall",
- "syscall.Setenv": "syscall",
- "syscall.Seteuid": "syscall",
- "syscall.Setfsgid": "syscall",
- "syscall.Setfsuid": "syscall",
- "syscall.Setgid": "syscall",
- "syscall.Setgroups": "syscall",
- "syscall.Sethostname": "syscall",
- "syscall.Setlogin": "syscall",
- "syscall.Setpgid": "syscall",
- "syscall.Setpriority": "syscall",
- "syscall.Setprivexec": "syscall",
- "syscall.Setregid": "syscall",
- "syscall.Setresgid": "syscall",
- "syscall.Setresuid": "syscall",
- "syscall.Setreuid": "syscall",
- "syscall.Setrlimit": "syscall",
- "syscall.Setsid": "syscall",
- "syscall.Setsockopt": "syscall",
- "syscall.SetsockoptByte": "syscall",
- "syscall.SetsockoptICMPv6Filter": "syscall",
- "syscall.SetsockoptIPMreq": "syscall",
- "syscall.SetsockoptIPMreqn": "syscall",
- "syscall.SetsockoptIPv6Mreq": "syscall",
- "syscall.SetsockoptInet4Addr": "syscall",
- "syscall.SetsockoptInt": "syscall",
- "syscall.SetsockoptLinger": "syscall",
- "syscall.SetsockoptString": "syscall",
- "syscall.SetsockoptTimeval": "syscall",
- "syscall.Settimeofday": "syscall",
- "syscall.Setuid": "syscall",
- "syscall.Setxattr": "syscall",
- "syscall.Shutdown": "syscall",
- "syscall.SidTypeAlias": "syscall",
- "syscall.SidTypeComputer": "syscall",
- "syscall.SidTypeDeletedAccount": "syscall",
- "syscall.SidTypeDomain": "syscall",
- "syscall.SidTypeGroup": "syscall",
- "syscall.SidTypeInvalid": "syscall",
- "syscall.SidTypeLabel": "syscall",
- "syscall.SidTypeUnknown": "syscall",
- "syscall.SidTypeUser": "syscall",
- "syscall.SidTypeWellKnownGroup": "syscall",
- "syscall.Signal": "syscall",
- "syscall.SizeofBpfHdr": "syscall",
- "syscall.SizeofBpfInsn": "syscall",
- "syscall.SizeofBpfProgram": "syscall",
- "syscall.SizeofBpfStat": "syscall",
- "syscall.SizeofBpfVersion": "syscall",
- "syscall.SizeofBpfZbuf": "syscall",
- "syscall.SizeofBpfZbufHeader": "syscall",
- "syscall.SizeofCmsghdr": "syscall",
- "syscall.SizeofICMPv6Filter": "syscall",
- "syscall.SizeofIPMreq": "syscall",
- "syscall.SizeofIPMreqn": "syscall",
- "syscall.SizeofIPv6MTUInfo": "syscall",
- "syscall.SizeofIPv6Mreq": "syscall",
- "syscall.SizeofIfAddrmsg": "syscall",
- "syscall.SizeofIfAnnounceMsghdr": "syscall",
- "syscall.SizeofIfData": "syscall",
- "syscall.SizeofIfInfomsg": "syscall",
- "syscall.SizeofIfMsghdr": "syscall",
- "syscall.SizeofIfaMsghdr": "syscall",
- "syscall.SizeofIfmaMsghdr": "syscall",
- "syscall.SizeofIfmaMsghdr2": "syscall",
- "syscall.SizeofInet4Pktinfo": "syscall",
- "syscall.SizeofInet6Pktinfo": "syscall",
- "syscall.SizeofInotifyEvent": "syscall",
- "syscall.SizeofLinger": "syscall",
- "syscall.SizeofMsghdr": "syscall",
- "syscall.SizeofNlAttr": "syscall",
- "syscall.SizeofNlMsgerr": "syscall",
- "syscall.SizeofNlMsghdr": "syscall",
- "syscall.SizeofRtAttr": "syscall",
- "syscall.SizeofRtGenmsg": "syscall",
- "syscall.SizeofRtMetrics": "syscall",
- "syscall.SizeofRtMsg": "syscall",
- "syscall.SizeofRtMsghdr": "syscall",
- "syscall.SizeofRtNexthop": "syscall",
- "syscall.SizeofSockFilter": "syscall",
- "syscall.SizeofSockFprog": "syscall",
- "syscall.SizeofSockaddrAny": "syscall",
- "syscall.SizeofSockaddrDatalink": "syscall",
- "syscall.SizeofSockaddrInet4": "syscall",
- "syscall.SizeofSockaddrInet6": "syscall",
- "syscall.SizeofSockaddrLinklayer": "syscall",
- "syscall.SizeofSockaddrNetlink": "syscall",
- "syscall.SizeofSockaddrUnix": "syscall",
- "syscall.SizeofTCPInfo": "syscall",
- "syscall.SizeofUcred": "syscall",
- "syscall.SlicePtrFromStrings": "syscall",
- "syscall.SockFilter": "syscall",
- "syscall.SockFprog": "syscall",
- "syscall.SockaddrDatalink": "syscall",
- "syscall.SockaddrGen": "syscall",
- "syscall.SockaddrInet4": "syscall",
- "syscall.SockaddrInet6": "syscall",
- "syscall.SockaddrLinklayer": "syscall",
- "syscall.SockaddrNetlink": "syscall",
- "syscall.SockaddrUnix": "syscall",
- "syscall.Socket": "syscall",
- "syscall.SocketControlMessage": "syscall",
- "syscall.SocketDisableIPv6": "syscall",
- "syscall.Socketpair": "syscall",
- "syscall.Splice": "syscall",
- "syscall.StartProcess": "syscall",
- "syscall.StartupInfo": "syscall",
- "syscall.Stat": "syscall",
- "syscall.Stat_t": "syscall",
- "syscall.Statfs": "syscall",
- "syscall.Statfs_t": "syscall",
- "syscall.Stderr": "syscall",
- "syscall.Stdin": "syscall",
- "syscall.Stdout": "syscall",
- "syscall.StringBytePtr": "syscall",
- "syscall.StringByteSlice": "syscall",
- "syscall.StringSlicePtr": "syscall",
- "syscall.StringToSid": "syscall",
- "syscall.StringToUTF16": "syscall",
- "syscall.StringToUTF16Ptr": "syscall",
- "syscall.Symlink": "syscall",
- "syscall.Sync": "syscall",
- "syscall.SyncFileRange": "syscall",
- "syscall.SysProcAttr": "syscall",
- "syscall.Syscall": "syscall",
- "syscall.Syscall12": "syscall",
- "syscall.Syscall15": "syscall",
- "syscall.Syscall6": "syscall",
- "syscall.Syscall9": "syscall",
- "syscall.Sysctl": "syscall",
- "syscall.SysctlUint32": "syscall",
- "syscall.Sysctlnode": "syscall",
- "syscall.Sysinfo": "syscall",
- "syscall.Sysinfo_t": "syscall",
- "syscall.Systemtime": "syscall",
- "syscall.TCGETS": "syscall",
- "syscall.TCIFLUSH": "syscall",
- "syscall.TCIOFLUSH": "syscall",
- "syscall.TCOFLUSH": "syscall",
- "syscall.TCPInfo": "syscall",
- "syscall.TCP_CA_NAME_MAX": "syscall",
- "syscall.TCP_CONGCTL": "syscall",
- "syscall.TCP_CONGESTION": "syscall",
- "syscall.TCP_CONNECTIONTIMEOUT": "syscall",
- "syscall.TCP_CORK": "syscall",
- "syscall.TCP_DEFER_ACCEPT": "syscall",
- "syscall.TCP_INFO": "syscall",
- "syscall.TCP_KEEPALIVE": "syscall",
- "syscall.TCP_KEEPCNT": "syscall",
- "syscall.TCP_KEEPIDLE": "syscall",
- "syscall.TCP_KEEPINIT": "syscall",
- "syscall.TCP_KEEPINTVL": "syscall",
- "syscall.TCP_LINGER2": "syscall",
- "syscall.TCP_MAXBURST": "syscall",
- "syscall.TCP_MAXHLEN": "syscall",
- "syscall.TCP_MAXOLEN": "syscall",
- "syscall.TCP_MAXSEG": "syscall",
- "syscall.TCP_MAXWIN": "syscall",
- "syscall.TCP_MAX_SACK": "syscall",
- "syscall.TCP_MAX_WINSHIFT": "syscall",
- "syscall.TCP_MD5SIG": "syscall",
- "syscall.TCP_MD5SIG_MAXKEYLEN": "syscall",
- "syscall.TCP_MINMSS": "syscall",
- "syscall.TCP_MINMSSOVERLOAD": "syscall",
- "syscall.TCP_MSS": "syscall",
- "syscall.TCP_NODELAY": "syscall",
- "syscall.TCP_NOOPT": "syscall",
- "syscall.TCP_NOPUSH": "syscall",
- "syscall.TCP_NSTATES": "syscall",
- "syscall.TCP_QUICKACK": "syscall",
- "syscall.TCP_RXT_CONNDROPTIME": "syscall",
- "syscall.TCP_RXT_FINDROP": "syscall",
- "syscall.TCP_SACK_ENABLE": "syscall",
- "syscall.TCP_SYNCNT": "syscall",
- "syscall.TCP_WINDOW_CLAMP": "syscall",
- "syscall.TCSAFLUSH": "syscall",
- "syscall.TCSETS": "syscall",
- "syscall.TF_DISCONNECT": "syscall",
- "syscall.TF_REUSE_SOCKET": "syscall",
- "syscall.TF_USE_DEFAULT_WORKER": "syscall",
- "syscall.TF_USE_KERNEL_APC": "syscall",
- "syscall.TF_USE_SYSTEM_THREAD": "syscall",
- "syscall.TF_WRITE_BEHIND": "syscall",
- "syscall.TIME_ZONE_ID_DAYLIGHT": "syscall",
- "syscall.TIME_ZONE_ID_STANDARD": "syscall",
- "syscall.TIME_ZONE_ID_UNKNOWN": "syscall",
- "syscall.TIOCCBRK": "syscall",
- "syscall.TIOCCDTR": "syscall",
- "syscall.TIOCCONS": "syscall",
- "syscall.TIOCDCDTIMESTAMP": "syscall",
- "syscall.TIOCDRAIN": "syscall",
- "syscall.TIOCDSIMICROCODE": "syscall",
- "syscall.TIOCEXCL": "syscall",
- "syscall.TIOCEXT": "syscall",
- "syscall.TIOCFLAG_CDTRCTS": "syscall",
- "syscall.TIOCFLAG_CLOCAL": "syscall",
- "syscall.TIOCFLAG_CRTSCTS": "syscall",
- "syscall.TIOCFLAG_MDMBUF": "syscall",
- "syscall.TIOCFLAG_PPS": "syscall",
- "syscall.TIOCFLAG_SOFTCAR": "syscall",
- "syscall.TIOCFLUSH": "syscall",
- "syscall.TIOCGDEV": "syscall",
- "syscall.TIOCGDRAINWAIT": "syscall",
- "syscall.TIOCGETA": "syscall",
- "syscall.TIOCGETD": "syscall",
- "syscall.TIOCGFLAGS": "syscall",
- "syscall.TIOCGICOUNT": "syscall",
- "syscall.TIOCGLCKTRMIOS": "syscall",
- "syscall.TIOCGLINED": "syscall",
- "syscall.TIOCGPGRP": "syscall",
- "syscall.TIOCGPTN": "syscall",
- "syscall.TIOCGQSIZE": "syscall",
- "syscall.TIOCGRANTPT": "syscall",
- "syscall.TIOCGRS485": "syscall",
- "syscall.TIOCGSERIAL": "syscall",
- "syscall.TIOCGSID": "syscall",
- "syscall.TIOCGSIZE": "syscall",
- "syscall.TIOCGSOFTCAR": "syscall",
- "syscall.TIOCGTSTAMP": "syscall",
- "syscall.TIOCGWINSZ": "syscall",
- "syscall.TIOCINQ": "syscall",
- "syscall.TIOCIXOFF": "syscall",
- "syscall.TIOCIXON": "syscall",
- "syscall.TIOCLINUX": "syscall",
- "syscall.TIOCMBIC": "syscall",
- "syscall.TIOCMBIS": "syscall",
- "syscall.TIOCMGDTRWAIT": "syscall",
- "syscall.TIOCMGET": "syscall",
- "syscall.TIOCMIWAIT": "syscall",
- "syscall.TIOCMODG": "syscall",
- "syscall.TIOCMODS": "syscall",
- "syscall.TIOCMSDTRWAIT": "syscall",
- "syscall.TIOCMSET": "syscall",
- "syscall.TIOCM_CAR": "syscall",
- "syscall.TIOCM_CD": "syscall",
- "syscall.TIOCM_CTS": "syscall",
- "syscall.TIOCM_DCD": "syscall",
- "syscall.TIOCM_DSR": "syscall",
- "syscall.TIOCM_DTR": "syscall",
- "syscall.TIOCM_LE": "syscall",
- "syscall.TIOCM_RI": "syscall",
- "syscall.TIOCM_RNG": "syscall",
- "syscall.TIOCM_RTS": "syscall",
- "syscall.TIOCM_SR": "syscall",
- "syscall.TIOCM_ST": "syscall",
- "syscall.TIOCNOTTY": "syscall",
- "syscall.TIOCNXCL": "syscall",
- "syscall.TIOCOUTQ": "syscall",
- "syscall.TIOCPKT": "syscall",
- "syscall.TIOCPKT_DATA": "syscall",
- "syscall.TIOCPKT_DOSTOP": "syscall",
- "syscall.TIOCPKT_FLUSHREAD": "syscall",
- "syscall.TIOCPKT_FLUSHWRITE": "syscall",
- "syscall.TIOCPKT_IOCTL": "syscall",
- "syscall.TIOCPKT_NOSTOP": "syscall",
- "syscall.TIOCPKT_START": "syscall",
- "syscall.TIOCPKT_STOP": "syscall",
- "syscall.TIOCPTMASTER": "syscall",
- "syscall.TIOCPTMGET": "syscall",
- "syscall.TIOCPTSNAME": "syscall",
- "syscall.TIOCPTYGNAME": "syscall",
- "syscall.TIOCPTYGRANT": "syscall",
- "syscall.TIOCPTYUNLK": "syscall",
- "syscall.TIOCRCVFRAME": "syscall",
- "syscall.TIOCREMOTE": "syscall",
- "syscall.TIOCSBRK": "syscall",
- "syscall.TIOCSCONS": "syscall",
- "syscall.TIOCSCTTY": "syscall",
- "syscall.TIOCSDRAINWAIT": "syscall",
- "syscall.TIOCSDTR": "syscall",
- "syscall.TIOCSERCONFIG": "syscall",
- "syscall.TIOCSERGETLSR": "syscall",
- "syscall.TIOCSERGETMULTI": "syscall",
- "syscall.TIOCSERGSTRUCT": "syscall",
- "syscall.TIOCSERGWILD": "syscall",
- "syscall.TIOCSERSETMULTI": "syscall",
- "syscall.TIOCSERSWILD": "syscall",
- "syscall.TIOCSER_TEMT": "syscall",
- "syscall.TIOCSETA": "syscall",
- "syscall.TIOCSETAF": "syscall",
- "syscall.TIOCSETAW": "syscall",
- "syscall.TIOCSETD": "syscall",
- "syscall.TIOCSFLAGS": "syscall",
- "syscall.TIOCSIG": "syscall",
- "syscall.TIOCSLCKTRMIOS": "syscall",
- "syscall.TIOCSLINED": "syscall",
- "syscall.TIOCSPGRP": "syscall",
- "syscall.TIOCSPTLCK": "syscall",
- "syscall.TIOCSQSIZE": "syscall",
- "syscall.TIOCSRS485": "syscall",
- "syscall.TIOCSSERIAL": "syscall",
- "syscall.TIOCSSIZE": "syscall",
- "syscall.TIOCSSOFTCAR": "syscall",
- "syscall.TIOCSTART": "syscall",
- "syscall.TIOCSTAT": "syscall",
- "syscall.TIOCSTI": "syscall",
- "syscall.TIOCSTOP": "syscall",
- "syscall.TIOCSTSTAMP": "syscall",
- "syscall.TIOCSWINSZ": "syscall",
- "syscall.TIOCTIMESTAMP": "syscall",
- "syscall.TIOCUCNTL": "syscall",
- "syscall.TIOCVHANGUP": "syscall",
- "syscall.TIOCXMTFRAME": "syscall",
- "syscall.TOKEN_ADJUST_DEFAULT": "syscall",
- "syscall.TOKEN_ADJUST_GROUPS": "syscall",
- "syscall.TOKEN_ADJUST_PRIVILEGES": "syscall",
- "syscall.TOKEN_ALL_ACCESS": "syscall",
- "syscall.TOKEN_ASSIGN_PRIMARY": "syscall",
- "syscall.TOKEN_DUPLICATE": "syscall",
- "syscall.TOKEN_EXECUTE": "syscall",
- "syscall.TOKEN_IMPERSONATE": "syscall",
- "syscall.TOKEN_QUERY": "syscall",
- "syscall.TOKEN_QUERY_SOURCE": "syscall",
- "syscall.TOKEN_READ": "syscall",
- "syscall.TOKEN_WRITE": "syscall",
- "syscall.TOSTOP": "syscall",
- "syscall.TRUNCATE_EXISTING": "syscall",
- "syscall.TUNATTACHFILTER": "syscall",
- "syscall.TUNDETACHFILTER": "syscall",
- "syscall.TUNGETFEATURES": "syscall",
- "syscall.TUNGETIFF": "syscall",
- "syscall.TUNGETSNDBUF": "syscall",
- "syscall.TUNGETVNETHDRSZ": "syscall",
- "syscall.TUNSETDEBUG": "syscall",
- "syscall.TUNSETGROUP": "syscall",
- "syscall.TUNSETIFF": "syscall",
- "syscall.TUNSETLINK": "syscall",
- "syscall.TUNSETNOCSUM": "syscall",
- "syscall.TUNSETOFFLOAD": "syscall",
- "syscall.TUNSETOWNER": "syscall",
- "syscall.TUNSETPERSIST": "syscall",
- "syscall.TUNSETSNDBUF": "syscall",
- "syscall.TUNSETTXFILTER": "syscall",
- "syscall.TUNSETVNETHDRSZ": "syscall",
- "syscall.Tee": "syscall",
- "syscall.TerminateProcess": "syscall",
- "syscall.Termios": "syscall",
- "syscall.Tgkill": "syscall",
- "syscall.Time": "syscall",
- "syscall.Time_t": "syscall",
- "syscall.Times": "syscall",
- "syscall.Timespec": "syscall",
- "syscall.TimespecToNsec": "syscall",
- "syscall.Timeval": "syscall",
- "syscall.Timeval32": "syscall",
- "syscall.TimevalToNsec": "syscall",
- "syscall.Timex": "syscall",
- "syscall.Timezoneinformation": "syscall",
- "syscall.Tms": "syscall",
- "syscall.Token": "syscall",
- "syscall.TokenAccessInformation": "syscall",
- "syscall.TokenAuditPolicy": "syscall",
- "syscall.TokenDefaultDacl": "syscall",
- "syscall.TokenElevation": "syscall",
- "syscall.TokenElevationType": "syscall",
- "syscall.TokenGroups": "syscall",
- "syscall.TokenGroupsAndPrivileges": "syscall",
- "syscall.TokenHasRestrictions": "syscall",
- "syscall.TokenImpersonationLevel": "syscall",
- "syscall.TokenIntegrityLevel": "syscall",
- "syscall.TokenLinkedToken": "syscall",
- "syscall.TokenLogonSid": "syscall",
- "syscall.TokenMandatoryPolicy": "syscall",
- "syscall.TokenOrigin": "syscall",
- "syscall.TokenOwner": "syscall",
- "syscall.TokenPrimaryGroup": "syscall",
- "syscall.TokenPrivileges": "syscall",
- "syscall.TokenRestrictedSids": "syscall",
- "syscall.TokenSandBoxInert": "syscall",
- "syscall.TokenSessionId": "syscall",
- "syscall.TokenSessionReference": "syscall",
- "syscall.TokenSource": "syscall",
- "syscall.TokenStatistics": "syscall",
- "syscall.TokenType": "syscall",
- "syscall.TokenUIAccess": "syscall",
- "syscall.TokenUser": "syscall",
- "syscall.TokenVirtualizationAllowed": "syscall",
- "syscall.TokenVirtualizationEnabled": "syscall",
- "syscall.Tokenprimarygroup": "syscall",
- "syscall.Tokenuser": "syscall",
- "syscall.TranslateAccountName": "syscall",
- "syscall.TranslateName": "syscall",
- "syscall.TransmitFile": "syscall",
- "syscall.TransmitFileBuffers": "syscall",
- "syscall.Truncate": "syscall",
- "syscall.USAGE_MATCH_TYPE_AND": "syscall",
- "syscall.USAGE_MATCH_TYPE_OR": "syscall",
- "syscall.UTF16FromString": "syscall",
- "syscall.UTF16PtrFromString": "syscall",
- "syscall.UTF16ToString": "syscall",
- "syscall.Ucred": "syscall",
- "syscall.Umask": "syscall",
- "syscall.Uname": "syscall",
- "syscall.Undelete": "syscall",
- "syscall.UnixCredentials": "syscall",
- "syscall.UnixRights": "syscall",
- "syscall.Unlink": "syscall",
- "syscall.Unlinkat": "syscall",
- "syscall.UnmapViewOfFile": "syscall",
- "syscall.Unmount": "syscall",
- "syscall.Unshare": "syscall",
- "syscall.UserInfo10": "syscall",
- "syscall.Ustat": "syscall",
- "syscall.Ustat_t": "syscall",
- "syscall.Utimbuf": "syscall",
- "syscall.Utime": "syscall",
- "syscall.Utimes": "syscall",
- "syscall.UtimesNano": "syscall",
- "syscall.Utsname": "syscall",
- "syscall.VDISCARD": "syscall",
- "syscall.VDSUSP": "syscall",
- "syscall.VEOF": "syscall",
- "syscall.VEOL": "syscall",
- "syscall.VEOL2": "syscall",
- "syscall.VERASE": "syscall",
- "syscall.VERASE2": "syscall",
- "syscall.VINTR": "syscall",
- "syscall.VKILL": "syscall",
- "syscall.VLNEXT": "syscall",
- "syscall.VMIN": "syscall",
- "syscall.VQUIT": "syscall",
- "syscall.VREPRINT": "syscall",
- "syscall.VSTART": "syscall",
- "syscall.VSTATUS": "syscall",
- "syscall.VSTOP": "syscall",
- "syscall.VSUSP": "syscall",
- "syscall.VSWTC": "syscall",
- "syscall.VT0": "syscall",
- "syscall.VT1": "syscall",
- "syscall.VTDLY": "syscall",
- "syscall.VTIME": "syscall",
- "syscall.VWERASE": "syscall",
- "syscall.VirtualLock": "syscall",
- "syscall.VirtualUnlock": "syscall",
- "syscall.WAIT_ABANDONED": "syscall",
- "syscall.WAIT_FAILED": "syscall",
- "syscall.WAIT_OBJECT_0": "syscall",
- "syscall.WAIT_TIMEOUT": "syscall",
- "syscall.WALL": "syscall",
- "syscall.WALLSIG": "syscall",
- "syscall.WALTSIG": "syscall",
- "syscall.WCLONE": "syscall",
- "syscall.WCONTINUED": "syscall",
- "syscall.WCOREFLAG": "syscall",
- "syscall.WEXITED": "syscall",
- "syscall.WLINUXCLONE": "syscall",
- "syscall.WNOHANG": "syscall",
- "syscall.WNOTHREAD": "syscall",
- "syscall.WNOWAIT": "syscall",
- "syscall.WNOZOMBIE": "syscall",
- "syscall.WOPTSCHECKED": "syscall",
- "syscall.WORDSIZE": "syscall",
- "syscall.WSABuf": "syscall",
- "syscall.WSACleanup": "syscall",
- "syscall.WSADESCRIPTION_LEN": "syscall",
- "syscall.WSAData": "syscall",
- "syscall.WSAEACCES": "syscall",
- "syscall.WSAEnumProtocols": "syscall",
- "syscall.WSAID_CONNECTEX": "syscall",
- "syscall.WSAIoctl": "syscall",
- "syscall.WSAPROTOCOL_LEN": "syscall",
- "syscall.WSAProtocolChain": "syscall",
- "syscall.WSAProtocolInfo": "syscall",
- "syscall.WSARecv": "syscall",
- "syscall.WSARecvFrom": "syscall",
- "syscall.WSASYS_STATUS_LEN": "syscall",
- "syscall.WSASend": "syscall",
- "syscall.WSASendTo": "syscall",
- "syscall.WSASendto": "syscall",
- "syscall.WSAStartup": "syscall",
- "syscall.WSTOPPED": "syscall",
- "syscall.WTRAPPED": "syscall",
- "syscall.WUNTRACED": "syscall",
- "syscall.Wait4": "syscall",
- "syscall.WaitForSingleObject": "syscall",
- "syscall.WaitStatus": "syscall",
- "syscall.Win32FileAttributeData": "syscall",
- "syscall.Win32finddata": "syscall",
- "syscall.Write": "syscall",
- "syscall.WriteConsole": "syscall",
- "syscall.WriteFile": "syscall",
- "syscall.X509_ASN_ENCODING": "syscall",
- "syscall.XCASE": "syscall",
- "syscall.XP1_CONNECTIONLESS": "syscall",
- "syscall.XP1_CONNECT_DATA": "syscall",
- "syscall.XP1_DISCONNECT_DATA": "syscall",
- "syscall.XP1_EXPEDITED_DATA": "syscall",
- "syscall.XP1_GRACEFUL_CLOSE": "syscall",
- "syscall.XP1_GUARANTEED_DELIVERY": "syscall",
- "syscall.XP1_GUARANTEED_ORDER": "syscall",
- "syscall.XP1_IFS_HANDLES": "syscall",
- "syscall.XP1_MESSAGE_ORIENTED": "syscall",
- "syscall.XP1_MULTIPOINT_CONTROL_PLANE": "syscall",
- "syscall.XP1_MULTIPOINT_DATA_PLANE": "syscall",
- "syscall.XP1_PARTIAL_MESSAGE": "syscall",
- "syscall.XP1_PSEUDO_STREAM": "syscall",
- "syscall.XP1_QOS_SUPPORTED": "syscall",
- "syscall.XP1_SAN_SUPPORT_SDP": "syscall",
- "syscall.XP1_SUPPORT_BROADCAST": "syscall",
- "syscall.XP1_SUPPORT_MULTIPOINT": "syscall",
- "syscall.XP1_UNI_RECV": "syscall",
- "syscall.XP1_UNI_SEND": "syscall",
- "syslog.Dial": "log/syslog",
- "syslog.LOG_ALERT": "log/syslog",
- "syslog.LOG_AUTH": "log/syslog",
- "syslog.LOG_AUTHPRIV": "log/syslog",
- "syslog.LOG_CRIT": "log/syslog",
- "syslog.LOG_CRON": "log/syslog",
- "syslog.LOG_DAEMON": "log/syslog",
- "syslog.LOG_DEBUG": "log/syslog",
- "syslog.LOG_EMERG": "log/syslog",
- "syslog.LOG_ERR": "log/syslog",
- "syslog.LOG_FTP": "log/syslog",
- "syslog.LOG_INFO": "log/syslog",
- "syslog.LOG_KERN": "log/syslog",
- "syslog.LOG_LOCAL0": "log/syslog",
- "syslog.LOG_LOCAL1": "log/syslog",
- "syslog.LOG_LOCAL2": "log/syslog",
- "syslog.LOG_LOCAL3": "log/syslog",
- "syslog.LOG_LOCAL4": "log/syslog",
- "syslog.LOG_LOCAL5": "log/syslog",
- "syslog.LOG_LOCAL6": "log/syslog",
- "syslog.LOG_LOCAL7": "log/syslog",
- "syslog.LOG_LPR": "log/syslog",
- "syslog.LOG_MAIL": "log/syslog",
- "syslog.LOG_NEWS": "log/syslog",
- "syslog.LOG_NOTICE": "log/syslog",
- "syslog.LOG_SYSLOG": "log/syslog",
- "syslog.LOG_USER": "log/syslog",
- "syslog.LOG_UUCP": "log/syslog",
- "syslog.LOG_WARNING": "log/syslog",
- "syslog.New": "log/syslog",
- "syslog.NewLogger": "log/syslog",
- "syslog.Priority": "log/syslog",
- "syslog.Writer": "log/syslog",
- "tabwriter.AlignRight": "text/tabwriter",
- "tabwriter.Debug": "text/tabwriter",
- "tabwriter.DiscardEmptyColumns": "text/tabwriter",
- "tabwriter.Escape": "text/tabwriter",
- "tabwriter.FilterHTML": "text/tabwriter",
- "tabwriter.NewWriter": "text/tabwriter",
- "tabwriter.StripEscape": "text/tabwriter",
- "tabwriter.TabIndent": "text/tabwriter",
- "tabwriter.Writer": "text/tabwriter",
- "tar.ErrFieldTooLong": "archive/tar",
- "tar.ErrHeader": "archive/tar",
- "tar.ErrWriteAfterClose": "archive/tar",
- "tar.ErrWriteTooLong": "archive/tar",
- "tar.FileInfoHeader": "archive/tar",
- "tar.Header": "archive/tar",
- "tar.NewReader": "archive/tar",
- "tar.NewWriter": "archive/tar",
- "tar.Reader": "archive/tar",
- "tar.TypeBlock": "archive/tar",
- "tar.TypeChar": "archive/tar",
- "tar.TypeCont": "archive/tar",
- "tar.TypeDir": "archive/tar",
- "tar.TypeFifo": "archive/tar",
- "tar.TypeGNULongLink": "archive/tar",
- "tar.TypeGNULongName": "archive/tar",
- "tar.TypeLink": "archive/tar",
- "tar.TypeReg": "archive/tar",
- "tar.TypeRegA": "archive/tar",
- "tar.TypeSymlink": "archive/tar",
- "tar.TypeXGlobalHeader": "archive/tar",
- "tar.TypeXHeader": "archive/tar",
- "tar.Writer": "archive/tar",
- "template.CSS": "html/template",
- "template.ErrAmbigContext": "html/template",
- "template.ErrBadHTML": "html/template",
- "template.ErrBranchEnd": "html/template",
- "template.ErrEndContext": "html/template",
- "template.ErrNoSuchTemplate": "html/template",
- "template.ErrOutputContext": "html/template",
- "template.ErrPartialCharset": "html/template",
- "template.ErrPartialEscape": "html/template",
- "template.ErrRangeLoopReentry": "html/template",
- "template.ErrSlashAmbig": "html/template",
- "template.Error": "html/template",
- "template.ErrorCode": "html/template",
- // "template.FuncMap" is ambiguous
- "template.HTML": "html/template",
- "template.HTMLAttr": "html/template",
- // "template.HTMLEscape" is ambiguous
- // "template.HTMLEscapeString" is ambiguous
- // "template.HTMLEscaper" is ambiguous
- "template.JS": "html/template",
- // "template.JSEscape" is ambiguous
- // "template.JSEscapeString" is ambiguous
- // "template.JSEscaper" is ambiguous
- "template.JSStr": "html/template",
- // "template.Must" is ambiguous
- // "template.New" is ambiguous
- "template.OK": "html/template",
- // "template.ParseFiles" is ambiguous
- // "template.ParseGlob" is ambiguous
- // "template.Template" is ambiguous
- "template.URL": "html/template",
- // "template.URLQueryEscaper" is ambiguous
- "testing.AllocsPerRun": "testing",
- "testing.B": "testing",
- "testing.Benchmark": "testing",
- "testing.BenchmarkResult": "testing",
- "testing.Cover": "testing",
- "testing.CoverBlock": "testing",
- "testing.InternalBenchmark": "testing",
- "testing.InternalExample": "testing",
- "testing.InternalTest": "testing",
- "testing.Main": "testing",
- "testing.RegisterCover": "testing",
- "testing.RunBenchmarks": "testing",
- "testing.RunExamples": "testing",
- "testing.RunTests": "testing",
- "testing.Short": "testing",
- "testing.T": "testing",
- "testing.Verbose": "testing",
- "textproto.CanonicalMIMEHeaderKey": "net/textproto",
- "textproto.Conn": "net/textproto",
- "textproto.Dial": "net/textproto",
- "textproto.Error": "net/textproto",
- "textproto.MIMEHeader": "net/textproto",
- "textproto.NewConn": "net/textproto",
- "textproto.NewReader": "net/textproto",
- "textproto.NewWriter": "net/textproto",
- "textproto.Pipeline": "net/textproto",
- "textproto.ProtocolError": "net/textproto",
- "textproto.Reader": "net/textproto",
- "textproto.TrimBytes": "net/textproto",
- "textproto.TrimString": "net/textproto",
- "textproto.Writer": "net/textproto",
- "time.ANSIC": "time",
- "time.After": "time",
- "time.AfterFunc": "time",
- "time.April": "time",
- "time.August": "time",
- "time.Date": "time",
- "time.December": "time",
- "time.Duration": "time",
- "time.February": "time",
- "time.FixedZone": "time",
- "time.Friday": "time",
- "time.Hour": "time",
- "time.January": "time",
- "time.July": "time",
- "time.June": "time",
- "time.Kitchen": "time",
- "time.LoadLocation": "time",
- "time.Local": "time",
- "time.Location": "time",
- "time.March": "time",
- "time.May": "time",
- "time.Microsecond": "time",
- "time.Millisecond": "time",
- "time.Minute": "time",
- "time.Monday": "time",
- "time.Month": "time",
- "time.Nanosecond": "time",
- "time.NewTicker": "time",
- "time.NewTimer": "time",
- "time.November": "time",
- "time.Now": "time",
- "time.October": "time",
- "time.Parse": "time",
- "time.ParseDuration": "time",
- "time.ParseError": "time",
- "time.ParseInLocation": "time",
- "time.RFC1123": "time",
- "time.RFC1123Z": "time",
- "time.RFC3339": "time",
- "time.RFC3339Nano": "time",
- "time.RFC822": "time",
- "time.RFC822Z": "time",
- "time.RFC850": "time",
- "time.RubyDate": "time",
- "time.Saturday": "time",
- "time.Second": "time",
- "time.September": "time",
- "time.Since": "time",
- "time.Sleep": "time",
- "time.Stamp": "time",
- "time.StampMicro": "time",
- "time.StampMilli": "time",
- "time.StampNano": "time",
- "time.Sunday": "time",
- "time.Thursday": "time",
- "time.Tick": "time",
- "time.Ticker": "time",
- "time.Time": "time",
- "time.Timer": "time",
- "time.Tuesday": "time",
- "time.UTC": "time",
- "time.Unix": "time",
- "time.UnixDate": "time",
- "time.Wednesday": "time",
- "time.Weekday": "time",
- "tls.Certificate": "crypto/tls",
- "tls.Client": "crypto/tls",
- "tls.ClientAuthType": "crypto/tls",
- "tls.Config": "crypto/tls",
- "tls.Conn": "crypto/tls",
- "tls.ConnectionState": "crypto/tls",
- "tls.Dial": "crypto/tls",
- "tls.Listen": "crypto/tls",
- "tls.LoadX509KeyPair": "crypto/tls",
- "tls.NewListener": "crypto/tls",
- "tls.NoClientCert": "crypto/tls",
- "tls.RequestClientCert": "crypto/tls",
- "tls.RequireAndVerifyClientCert": "crypto/tls",
- "tls.RequireAnyClientCert": "crypto/tls",
- "tls.Server": "crypto/tls",
- "tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA": "crypto/tls",
- "tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256": "crypto/tls",
- "tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA": "crypto/tls",
- "tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA": "crypto/tls",
- "tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA": "crypto/tls",
- "tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA": "crypto/tls",
- "tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256": "crypto/tls",
- "tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA": "crypto/tls",
- "tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA": "crypto/tls",
- "tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA": "crypto/tls",
- "tls.TLS_RSA_WITH_AES_128_CBC_SHA": "crypto/tls",
- "tls.TLS_RSA_WITH_AES_256_CBC_SHA": "crypto/tls",
- "tls.TLS_RSA_WITH_RC4_128_SHA": "crypto/tls",
- "tls.VerifyClientCertIfGiven": "crypto/tls",
- "tls.VersionSSL30": "crypto/tls",
- "tls.VersionTLS10": "crypto/tls",
- "tls.VersionTLS11": "crypto/tls",
- "tls.VersionTLS12": "crypto/tls",
- "tls.X509KeyPair": "crypto/tls",
- "token.ADD": "go/token",
- "token.ADD_ASSIGN": "go/token",
- "token.AND": "go/token",
- "token.AND_ASSIGN": "go/token",
- "token.AND_NOT": "go/token",
- "token.AND_NOT_ASSIGN": "go/token",
- "token.ARROW": "go/token",
- "token.ASSIGN": "go/token",
- "token.BREAK": "go/token",
- "token.CASE": "go/token",
- "token.CHAN": "go/token",
- "token.CHAR": "go/token",
- "token.COLON": "go/token",
- "token.COMMA": "go/token",
- "token.COMMENT": "go/token",
- "token.CONST": "go/token",
- "token.CONTINUE": "go/token",
- "token.DEC": "go/token",
- "token.DEFAULT": "go/token",
- "token.DEFER": "go/token",
- "token.DEFINE": "go/token",
- "token.ELLIPSIS": "go/token",
- "token.ELSE": "go/token",
- "token.EOF": "go/token",
- "token.EQL": "go/token",
- "token.FALLTHROUGH": "go/token",
- "token.FLOAT": "go/token",
- "token.FOR": "go/token",
- "token.FUNC": "go/token",
- "token.File": "go/token",
- "token.FileSet": "go/token",
- "token.GEQ": "go/token",
- "token.GO": "go/token",
- "token.GOTO": "go/token",
- "token.GTR": "go/token",
- "token.HighestPrec": "go/token",
- "token.IDENT": "go/token",
- "token.IF": "go/token",
- "token.ILLEGAL": "go/token",
- "token.IMAG": "go/token",
- "token.IMPORT": "go/token",
- "token.INC": "go/token",
- "token.INT": "go/token",
- "token.INTERFACE": "go/token",
- "token.LAND": "go/token",
- "token.LBRACE": "go/token",
- "token.LBRACK": "go/token",
- "token.LEQ": "go/token",
- "token.LOR": "go/token",
- "token.LPAREN": "go/token",
- "token.LSS": "go/token",
- "token.Lookup": "go/token",
- "token.LowestPrec": "go/token",
- "token.MAP": "go/token",
- "token.MUL": "go/token",
- "token.MUL_ASSIGN": "go/token",
- "token.NEQ": "go/token",
- "token.NOT": "go/token",
- "token.NewFileSet": "go/token",
- "token.NoPos": "go/token",
- "token.OR": "go/token",
- "token.OR_ASSIGN": "go/token",
- "token.PACKAGE": "go/token",
- "token.PERIOD": "go/token",
- "token.Pos": "go/token",
- "token.Position": "go/token",
- "token.QUO": "go/token",
- "token.QUO_ASSIGN": "go/token",
- "token.RANGE": "go/token",
- "token.RBRACE": "go/token",
- "token.RBRACK": "go/token",
- "token.REM": "go/token",
- "token.REM_ASSIGN": "go/token",
- "token.RETURN": "go/token",
- "token.RPAREN": "go/token",
- "token.SELECT": "go/token",
- "token.SEMICOLON": "go/token",
- "token.SHL": "go/token",
- "token.SHL_ASSIGN": "go/token",
- "token.SHR": "go/token",
- "token.SHR_ASSIGN": "go/token",
- "token.STRING": "go/token",
- "token.STRUCT": "go/token",
- "token.SUB": "go/token",
- "token.SUB_ASSIGN": "go/token",
- "token.SWITCH": "go/token",
- "token.TYPE": "go/token",
- "token.Token": "go/token",
- "token.UnaryPrec": "go/token",
- "token.VAR": "go/token",
- "token.XOR": "go/token",
- "token.XOR_ASSIGN": "go/token",
- "unicode.ASCII_Hex_Digit": "unicode",
- "unicode.Arabic": "unicode",
- "unicode.Armenian": "unicode",
- "unicode.Avestan": "unicode",
- "unicode.AzeriCase": "unicode",
- "unicode.Balinese": "unicode",
- "unicode.Bamum": "unicode",
- "unicode.Batak": "unicode",
- "unicode.Bengali": "unicode",
- "unicode.Bidi_Control": "unicode",
- "unicode.Bopomofo": "unicode",
- "unicode.Brahmi": "unicode",
- "unicode.Braille": "unicode",
- "unicode.Buginese": "unicode",
- "unicode.Buhid": "unicode",
- "unicode.C": "unicode",
- "unicode.Canadian_Aboriginal": "unicode",
- "unicode.Carian": "unicode",
- "unicode.CaseRange": "unicode",
- "unicode.CaseRanges": "unicode",
- "unicode.Categories": "unicode",
- "unicode.Cc": "unicode",
- "unicode.Cf": "unicode",
- "unicode.Chakma": "unicode",
- "unicode.Cham": "unicode",
- "unicode.Cherokee": "unicode",
- "unicode.Co": "unicode",
- "unicode.Common": "unicode",
- "unicode.Coptic": "unicode",
- "unicode.Cs": "unicode",
- "unicode.Cuneiform": "unicode",
- "unicode.Cypriot": "unicode",
- "unicode.Cyrillic": "unicode",
- "unicode.Dash": "unicode",
- "unicode.Deprecated": "unicode",
- "unicode.Deseret": "unicode",
- "unicode.Devanagari": "unicode",
- "unicode.Diacritic": "unicode",
- "unicode.Digit": "unicode",
- "unicode.Egyptian_Hieroglyphs": "unicode",
- "unicode.Ethiopic": "unicode",
- "unicode.Extender": "unicode",
- "unicode.FoldCategory": "unicode",
- "unicode.FoldScript": "unicode",
- "unicode.Georgian": "unicode",
- "unicode.Glagolitic": "unicode",
- "unicode.Gothic": "unicode",
- "unicode.GraphicRanges": "unicode",
- "unicode.Greek": "unicode",
- "unicode.Gujarati": "unicode",
- "unicode.Gurmukhi": "unicode",
- "unicode.Han": "unicode",
- "unicode.Hangul": "unicode",
- "unicode.Hanunoo": "unicode",
- "unicode.Hebrew": "unicode",
- "unicode.Hex_Digit": "unicode",
- "unicode.Hiragana": "unicode",
- "unicode.Hyphen": "unicode",
- "unicode.IDS_Binary_Operator": "unicode",
- "unicode.IDS_Trinary_Operator": "unicode",
- "unicode.Ideographic": "unicode",
- "unicode.Imperial_Aramaic": "unicode",
- "unicode.In": "unicode",
- "unicode.Inherited": "unicode",
- "unicode.Inscriptional_Pahlavi": "unicode",
- "unicode.Inscriptional_Parthian": "unicode",
- "unicode.Is": "unicode",
- "unicode.IsControl": "unicode",
- "unicode.IsDigit": "unicode",
- "unicode.IsGraphic": "unicode",
- "unicode.IsLetter": "unicode",
- "unicode.IsLower": "unicode",
- "unicode.IsMark": "unicode",
- "unicode.IsNumber": "unicode",
- "unicode.IsOneOf": "unicode",
- "unicode.IsPrint": "unicode",
- "unicode.IsPunct": "unicode",
- "unicode.IsSpace": "unicode",
- "unicode.IsSymbol": "unicode",
- "unicode.IsTitle": "unicode",
- "unicode.IsUpper": "unicode",
- "unicode.Javanese": "unicode",
- "unicode.Join_Control": "unicode",
- "unicode.Kaithi": "unicode",
- "unicode.Kannada": "unicode",
- "unicode.Katakana": "unicode",
- "unicode.Kayah_Li": "unicode",
- "unicode.Kharoshthi": "unicode",
- "unicode.Khmer": "unicode",
- "unicode.L": "unicode",
- "unicode.Lao": "unicode",
- "unicode.Latin": "unicode",
- "unicode.Lepcha": "unicode",
- "unicode.Letter": "unicode",
- "unicode.Limbu": "unicode",
- "unicode.Linear_B": "unicode",
- "unicode.Lisu": "unicode",
- "unicode.Ll": "unicode",
- "unicode.Lm": "unicode",
- "unicode.Lo": "unicode",
- "unicode.Logical_Order_Exception": "unicode",
- "unicode.Lower": "unicode",
- "unicode.LowerCase": "unicode",
- "unicode.Lt": "unicode",
- "unicode.Lu": "unicode",
- "unicode.Lycian": "unicode",
- "unicode.Lydian": "unicode",
- "unicode.M": "unicode",
- "unicode.Malayalam": "unicode",
- "unicode.Mandaic": "unicode",
- "unicode.Mark": "unicode",
- "unicode.MaxASCII": "unicode",
- "unicode.MaxCase": "unicode",
- "unicode.MaxLatin1": "unicode",
- "unicode.MaxRune": "unicode",
- "unicode.Mc": "unicode",
- "unicode.Me": "unicode",
- "unicode.Meetei_Mayek": "unicode",
- "unicode.Meroitic_Cursive": "unicode",
- "unicode.Meroitic_Hieroglyphs": "unicode",
- "unicode.Miao": "unicode",
- "unicode.Mn": "unicode",
- "unicode.Mongolian": "unicode",
- "unicode.Myanmar": "unicode",
- "unicode.N": "unicode",
- "unicode.Nd": "unicode",
- "unicode.New_Tai_Lue": "unicode",
- "unicode.Nko": "unicode",
- "unicode.Nl": "unicode",
- "unicode.No": "unicode",
- "unicode.Noncharacter_Code_Point": "unicode",
- "unicode.Number": "unicode",
- "unicode.Ogham": "unicode",
- "unicode.Ol_Chiki": "unicode",
- "unicode.Old_Italic": "unicode",
- "unicode.Old_Persian": "unicode",
- "unicode.Old_South_Arabian": "unicode",
- "unicode.Old_Turkic": "unicode",
- "unicode.Oriya": "unicode",
- "unicode.Osmanya": "unicode",
- "unicode.Other": "unicode",
- "unicode.Other_Alphabetic": "unicode",
- "unicode.Other_Default_Ignorable_Code_Point": "unicode",
- "unicode.Other_Grapheme_Extend": "unicode",
- "unicode.Other_ID_Continue": "unicode",
- "unicode.Other_ID_Start": "unicode",
- "unicode.Other_Lowercase": "unicode",
- "unicode.Other_Math": "unicode",
- "unicode.Other_Uppercase": "unicode",
- "unicode.P": "unicode",
- "unicode.Pattern_Syntax": "unicode",
- "unicode.Pattern_White_Space": "unicode",
- "unicode.Pc": "unicode",
- "unicode.Pd": "unicode",
- "unicode.Pe": "unicode",
- "unicode.Pf": "unicode",
- "unicode.Phags_Pa": "unicode",
- "unicode.Phoenician": "unicode",
- "unicode.Pi": "unicode",
- "unicode.Po": "unicode",
- "unicode.PrintRanges": "unicode",
- "unicode.Properties": "unicode",
- "unicode.Ps": "unicode",
- "unicode.Punct": "unicode",
- "unicode.Quotation_Mark": "unicode",
- "unicode.Radical": "unicode",
- "unicode.Range16": "unicode",
- "unicode.Range32": "unicode",
- "unicode.RangeTable": "unicode",
- "unicode.Rejang": "unicode",
- "unicode.ReplacementChar": "unicode",
- "unicode.Runic": "unicode",
- "unicode.S": "unicode",
- "unicode.STerm": "unicode",
- "unicode.Samaritan": "unicode",
- "unicode.Saurashtra": "unicode",
- "unicode.Sc": "unicode",
- "unicode.Scripts": "unicode",
- "unicode.Sharada": "unicode",
- "unicode.Shavian": "unicode",
- "unicode.SimpleFold": "unicode",
- "unicode.Sinhala": "unicode",
- "unicode.Sk": "unicode",
- "unicode.Sm": "unicode",
- "unicode.So": "unicode",
- "unicode.Soft_Dotted": "unicode",
- "unicode.Sora_Sompeng": "unicode",
- "unicode.Space": "unicode",
- "unicode.SpecialCase": "unicode",
- "unicode.Sundanese": "unicode",
- "unicode.Syloti_Nagri": "unicode",
- "unicode.Symbol": "unicode",
- "unicode.Syriac": "unicode",
- "unicode.Tagalog": "unicode",
- "unicode.Tagbanwa": "unicode",
- "unicode.Tai_Le": "unicode",
- "unicode.Tai_Tham": "unicode",
- "unicode.Tai_Viet": "unicode",
- "unicode.Takri": "unicode",
- "unicode.Tamil": "unicode",
- "unicode.Telugu": "unicode",
- "unicode.Terminal_Punctuation": "unicode",
- "unicode.Thaana": "unicode",
- "unicode.Thai": "unicode",
- "unicode.Tibetan": "unicode",
- "unicode.Tifinagh": "unicode",
- "unicode.Title": "unicode",
- "unicode.TitleCase": "unicode",
- "unicode.To": "unicode",
- "unicode.ToLower": "unicode",
- "unicode.ToTitle": "unicode",
- "unicode.ToUpper": "unicode",
- "unicode.TurkishCase": "unicode",
- "unicode.Ugaritic": "unicode",
- "unicode.Unified_Ideograph": "unicode",
- "unicode.Upper": "unicode",
- "unicode.UpperCase": "unicode",
- "unicode.UpperLower": "unicode",
- "unicode.Vai": "unicode",
- "unicode.Variation_Selector": "unicode",
- "unicode.Version": "unicode",
- "unicode.White_Space": "unicode",
- "unicode.Yi": "unicode",
- "unicode.Z": "unicode",
- "unicode.Zl": "unicode",
- "unicode.Zp": "unicode",
- "unicode.Zs": "unicode",
- "url.Error": "net/url",
- "url.EscapeError": "net/url",
- "url.Parse": "net/url",
- "url.ParseQuery": "net/url",
- "url.ParseRequestURI": "net/url",
- "url.QueryEscape": "net/url",
- "url.QueryUnescape": "net/url",
- "url.URL": "net/url",
- "url.User": "net/url",
- "url.UserPassword": "net/url",
- "url.Userinfo": "net/url",
- "url.Values": "net/url",
- "user.Current": "os/user",
- "user.Lookup": "os/user",
- "user.LookupId": "os/user",
- "user.UnknownUserError": "os/user",
- "user.UnknownUserIdError": "os/user",
- "user.User": "os/user",
- "utf16.Decode": "unicode/utf16",
- "utf16.DecodeRune": "unicode/utf16",
- "utf16.Encode": "unicode/utf16",
- "utf16.EncodeRune": "unicode/utf16",
- "utf16.IsSurrogate": "unicode/utf16",
- "utf8.DecodeLastRune": "unicode/utf8",
- "utf8.DecodeLastRuneInString": "unicode/utf8",
- "utf8.DecodeRune": "unicode/utf8",
- "utf8.DecodeRuneInString": "unicode/utf8",
- "utf8.EncodeRune": "unicode/utf8",
- "utf8.FullRune": "unicode/utf8",
- "utf8.FullRuneInString": "unicode/utf8",
- "utf8.MaxRune": "unicode/utf8",
- "utf8.RuneCount": "unicode/utf8",
- "utf8.RuneCountInString": "unicode/utf8",
- "utf8.RuneError": "unicode/utf8",
- "utf8.RuneLen": "unicode/utf8",
- "utf8.RuneSelf": "unicode/utf8",
- "utf8.RuneStart": "unicode/utf8",
- "utf8.UTFMax": "unicode/utf8",
- "utf8.Valid": "unicode/utf8",
- "utf8.ValidRune": "unicode/utf8",
- "utf8.ValidString": "unicode/utf8",
- "x509.CANotAuthorizedForThisName": "crypto/x509",
- "x509.CertPool": "crypto/x509",
- "x509.Certificate": "crypto/x509",
- "x509.CertificateInvalidError": "crypto/x509",
- "x509.ConstraintViolationError": "crypto/x509",
- "x509.CreateCertificate": "crypto/x509",
- "x509.DSA": "crypto/x509",
- "x509.DSAWithSHA1": "crypto/x509",
- "x509.DSAWithSHA256": "crypto/x509",
- "x509.DecryptPEMBlock": "crypto/x509",
- "x509.ECDSA": "crypto/x509",
- "x509.ECDSAWithSHA1": "crypto/x509",
- "x509.ECDSAWithSHA256": "crypto/x509",
- "x509.ECDSAWithSHA384": "crypto/x509",
- "x509.ECDSAWithSHA512": "crypto/x509",
- "x509.EncryptPEMBlock": "crypto/x509",
- "x509.ErrUnsupportedAlgorithm": "crypto/x509",
- "x509.Expired": "crypto/x509",
- "x509.ExtKeyUsage": "crypto/x509",
- "x509.ExtKeyUsageAny": "crypto/x509",
- "x509.ExtKeyUsageClientAuth": "crypto/x509",
- "x509.ExtKeyUsageCodeSigning": "crypto/x509",
- "x509.ExtKeyUsageEmailProtection": "crypto/x509",
- "x509.ExtKeyUsageIPSECEndSystem": "crypto/x509",
- "x509.ExtKeyUsageIPSECTunnel": "crypto/x509",
- "x509.ExtKeyUsageIPSECUser": "crypto/x509",
- "x509.ExtKeyUsageMicrosoftServerGatedCrypto": "crypto/x509",
- "x509.ExtKeyUsageNetscapeServerGatedCrypto": "crypto/x509",
- "x509.ExtKeyUsageOCSPSigning": "crypto/x509",
- "x509.ExtKeyUsageServerAuth": "crypto/x509",
- "x509.ExtKeyUsageTimeStamping": "crypto/x509",
- "x509.HostnameError": "crypto/x509",
- "x509.IncompatibleUsage": "crypto/x509",
- "x509.IncorrectPasswordError": "crypto/x509",
- "x509.InvalidReason": "crypto/x509",
- "x509.IsEncryptedPEMBlock": "crypto/x509",
- "x509.KeyUsage": "crypto/x509",
- "x509.KeyUsageCRLSign": "crypto/x509",
- "x509.KeyUsageCertSign": "crypto/x509",
- "x509.KeyUsageContentCommitment": "crypto/x509",
- "x509.KeyUsageDataEncipherment": "crypto/x509",
- "x509.KeyUsageDecipherOnly": "crypto/x509",
- "x509.KeyUsageDigitalSignature": "crypto/x509",
- "x509.KeyUsageEncipherOnly": "crypto/x509",
- "x509.KeyUsageKeyAgreement": "crypto/x509",
- "x509.KeyUsageKeyEncipherment": "crypto/x509",
- "x509.MD2WithRSA": "crypto/x509",
- "x509.MD5WithRSA": "crypto/x509",
- "x509.MarshalECPrivateKey": "crypto/x509",
- "x509.MarshalPKCS1PrivateKey": "crypto/x509",
- "x509.MarshalPKIXPublicKey": "crypto/x509",
- "x509.NewCertPool": "crypto/x509",
- "x509.NotAuthorizedToSign": "crypto/x509",
- "x509.PEMCipher": "crypto/x509",
- "x509.PEMCipher3DES": "crypto/x509",
- "x509.PEMCipherAES128": "crypto/x509",
- "x509.PEMCipherAES192": "crypto/x509",
- "x509.PEMCipherAES256": "crypto/x509",
- "x509.PEMCipherDES": "crypto/x509",
- "x509.ParseCRL": "crypto/x509",
- "x509.ParseCertificate": "crypto/x509",
- "x509.ParseCertificates": "crypto/x509",
- "x509.ParseDERCRL": "crypto/x509",
- "x509.ParseECPrivateKey": "crypto/x509",
- "x509.ParsePKCS1PrivateKey": "crypto/x509",
- "x509.ParsePKCS8PrivateKey": "crypto/x509",
- "x509.ParsePKIXPublicKey": "crypto/x509",
- "x509.PublicKeyAlgorithm": "crypto/x509",
- "x509.RSA": "crypto/x509",
- "x509.SHA1WithRSA": "crypto/x509",
- "x509.SHA256WithRSA": "crypto/x509",
- "x509.SHA384WithRSA": "crypto/x509",
- "x509.SHA512WithRSA": "crypto/x509",
- "x509.SignatureAlgorithm": "crypto/x509",
- "x509.SystemRootsError": "crypto/x509",
- "x509.TooManyIntermediates": "crypto/x509",
- "x509.UnhandledCriticalExtension": "crypto/x509",
- "x509.UnknownAuthorityError": "crypto/x509",
- "x509.UnknownPublicKeyAlgorithm": "crypto/x509",
- "x509.UnknownSignatureAlgorithm": "crypto/x509",
- "x509.VerifyOptions": "crypto/x509",
- "xml.Attr": "encoding/xml",
- "xml.CharData": "encoding/xml",
- "xml.Comment": "encoding/xml",
- "xml.CopyToken": "encoding/xml",
- "xml.Decoder": "encoding/xml",
- "xml.Directive": "encoding/xml",
- "xml.Encoder": "encoding/xml",
- "xml.EndElement": "encoding/xml",
- "xml.Escape": "encoding/xml",
- "xml.EscapeText": "encoding/xml",
- "xml.HTMLAutoClose": "encoding/xml",
- "xml.HTMLEntity": "encoding/xml",
- "xml.Header": "encoding/xml",
- "xml.Marshal": "encoding/xml",
- "xml.MarshalIndent": "encoding/xml",
- "xml.Marshaler": "encoding/xml",
- "xml.MarshalerAttr": "encoding/xml",
- "xml.Name": "encoding/xml",
- "xml.NewDecoder": "encoding/xml",
- "xml.NewEncoder": "encoding/xml",
- "xml.ProcInst": "encoding/xml",
- "xml.StartElement": "encoding/xml",
- "xml.SyntaxError": "encoding/xml",
- "xml.TagPathError": "encoding/xml",
- "xml.Token": "encoding/xml",
- "xml.Unmarshal": "encoding/xml",
- "xml.UnmarshalError": "encoding/xml",
- "xml.Unmarshaler": "encoding/xml",
- "xml.UnmarshalerAttr": "encoding/xml",
- "xml.UnsupportedTypeError": "encoding/xml",
- "zip.Compressor": "archive/zip",
- "zip.Decompressor": "archive/zip",
- "zip.Deflate": "archive/zip",
- "zip.ErrAlgorithm": "archive/zip",
- "zip.ErrChecksum": "archive/zip",
- "zip.ErrFormat": "archive/zip",
- "zip.File": "archive/zip",
- "zip.FileHeader": "archive/zip",
- "zip.FileInfoHeader": "archive/zip",
- "zip.NewReader": "archive/zip",
- "zip.NewWriter": "archive/zip",
- "zip.OpenReader": "archive/zip",
- "zip.ReadCloser": "archive/zip",
- "zip.Reader": "archive/zip",
- "zip.RegisterCompressor": "archive/zip",
- "zip.RegisterDecompressor": "archive/zip",
- "zip.Store": "archive/zip",
- "zip.Writer": "archive/zip",
- "zlib.BestCompression": "compress/zlib",
- "zlib.BestSpeed": "compress/zlib",
- "zlib.DefaultCompression": "compress/zlib",
- "zlib.ErrChecksum": "compress/zlib",
- "zlib.ErrDictionary": "compress/zlib",
- "zlib.ErrHeader": "compress/zlib",
- "zlib.NewReader": "compress/zlib",
- "zlib.NewReaderDict": "compress/zlib",
- "zlib.NewWriter": "compress/zlib",
- "zlib.NewWriterLevel": "compress/zlib",
- "zlib.NewWriterLevelDict": "compress/zlib",
- "zlib.NoCompression": "compress/zlib",
- "zlib.Writer": "compress/zlib",
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/TODO b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/TODO
deleted file mode 100644
index 014f8044..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/TODO
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-ORACLE TODO
-===========
-
-General
-=======
-
-Refactor control flow so that each mode has a "one-shot setup" function.
-
-Use a fault-tolerant parser that can recover from bad parses.
-
-Save unsaved editor buffers into an archive and provide that to the
-tools, which should act as if they were saved.
-
-Fix: make the guessImportPath hack work with external _test.go files too.
-
-Allow the analysis scope to include multiple test packages at once.
-
-Include complete pos/end information Serial output.
- But beware that sometimes a single token (e.g. +) is more helpful
- than the pos/end of the containing expression (e.g. x \n + \n y).
-
-Remove pointer analysis context information when printing results as
-it tends to be unhelpful.
-
-Specific queries
-================
-
-callers, callees
-
- Use a type-based (e.g. RTA) callgraph when a callers/callees query is
- outside the analysis scope.
-
-implements
-
- Make it require that the selection is a type, and show only the
- implements relation as it applies to that type.
-
-definition, referrers
-
- Use the parser's resolver information to answer the query
- for local names. Only run the type checker if that fails.
- (NB: gri's new parser won't do any resolution.)
-
- referrers: Show the text of the matching line of code, like grep.
-
- definition: Make it work with qualified identifiers (SelectorExpr) too.
-
- references: Make it work on things that are implicit idents, like
- import specs, perhaps?
-
-what
-
- Report def/ref info if available.
- Editors could use it to highlight all idents of the same local var.
-
- Fix: support it in (*Oracle).Query (long-running tools).
-
- More tests.
-
-pointsto
-
- When invoked on a function Ident, we get an error.
-
- When invoked on a named return parameter, we get an error.
-
-describe
-
- When invoked on a var, we want to see the type and its methods.
-
- Split "show type" and "describe syntax" into separate commands?
-
-peers
-
- Permit querying from a makechan, close(), for...range, or reflective op.
-
- Report aliasing reflect.{Send,Recv,Close} and close() operations.
-
-New queries
-
-"updaters": show all statements that may update the selected lvalue
- (local, global, field, etc).
-
-"creators": show all places where an object of type T is created
- (&T{}, var t T, new(T), new(struct{array [3]T}), etc.
- (Useful for datatypes whose zero value is not safe)
-
-
-Editor-specific
-===============
-
-Add support for "what" to .el; clean up.
-
-Emacs: use JSON to get the raw information from the oracle. Don't
- open an editor buffer for simpler queries, just jump to the result
- and/or display it in the modeline.
-
-Emacs: go-root-and-paths depends on the current buffer, so be sure to
- call it from within the source file, not the *go-oracle* buffer:
- the user may have switched workspaces and the oracle should run in
- the new one.
-
-Support other editors: vim, Eclipse, Sublime, etc.
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callees.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callees.go
deleted file mode 100644
index a900b7b3..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callees.go
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- "sort"
-
- "code.google.com/p/go.tools/go/ssa"
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// Callees reports the possible callees of the function call site
-// identified by the specified source location.
-func callees(o *Oracle, qpos *QueryPos) (queryResult, error) {
- pkg := o.prog.Package(qpos.info.Pkg)
- if pkg == nil {
- return nil, fmt.Errorf("no SSA package")
- }
-
- // Determine the enclosing call for the specified position.
- var e *ast.CallExpr
- for _, n := range qpos.path {
- if e, _ = n.(*ast.CallExpr); e != nil {
- break
- }
- }
- if e == nil {
- return nil, fmt.Errorf("there is no function call here")
- }
- // TODO(adonovan): issue an error if the call is "too far
- // away" from the current selection, as this most likely is
- // not what the user intended.
-
- // Reject type conversions.
- if qpos.info.IsType(e.Fun) {
- return nil, fmt.Errorf("this is a type conversion, not a function call")
- }
-
- // Reject calls to built-ins.
- if id, ok := unparen(e.Fun).(*ast.Ident); ok {
- if b, ok := qpos.info.ObjectOf(id).(*types.Builtin); ok {
- return nil, fmt.Errorf("this is a call to the built-in '%s' operator", b.Name())
- }
- }
-
- buildSSA(o)
-
- // Ascertain calling function and call site.
- callerFn := ssa.EnclosingFunction(pkg, qpos.path)
- if callerFn == nil {
- return nil, fmt.Errorf("no SSA function built for this location (dead code?)")
- }
-
- // Find the call site.
- site, err := findCallSite(callerFn, e.Lparen)
- if err != nil {
- return nil, err
- }
-
- funcs, err := findCallees(o, site)
- if err != nil {
- return nil, err
- }
-
- return &calleesResult{
- site: site,
- funcs: funcs,
- }, nil
-}
-
-func findCallSite(fn *ssa.Function, lparen token.Pos) (ssa.CallInstruction, error) {
- for _, b := range fn.Blocks {
- for _, instr := range b.Instrs {
- if site, ok := instr.(ssa.CallInstruction); ok && instr.Pos() == lparen {
- return site, nil
- }
- }
- }
- return nil, fmt.Errorf("this call site is unreachable in this analysis")
-}
-
-func findCallees(o *Oracle, site ssa.CallInstruction) ([]*ssa.Function, error) {
- // Avoid running the pointer analysis for static calls.
- if callee := site.Common().StaticCallee(); callee != nil {
- switch callee.String() {
- case "runtime.SetFinalizer", "(reflect.Value).Call":
- // The PTA treats calls to these intrinsics as dynamic.
- // TODO(adonovan): avoid reliance on PTA internals.
-
- default:
- return []*ssa.Function{callee}, nil // singleton
- }
- }
-
- // Dynamic call: use pointer analysis.
- o.ptaConfig.BuildCallGraph = true
- cg := ptrAnalysis(o).CallGraph
- cg.DeleteSyntheticNodes()
-
- // Find all call edges from the site.
- n := cg.Nodes[site.Parent()]
- if n == nil {
- return nil, fmt.Errorf("this call site is unreachable in this analysis")
- }
- calleesMap := make(map[*ssa.Function]bool)
- for _, edge := range n.Out {
- if edge.Site == site {
- calleesMap[edge.Callee.Func] = true
- }
- }
-
- // De-duplicate and sort.
- funcs := make([]*ssa.Function, 0, len(calleesMap))
- for f := range calleesMap {
- funcs = append(funcs, f)
- }
- sort.Sort(byFuncPos(funcs))
- return funcs, nil
-}
-
-type calleesResult struct {
- site ssa.CallInstruction
- funcs []*ssa.Function
-}
-
-func (r *calleesResult) display(printf printfFunc) {
- if len(r.funcs) == 0 {
- // dynamic call on a provably nil func/interface
- printf(r.site, "%s on nil value", r.site.Common().Description())
- } else {
- printf(r.site, "this %s dispatches to:", r.site.Common().Description())
- for _, callee := range r.funcs {
- printf(callee, "\t%s", callee)
- }
- }
-}
-
-func (r *calleesResult) toSerial(res *serial.Result, fset *token.FileSet) {
- j := &serial.Callees{
- Pos: fset.Position(r.site.Pos()).String(),
- Desc: r.site.Common().Description(),
- }
- for _, callee := range r.funcs {
- j.Callees = append(j.Callees, &serial.CalleesItem{
- Name: callee.String(),
- Pos: fset.Position(callee.Pos()).String(),
- })
- }
- res.Callees = j
-}
-
-type byFuncPos []*ssa.Function
-
-func (a byFuncPos) Len() int { return len(a) }
-func (a byFuncPos) Less(i, j int) bool { return a[i].Pos() < a[j].Pos() }
-func (a byFuncPos) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callers.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callers.go
deleted file mode 100644
index ac3d37b4..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callers.go
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/token"
-
- "code.google.com/p/go.tools/go/callgraph"
- "code.google.com/p/go.tools/go/ssa"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// Callers reports the possible callers of the function
-// immediately enclosing the specified source location.
-//
-func callers(o *Oracle, qpos *QueryPos) (queryResult, error) {
- pkg := o.prog.Package(qpos.info.Pkg)
- if pkg == nil {
- return nil, fmt.Errorf("no SSA package")
- }
- if !ssa.HasEnclosingFunction(pkg, qpos.path) {
- return nil, fmt.Errorf("this position is not inside a function")
- }
-
- buildSSA(o)
-
- target := ssa.EnclosingFunction(pkg, qpos.path)
- if target == nil {
- return nil, fmt.Errorf("no SSA function built for this location (dead code?)")
- }
-
- // Run the pointer analysis, recording each
- // call found to originate from target.
- o.ptaConfig.BuildCallGraph = true
- cg := ptrAnalysis(o).CallGraph
- cg.DeleteSyntheticNodes()
- edges := cg.CreateNode(target).In
- // TODO(adonovan): sort + dedup calls to ensure test determinism.
-
- return &callersResult{
- target: target,
- callgraph: cg,
- edges: edges,
- }, nil
-}
-
-type callersResult struct {
- target *ssa.Function
- callgraph *callgraph.Graph
- edges []*callgraph.Edge
-}
-
-func (r *callersResult) display(printf printfFunc) {
- root := r.callgraph.Root
- if r.edges == nil {
- printf(r.target, "%s is not reachable in this program.", r.target)
- } else {
- printf(r.target, "%s is called from these %d sites:", r.target, len(r.edges))
- for _, edge := range r.edges {
- if edge.Caller == root {
- printf(r.target, "the root of the call graph")
- } else {
- printf(edge.Site, "\t%s from %s", edge.Site.Common().Description(), edge.Caller.Func)
- }
- }
- }
-}
-
-func (r *callersResult) toSerial(res *serial.Result, fset *token.FileSet) {
- root := r.callgraph.Root
- var callers []serial.Caller
- for _, edge := range r.edges {
- var c serial.Caller
- c.Caller = edge.Caller.Func.String()
- if edge.Caller == root {
- c.Desc = "synthetic call"
- } else {
- c.Pos = fset.Position(edge.Site.Pos()).String()
- c.Desc = edge.Site.Common().Description()
- }
- callers = append(callers, c)
- }
- res.Callers = callers
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callgraph.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callgraph.go
deleted file mode 100644
index 1de25cd0..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callgraph.go
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/token"
- "sort"
-
- "code.google.com/p/go.tools/go/callgraph"
- "code.google.com/p/go.tools/go/ssa"
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// doCallgraph displays the entire callgraph of the current program,
-// or if a query -pos was provided, the query package.
-func doCallgraph(o *Oracle, qpos *QueryPos) (queryResult, error) {
- buildSSA(o)
-
- // Run the pointer analysis and build the callgraph.
- o.ptaConfig.BuildCallGraph = true
- cg := ptrAnalysis(o).CallGraph
- cg.DeleteSyntheticNodes()
-
- var qpkg *types.Package
- var roots []*callgraph.Node
- if qpos == nil {
- // No -pos provided: show complete callgraph.
- roots = append(roots, cg.Root)
-
- } else {
- // A query -pos was provided: restrict result to
- // functions belonging to the query package.
- qpkg = qpos.info.Pkg
- isQueryPkg := func(fn *ssa.Function) bool {
- return fn.Pkg != nil && fn.Pkg.Object == qpkg
- }
-
- // First compute the nodes to keep and remove.
- var nodes, remove []*callgraph.Node
- for fn, cgn := range cg.Nodes {
- if isQueryPkg(fn) {
- nodes = append(nodes, cgn)
- } else {
- remove = append(remove, cgn)
- }
- }
-
- // Compact the Node.ID sequence of the remaining
- // nodes, preserving the original order.
- sort.Sort(nodesByID(nodes))
- for i, cgn := range nodes {
- cgn.ID = i
- }
-
- // Compute the set of roots:
- // in-package nodes with out-of-package callers.
- // For determinism, roots are ordered by original Node.ID.
- for _, cgn := range nodes {
- for _, e := range cgn.In {
- if !isQueryPkg(e.Caller.Func) {
- roots = append(roots, cgn)
- break
- }
- }
- }
-
- // Finally, discard all out-of-package nodes.
- for _, cgn := range remove {
- cg.DeleteNode(cgn)
- }
- }
-
- return &callgraphResult{qpkg, cg.Nodes, roots}, nil
-}
-
-type callgraphResult struct {
- qpkg *types.Package
- nodes map[*ssa.Function]*callgraph.Node
- roots []*callgraph.Node
-}
-
-func (r *callgraphResult) display(printf printfFunc) {
- descr := "the entire program"
- if r.qpkg != nil {
- descr = fmt.Sprintf("package %s", r.qpkg.Path())
- }
-
- printf(nil, `
-Below is a call graph of %s.
-The numbered nodes form a spanning tree.
-Non-numbered nodes indicate back- or cross-edges to the node whose
- number follows in parentheses.
-`, descr)
-
- printed := make(map[*callgraph.Node]int)
- var print func(caller *callgraph.Node, indent int)
- print = func(caller *callgraph.Node, indent int) {
- if num, ok := printed[caller]; !ok {
- num = len(printed)
- printed[caller] = num
-
- // Sort the children into name order for deterministic* output.
- // (*mostly: anon funcs' names are not globally unique.)
- var funcs funcsByName
- for callee := range callgraph.CalleesOf(caller) {
- funcs = append(funcs, callee.Func)
- }
- sort.Sort(funcs)
-
- printf(caller.Func, "%d\t%*s%s", num, 4*indent, "", caller.Func.RelString(r.qpkg))
- for _, callee := range funcs {
- print(r.nodes[callee], indent+1)
- }
- } else {
- printf(caller.Func, "\t%*s%s (%d)", 4*indent, "", caller.Func.RelString(r.qpkg), num)
- }
- }
- for _, root := range r.roots {
- print(root, 0)
- }
-}
-
-type nodesByID []*callgraph.Node
-
-func (s nodesByID) Len() int { return len(s) }
-func (s nodesByID) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
-func (s nodesByID) Less(i, j int) bool { return s[i].ID < s[j].ID }
-
-type funcsByName []*ssa.Function
-
-func (s funcsByName) Len() int { return len(s) }
-func (s funcsByName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
-func (s funcsByName) Less(i, j int) bool { return s[i].String() < s[j].String() }
-
-func (r *callgraphResult) toSerial(res *serial.Result, fset *token.FileSet) {
- cg := make([]serial.CallGraph, len(r.nodes))
- for _, n := range r.nodes {
- j := &cg[n.ID]
- fn := n.Func
- j.Name = fn.String()
- j.Pos = fset.Position(fn.Pos()).String()
- for callee := range callgraph.CalleesOf(n) {
- j.Children = append(j.Children, callee.ID)
- }
- sort.Ints(j.Children)
- }
- res.Callgraph = cg
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callstack.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callstack.go
deleted file mode 100644
index e71e09ec..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/callstack.go
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/token"
-
- "code.google.com/p/go.tools/go/callgraph"
- "code.google.com/p/go.tools/go/ssa"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// Callstack displays an arbitrary path from a root of the callgraph
-// to the function at the current position.
-//
-// The information may be misleading in a context-insensitive
-// analysis. e.g. the call path X->Y->Z might be infeasible if Y never
-// calls Z when it is called from X. TODO(adonovan): think about UI.
-//
-// TODO(adonovan): permit user to specify a starting point other than
-// the analysis root.
-//
-func callstack(o *Oracle, qpos *QueryPos) (queryResult, error) {
- pkg := o.prog.Package(qpos.info.Pkg)
- if pkg == nil {
- return nil, fmt.Errorf("no SSA package")
- }
-
- if !ssa.HasEnclosingFunction(pkg, qpos.path) {
- return nil, fmt.Errorf("this position is not inside a function")
- }
-
- buildSSA(o)
-
- target := ssa.EnclosingFunction(pkg, qpos.path)
- if target == nil {
- return nil, fmt.Errorf("no SSA function built for this location (dead code?)")
- }
-
- // Run the pointer analysis and build the complete call graph.
- o.ptaConfig.BuildCallGraph = true
- cg := ptrAnalysis(o).CallGraph
- cg.DeleteSyntheticNodes()
-
- // Search for an arbitrary path from a root to the target function.
- isEnd := func(n *callgraph.Node) bool { return n.Func == target }
- callpath := callgraph.PathSearch(cg.Root, isEnd)
- if callpath != nil {
- callpath = callpath[1:] // remove synthetic edge from
- }
-
- return &callstackResult{
- qpos: qpos,
- target: target,
- callpath: callpath,
- }, nil
-}
-
-type callstackResult struct {
- qpos *QueryPos
- target *ssa.Function
- callpath []*callgraph.Edge
-}
-
-func (r *callstackResult) display(printf printfFunc) {
- if r.callpath != nil {
- printf(r.qpos, "Found a call path from root to %s", r.target)
- printf(r.target, "%s", r.target)
- for i := len(r.callpath) - 1; i >= 0; i-- {
- edge := r.callpath[i]
- printf(edge.Site, "%s from %s", edge.Site.Common().Description(), edge.Caller.Func)
- }
- } else {
- printf(r.target, "%s is unreachable in this analysis scope", r.target)
- }
-}
-
-func (r *callstackResult) toSerial(res *serial.Result, fset *token.FileSet) {
- var callers []serial.Caller
- for i := len(r.callpath) - 1; i >= 0; i-- { // (innermost first)
- edge := r.callpath[i]
- callers = append(callers, serial.Caller{
- Pos: fset.Position(edge.Site.Pos()).String(),
- Caller: edge.Caller.Func.String(),
- Desc: edge.Site.Common().Description(),
- })
- }
- res.Callstack = &serial.CallStack{
- Pos: fset.Position(r.target.Pos()).String(),
- Target: r.target.String(),
- Callers: callers,
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/definition.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/definition.go
deleted file mode 100644
index 16ba5eb3..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/definition.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/ast"
- "go/token"
-
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// definition reports the location of the definition of an identifier.
-//
-// TODO(adonovan): opt: for intra-file references, the parser's
-// resolution might be enough; we should start with that.
-//
-func definition(o *Oracle, qpos *QueryPos) (queryResult, error) {
- id, _ := qpos.path[0].(*ast.Ident)
- if id == nil {
- return nil, fmt.Errorf("no identifier here")
- }
-
- obj := qpos.info.ObjectOf(id)
- if obj == nil {
- // Happens for y in "switch y := x.(type)", but I think that's all.
- return nil, fmt.Errorf("no object for identifier")
- }
-
- return &definitionResult{qpos, obj}, nil
-}
-
-type definitionResult struct {
- qpos *QueryPos
- obj types.Object // object it denotes
-}
-
-func (r *definitionResult) display(printf printfFunc) {
- printf(r.obj, "defined here as %s", r.qpos.ObjectString(r.obj))
-}
-
-func (r *definitionResult) toSerial(res *serial.Result, fset *token.FileSet) {
- definition := &serial.Definition{
- Desc: r.obj.String(),
- }
- if pos := r.obj.Pos(); pos != token.NoPos { // Package objects have no Pos()
- definition.ObjPos = fset.Position(pos).String()
- }
- res.Definition = definition
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/describe.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/describe.go
deleted file mode 100644
index 149172cd..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/describe.go
+++ /dev/null
@@ -1,736 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "bytes"
- "fmt"
- "go/ast"
- "go/token"
- "os"
- "strings"
-
- "code.google.com/p/go.tools/astutil"
- "code.google.com/p/go.tools/go/exact"
- "code.google.com/p/go.tools/go/loader"
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/go/types/typeutil"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// describe describes the syntax node denoted by the query position,
-// including:
-// - its syntactic category
-// - the definition of its referent (for identifiers) [now redundant]
-// - its type and method set (for an expression or type expression)
-//
-func describe(o *Oracle, qpos *QueryPos) (queryResult, error) {
- if false { // debugging
- fprintf(os.Stderr, o.fset, qpos.path[0], "you selected: %s %s",
- astutil.NodeDescription(qpos.path[0]), pathToString(qpos.path))
- }
-
- path, action := findInterestingNode(qpos.info, qpos.path)
- switch action {
- case actionExpr:
- return describeValue(o, qpos, path)
-
- case actionType:
- return describeType(o, qpos, path)
-
- case actionPackage:
- return describePackage(o, qpos, path)
-
- case actionStmt:
- return describeStmt(o, qpos, path)
-
- case actionUnknown:
- return &describeUnknownResult{path[0]}, nil
-
- default:
- panic(action) // unreachable
- }
-}
-
-type describeUnknownResult struct {
- node ast.Node
-}
-
-func (r *describeUnknownResult) display(printf printfFunc) {
- // Nothing much to say about misc syntax.
- printf(r.node, "%s", astutil.NodeDescription(r.node))
-}
-
-func (r *describeUnknownResult) toSerial(res *serial.Result, fset *token.FileSet) {
- res.Describe = &serial.Describe{
- Desc: astutil.NodeDescription(r.node),
- Pos: fset.Position(r.node.Pos()).String(),
- }
-}
-
-type action int
-
-const (
- actionUnknown action = iota // None of the below
- actionExpr // FuncDecl, true Expr or Ident(types.{Const,Var})
- actionType // type Expr or Ident(types.TypeName).
- actionStmt // Stmt or Ident(types.Label)
- actionPackage // Ident(types.Package) or ImportSpec
-)
-
-// findInterestingNode classifies the syntax node denoted by path as one of:
-// - an expression, part of an expression or a reference to a constant
-// or variable;
-// - a type, part of a type, or a reference to a named type;
-// - a statement, part of a statement, or a label referring to a statement;
-// - part of a package declaration or import spec.
-// - none of the above.
-// and returns the most "interesting" associated node, which may be
-// the same node, an ancestor or a descendent.
-//
-func findInterestingNode(pkginfo *loader.PackageInfo, path []ast.Node) ([]ast.Node, action) {
- // TODO(adonovan): integrate with go/types/stdlib_test.go and
- // apply this to every AST node we can find to make sure it
- // doesn't crash.
-
- // TODO(adonovan): audit for ParenExpr safety, esp. since we
- // traverse up and down.
-
- // TODO(adonovan): if the users selects the "." in
- // "fmt.Fprintf()", they'll get an ambiguous selection error;
- // we won't even reach here. Can we do better?
-
- // TODO(adonovan): describing a field within 'type T struct {...}'
- // describes the (anonymous) struct type and concludes "no methods".
- // We should ascend to the enclosing type decl, if any.
-
- for len(path) > 0 {
- switch n := path[0].(type) {
- case *ast.GenDecl:
- if len(n.Specs) == 1 {
- // Descend to sole {Import,Type,Value}Spec child.
- path = append([]ast.Node{n.Specs[0]}, path...)
- continue
- }
- return path, actionUnknown // uninteresting
-
- case *ast.FuncDecl:
- // Descend to function name.
- path = append([]ast.Node{n.Name}, path...)
- continue
-
- case *ast.ImportSpec:
- return path, actionPackage
-
- case *ast.ValueSpec:
- if len(n.Names) == 1 {
- // Descend to sole Ident child.
- path = append([]ast.Node{n.Names[0]}, path...)
- continue
- }
- return path, actionUnknown // uninteresting
-
- case *ast.TypeSpec:
- // Descend to type name.
- path = append([]ast.Node{n.Name}, path...)
- continue
-
- case ast.Stmt:
- return path, actionStmt
-
- case *ast.ArrayType,
- *ast.StructType,
- *ast.FuncType,
- *ast.InterfaceType,
- *ast.MapType,
- *ast.ChanType:
- return path, actionType
-
- case *ast.Comment, *ast.CommentGroup, *ast.File, *ast.KeyValueExpr, *ast.CommClause:
- return path, actionUnknown // uninteresting
-
- case *ast.Ellipsis:
- // Continue to enclosing node.
- // e.g. [...]T in ArrayType
- // f(x...) in CallExpr
- // f(x...T) in FuncType
-
- case *ast.Field:
- // TODO(adonovan): this needs more thought,
- // since fields can be so many things.
- if len(n.Names) == 1 {
- // Descend to sole Ident child.
- path = append([]ast.Node{n.Names[0]}, path...)
- continue
- }
- // Zero names (e.g. anon field in struct)
- // or multiple field or param names:
- // continue to enclosing field list.
-
- case *ast.FieldList:
- // Continue to enclosing node:
- // {Struct,Func,Interface}Type or FuncDecl.
-
- case *ast.BasicLit:
- if _, ok := path[1].(*ast.ImportSpec); ok {
- return path[1:], actionPackage
- }
- return path, actionExpr
-
- case *ast.SelectorExpr:
- if pkginfo.ObjectOf(n.Sel) == nil {
- // TODO(adonovan): is this reachable?
- return path, actionUnknown
- }
- // Descend to .Sel child.
- path = append([]ast.Node{n.Sel}, path...)
- continue
-
- case *ast.Ident:
- switch pkginfo.ObjectOf(n).(type) {
- case *types.PkgName:
- return path, actionPackage
-
- case *types.Const:
- return path, actionExpr
-
- case *types.Label:
- return path, actionStmt
-
- case *types.TypeName:
- return path, actionType
-
- case *types.Var:
- // For x in 'struct {x T}', return struct type, for now.
- if _, ok := path[1].(*ast.Field); ok {
- _ = path[2].(*ast.FieldList) // assertion
- if _, ok := path[3].(*ast.StructType); ok {
- return path[3:], actionType
- }
- }
- return path, actionExpr
-
- case *types.Func:
- // For f in 'interface {f()}', return the interface type, for now.
- if _, ok := path[1].(*ast.Field); ok {
- _ = path[2].(*ast.FieldList) // assertion
- if _, ok := path[3].(*ast.InterfaceType); ok {
- return path[3:], actionType
- }
- }
- return path, actionExpr
-
- case *types.Builtin:
- // For reference to built-in function, return enclosing call.
- path = path[1:] // ascend to enclosing function call
- continue
-
- case *types.Nil:
- return path, actionExpr
- }
-
- // No object.
- switch path[1].(type) {
- case *ast.SelectorExpr:
- // Return enclosing selector expression.
- return path[1:], actionExpr
-
- case *ast.Field:
- // TODO(adonovan): test this.
- // e.g. all f in:
- // struct { f, g int }
- // interface { f() }
- // func (f T) method(f, g int) (f, g bool)
- //
- // switch path[3].(type) {
- // case *ast.FuncDecl:
- // case *ast.StructType:
- // case *ast.InterfaceType:
- // }
- //
- // return path[1:], actionExpr
- //
- // Unclear what to do with these.
- // Struct.Fields -- field
- // Interface.Methods -- field
- // FuncType.{Params.Results} -- actionExpr
- // FuncDecl.Recv -- actionExpr
-
- case *ast.File:
- // 'package foo'
- return path, actionPackage
-
- case *ast.ImportSpec:
- // TODO(adonovan): fix: why no package object? go/types bug?
- return path[1:], actionPackage
-
- default:
- // e.g. blank identifier (go/types bug?)
- // or y in "switch y := x.(type)" (go/types bug?)
- // or code in a _test.go file that's not part of the package.
- fmt.Printf("unknown reference %s in %T\n", n, path[1])
- return path, actionUnknown
- }
-
- case *ast.StarExpr:
- if pkginfo.IsType(n) {
- return path, actionType
- }
- return path, actionExpr
-
- case ast.Expr:
- // All Expr but {BasicLit,Ident,StarExpr} are
- // "true" expressions that evaluate to a value.
- return path, actionExpr
- }
-
- // Ascend to parent.
- path = path[1:]
- }
-
- return nil, actionUnknown // unreachable
-}
-
-func describeValue(o *Oracle, qpos *QueryPos, path []ast.Node) (*describeValueResult, error) {
- var expr ast.Expr
- var obj types.Object
- switch n := path[0].(type) {
- case *ast.ValueSpec:
- // ambiguous ValueSpec containing multiple names
- return nil, fmt.Errorf("multiple value specification")
- case *ast.Ident:
- obj = qpos.info.ObjectOf(n)
- expr = n
- case ast.Expr:
- expr = n
- default:
- // TODO(adonovan): is this reachable?
- return nil, fmt.Errorf("unexpected AST for expr: %T", n)
- }
-
- typ := qpos.info.TypeOf(expr)
- constVal := qpos.info.ValueOf(expr)
-
- return &describeValueResult{
- qpos: qpos,
- expr: expr,
- typ: typ,
- constVal: constVal,
- obj: obj,
- }, nil
-}
-
-type describeValueResult struct {
- qpos *QueryPos
- expr ast.Expr // query node
- typ types.Type // type of expression
- constVal exact.Value // value of expression, if constant
- obj types.Object // var/func/const object, if expr was Ident
-}
-
-func (r *describeValueResult) display(printf printfFunc) {
- var prefix, suffix string
- if r.constVal != nil {
- suffix = fmt.Sprintf(" of constant value %s", r.constVal)
- }
- switch obj := r.obj.(type) {
- case *types.Func:
- if recv := obj.Type().(*types.Signature).Recv(); recv != nil {
- if _, ok := recv.Type().Underlying().(*types.Interface); ok {
- prefix = "interface method "
- } else {
- prefix = "method "
- }
- }
- }
-
- // Describe the expression.
- if r.obj != nil {
- if r.obj.Pos() == r.expr.Pos() {
- // defining ident
- printf(r.expr, "definition of %s%s%s", prefix, r.qpos.ObjectString(r.obj), suffix)
- } else {
- // referring ident
- printf(r.expr, "reference to %s%s%s", prefix, r.qpos.ObjectString(r.obj), suffix)
- if def := r.obj.Pos(); def != token.NoPos {
- printf(def, "defined here")
- }
- }
- } else {
- desc := astutil.NodeDescription(r.expr)
- if suffix != "" {
- // constant expression
- printf(r.expr, "%s%s", desc, suffix)
- } else {
- // non-constant expression
- printf(r.expr, "%s of type %s", desc, r.qpos.TypeString(r.typ))
- }
- }
-}
-
-func (r *describeValueResult) toSerial(res *serial.Result, fset *token.FileSet) {
- var value, objpos string
- if r.constVal != nil {
- value = r.constVal.String()
- }
- if r.obj != nil {
- objpos = fset.Position(r.obj.Pos()).String()
- }
-
- res.Describe = &serial.Describe{
- Desc: astutil.NodeDescription(r.expr),
- Pos: fset.Position(r.expr.Pos()).String(),
- Detail: "value",
- Value: &serial.DescribeValue{
- Type: r.qpos.TypeString(r.typ),
- Value: value,
- ObjPos: objpos,
- },
- }
-}
-
-// ---- TYPE ------------------------------------------------------------
-
-func describeType(o *Oracle, qpos *QueryPos, path []ast.Node) (*describeTypeResult, error) {
- var description string
- var t types.Type
- switch n := path[0].(type) {
- case *ast.Ident:
- t = qpos.info.TypeOf(n)
- switch t := t.(type) {
- case *types.Basic:
- description = "reference to built-in "
-
- case *types.Named:
- isDef := t.Obj().Pos() == n.Pos() // see caveats at isDef above
- if isDef {
- description = "definition of "
- } else {
- description = "reference to "
- }
- }
-
- case ast.Expr:
- t = qpos.info.TypeOf(n)
-
- default:
- // Unreachable?
- return nil, fmt.Errorf("unexpected AST for type: %T", n)
- }
-
- description = description + "type " + qpos.TypeString(t)
-
- // Show sizes for structs and named types (it's fairly obvious for others).
- switch t.(type) {
- case *types.Named, *types.Struct:
- // TODO(adonovan): use o.imp.Config().TypeChecker.Sizes when
- // we add the Config() method (needs some thought).
- szs := types.StdSizes{8, 8}
- description = fmt.Sprintf("%s (size %d, align %d)", description,
- szs.Sizeof(t), szs.Alignof(t))
- }
-
- return &describeTypeResult{
- qpos: qpos,
- node: path[0],
- description: description,
- typ: t,
- methods: accessibleMethods(t, qpos.info.Pkg),
- }, nil
-}
-
-type describeTypeResult struct {
- qpos *QueryPos
- node ast.Node
- description string
- typ types.Type
- methods []*types.Selection
-}
-
-func (r *describeTypeResult) display(printf printfFunc) {
- printf(r.node, "%s", r.description)
-
- // Show the underlying type for a reference to a named type.
- if nt, ok := r.typ.(*types.Named); ok && r.node.Pos() != nt.Obj().Pos() {
- printf(nt.Obj(), "defined as %s", r.qpos.TypeString(nt.Underlying()))
- }
-
- // Print the method set, if the type kind is capable of bearing methods.
- switch r.typ.(type) {
- case *types.Interface, *types.Struct, *types.Named:
- if len(r.methods) > 0 {
- printf(r.node, "Method set:")
- for _, meth := range r.methods {
- printf(meth.Obj(), "\t%s", r.qpos.SelectionString(meth))
- }
- } else {
- printf(r.node, "No methods.")
- }
- }
-}
-
-func (r *describeTypeResult) toSerial(res *serial.Result, fset *token.FileSet) {
- var namePos, nameDef string
- if nt, ok := r.typ.(*types.Named); ok {
- namePos = fset.Position(nt.Obj().Pos()).String()
- nameDef = nt.Underlying().String()
- }
- res.Describe = &serial.Describe{
- Desc: r.description,
- Pos: fset.Position(r.node.Pos()).String(),
- Detail: "type",
- Type: &serial.DescribeType{
- Type: r.qpos.TypeString(r.typ),
- NamePos: namePos,
- NameDef: nameDef,
- Methods: methodsToSerial(r.qpos.info.Pkg, r.methods, fset),
- },
- }
-}
-
-// ---- PACKAGE ------------------------------------------------------------
-
-func describePackage(o *Oracle, qpos *QueryPos, path []ast.Node) (*describePackageResult, error) {
- var description string
- var pkg *types.Package
- switch n := path[0].(type) {
- case *ast.ImportSpec:
- pkgname := qpos.info.ImportSpecPkg(n)
- description = fmt.Sprintf("import of package %q", pkgname.Pkg().Path())
- pkg = pkgname.Pkg()
-
- case *ast.Ident:
- if _, isDef := path[1].(*ast.File); isDef {
- // e.g. package id
- pkg = qpos.info.Pkg
- description = fmt.Sprintf("definition of package %q", pkg.Path())
- } else {
- // e.g. import id
- // or id.F()
- pkg = qpos.info.ObjectOf(n).Pkg()
- description = fmt.Sprintf("reference to package %q", pkg.Path())
- }
-
- default:
- // Unreachable?
- return nil, fmt.Errorf("unexpected AST for package: %T", n)
- }
-
- var members []*describeMember
- // NB: "unsafe" has no types.Package
- if pkg != nil {
- // Enumerate the accessible package members
- // in lexicographic order.
- for _, name := range pkg.Scope().Names() {
- if pkg == qpos.info.Pkg || ast.IsExported(name) {
- mem := pkg.Scope().Lookup(name)
- var methods []*types.Selection
- if mem, ok := mem.(*types.TypeName); ok {
- methods = accessibleMethods(mem.Type(), qpos.info.Pkg)
- }
- members = append(members, &describeMember{
- mem,
- methods,
- })
-
- }
- }
- }
-
- return &describePackageResult{o.fset, path[0], description, pkg, members}, nil
-}
-
-type describePackageResult struct {
- fset *token.FileSet
- node ast.Node
- description string
- pkg *types.Package
- members []*describeMember // in lexicographic name order
-}
-
-type describeMember struct {
- obj types.Object
- methods []*types.Selection // in types.MethodSet order
-}
-
-func (r *describePackageResult) display(printf printfFunc) {
- printf(r.node, "%s", r.description)
-
- // Compute max width of name "column".
- maxname := 0
- for _, mem := range r.members {
- if l := len(mem.obj.Name()); l > maxname {
- maxname = l
- }
- }
-
- for _, mem := range r.members {
- printf(mem.obj, "\t%s", formatMember(mem.obj, maxname))
- for _, meth := range mem.methods {
- printf(meth.Obj(), "\t\t%s", types.SelectionString(r.pkg, meth))
- }
- }
-}
-
-func formatMember(obj types.Object, maxname int) string {
- var buf bytes.Buffer
- fmt.Fprintf(&buf, "%-5s %-*s", tokenOf(obj), maxname, obj.Name())
- switch obj := obj.(type) {
- case *types.Const:
- fmt.Fprintf(&buf, " %s = %s", types.TypeString(obj.Pkg(), obj.Type()), obj.Val().String())
-
- case *types.Func:
- fmt.Fprintf(&buf, " %s", types.TypeString(obj.Pkg(), obj.Type()))
-
- case *types.TypeName:
- // Abbreviate long aggregate type names.
- var abbrev string
- switch t := obj.Type().Underlying().(type) {
- case *types.Interface:
- if t.NumMethods() > 1 {
- abbrev = "interface{...}"
- }
- case *types.Struct:
- if t.NumFields() > 1 {
- abbrev = "struct{...}"
- }
- }
- if abbrev == "" {
- fmt.Fprintf(&buf, " %s", types.TypeString(obj.Pkg(), obj.Type().Underlying()))
- } else {
- fmt.Fprintf(&buf, " %s", abbrev)
- }
-
- case *types.Var:
- fmt.Fprintf(&buf, " %s", types.TypeString(obj.Pkg(), obj.Type()))
- }
- return buf.String()
-}
-
-func (r *describePackageResult) toSerial(res *serial.Result, fset *token.FileSet) {
- var members []*serial.DescribeMember
- for _, mem := range r.members {
- typ := mem.obj.Type()
- var val string
- switch mem := mem.obj.(type) {
- case *types.Const:
- val = mem.Val().String()
- case *types.TypeName:
- typ = typ.Underlying()
- }
- members = append(members, &serial.DescribeMember{
- Name: mem.obj.Name(),
- Type: typ.String(),
- Value: val,
- Pos: fset.Position(mem.obj.Pos()).String(),
- Kind: tokenOf(mem.obj),
- Methods: methodsToSerial(r.pkg, mem.methods, fset),
- })
- }
- res.Describe = &serial.Describe{
- Desc: r.description,
- Pos: fset.Position(r.node.Pos()).String(),
- Detail: "package",
- Package: &serial.DescribePackage{
- Path: r.pkg.Path(),
- Members: members,
- },
- }
-}
-
-func tokenOf(o types.Object) string {
- switch o.(type) {
- case *types.Func:
- return "func"
- case *types.Var:
- return "var"
- case *types.TypeName:
- return "type"
- case *types.Const:
- return "const"
- case *types.PkgName:
- return "package"
- }
- panic(o)
-}
-
-// ---- STATEMENT ------------------------------------------------------------
-
-func describeStmt(o *Oracle, qpos *QueryPos, path []ast.Node) (*describeStmtResult, error) {
- var description string
- switch n := path[0].(type) {
- case *ast.Ident:
- if qpos.info.ObjectOf(n).Pos() == n.Pos() {
- description = "labelled statement"
- } else {
- description = "reference to labelled statement"
- }
-
- default:
- // Nothing much to say about statements.
- description = astutil.NodeDescription(n)
- }
- return &describeStmtResult{o.fset, path[0], description}, nil
-}
-
-type describeStmtResult struct {
- fset *token.FileSet
- node ast.Node
- description string
-}
-
-func (r *describeStmtResult) display(printf printfFunc) {
- printf(r.node, "%s", r.description)
-}
-
-func (r *describeStmtResult) toSerial(res *serial.Result, fset *token.FileSet) {
- res.Describe = &serial.Describe{
- Desc: r.description,
- Pos: fset.Position(r.node.Pos()).String(),
- Detail: "unknown",
- }
-}
-
-// ------------------- Utilities -------------------
-
-// pathToString returns a string containing the concrete types of the
-// nodes in path.
-func pathToString(path []ast.Node) string {
- var buf bytes.Buffer
- fmt.Fprint(&buf, "[")
- for i, n := range path {
- if i > 0 {
- fmt.Fprint(&buf, " ")
- }
- fmt.Fprint(&buf, strings.TrimPrefix(fmt.Sprintf("%T", n), "*ast."))
- }
- fmt.Fprint(&buf, "]")
- return buf.String()
-}
-
-func accessibleMethods(t types.Type, from *types.Package) []*types.Selection {
- var methods []*types.Selection
- for _, meth := range typeutil.IntuitiveMethodSet(t, nil) {
- if isAccessibleFrom(meth.Obj(), from) {
- methods = append(methods, meth)
- }
- }
- return methods
-}
-
-func isAccessibleFrom(obj types.Object, pkg *types.Package) bool {
- return ast.IsExported(obj.Name()) || obj.Pkg() == pkg
-}
-
-func methodsToSerial(this *types.Package, methods []*types.Selection, fset *token.FileSet) []serial.DescribeMethod {
- var jmethods []serial.DescribeMethod
- for _, meth := range methods {
- jmethods = append(jmethods, serial.DescribeMethod{
- Name: types.SelectionString(this, meth),
- Pos: fset.Position(meth.Obj().Pos()).String(),
- })
- }
- return jmethods
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/freevars.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/freevars.go
deleted file mode 100644
index a142d15a..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/freevars.go
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "bytes"
- "go/ast"
- "go/printer"
- "go/token"
- "sort"
-
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// freevars displays the lexical (not package-level) free variables of
-// the selection.
-//
-// It treats A.B.C as a separate variable from A to reveal the parts
-// of an aggregate type that are actually needed.
-// This aids refactoring.
-//
-// TODO(adonovan): optionally display the free references to
-// file/package scope objects, and to objects from other packages.
-// Depending on where the resulting function abstraction will go,
-// these might be interesting. Perhaps group the results into three
-// bands.
-//
-func freevars(o *Oracle, qpos *QueryPos) (queryResult, error) {
- file := qpos.path[len(qpos.path)-1] // the enclosing file
- fileScope := qpos.info.Scopes[file]
- pkgScope := fileScope.Parent()
-
- // The id and sel functions return non-nil if they denote an
- // object o or selection o.x.y that is referenced by the
- // selection but defined neither within the selection nor at
- // file scope, i.e. it is in the lexical environment.
- var id func(n *ast.Ident) types.Object
- var sel func(n *ast.SelectorExpr) types.Object
-
- sel = func(n *ast.SelectorExpr) types.Object {
- switch x := unparen(n.X).(type) {
- case *ast.SelectorExpr:
- return sel(x)
- case *ast.Ident:
- return id(x)
- }
- return nil
- }
-
- id = func(n *ast.Ident) types.Object {
- obj := qpos.info.ObjectOf(n)
- if obj == nil {
- return nil // TODO(adonovan): fix: this fails for *types.Label.
- panic("no types.Object for ast.Ident")
- }
- if _, ok := obj.(*types.PkgName); ok {
- return nil // imported package
- }
- if n.Pos() == obj.Pos() {
- return nil // this ident is the definition, not a reference
- }
- if !(file.Pos() <= obj.Pos() && obj.Pos() <= file.End()) {
- return nil // not defined in this file
- }
- scope := obj.Parent()
- if scope == nil {
- return nil // e.g. interface method, struct field
- }
- if scope == fileScope || scope == pkgScope {
- return nil // defined at file or package scope
- }
- if qpos.start <= obj.Pos() && obj.Pos() <= qpos.end {
- return nil // defined within selection => not free
- }
- return obj
- }
-
- // Maps each reference that is free in the selection
- // to the object it refers to.
- // The map de-duplicates repeated references.
- refsMap := make(map[string]freevarsRef)
-
- // Visit all the identifiers in the selected ASTs.
- ast.Inspect(qpos.path[0], func(n ast.Node) bool {
- if n == nil {
- return true // popping DFS stack
- }
-
- // Is this node contained within the selection?
- // (freevars permits inexact selections,
- // like two stmts in a block.)
- if qpos.start <= n.Pos() && n.End() <= qpos.end {
- var obj types.Object
- var prune bool
- switch n := n.(type) {
- case *ast.Ident:
- obj = id(n)
-
- case *ast.SelectorExpr:
- obj = sel(n)
- prune = true
- }
-
- if obj != nil {
- var kind string
- switch obj.(type) {
- case *types.Var:
- kind = "var"
- case *types.Func:
- kind = "func"
- case *types.TypeName:
- kind = "type"
- case *types.Const:
- kind = "const"
- case *types.Label:
- kind = "label"
- default:
- panic(obj)
- }
-
- typ := qpos.info.TypeOf(n.(ast.Expr))
- ref := freevarsRef{kind, printNode(o.fset, n), typ, obj}
- refsMap[ref.ref] = ref
-
- if prune {
- return false // don't descend
- }
- }
- }
-
- return true // descend
- })
-
- refs := make([]freevarsRef, 0, len(refsMap))
- for _, ref := range refsMap {
- refs = append(refs, ref)
- }
- sort.Sort(byRef(refs))
-
- return &freevarsResult{
- qpos: qpos,
- refs: refs,
- }, nil
-}
-
-type freevarsResult struct {
- qpos *QueryPos
- refs []freevarsRef
-}
-
-type freevarsRef struct {
- kind string
- ref string
- typ types.Type
- obj types.Object
-}
-
-func (r *freevarsResult) display(printf printfFunc) {
- if len(r.refs) == 0 {
- printf(r.qpos, "No free identifiers.")
- } else {
- printf(r.qpos, "Free identifiers:")
- for _, ref := range r.refs {
- // Avoid printing "type T T".
- var typstr string
- if ref.kind != "type" {
- typstr = " " + types.TypeString(r.qpos.info.Pkg, ref.typ)
- }
- printf(ref.obj, "%s %s%s", ref.kind, ref.ref, typstr)
- }
- }
-}
-
-func (r *freevarsResult) toSerial(res *serial.Result, fset *token.FileSet) {
- var refs []*serial.FreeVar
- for _, ref := range r.refs {
- refs = append(refs,
- &serial.FreeVar{
- Pos: fset.Position(ref.obj.Pos()).String(),
- Kind: ref.kind,
- Ref: ref.ref,
- Type: ref.typ.String(),
- })
- }
- res.Freevars = refs
-}
-
-// -------- utils --------
-
-type byRef []freevarsRef
-
-func (p byRef) Len() int { return len(p) }
-func (p byRef) Less(i, j int) bool { return p[i].ref < p[j].ref }
-func (p byRef) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-
-// printNode returns the pretty-printed syntax of n.
-func printNode(fset *token.FileSet, n ast.Node) string {
- var buf bytes.Buffer
- printer.Fprint(&buf, fset, n)
- return buf.String()
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/implements.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/implements.go
deleted file mode 100644
index 3dcf42ee..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/implements.go
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- "reflect"
- "sort"
- "strings"
-
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// Implements displays the "implements" relation as it pertains to the
-// selected type.
-//
-func implements(o *Oracle, qpos *QueryPos) (queryResult, error) {
- // Find the selected type.
- // TODO(adonovan): fix: make it work on qualified Idents too.
- path, action := findInterestingNode(qpos.info, qpos.path)
- if action != actionType {
- return nil, fmt.Errorf("no type here")
- }
- T := qpos.info.TypeOf(path[0].(ast.Expr))
- if T == nil {
- return nil, fmt.Errorf("no type here")
- }
-
- // Find all named types, even local types (which can have
- // methods via promotion) and the built-in "error".
- //
- // TODO(adonovan): include all packages in PTA scope too?
- // i.e. don't reduceScope?
- //
- var allNamed []types.Type
- for _, info := range o.typeInfo {
- for _, obj := range info.Defs {
- if obj, ok := obj.(*types.TypeName); ok {
- allNamed = append(allNamed, obj.Type())
- }
- }
- }
- allNamed = append(allNamed, types.Universe.Lookup("error").Type())
-
- var msets types.MethodSetCache
-
- // Test each named type.
- var to, from, fromPtr []types.Type
- for _, U := range allNamed {
- if isInterface(T) {
- if msets.MethodSet(T).Len() == 0 {
- continue // empty interface
- }
- if isInterface(U) {
- if msets.MethodSet(U).Len() == 0 {
- continue // empty interface
- }
-
- // T interface, U interface
- if !types.Identical(T, U) {
- if types.AssignableTo(U, T) {
- to = append(to, U)
- }
- if types.AssignableTo(T, U) {
- from = append(from, U)
- }
- }
- } else {
- // T interface, U concrete
- if types.AssignableTo(U, T) {
- to = append(to, U)
- } else if pU := types.NewPointer(U); types.AssignableTo(pU, T) {
- to = append(to, pU)
- }
- }
- } else if isInterface(U) {
- if msets.MethodSet(U).Len() == 0 {
- continue // empty interface
- }
-
- // T concrete, U interface
- if types.AssignableTo(T, U) {
- from = append(from, U)
- } else if pT := types.NewPointer(T); types.AssignableTo(pT, U) {
- fromPtr = append(fromPtr, U)
- }
- }
- }
-
- var pos interface{} = qpos
- if nt, ok := deref(T).(*types.Named); ok {
- pos = nt.Obj()
- }
-
- // Sort types (arbitrarily) to ensure test determinism.
- sort.Sort(typesByString(to))
- sort.Sort(typesByString(from))
- sort.Sort(typesByString(fromPtr))
-
- return &implementsResult{T, pos, to, from, fromPtr}, nil
-}
-
-type implementsResult struct {
- t types.Type // queried type (not necessarily named)
- pos interface{} // pos of t (*types.Name or *QueryPos)
- to []types.Type // named or ptr-to-named types assignable to interface T
- from []types.Type // named interfaces assignable from T
- fromPtr []types.Type // named interfaces assignable only from *T
-}
-
-func (r *implementsResult) display(printf printfFunc) {
- if isInterface(r.t) {
- if types.NewMethodSet(r.t).Len() == 0 { // TODO(adonovan): cache mset
- printf(r.pos, "empty interface type %s", r.t)
- return
- }
-
- printf(r.pos, "interface type %s", r.t)
- // Show concrete types first; use two passes.
- for _, sub := range r.to {
- if !isInterface(sub) {
- printf(deref(sub).(*types.Named).Obj(), "\tis implemented by %s type %s",
- typeKind(sub), sub)
- }
- }
- for _, sub := range r.to {
- if isInterface(sub) {
- printf(deref(sub).(*types.Named).Obj(), "\tis implemented by %s type %s", typeKind(sub), sub)
- }
- }
-
- for _, super := range r.from {
- printf(super.(*types.Named).Obj(), "\timplements %s", super)
- }
- } else {
- if r.from != nil {
- printf(r.pos, "%s type %s", typeKind(r.t), r.t)
- for _, super := range r.from {
- printf(super.(*types.Named).Obj(), "\timplements %s", super)
- }
- }
- if r.fromPtr != nil {
- printf(r.pos, "pointer type *%s", r.t)
- for _, psuper := range r.fromPtr {
- printf(psuper.(*types.Named).Obj(), "\timplements %s", psuper)
- }
- } else if r.from == nil {
- printf(r.pos, "%s type %s implements only interface{}", typeKind(r.t), r.t)
- }
- }
-}
-
-func (r *implementsResult) toSerial(res *serial.Result, fset *token.FileSet) {
- res.Implements = &serial.Implements{
- T: makeImplementsType(r.t, fset),
- AssignableTo: makeImplementsTypes(r.to, fset),
- AssignableFrom: makeImplementsTypes(r.from, fset),
- AssignableFromPtr: makeImplementsTypes(r.fromPtr, fset),
- }
-}
-
-func makeImplementsTypes(tt []types.Type, fset *token.FileSet) []serial.ImplementsType {
- var r []serial.ImplementsType
- for _, t := range tt {
- r = append(r, makeImplementsType(t, fset))
- }
- return r
-}
-
-func makeImplementsType(T types.Type, fset *token.FileSet) serial.ImplementsType {
- var pos token.Pos
- if nt, ok := deref(T).(*types.Named); ok { // implementsResult.t may be non-named
- pos = nt.Obj().Pos()
- }
- return serial.ImplementsType{
- Name: T.String(),
- Pos: fset.Position(pos).String(),
- Kind: typeKind(T),
- }
-}
-
-// typeKind returns a string describing the underlying kind of type,
-// e.g. "slice", "array", "struct".
-func typeKind(T types.Type) string {
- s := reflect.TypeOf(T.Underlying()).String()
- return strings.ToLower(strings.TrimPrefix(s, "*types."))
-}
-
-func isInterface(T types.Type) bool {
- _, isI := T.Underlying().(*types.Interface)
- return isI
-}
-
-type typesByString []types.Type
-
-func (p typesByString) Len() int { return len(p) }
-func (p typesByString) Less(i, j int) bool { return p[i].String() < p[j].String() }
-func (p typesByString) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/oracle.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/oracle.go
deleted file mode 100644
index f4bb9936..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/oracle.go
+++ /dev/null
@@ -1,557 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package oracle contains the implementation of the oracle tool whose
-// command-line is provided by code.google.com/p/go.tools/cmd/oracle.
-//
-// http://golang.org/s/oracle-design
-// http://golang.org/s/oracle-user-manual
-//
-package oracle
-
-// This file defines oracle.Query, the entry point for the oracle tool.
-// The actual executable is defined in cmd/oracle.
-
-// TODO(adonovan): new queries
-// - show all statements that may update the selected lvalue
-// (local, global, field, etc).
-// - show all places where an object of type T is created
-// (&T{}, var t T, new(T), new(struct{array [3]T}), etc.
-
-// ORACLE CONTROL FLOW
-//
-// The Oracle is somewhat convoluted due to the need to support two
-// very different use-cases, "one-shot" and "long running", and to do
-// so quickly.
-//
-// The cmd/oracle tool issues "one-shot" queries via the exported
-// Query function, which creates an Oracle to answer a single query.
-// newOracle consults the 'needs' flags of the query mode and the
-// package containing the query to avoid doing more work than it needs
-// (loading, parsing, type checking, SSA construction).
-//
-// The Pythia tool (github.com/fzipp/pythia) is an example of a "long
-// running" tool. It calls New() and then loops, calling
-// ParseQueryPos and (*Oracle).Query to handle each incoming HTTP
-// query. Since New cannot see which queries will follow, it must
-// load, parse, type-check and SSA-build the entire transitive closure
-// of the analysis scope, retaining full debug information and all
-// typed ASTs.
-//
-// TODO(adonovan): experiment with inverting the control flow by
-// making each mode consist of two functions: a "one-shot setup"
-// function and the existing "impl" function. The one-shot setup
-// function would do all of the work of Query and newOracle,
-// specialized to each mode, calling library utilities for the common
-// things. This would give it more control over "scope reduction".
-// Long running tools would not call the one-shot setup function but
-// would have their own setup function equivalent to the existing
-// 'needsAll' flow path.
-
-import (
- "fmt"
- "go/ast"
- "go/build"
- "go/token"
- "io"
-
- "code.google.com/p/go.tools/astutil"
- "code.google.com/p/go.tools/go/loader"
- "code.google.com/p/go.tools/go/pointer"
- "code.google.com/p/go.tools/go/ssa"
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// An Oracle holds the program state required for one or more queries.
-type Oracle struct {
- fset *token.FileSet // file set [all queries]
- prog *ssa.Program // the SSA program [needSSA]
- ptaConfig pointer.Config // pointer analysis configuration [needPTA]
- typeInfo map[*types.Package]*loader.PackageInfo // type info for all ASTs in the program [needRetainTypeInfo]
-}
-
-// A set of bits indicating the analytical requirements of each mode.
-//
-// Typed ASTs for the whole program are always constructed
-// transiently; they are retained only for the queried package unless
-// needRetainTypeInfo is set.
-const (
- needPos = 1 << iota // needs a position
- needExactPos // needs an exact AST selection; implies needPos
- needRetainTypeInfo // needs to retain type info for all ASTs in the program
- needSSA // needs ssa.Packages for whole program
- needSSADebug // needs debug info for ssa.Packages
- needPTA = needSSA // needs pointer analysis
- needAll = -1 // needs everything (e.g. a sequence of queries)
-)
-
-type modeInfo struct {
- name string
- needs int
- impl func(*Oracle, *QueryPos) (queryResult, error)
-}
-
-var modes = []*modeInfo{
- // Pointer analyses, whole program:
- {"callees", needPTA | needExactPos, callees},
- {"callers", needPTA | needPos, callers},
- {"callgraph", needPTA, doCallgraph},
- {"callstack", needPTA | needPos, callstack},
- {"peers", needPTA | needSSADebug | needPos, peers},
- {"pointsto", needPTA | needSSADebug | needExactPos, pointsto},
-
- // Type-based, modular analyses:
- {"definition", needPos, definition},
- {"describe", needExactPos, describe},
- {"freevars", needPos, freevars},
-
- // Type-based, whole-program analyses:
- {"implements", needRetainTypeInfo | needPos, implements},
- {"referrers", needRetainTypeInfo | needPos, referrers},
-}
-
-func findMode(mode string) *modeInfo {
- for _, m := range modes {
- if m.name == mode {
- return m
- }
- }
- return nil
-}
-
-type printfFunc func(pos interface{}, format string, args ...interface{})
-
-// queryResult is the interface of each query-specific result type.
-type queryResult interface {
- toSerial(res *serial.Result, fset *token.FileSet)
- display(printf printfFunc)
-}
-
-// A QueryPos represents the position provided as input to a query:
-// a textual extent in the program's source code, the AST node it
-// corresponds to, and the package to which it belongs.
-// Instances are created by ParseQueryPos.
-//
-type QueryPos struct {
- fset *token.FileSet
- start, end token.Pos // source extent of query
- path []ast.Node // AST path from query node to root of ast.File
- exact bool // 2nd result of PathEnclosingInterval
- info *loader.PackageInfo // type info for the queried package (nil for fastQueryPos)
-}
-
-// TypeString prints type T relative to the query position.
-func (qpos *QueryPos) TypeString(T types.Type) string {
- return types.TypeString(qpos.info.Pkg, T)
-}
-
-// ObjectString prints object obj relative to the query position.
-func (qpos *QueryPos) ObjectString(obj types.Object) string {
- return types.ObjectString(qpos.info.Pkg, obj)
-}
-
-// SelectionString prints selection sel relative to the query position.
-func (qpos *QueryPos) SelectionString(sel *types.Selection) string {
- return types.SelectionString(qpos.info.Pkg, sel)
-}
-
-// A Result encapsulates the result of an oracle.Query.
-type Result struct {
- fset *token.FileSet
- q queryResult // the query-specific result
- mode string // query mode
- warnings []pointer.Warning // pointer analysis warnings (TODO(adonovan): fix: never populated!)
-}
-
-// Serial returns an instance of serial.Result, which implements the
-// {xml,json}.Marshaler interfaces so that query results can be
-// serialized as JSON or XML.
-//
-func (res *Result) Serial() *serial.Result {
- resj := &serial.Result{Mode: res.mode}
- res.q.toSerial(resj, res.fset)
- for _, w := range res.warnings {
- resj.Warnings = append(resj.Warnings, serial.PTAWarning{
- Pos: res.fset.Position(w.Pos).String(),
- Message: w.Message,
- })
- }
- return resj
-}
-
-// Query runs a single oracle query.
-//
-// args specify the main package in (*loader.Config).FromArgs syntax.
-// mode is the query mode ("callers", etc).
-// ptalog is the (optional) pointer-analysis log file.
-// buildContext is the go/build configuration for locating packages.
-// reflection determines whether to model reflection soundly (currently slow).
-//
-// Clients that intend to perform multiple queries against the same
-// analysis scope should use this pattern instead:
-//
-// conf := loader.Config{Build: buildContext, SourceImports: true}
-// ... populate config, e.g. conf.FromArgs(args) ...
-// iprog, err := conf.Load()
-// if err != nil { ... }
-// o, err := oracle.New(iprog, nil, false)
-// if err != nil { ... }
-// for ... {
-// qpos, err := oracle.ParseQueryPos(imp, pos, needExact)
-// if err != nil { ... }
-//
-// res, err := o.Query(mode, qpos)
-// if err != nil { ... }
-//
-// // use res
-// }
-//
-// TODO(adonovan): the ideal 'needsExact' parameter for ParseQueryPos
-// depends on the query mode; how should we expose this?
-//
-func Query(args []string, mode, pos string, ptalog io.Writer, buildContext *build.Context, reflection bool) (*Result, error) {
- if mode == "what" {
- // Bypass package loading, type checking, SSA construction.
- return what(pos, buildContext)
- }
-
- minfo := findMode(mode)
- if minfo == nil {
- return nil, fmt.Errorf("invalid mode type: %q", mode)
- }
-
- conf := loader.Config{Build: buildContext, SourceImports: true}
-
- // Determine initial packages.
- args, err := conf.FromArgs(args, true)
- if err != nil {
- return nil, err
- }
- if len(args) > 0 {
- return nil, fmt.Errorf("surplus arguments: %q", args)
- }
-
- // For queries needing only a single typed package,
- // reduce the analysis scope to that package.
- if minfo.needs&(needSSA|needRetainTypeInfo) == 0 {
- reduceScope(pos, &conf)
- }
-
- // TODO(adonovan): report type errors to the user via Serial
- // types, not stderr?
- // conf.TypeChecker.Error = func(err error) {
- // E := err.(types.Error)
- // fmt.Fprintf(os.Stderr, "%s: %s\n", E.Fset.Position(E.Pos), E.Msg)
- // }
-
- // Load/parse/type-check the program.
- iprog, err := conf.Load()
- if err != nil {
- return nil, err
- }
-
- o, err := newOracle(iprog, ptalog, minfo.needs, reflection)
- if err != nil {
- return nil, err
- }
-
- qpos, err := ParseQueryPos(iprog, pos, minfo.needs&needExactPos != 0)
- if err != nil && minfo.needs&(needPos|needExactPos) != 0 {
- return nil, err
- }
-
- // SSA is built and we have the QueryPos.
- // Release the other ASTs and type info to the GC.
- iprog = nil
-
- return o.query(minfo, qpos)
-}
-
-// reduceScope is called for one-shot queries that need only a single
-// typed package. It attempts to guess the query package from pos and
-// reduce the analysis scope (set of loaded packages) to just that one
-// plus (the exported parts of) its dependencies. It leaves its
-// arguments unchanged on failure.
-//
-// TODO(adonovan): this is a real mess... but it's fast.
-//
-func reduceScope(pos string, conf *loader.Config) {
- fqpos, err := fastQueryPos(pos)
- if err != nil {
- return // bad query
- }
-
- // TODO(adonovan): fix: this gives the wrong results for files
- // in non-importable packages such as tests and ad-hoc packages
- // specified as a list of files (incl. the oracle's tests).
- _, importPath, err := guessImportPath(fqpos.fset.File(fqpos.start).Name(), conf.Build)
- if err != nil {
- return // can't find GOPATH dir
- }
- if importPath == "" {
- return
- }
-
- // Check that it's possible to load the queried package.
- // (e.g. oracle tests contain different 'package' decls in same dir.)
- // Keep consistent with logic in loader/util.go!
- cfg2 := *conf.Build
- cfg2.CgoEnabled = false
- bp, err := cfg2.Import(importPath, "", 0)
- if err != nil {
- return // no files for package
- }
-
- // Check that the queried file appears in the package:
- // it might be a '// +build ignore' from an ad-hoc main
- // package, e.g. $GOROOT/src/pkg/net/http/triv.go.
- if !pkgContainsFile(bp, fqpos.fset.File(fqpos.start).Name()) {
- return // not found
- }
-
- conf.TypeCheckFuncBodies = func(p string) bool { return p == importPath }
-
- // Ignore packages specified on command line.
- conf.CreatePkgs = nil
- conf.ImportPkgs = nil
-
- // Instead load just the one containing the query position
- // (and possibly its corresponding tests/production code).
- // TODO(adonovan): set 'augment' based on which file list
- // contains
- _ = conf.ImportWithTests(importPath) // ignore error
-}
-
-func pkgContainsFile(bp *build.Package, filename string) bool {
- for _, files := range [][]string{bp.GoFiles, bp.TestGoFiles, bp.XTestGoFiles} {
- for _, file := range files {
- if sameFile(file, filename) {
- return true
- }
- }
- }
- return false
-}
-
-// New constructs a new Oracle that can be used for a sequence of queries.
-//
-// iprog specifies the program to analyze.
-// ptalog is the (optional) pointer-analysis log file.
-// reflection determines whether to model reflection soundly (currently slow).
-//
-func New(iprog *loader.Program, ptalog io.Writer, reflection bool) (*Oracle, error) {
- return newOracle(iprog, ptalog, needAll, reflection)
-}
-
-func newOracle(iprog *loader.Program, ptalog io.Writer, needs int, reflection bool) (*Oracle, error) {
- o := &Oracle{fset: iprog.Fset}
-
- // Retain type info for all ASTs in the program.
- if needs&needRetainTypeInfo != 0 {
- o.typeInfo = iprog.AllPackages
- }
-
- // Create SSA package for the initial packages and their dependencies.
- if needs&needSSA != 0 {
- var mode ssa.BuilderMode
- if needs&needSSADebug != 0 {
- mode |= ssa.GlobalDebug
- }
- prog := ssa.Create(iprog, mode)
-
- // For each initial package (specified on the command line),
- // if it has a main function, analyze that,
- // otherwise analyze its tests, if any.
- var testPkgs, mains []*ssa.Package
- for _, info := range iprog.InitialPackages() {
- initialPkg := prog.Package(info.Pkg)
-
- // Add package to the pointer analysis scope.
- if initialPkg.Func("main") != nil {
- mains = append(mains, initialPkg)
- } else {
- testPkgs = append(testPkgs, initialPkg)
- }
- }
- if testPkgs != nil {
- if p := prog.CreateTestMainPackage(testPkgs...); p != nil {
- mains = append(mains, p)
- }
- }
- if mains == nil {
- return nil, fmt.Errorf("analysis scope has no main and no tests")
- }
- o.ptaConfig.Log = ptalog
- o.ptaConfig.Reflection = reflection
- o.ptaConfig.Mains = mains
-
- o.prog = prog
- }
-
- return o, nil
-}
-
-// Query runs the query of the specified mode and selection.
-//
-// TODO(adonovan): fix: this function does not currently support the
-// "what" query, which needs to access the go/build.Context.
-//
-func (o *Oracle) Query(mode string, qpos *QueryPos) (*Result, error) {
- minfo := findMode(mode)
- if minfo == nil {
- return nil, fmt.Errorf("invalid mode type: %q", mode)
- }
- return o.query(minfo, qpos)
-}
-
-func (o *Oracle) query(minfo *modeInfo, qpos *QueryPos) (*Result, error) {
- // Clear out residue of previous query (for long-running clients).
- o.ptaConfig.Queries = nil
- o.ptaConfig.IndirectQueries = nil
-
- res := &Result{
- mode: minfo.name,
- fset: o.fset,
- }
- var err error
- res.q, err = minfo.impl(o, qpos)
- if err != nil {
- return nil, err
- }
- return res, nil
-}
-
-// ParseQueryPos parses the source query position pos.
-// If needExact, it must identify a single AST subtree;
-// this is appropriate for queries that allow fairly arbitrary syntax,
-// e.g. "describe".
-//
-func ParseQueryPos(iprog *loader.Program, posFlag string, needExact bool) (*QueryPos, error) {
- filename, startOffset, endOffset, err := parsePosFlag(posFlag)
- if err != nil {
- return nil, err
- }
- start, end, err := findQueryPos(iprog.Fset, filename, startOffset, endOffset)
- if err != nil {
- return nil, err
- }
- info, path, exact := iprog.PathEnclosingInterval(start, end)
- if path == nil {
- return nil, fmt.Errorf("no syntax here")
- }
- if needExact && !exact {
- return nil, fmt.Errorf("ambiguous selection within %s", astutil.NodeDescription(path[0]))
- }
- return &QueryPos{iprog.Fset, start, end, path, exact, info}, nil
-}
-
-// WriteTo writes the oracle query result res to out in a compiler diagnostic format.
-func (res *Result) WriteTo(out io.Writer) {
- printf := func(pos interface{}, format string, args ...interface{}) {
- fprintf(out, res.fset, pos, format, args...)
- }
- res.q.display(printf)
-
- // Print warnings after the main output.
- if res.warnings != nil {
- fmt.Fprintln(out, "\nPointer analysis warnings:")
- for _, w := range res.warnings {
- printf(w.Pos, "warning: "+w.Message)
- }
- }
-}
-
-// ---------- Utilities ----------
-
-// buildSSA constructs the SSA representation of Go-source function bodies.
-// Not needed in simpler modes, e.g. freevars.
-//
-func buildSSA(o *Oracle) {
- o.prog.BuildAll()
-}
-
-// ptrAnalysis runs the pointer analysis and returns its result.
-func ptrAnalysis(o *Oracle) *pointer.Result {
- result, err := pointer.Analyze(&o.ptaConfig)
- if err != nil {
- panic(err) // pointer analysis internal error
- }
- return result
-}
-
-// unparen returns e with any enclosing parentheses stripped.
-func unparen(e ast.Expr) ast.Expr {
- for {
- p, ok := e.(*ast.ParenExpr)
- if !ok {
- break
- }
- e = p.X
- }
- return e
-}
-
-// deref returns a pointer's element type; otherwise it returns typ.
-func deref(typ types.Type) types.Type {
- if p, ok := typ.Underlying().(*types.Pointer); ok {
- return p.Elem()
- }
- return typ
-}
-
-// fprintf prints to w a message of the form "location: message\n"
-// where location is derived from pos.
-//
-// pos must be one of:
-// - a token.Pos, denoting a position
-// - an ast.Node, denoting an interval
-// - anything with a Pos() method:
-// ssa.Member, ssa.Value, ssa.Instruction, types.Object, pointer.Label, etc.
-// - a QueryPos, denoting the extent of the user's query.
-// - nil, meaning no position at all.
-//
-// The output format is is compatible with the 'gnu'
-// compilation-error-regexp in Emacs' compilation mode.
-// TODO(adonovan): support other editors.
-//
-func fprintf(w io.Writer, fset *token.FileSet, pos interface{}, format string, args ...interface{}) {
- var start, end token.Pos
- switch pos := pos.(type) {
- case ast.Node:
- start = pos.Pos()
- end = pos.End()
- case token.Pos:
- start = pos
- end = start
- case interface {
- Pos() token.Pos
- }:
- start = pos.Pos()
- end = start
- case *QueryPos:
- start = pos.start
- end = pos.end
- case nil:
- // no-op
- default:
- panic(fmt.Sprintf("invalid pos: %T", pos))
- }
-
- if sp := fset.Position(start); start == end {
- // (prints "-: " for token.NoPos)
- fmt.Fprintf(w, "%s: ", sp)
- } else {
- ep := fset.Position(end)
- // The -1 below is a concession to Emacs's broken use of
- // inclusive (not half-open) intervals.
- // Other editors may not want it.
- // TODO(adonovan): add an -editor=vim|emacs|acme|auto
- // flag; auto uses EMACS=t / VIM=... / etc env vars.
- fmt.Fprintf(w, "%s:%d.%d-%d.%d: ",
- sp.Filename, sp.Line, sp.Column, ep.Line, ep.Column-1)
- }
- fmt.Fprintf(w, format, args...)
- io.WriteString(w, "\n")
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/oracle_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/oracle_test.go
deleted file mode 100644
index 3bbd23f9..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/oracle_test.go
+++ /dev/null
@@ -1,319 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle_test
-
-// This file defines a test framework for oracle queries.
-//
-// The files beneath testdata/src/main contain Go programs containing
-// query annotations of the form:
-//
-// @verb id "select"
-//
-// where verb is the query mode (e.g. "callers"), id is a unique name
-// for this query, and "select" is a regular expression matching the
-// substring of the current line that is the query's input selection.
-//
-// The expected output for each query is provided in the accompanying
-// .golden file.
-//
-// (Location information is not included because it's too fragile to
-// display as text. TODO(adonovan): think about how we can test its
-// correctness, since it is critical information.)
-//
-// Run this test with:
-// % go test code.google.com/p/go.tools/oracle -update
-// to update the golden files.
-
-import (
- "bytes"
- "encoding/json"
- "flag"
- "fmt"
- "go/build"
- "go/parser"
- "go/token"
- "io"
- "io/ioutil"
- "os"
- "os/exec"
- "regexp"
- "runtime"
- "strconv"
- "strings"
- "testing"
-
- "code.google.com/p/go.tools/go/loader"
- "code.google.com/p/go.tools/oracle"
-)
-
-var updateFlag = flag.Bool("update", false, "Update the golden files.")
-
-type query struct {
- id string // unique id
- verb string // query mode, e.g. "callees"
- posn token.Position // position of of query
- filename string
- queryPos string // value of -pos flag
-}
-
-func parseRegexp(text string) (*regexp.Regexp, error) {
- pattern, err := strconv.Unquote(text)
- if err != nil {
- return nil, fmt.Errorf("can't unquote %s", text)
- }
- return regexp.Compile(pattern)
-}
-
-// parseQueries parses and returns the queries in the named file.
-func parseQueries(t *testing.T, filename string) []*query {
- filedata, err := ioutil.ReadFile(filename)
- if err != nil {
- t.Fatal(err)
- }
-
- // Parse the file once to discover the test queries.
- var fset token.FileSet
- f, err := parser.ParseFile(&fset, filename, filedata, parser.ParseComments)
- if err != nil {
- t.Fatal(err)
- }
-
- lines := bytes.Split(filedata, []byte("\n"))
-
- var queries []*query
- queriesById := make(map[string]*query)
-
- // Find all annotations of these forms:
- expectRe := regexp.MustCompile(`@([a-z]+)\s+(\S+)\s+(\".*)$`) // @verb id "regexp"
- for _, c := range f.Comments {
- text := strings.TrimSpace(c.Text())
- if text == "" || text[0] != '@' {
- continue
- }
- posn := fset.Position(c.Pos())
-
- // @verb id "regexp"
- match := expectRe.FindStringSubmatch(text)
- if match == nil {
- t.Errorf("%s: ill-formed query: %s", posn, text)
- continue
- }
-
- id := match[2]
- if prev, ok := queriesById[id]; ok {
- t.Errorf("%s: duplicate id %s", posn, id)
- t.Errorf("%s: previously used here", prev.posn)
- continue
- }
-
- q := &query{
- id: id,
- verb: match[1],
- filename: filename,
- posn: posn,
- }
-
- if match[3] != `"nopos"` {
- selectRe, err := parseRegexp(match[3])
- if err != nil {
- t.Errorf("%s: %s", posn, err)
- continue
- }
-
- // Find text of the current line, sans query.
- // (Queries must be // not /**/ comments.)
- line := lines[posn.Line-1][:posn.Column-1]
-
- // Apply regexp to current line to find input selection.
- loc := selectRe.FindIndex(line)
- if loc == nil {
- t.Errorf("%s: selection pattern %s doesn't match line %q",
- posn, match[3], string(line))
- continue
- }
-
- // Assumes ASCII. TODO(adonovan): test on UTF-8.
- linestart := posn.Offset - (posn.Column - 1)
-
- // Compute the file offsets.
- q.queryPos = fmt.Sprintf("%s:#%d,#%d",
- filename, linestart+loc[0], linestart+loc[1])
- }
-
- queries = append(queries, q)
- queriesById[id] = q
- }
-
- // Return the slice, not map, for deterministic iteration.
- return queries
-}
-
-// WriteResult writes res (-format=plain) to w, stripping file locations.
-func WriteResult(w io.Writer, res *oracle.Result) {
- capture := new(bytes.Buffer) // capture standard output
- res.WriteTo(capture)
- for _, line := range strings.Split(capture.String(), "\n") {
- // Remove a "file:line: " prefix.
- if i := strings.Index(line, ": "); i >= 0 {
- line = line[i+2:]
- }
- fmt.Fprintf(w, "%s\n", line)
- }
-}
-
-// doQuery poses query q to the oracle and writes its response and
-// error (if any) to out.
-func doQuery(out io.Writer, q *query, useJson bool) {
- fmt.Fprintf(out, "-------- @%s %s --------\n", q.verb, q.id)
-
- var buildContext = build.Default
- buildContext.GOPATH = "testdata"
- res, err := oracle.Query([]string{q.filename},
- q.verb,
- q.queryPos,
- nil, // ptalog,
- &buildContext,
- true) // reflection
- if err != nil {
- fmt.Fprintf(out, "\nError: %s\n", err)
- return
- }
-
- if useJson {
- // JSON output
- b, err := json.MarshalIndent(res.Serial(), "", "\t")
- if err != nil {
- fmt.Fprintf(out, "JSON error: %s\n", err.Error())
- return
- }
- out.Write(b)
- } else {
- // "plain" (compiler diagnostic format) output
- WriteResult(out, res)
- }
-}
-
-func TestOracle(t *testing.T) {
- switch runtime.GOOS {
- case "windows":
- t.Skipf("skipping test on %q (no /usr/bin/diff)", runtime.GOOS)
- }
-
- for _, filename := range []string{
- "testdata/src/main/calls.go",
- "testdata/src/main/callgraph.go",
- "testdata/src/main/callgraph2.go",
- "testdata/src/main/describe.go",
- "testdata/src/main/freevars.go",
- "testdata/src/main/implements.go",
- "testdata/src/main/imports.go",
- "testdata/src/main/peers.go",
- "testdata/src/main/pointsto.go",
- "testdata/src/main/reflection.go",
- "testdata/src/main/what.go",
- // JSON:
- // TODO(adonovan): most of these are very similar; combine them.
- "testdata/src/main/callgraph-json.go",
- "testdata/src/main/calls-json.go",
- "testdata/src/main/peers-json.go",
- "testdata/src/main/describe-json.go",
- "testdata/src/main/implements-json.go",
- "testdata/src/main/pointsto-json.go",
- "testdata/src/main/referrers-json.go",
- "testdata/src/main/what-json.go",
- } {
- useJson := strings.HasSuffix(filename, "-json.go")
- queries := parseQueries(t, filename)
- golden := filename + "lden"
- got := filename + "t"
- gotfh, err := os.Create(got)
- if err != nil {
- t.Errorf("Create(%s) failed: %s", got, err)
- continue
- }
- defer gotfh.Close()
- defer os.Remove(got)
-
- // Run the oracle on each query, redirecting its output
- // and error (if any) to the foo.got file.
- for _, q := range queries {
- doQuery(gotfh, q, useJson)
- }
-
- // Compare foo.got with foo.golden.
- var cmd *exec.Cmd
- switch runtime.GOOS {
- case "plan9":
- cmd = exec.Command("/bin/diff", "-c", golden, got)
- default:
- cmd = exec.Command("/usr/bin/diff", "-u", golden, got)
- }
- buf := new(bytes.Buffer)
- cmd.Stdout = buf
- cmd.Stderr = os.Stderr
- if err := cmd.Run(); err != nil {
- t.Errorf("Oracle tests for %s failed: %s.\n%s\n",
- filename, err, buf)
-
- if *updateFlag {
- t.Logf("Updating %s...", golden)
- if err := exec.Command("/bin/cp", got, golden).Run(); err != nil {
- t.Errorf("Update failed: %s", err)
- }
- }
- }
- }
-}
-
-func TestMultipleQueries(t *testing.T) {
- // Loader
- var buildContext = build.Default
- buildContext.GOPATH = "testdata"
- conf := loader.Config{Build: &buildContext, SourceImports: true}
- filename := "testdata/src/main/multi.go"
- conf.CreateFromFilenames("", filename)
- iprog, err := conf.Load()
- if err != nil {
- t.Fatalf("Load failed: %s", err)
- }
-
- // Oracle
- o, err := oracle.New(iprog, nil, true)
- if err != nil {
- t.Fatalf("oracle.New failed: %s", err)
- }
-
- // QueryPos
- pos := filename + ":#54,#58"
- qpos, err := oracle.ParseQueryPos(iprog, pos, true)
- if err != nil {
- t.Fatalf("oracle.ParseQueryPos(%q) failed: %s", pos, err)
- }
- // SSA is built and we have the QueryPos.
- // Release the other ASTs and type info to the GC.
- iprog = nil
-
- // Run different query modes on same scope and selection.
- out := new(bytes.Buffer)
- for _, mode := range [...]string{"callers", "describe", "freevars"} {
- res, err := o.Query(mode, qpos)
- if err != nil {
- t.Errorf("(*oracle.Oracle).Query(%q) failed: %s", pos, err)
- }
- WriteResult(out, res)
- }
- want := `multi.f is called from these 1 sites:
- static function call from multi.main
-
-function call (or conversion) of type ()
-
-Free identifiers:
-var x int
-
-`
- if got := out.String(); got != want {
- t.Errorf("Query output differs; want <<%s>>, got <<%s>>\n", want, got)
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/peers.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/peers.go
deleted file mode 100644
index d4c910d5..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/peers.go
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- "sort"
-
- "code.google.com/p/go.tools/go/ssa"
- "code.google.com/p/go.tools/go/ssa/ssautil"
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// peers enumerates, for a given channel send (or receive) operation,
-// the set of possible receives (or sends) that correspond to it.
-//
-// TODO(adonovan): support reflect.{Select,Recv,Send,Close}.
-// TODO(adonovan): permit the user to query based on a MakeChan (not send/recv),
-// or the implicit receive in "for v := range ch".
-// TODO(adonovan): support "close" as a channel op.
-//
-func peers(o *Oracle, qpos *QueryPos) (queryResult, error) {
- arrowPos := findArrow(qpos)
- if arrowPos == token.NoPos {
- return nil, fmt.Errorf("there is no send/receive here")
- }
-
- buildSSA(o)
-
- var queryOp chanOp // the originating send or receive operation
- var ops []chanOp // all sends/receives of opposite direction
-
- // Look at all send/receive instructions in the whole ssa.Program.
- // Build a list of those of same type to query.
- allFuncs := ssautil.AllFunctions(o.prog)
- for fn := range allFuncs {
- for _, b := range fn.Blocks {
- for _, instr := range b.Instrs {
- for _, op := range chanOps(instr) {
- ops = append(ops, op)
- if op.pos == arrowPos {
- queryOp = op // we found the query op
- }
- }
- }
- }
- }
- if queryOp.ch == nil {
- return nil, fmt.Errorf("ssa.Instruction for send/receive not found")
- }
-
- // Discard operations of wrong channel element type.
- // Build set of channel ssa.Values as query to pointer analysis.
- // We compare channels by element types, not channel types, to
- // ignore both directionality and type names.
- queryType := queryOp.ch.Type()
- queryElemType := queryType.Underlying().(*types.Chan).Elem()
- o.ptaConfig.AddQuery(queryOp.ch)
- i := 0
- for _, op := range ops {
- if types.Identical(op.ch.Type().Underlying().(*types.Chan).Elem(), queryElemType) {
- o.ptaConfig.AddQuery(op.ch)
- ops[i] = op
- i++
- }
- }
- ops = ops[:i]
-
- // Run the pointer analysis.
- ptares := ptrAnalysis(o)
-
- // Find the points-to set.
- queryChanPtr := ptares.Queries[queryOp.ch]
-
- // Ascertain which make(chan) labels the query's channel can alias.
- var makes []token.Pos
- for _, label := range queryChanPtr.PointsTo().Labels() {
- makes = append(makes, label.Pos())
- }
- sort.Sort(byPos(makes))
-
- // Ascertain which send/receive operations can alias the same make(chan) labels.
- var sends, receives []token.Pos
- for _, op := range ops {
- if ptr, ok := ptares.Queries[op.ch]; ok && ptr.MayAlias(queryChanPtr) {
- if op.dir == types.SendOnly {
- sends = append(sends, op.pos)
- } else {
- receives = append(receives, op.pos)
- }
- }
- }
- sort.Sort(byPos(sends))
- sort.Sort(byPos(receives))
-
- return &peersResult{
- queryPos: arrowPos,
- queryType: queryType,
- makes: makes,
- sends: sends,
- receives: receives,
- }, nil
-}
-
-// findArrow returns the position of the enclosing send/receive op
-// (<-) for the query position, or token.NoPos if not found.
-//
-func findArrow(qpos *QueryPos) token.Pos {
- for _, n := range qpos.path {
- switch n := n.(type) {
- case *ast.UnaryExpr:
- if n.Op == token.ARROW {
- return n.OpPos
- }
- case *ast.SendStmt:
- return n.Arrow
- }
- }
- return token.NoPos
-}
-
-// chanOp abstracts an ssa.Send, ssa.Unop(ARROW), or a SelectState.
-type chanOp struct {
- ch ssa.Value
- dir types.ChanDir // SendOnly or RecvOnly
- pos token.Pos
-}
-
-// chanOps returns a slice of all the channel operations in the instruction.
-func chanOps(instr ssa.Instruction) []chanOp {
- // TODO(adonovan): handle calls to reflect.{Select,Recv,Send,Close} too.
- var ops []chanOp
- switch instr := instr.(type) {
- case *ssa.UnOp:
- if instr.Op == token.ARROW {
- ops = append(ops, chanOp{instr.X, types.RecvOnly, instr.Pos()})
- }
- case *ssa.Send:
- ops = append(ops, chanOp{instr.Chan, types.SendOnly, instr.Pos()})
- case *ssa.Select:
- for _, st := range instr.States {
- ops = append(ops, chanOp{st.Chan, st.Dir, st.Pos})
- }
- }
- return ops
-}
-
-type peersResult struct {
- queryPos token.Pos // of queried '<-' token
- queryType types.Type // type of queried channel
- makes, sends, receives []token.Pos // positions of alisaed makechan/send/receive instrs
-}
-
-func (r *peersResult) display(printf printfFunc) {
- if len(r.makes) == 0 {
- printf(r.queryPos, "This channel can't point to anything.")
- return
- }
- printf(r.queryPos, "This channel of type %s may be:", r.queryType)
- for _, alloc := range r.makes {
- printf(alloc, "\tallocated here")
- }
- for _, send := range r.sends {
- printf(send, "\tsent to, here")
- }
- for _, receive := range r.receives {
- printf(receive, "\treceived from, here")
- }
-}
-
-func (r *peersResult) toSerial(res *serial.Result, fset *token.FileSet) {
- peers := &serial.Peers{
- Pos: fset.Position(r.queryPos).String(),
- Type: r.queryType.String(),
- }
- for _, alloc := range r.makes {
- peers.Allocs = append(peers.Allocs, fset.Position(alloc).String())
- }
- for _, send := range r.sends {
- peers.Sends = append(peers.Sends, fset.Position(send).String())
- }
- for _, receive := range r.receives {
- peers.Receives = append(peers.Receives, fset.Position(receive).String())
- }
- res.Peers = peers
-}
-
-// -------- utils --------
-
-type byPos []token.Pos
-
-func (p byPos) Len() int { return len(p) }
-func (p byPos) Less(i, j int) bool { return p[i] < p[j] }
-func (p byPos) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/pointsto.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/pointsto.go
deleted file mode 100644
index 76eb2aaf..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/pointsto.go
+++ /dev/null
@@ -1,255 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- "sort"
-
- "code.google.com/p/go.tools/astutil"
- "code.google.com/p/go.tools/go/loader"
- "code.google.com/p/go.tools/go/pointer"
- "code.google.com/p/go.tools/go/ssa"
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// pointsto runs the pointer analysis on the selected expression,
-// and reports its points-to set (for a pointer-like expression)
-// or its dynamic types (for an interface, reflect.Value, or
-// reflect.Type expression) and their points-to sets.
-//
-// All printed sets are sorted to ensure determinism.
-//
-func pointsto(o *Oracle, qpos *QueryPos) (queryResult, error) {
- path, action := findInterestingNode(qpos.info, qpos.path)
- if action != actionExpr {
- return nil, fmt.Errorf("pointer analysis wants an expression; got %s",
- astutil.NodeDescription(qpos.path[0]))
- }
-
- var expr ast.Expr
- var obj types.Object
- switch n := path[0].(type) {
- case *ast.ValueSpec:
- // ambiguous ValueSpec containing multiple names
- return nil, fmt.Errorf("multiple value specification")
- case *ast.Ident:
- obj = qpos.info.ObjectOf(n)
- expr = n
- case ast.Expr:
- expr = n
- default:
- // TODO(adonovan): is this reachable?
- return nil, fmt.Errorf("unexpected AST for expr: %T", n)
- }
-
- // Reject non-pointerlike types (includes all constants).
- typ := qpos.info.TypeOf(expr)
- if !pointer.CanPoint(typ) {
- return nil, fmt.Errorf("pointer analysis wants an expression of reference type; got %s", typ)
- }
-
- // Determine the ssa.Value for the expression.
- var value ssa.Value
- var isAddr bool
- var err error
- if obj != nil {
- // def/ref of func/var object
- value, isAddr, err = ssaValueForIdent(o.prog, qpos.info, obj, path)
- } else {
- value, isAddr, err = ssaValueForExpr(o.prog, qpos.info, path)
- }
- if err != nil {
- return nil, err // e.g. trivially dead code
- }
-
- // Run the pointer analysis.
- ptrs, err := runPTA(o, value, isAddr)
- if err != nil {
- return nil, err // e.g. analytically unreachable
- }
-
- return &pointstoResult{
- qpos: qpos,
- typ: typ,
- ptrs: ptrs,
- }, nil
-}
-
-// ssaValueForIdent returns the ssa.Value for the ast.Ident whose path
-// to the root of the AST is path. isAddr reports whether the
-// ssa.Value is the address denoted by the ast.Ident, not its value.
-//
-func ssaValueForIdent(prog *ssa.Program, qinfo *loader.PackageInfo, obj types.Object, path []ast.Node) (value ssa.Value, isAddr bool, err error) {
- switch obj := obj.(type) {
- case *types.Var:
- pkg := prog.Package(qinfo.Pkg)
- pkg.Build()
- if v, addr := prog.VarValue(obj, pkg, path); v != nil {
- return v, addr, nil
- }
- return nil, false, fmt.Errorf("can't locate SSA Value for var %s", obj.Name())
-
- case *types.Func:
- return prog.FuncValue(obj), false, nil
- }
- panic(obj)
-}
-
-// ssaValueForExpr returns the ssa.Value of the non-ast.Ident
-// expression whose path to the root of the AST is path.
-//
-func ssaValueForExpr(prog *ssa.Program, qinfo *loader.PackageInfo, path []ast.Node) (value ssa.Value, isAddr bool, err error) {
- pkg := prog.Package(qinfo.Pkg)
- pkg.SetDebugMode(true)
- pkg.Build()
-
- fn := ssa.EnclosingFunction(pkg, path)
- if fn == nil {
- return nil, false, fmt.Errorf("no SSA function built for this location (dead code?)")
- }
-
- if v, addr := fn.ValueForExpr(path[0].(ast.Expr)); v != nil {
- return v, addr, nil
- }
-
- return nil, false, fmt.Errorf("can't locate SSA Value for expression in %s", fn)
-}
-
-// runPTA runs the pointer analysis of the selected SSA value or address.
-func runPTA(o *Oracle, v ssa.Value, isAddr bool) (ptrs []pointerResult, err error) {
- buildSSA(o)
-
- if isAddr {
- o.ptaConfig.AddIndirectQuery(v)
- } else {
- o.ptaConfig.AddQuery(v)
- }
- ptares := ptrAnalysis(o)
-
- var ptr pointer.Pointer
- if isAddr {
- ptr = ptares.IndirectQueries[v]
- } else {
- ptr = ptares.Queries[v]
- }
- if ptr == (pointer.Pointer{}) {
- return nil, fmt.Errorf("pointer analysis did not find expression (dead code?)")
- }
- pts := ptr.PointsTo()
-
- if pointer.CanHaveDynamicTypes(v.Type()) {
- // Show concrete types for interface/reflect.Value expression.
- if concs := pts.DynamicTypes(); concs.Len() > 0 {
- concs.Iterate(func(conc types.Type, pta interface{}) {
- labels := pta.(pointer.PointsToSet).Labels()
- sort.Sort(byPosAndString(labels)) // to ensure determinism
- ptrs = append(ptrs, pointerResult{conc, labels})
- })
- }
- } else {
- // Show labels for other expressions.
- labels := pts.Labels()
- sort.Sort(byPosAndString(labels)) // to ensure determinism
- ptrs = append(ptrs, pointerResult{v.Type(), labels})
- }
- sort.Sort(byTypeString(ptrs)) // to ensure determinism
- return ptrs, nil
-}
-
-type pointerResult struct {
- typ types.Type // type of the pointer (always concrete)
- labels []*pointer.Label // set of labels
-}
-
-type pointstoResult struct {
- qpos *QueryPos
- typ types.Type // type of expression
- ptrs []pointerResult // pointer info (typ is concrete => len==1)
-}
-
-func (r *pointstoResult) display(printf printfFunc) {
- if pointer.CanHaveDynamicTypes(r.typ) {
- // Show concrete types for interface, reflect.Type or
- // reflect.Value expression.
-
- if len(r.ptrs) > 0 {
- printf(r.qpos, "this %s may contain these dynamic types:", r.qpos.TypeString(r.typ))
- for _, ptr := range r.ptrs {
- var obj types.Object
- if nt, ok := deref(ptr.typ).(*types.Named); ok {
- obj = nt.Obj()
- }
- if len(ptr.labels) > 0 {
- printf(obj, "\t%s, may point to:", r.qpos.TypeString(ptr.typ))
- printLabels(printf, ptr.labels, "\t\t")
- } else {
- printf(obj, "\t%s", r.qpos.TypeString(ptr.typ))
- }
- }
- } else {
- printf(r.qpos, "this %s cannot contain any dynamic types.", r.typ)
- }
- } else {
- // Show labels for other expressions.
- if ptr := r.ptrs[0]; len(ptr.labels) > 0 {
- printf(r.qpos, "this %s may point to these objects:",
- r.qpos.TypeString(r.typ))
- printLabels(printf, ptr.labels, "\t")
- } else {
- printf(r.qpos, "this %s may not point to anything.",
- r.qpos.TypeString(r.typ))
- }
- }
-}
-
-func (r *pointstoResult) toSerial(res *serial.Result, fset *token.FileSet) {
- var pts []serial.PointsTo
- for _, ptr := range r.ptrs {
- var namePos string
- if nt, ok := deref(ptr.typ).(*types.Named); ok {
- namePos = fset.Position(nt.Obj().Pos()).String()
- }
- var labels []serial.PointsToLabel
- for _, l := range ptr.labels {
- labels = append(labels, serial.PointsToLabel{
- Pos: fset.Position(l.Pos()).String(),
- Desc: l.String(),
- })
- }
- pts = append(pts, serial.PointsTo{
- Type: r.qpos.TypeString(ptr.typ),
- NamePos: namePos,
- Labels: labels,
- })
- }
- res.PointsTo = pts
-}
-
-type byTypeString []pointerResult
-
-func (a byTypeString) Len() int { return len(a) }
-func (a byTypeString) Less(i, j int) bool { return a[i].typ.String() < a[j].typ.String() }
-func (a byTypeString) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
-
-type byPosAndString []*pointer.Label
-
-func (a byPosAndString) Len() int { return len(a) }
-func (a byPosAndString) Less(i, j int) bool {
- cmp := a[i].Pos() - a[j].Pos()
- return cmp < 0 || (cmp == 0 && a[i].String() < a[j].String())
-}
-func (a byPosAndString) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
-
-func printLabels(printf printfFunc, labels []*pointer.Label, prefix string) {
- // TODO(adonovan): due to context-sensitivity, many of these
- // labels may differ only by context, which isn't apparent.
- for _, label := range labels {
- printf(label, "%s%s", prefix, label)
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/pos.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/pos.go
deleted file mode 100644
index 4ae30a6e..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/pos.go
+++ /dev/null
@@ -1,149 +0,0 @@
-package oracle
-
-// This file defines utilities for working with file positions.
-
-import (
- "fmt"
- "go/parser"
- "go/token"
- "os"
- "path/filepath"
- "strconv"
- "strings"
-
- "code.google.com/p/go.tools/astutil"
-)
-
-// parseOctothorpDecimal returns the numeric value if s matches "#%d",
-// otherwise -1.
-func parseOctothorpDecimal(s string) int {
- if s != "" && s[0] == '#' {
- if s, err := strconv.ParseInt(s[1:], 10, 32); err == nil {
- return int(s)
- }
- }
- return -1
-}
-
-// parsePosFlag parses a string of the form "file:pos" or
-// file:start,end" where pos, start, end match #%d and represent byte
-// offsets, and returns its components.
-//
-// (Numbers without a '#' prefix are reserved for future use,
-// e.g. to indicate line/column positions.)
-//
-func parsePosFlag(posFlag string) (filename string, startOffset, endOffset int, err error) {
- if posFlag == "" {
- err = fmt.Errorf("no source position specified (-pos flag)")
- return
- }
-
- colon := strings.LastIndex(posFlag, ":")
- if colon < 0 {
- err = fmt.Errorf("invalid source position -pos=%q", posFlag)
- return
- }
- filename, offset := posFlag[:colon], posFlag[colon+1:]
- startOffset = -1
- endOffset = -1
- if hyphen := strings.Index(offset, ","); hyphen < 0 {
- // e.g. "foo.go:#123"
- startOffset = parseOctothorpDecimal(offset)
- endOffset = startOffset
- } else {
- // e.g. "foo.go:#123,#456"
- startOffset = parseOctothorpDecimal(offset[:hyphen])
- endOffset = parseOctothorpDecimal(offset[hyphen+1:])
- }
- if startOffset < 0 || endOffset < 0 {
- err = fmt.Errorf("invalid -pos offset %q", offset)
- return
- }
- return
-}
-
-// findQueryPos searches fset for filename and translates the
-// specified file-relative byte offsets into token.Pos form. It
-// returns an error if the file was not found or the offsets were out
-// of bounds.
-//
-func findQueryPos(fset *token.FileSet, filename string, startOffset, endOffset int) (start, end token.Pos, err error) {
- var file *token.File
- fset.Iterate(func(f *token.File) bool {
- if sameFile(filename, f.Name()) {
- // (f.Name() is absolute)
- file = f
- return false // done
- }
- return true // continue
- })
- if file == nil {
- err = fmt.Errorf("couldn't find file containing position")
- return
- }
-
- // Range check [start..end], inclusive of both end-points.
-
- if 0 <= startOffset && startOffset <= file.Size() {
- start = file.Pos(int(startOffset))
- } else {
- err = fmt.Errorf("start position is beyond end of file")
- return
- }
-
- if 0 <= endOffset && endOffset <= file.Size() {
- end = file.Pos(int(endOffset))
- } else {
- err = fmt.Errorf("end position is beyond end of file")
- return
- }
-
- return
-}
-
-// sameFile returns true if x and y have the same basename and denote
-// the same file.
-//
-func sameFile(x, y string) bool {
- if filepath.Base(x) == filepath.Base(y) { // (optimisation)
- if xi, err := os.Stat(x); err == nil {
- if yi, err := os.Stat(y); err == nil {
- return os.SameFile(xi, yi)
- }
- }
- }
- return false
-}
-
-// fastQueryPos parses the -pos flag and returns a QueryPos.
-// It parses only a single file, and does not run the type checker.
-//
-// Caveat: the token.{FileSet,Pos} info it contains is not comparable
-// with that from the oracle's FileSet! (We don't accept oracle.fset
-// as a parameter because we don't want the same filename to appear
-// multiple times in one FileSet.)
-//
-func fastQueryPos(posFlag string) (*QueryPos, error) {
- filename, startOffset, endOffset, err := parsePosFlag(posFlag)
- if err != nil {
- return nil, err
- }
-
- fset := token.NewFileSet()
- f, err := parser.ParseFile(fset, filename, nil, 0)
- if err != nil {
- return nil, err
- }
-
- start, end, err := findQueryPos(fset, filename, startOffset, endOffset)
- if err != nil {
- return nil, err
- }
-
- path, exact := astutil.PathEnclosingInterval(f, start, end)
- if path == nil {
- return nil, fmt.Errorf("no syntax here")
- }
-
- return &QueryPos{fset, start, end, path, exact, nil}, nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/referrers.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/referrers.go
deleted file mode 100644
index ddab2361..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/referrers.go
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- "sort"
-
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// Referrers reports all identifiers that resolve to the same object
-// as the queried identifier, within any package in the analysis scope.
-//
-func referrers(o *Oracle, qpos *QueryPos) (queryResult, error) {
- id, _ := qpos.path[0].(*ast.Ident)
- if id == nil {
- return nil, fmt.Errorf("no identifier here")
- }
-
- obj := qpos.info.ObjectOf(id)
- if obj == nil {
- // Happens for y in "switch y := x.(type)", but I think that's all.
- return nil, fmt.Errorf("no object for identifier")
- }
-
- // Iterate over all go/types' Uses facts for the entire program.
- var refs []*ast.Ident
- for _, info := range o.typeInfo {
- for id2, obj2 := range info.Uses {
- if sameObj(obj, obj2) {
- refs = append(refs, id2)
- }
- }
- }
- sort.Sort(byNamePos(refs))
-
- return &referrersResult{
- query: id,
- obj: obj,
- refs: refs,
- }, nil
-}
-
-// same reports whether x and y are identical, or both are PkgNames
-// referring to the same Package.
-//
-func sameObj(x, y types.Object) bool {
- if x == y {
- return true
- }
- if _, ok := x.(*types.PkgName); ok {
- if _, ok := y.(*types.PkgName); ok {
- return x.Pkg() == y.Pkg()
- }
- }
- return false
-}
-
-// -------- utils --------
-
-type byNamePos []*ast.Ident
-
-func (p byNamePos) Len() int { return len(p) }
-func (p byNamePos) Less(i, j int) bool { return p[i].NamePos < p[j].NamePos }
-func (p byNamePos) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-
-type referrersResult struct {
- query *ast.Ident // identifer of query
- obj types.Object // object it denotes
- refs []*ast.Ident // set of all other references to it
-}
-
-func (r *referrersResult) display(printf printfFunc) {
- if r.query.Pos() != r.obj.Pos() {
- printf(r.query, "reference to %s", r.obj.Name())
- }
- // TODO(adonovan): pretty-print object using same logic as
- // (*describeValueResult).display.
- printf(r.obj, "defined here as %s", r.obj)
- for _, ref := range r.refs {
- if r.query != ref {
- printf(ref, "referenced here")
- }
- }
-}
-
-// TODO(adonovan): encode extent, not just Pos info, in Serial form.
-
-func (r *referrersResult) toSerial(res *serial.Result, fset *token.FileSet) {
- referrers := &serial.Referrers{
- Pos: fset.Position(r.query.Pos()).String(),
- Desc: r.obj.String(),
- }
- if pos := r.obj.Pos(); pos != token.NoPos { // Package objects have no Pos()
- referrers.ObjPos = fset.Position(pos).String()
- }
- for _, ref := range r.refs {
- referrers.Refs = append(referrers.Refs, fset.Position(ref.NamePos).String())
- }
- res.Referrers = referrers
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/serial/serial.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/serial/serial.go
deleted file mode 100644
index 316ecffc..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/serial/serial.go
+++ /dev/null
@@ -1,255 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package serial defines the oracle's schema for structured data
-// serialization using JSON, XML, etc.
-package serial
-
-// All 'pos' strings are of the form "file:line:col".
-// TODO(adonovan): improve performance by sharing filename strings.
-// TODO(adonovan): improve precision by providing the start/end
-// interval when available.
-//
-// TODO(adonovan): consider richer encodings of types, functions,
-// methods, etc.
-
-// A Peers is the result of a 'peers' query.
-// If Allocs is empty, the selected channel can't point to anything.
-type Peers struct {
- Pos string `json:"pos"` // location of the selected channel op (<-)
- Type string `json:"type"` // type of the selected channel
- Allocs []string `json:"allocs,omitempty"` // locations of aliased make(chan) ops
- Sends []string `json:"sends,omitempty"` // locations of aliased ch<-x ops
- Receives []string `json:"receives,omitempty"` // locations of aliased <-ch ops
-}
-
-// A Referrers is the result of a 'referrers' query.
-type Referrers struct {
- Pos string `json:"pos"` // location of the query reference
- ObjPos string `json:"objpos,omitempty"` // location of the definition
- Desc string `json:"desc"` // description of the denoted object
- Refs []string `json:"refs,omitempty"` // locations of all references
-}
-
-// A Definition is the result of a 'definition' query.
-type Definition struct {
- ObjPos string `json:"objpos,omitempty"` // location of the definition
- Desc string `json:"desc"` // description of the denoted object
-}
-
-type CalleesItem struct {
- Name string `json:"name"` // full name of called function
- Pos string `json:"pos"` // location of called function
-}
-
-// A Callees is the result of a 'callees' query.
-//
-// Callees is nonempty unless the call was a dynamic call on a
-// provably nil func or interface value.
-type Callees struct {
- Pos string `json:"pos"` // location of selected call site
- Desc string `json:"desc"` // description of call site
- Callees []*CalleesItem `json:"callees,omitempty"` // set of possible call targets
-}
-
-// A Caller is one element of the slice returned by a 'callers' query.
-// (Callstack also contains a similar slice.)
-//
-// The root of the callgraph has an unspecified "Caller" string.
-type Caller struct {
- Pos string `json:"pos,omitempty"` // location of the calling function
- Desc string `json:"desc"` // description of call site
- Caller string `json:"caller"` // full name of calling function
-}
-
-// A CallGraph is one element of the slice returned by a 'callgraph' query.
-// The index of each item in the slice is used to identify it in the
-// Callers adjacency list.
-//
-// Multiple nodes may have the same Name due to context-sensitive
-// treatment of some functions.
-//
-// TODO(adonovan): perhaps include edge labels (i.e. callsites).
-type CallGraph struct {
- Name string `json:"name"` // full name of function
- Pos string `json:"pos"` // location of function
- Children []int `json:"children,omitempty"` // indices of child nodes in callgraph list
-}
-
-// A CallStack is the result of a 'callstack' query.
-// It indicates an arbitrary path from the root of the callgraph to
-// the query function.
-//
-// If the Callers slice is empty, the function was unreachable in this
-// analysis scope.
-type CallStack struct {
- Pos string `json:"pos"` // location of the selected function
- Target string `json:"target"` // the selected function
- Callers []Caller `json:"callers"` // enclosing calls, innermost first.
-}
-
-// A FreeVar is one element of the slice returned by a 'freevars'
-// query. Each one identifies an expression referencing a local
-// identifier defined outside the selected region.
-type FreeVar struct {
- Pos string `json:"pos"` // location of the identifier's definition
- Kind string `json:"kind"` // one of {var,func,type,const,label}
- Ref string `json:"ref"` // referring expression (e.g. "x" or "x.y.z")
- Type string `json:"type"` // type of the expression
-}
-
-// An Implements contains the result of an 'implements' query.
-
-// It describes the queried type, the set of named non-empty interface
-// types to which it is assignable, and the set of named/*named types
-// (concrete or non-empty interface) which may be assigned to it.
-//
-type Implements struct {
- T ImplementsType `json:"type,omitempty"` // the queried type
- AssignableTo []ImplementsType `json:"to,omitempty"` // types assignable to T
- AssignableFrom []ImplementsType `json:"from,omitempty"` // interface types assignable from T
- AssignableFromPtr []ImplementsType `json:"fromptr,omitempty"` // interface types assignable only from *T
-}
-
-// An ImplementsType describes a single type as part of an 'implements' query.
-type ImplementsType struct {
- Name string `json:"name"` // full name of the type
- Pos string `json:"pos"` // location of its definition
- Kind string `json:"kind"` // "basic", "array", etc
-}
-
-// A SyntaxNode is one element of a stack of enclosing syntax nodes in
-// a "what" query.
-type SyntaxNode struct {
- Description string `json:"desc"` // description of syntax tree
- Start int `json:"start"` // start offset (0-based)
- End int `json:"end"` // end offset
-}
-
-// A What is the result of the "what" query, which quickly identifies
-// the selection, parsing only a single file. It is intended for use
-// in low-latency GUIs.
-type What struct {
- Enclosing []SyntaxNode `json:"enclosing"` // enclosing nodes of syntax tree
- Modes []string `json:"modes"` // query modes enabled for this selection.
- SrcDir string `json:"srcdir,omitempty"` // $GOROOT src directory containing queried package
- ImportPath string `json:"importpath,omitempty"` // import path of queried package
-}
-
-// A PointsToLabel describes a pointer analysis label.
-//
-// A "label" is an object that may be pointed to by a pointer, map,
-// channel, 'func', slice or interface. Labels include:
-// - functions
-// - globals
-// - arrays created by literals (e.g. []byte("foo")) and conversions ([]byte(s))
-// - stack- and heap-allocated variables (including composite literals)
-// - arrays allocated by append()
-// - channels, maps and arrays created by make()
-// - and their subelements, e.g. "alloc.y[*].z"
-//
-type PointsToLabel struct {
- Pos string `json:"pos"` // location of syntax that allocated the object
- Desc string `json:"desc"` // description of the label
-}
-
-// A PointsTo is one element of the result of a 'pointsto' query on an
-// expression. It describes a single pointer: its type and the set of
-// "labels" it points to.
-//
-// If the pointer is of interface type, it will have one PTS entry
-// describing each concrete type that it may contain. For each
-// concrete type that is a pointer, the PTS entry describes the labels
-// it may point to. The same is true for reflect.Values, except the
-// dynamic types needn't be concrete.
-//
-type PointsTo struct {
- Type string `json:"type"` // (concrete) type of the pointer
- NamePos string `json:"namepos,omitempty"` // location of type defn, if Named
- Labels []PointsToLabel `json:"labels,omitempty"` // pointed-to objects
-}
-
-// A DescribeValue is the additional result of a 'describe' query
-// if the selection indicates a value or expression.
-type DescribeValue struct {
- Type string `json:"type"` // type of the expression
- Value string `json:"value,omitempty"` // value of the expression, if constant
- ObjPos string `json:"objpos,omitempty"` // location of the definition, if an Ident
-}
-
-type DescribeMethod struct {
- Name string `json:"name"` // method name, as defined by types.Selection.String()
- Pos string `json:"pos"` // location of the method's definition
-}
-
-// A DescribeType is the additional result of a 'describe' query
-// if the selection indicates a type.
-type DescribeType struct {
- Type string `json:"type"` // the string form of the type
- NamePos string `json:"namepos,omitempty"` // location of definition of type, if named
- NameDef string `json:"namedef,omitempty"` // underlying definition of type, if named
- Methods []DescribeMethod `json:"methods,omitempty"` // methods of the type
-}
-
-type DescribeMember struct {
- Name string `json:"name"` // name of member
- Type string `json:"type,omitempty"` // type of member (underlying, if 'type')
- Value string `json:"value,omitempty"` // value of member (if 'const')
- Pos string `json:"pos"` // location of definition of member
- Kind string `json:"kind"` // one of {var,const,func,type}
- Methods []DescribeMethod `json:"methods,omitempty"` // methods (if member is a type)
-}
-
-// A DescribePackage is the additional result of a 'describe' if
-// the selection indicates a package.
-type DescribePackage struct {
- Path string `json:"path"` // import path of the package
- Members []*DescribeMember `json:"members,omitempty"` // accessible members of the package
-}
-
-// A Describe is the result of a 'describe' query.
-// It may contain an element describing the selected semantic entity
-// in detail.
-type Describe struct {
- Desc string `json:"desc"` // description of the selected syntax node
- Pos string `json:"pos"` // location of the selected syntax node
- Detail string `json:"detail,omitempty"` // one of {package, type, value}, or "".
-
- // At most one of the following fields is populated:
- // the one specified by 'detail'.
- Package *DescribePackage `json:"package,omitempty"`
- Type *DescribeType `json:"type,omitempty"`
- Value *DescribeValue `json:"value,omitempty"`
-}
-
-type PTAWarning struct {
- Pos string `json:"pos"` // location associated with warning
- Message string `json:"message"` // warning message
-}
-
-// A Result is the common result of any oracle query.
-// It contains a query-specific result element.
-//
-// TODO(adonovan): perhaps include other info such as: analysis scope,
-// raw query position, stack of ast nodes, query package, etc.
-type Result struct {
- Mode string `json:"mode"` // mode of the query
-
- // Exactly one of the following fields is populated:
- // the one specified by 'mode'.
- Callees *Callees `json:"callees,omitempty"`
- Callers []Caller `json:"callers,omitempty"`
- Callgraph []CallGraph `json:"callgraph,omitempty"`
- Callstack *CallStack `json:"callstack,omitempty"`
- Definition *Definition `json:"definition,omitempty"`
- Describe *Describe `json:"describe,omitempty"`
- Freevars []*FreeVar `json:"freevars,omitempty"`
- Implements *Implements `json:"implements,omitempty"`
- Peers *Peers `json:"peers,omitempty"`
- PointsTo []PointsTo `json:"pointsto,omitempty"`
- Referrers *Referrers `json:"referrers,omitempty"`
- What *What `json:"what,omitempty"`
-
- Warnings []PTAWarning `json:"warnings,omitempty"` // warnings from pointer analysis
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/lib/lib.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/lib/lib.go
deleted file mode 100644
index 0603d4b4..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/lib/lib.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package lib
-
-type Type int
-
-func (Type) Method(x *int) *int {
- return x
-}
-
-func Func() {
-}
-
-const Const = 3
-
-var Var = 0
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph-json.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph-json.go
deleted file mode 100644
index 33708fd0..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph-json.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package main
-
-// Tests of call-graph queries, -format=json.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See callgraph-json.golden for expected query results.
-
-func A() {}
-
-func B() {}
-
-// call is not (yet) treated context-sensitively.
-func call(f func()) {
- f()
-}
-
-// nop *is* treated context-sensitively.
-func nop() {}
-
-func call2(f func()) {
- f()
- f()
-}
-
-func main() {
- call(A)
- call(B)
-
- nop()
- nop()
-
- call2(func() {
- // called twice from main.call2,
- // but call2 is not context sensitive (yet).
- })
-
- print("builtin")
- _ = string("type conversion")
- call(nil)
- if false {
- main()
- }
- var nilFunc func()
- nilFunc()
- var i interface {
- f()
- }
- i.f()
-}
-
-func deadcode() {
- main()
-}
-
-// @callgraph callgraph "^"
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph-json.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph-json.golden
deleted file mode 100644
index f0d10860..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph-json.golden
+++ /dev/null
@@ -1,50 +0,0 @@
--------- @callgraph callgraph --------
-{
- "mode": "callgraph",
- "callgraph": [
- {
- "name": "main.main",
- "pos": "testdata/src/main/callgraph-json.go:24:6",
- "children": [
- 1,
- 2,
- 3
- ]
- },
- {
- "name": "main.call",
- "pos": "testdata/src/main/callgraph-json.go:12:6",
- "children": [
- 5,
- 6
- ]
- },
- {
- "name": "main.nop",
- "pos": "testdata/src/main/callgraph-json.go:17:6"
- },
- {
- "name": "main.call2",
- "pos": "testdata/src/main/callgraph-json.go:19:6",
- "children": [
- 7
- ]
- },
- {
- "name": "main.init",
- "pos": "-"
- },
- {
- "name": "main.A",
- "pos": "testdata/src/main/callgraph-json.go:7:6"
- },
- {
- "name": "main.B",
- "pos": "testdata/src/main/callgraph-json.go:9:6"
- },
- {
- "name": "main$1",
- "pos": "testdata/src/main/callgraph-json.go:31:8"
- }
- ]
-}
\ No newline at end of file
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph.go
deleted file mode 100644
index ee190df8..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package main
-
-// Tests of call-graph queries.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See callgraph.golden for expected query results.
-
-import "lib"
-
-func A() {}
-
-func B() {}
-
-// call is not (yet) treated context-sensitively.
-func call(f func()) {
- f()
-}
-
-// nop *is* treated context-sensitively.
-func nop() {}
-
-func call2(f func()) {
- f()
- f()
-}
-
-func main() {
- call(A)
- call(B)
-
- nop()
- nop()
-
- call2(func() {
- // called twice from main.call2,
- // but call2 is not context sensitive (yet).
- })
-
- print("builtin")
- _ = string("type conversion")
- call(nil)
- if false {
- main()
- }
- var nilFunc func()
- nilFunc()
- var i interface {
- f()
- }
- i.f()
-
- lib.Func()
-}
-
-func deadcode() {
- main()
-}
-
-// @callgraph callgraph-main "^"
-
-// @callgraph callgraph-complete "nopos"
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph.golden
deleted file mode 100644
index 34a94261..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph.golden
+++ /dev/null
@@ -1,35 +0,0 @@
--------- @callgraph callgraph-main --------
-
-Below is a call graph of package main.
-The numbered nodes form a spanning tree.
-Non-numbered nodes indicate back- or cross-edges to the node whose
- number follows in parentheses.
-
-0 init
-1 main
-2 call
-3 A
-4 B
-5 call2
-6 main$1
-7 nop
-
--------- @callgraph callgraph-complete --------
-
-Below is a call graph of the entire program.
-The numbered nodes form a spanning tree.
-Non-numbered nodes indicate back- or cross-edges to the node whose
- number follows in parentheses.
-
-0
-1 main.init
-2 lib.init
-3 main.main
-4 lib.Func
-5 main.call
-6 main.A
-7 main.B
-8 main.call2
-9 main$1
-10 main.nop
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph2.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph2.go
deleted file mode 100644
index 5da4c880..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph2.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package main
-
-// Tests of call-graph queries.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See callgraph2.golden for expected query results.
-
-// (Regression test for pointer analysis: programs that use reflection
-// create some cgnodes before the root of the callgraph.)
-import _ "reflect"
-
-func f() {}
-func main() {
- f()
-}
-
-// @callgraph callgraph "^"
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph2.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph2.golden
deleted file mode 100644
index 1208b565..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/callgraph2.golden
+++ /dev/null
@@ -1,11 +0,0 @@
--------- @callgraph callgraph --------
-
-Below is a call graph of package main.
-The numbered nodes form a spanning tree.
-Non-numbered nodes indicate back- or cross-edges to the node whose
- number follows in parentheses.
-
-0 init
-1 main
-2 f
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls-json.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls-json.go
deleted file mode 100644
index 1c7a6c99..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls-json.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package main
-
-// Tests of call-graph queries, -format=json.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See calls-json.golden for expected query results.
-
-func call(f func()) {
- f() // @callees @callees-f "f"
-}
-
-func main() {
- call(func() {
- // @callers callers-main.anon "^"
- // @callstack callstack-main.anon "^"
- })
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls-json.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls-json.golden
deleted file mode 100644
index f063bc0b..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls-json.golden
+++ /dev/null
@@ -1,33 +0,0 @@
--------- @callees @callees-f --------
-{
- "mode": "callees",
- "callees": {
- "pos": "testdata/src/main/calls-json.go:8:3",
- "desc": "dynamic function call",
- "callees": [
- {
- "name": "main$1",
- "pos": "testdata/src/main/calls-json.go:12:7"
- }
- ]
- }
-}-------- @callstack callstack-main.anon --------
-{
- "mode": "callstack",
- "callstack": {
- "pos": "testdata/src/main/calls-json.go:12:7",
- "target": "main$1",
- "callers": [
- {
- "pos": "testdata/src/main/calls-json.go:8:3",
- "desc": "dynamic function call",
- "caller": "main.call"
- },
- {
- "pos": "testdata/src/main/calls-json.go:12:6",
- "desc": "static function call",
- "caller": "main.main"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls.go
deleted file mode 100644
index 7c54e0e9..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package main
-
-// Tests of call-graph queries.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See calls.golden for expected query results.
-
-func A(x *int) { // @pointsto pointsto-A-x "x"
- // @callers callers-A "^"
- // @callstack callstack-A "^"
-}
-
-func B(x *int) { // @pointsto pointsto-B-x "x"
- // @callers callers-B "^"
-}
-
-// apply is not (yet) treated context-sensitively.
-func apply(f func(x *int), x *int) {
- f(x) // @callees callees-apply "f"
- // @callers callers-apply "^"
-}
-
-// store *is* treated context-sensitively,
-// so the points-to sets for pc, pd are precise.
-func store(ptr **int, value *int) {
- *ptr = value
- // @callers callers-store "^"
-}
-
-func call(f func() *int) {
- // Result points to anon function.
- f() // @pointsto pointsto-result-f "f"
-
- // Target of call is anon function.
- f() // @callees callees-main.call-f "f"
-
- // @callers callers-main.call "^"
-}
-
-func main() {
- var a, b int
- apply(A, &a) // @callees callees-main-apply1 "app"
- apply(B, &b)
-
- var c, d int
- var pc, pd *int // @pointsto pointsto-pc "pc"
- store(&pc, &c)
- store(&pd, &d)
- _ = pd // @pointsto pointsto-pd "pd"
-
- call(func() *int {
- // We are called twice from main.call
- // @callers callers-main.anon "^"
- return &a
- })
-
- // Errors
- _ = "no function call here" // @callees callees-err-no-call "no"
- print("builtin") // @callees callees-err-builtin "builtin"
- _ = string("type conversion") // @callees callees-err-conversion "str"
- call(nil) // @callees callees-err-bad-selection "call\\(nil"
- if false {
- main() // @callees callees-err-deadcode1 "main"
- }
- var nilFunc func()
- nilFunc() // @callees callees-err-nil-func "nilFunc"
- var i interface {
- f()
- }
- i.f() // @callees callees-err-nil-interface "i.f"
-
- i = new(myint)
- i.f() // @callees callees-not-a-wrapper "f"
-}
-
-type myint int
-
-func (myint) f() {
- // @callers callers-not-a-wrapper "^"
-}
-
-var dynamic = func() {}
-
-func deadcode() {
- main() // @callees callees-err-deadcode2 "main"
- // @callers callers-err-deadcode "^"
- // @callstack callstack-err-deadcode "^"
-
- // Within dead code, dynamic calls have no callees.
- dynamic() // @callees callees-err-deadcode3 "dynamic"
-}
-
-// This code belongs to init.
-var global = 123 // @callers callers-global "global"
-
-// The package initializer may be called by other packages' inits, or
-// in this case, the root of the callgraph. The source-level init functions
-// are in turn called by it.
-func init() {
- // @callstack callstack-init "^"
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls.golden
deleted file mode 100644
index 96e3b389..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/calls.golden
+++ /dev/null
@@ -1,108 +0,0 @@
--------- @pointsto pointsto-A-x --------
-this *int may point to these objects:
- a
- b
-
--------- @callstack callstack-A --------
-Found a call path from root to main.A
-main.A
-dynamic function call from main.apply
-static function call from main.main
-
--------- @pointsto pointsto-B-x --------
-this *int may point to these objects:
- a
- b
-
--------- @callers callers-B --------
-main.B is called from these 1 sites:
- dynamic function call from main.apply
-
--------- @callees callees-apply --------
-this dynamic function call dispatches to:
- main.A
- main.B
-
--------- @callers callers-apply --------
-main.apply is called from these 2 sites:
- static function call from main.main
- static function call from main.main
-
--------- @callers callers-store --------
-main.store is called from these 2 sites:
- static function call from main.main
- static function call from main.main
-
--------- @pointsto pointsto-result-f --------
-this func() *int may point to these objects:
- main$1
-
--------- @callees callees-main.call-f --------
-this dynamic function call dispatches to:
- main$1
-
--------- @callers callers-main.call --------
-main.call is called from these 2 sites:
- static function call from main.main
- static function call from main.main
-
--------- @callees callees-main-apply1 --------
-this static function call dispatches to:
- main.apply
-
--------- @pointsto pointsto-pc --------
-this *int may point to these objects:
- c
-
--------- @pointsto pointsto-pd --------
-this *int may point to these objects:
- d
-
--------- @callees callees-err-no-call --------
-
-Error: there is no function call here
--------- @callees callees-err-builtin --------
-
-Error: this is a call to the built-in 'print' operator
--------- @callees callees-err-conversion --------
-
-Error: this is a type conversion, not a function call
--------- @callees callees-err-bad-selection --------
-
-Error: ambiguous selection within function call (or conversion)
--------- @callees callees-err-deadcode1 --------
-
-Error: this call site is unreachable in this analysis
--------- @callees callees-err-nil-func --------
-dynamic function call on nil value
-
--------- @callees callees-err-nil-interface --------
-dynamic method call on nil value
-
--------- @callees callees-not-a-wrapper --------
-this dynamic method call dispatches to:
- (main.myint).f
-
--------- @callers callers-not-a-wrapper --------
-(main.myint).f is called from these 1 sites:
- dynamic method call from main.main
-
--------- @callees callees-err-deadcode2 --------
-this static function call dispatches to:
- main.main
-
--------- @callstack callstack-err-deadcode --------
-main.deadcode is unreachable in this analysis scope
-
--------- @callees callees-err-deadcode3 --------
-
-Error: this call site is unreachable in this analysis
--------- @callers callers-global --------
-main.init is called from these 1 sites:
-the root of the call graph
-
--------- @callstack callstack-init --------
-Found a call path from root to main.init$1
-main.init$1
-static function call from main.init
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe-json.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe-json.go
deleted file mode 100644
index 1f22d019..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe-json.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package describe // @describe pkgdecl "describe"
-
-// Tests of 'describe' query, -format=json.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See describe-json.golden for expected query results.
-
-func main() { //
- var s struct{ x [3]int }
- p := &s.x[0] // @describe desc-val-p "p"
- _ = p
-
- var i I = C(0)
- if i == nil {
- i = new(D)
- }
- print(i) // @describe desc-val-i "\\bi\\b"
-
- go main() // @describe desc-stmt "go"
-}
-
-type I interface {
- f()
-}
-
-type C int // @describe desc-type-C "C"
-type D struct{}
-
-func (c C) f() {}
-func (d *D) f() {}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe-json.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe-json.golden
deleted file mode 100644
index 8baf837e..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe-json.golden
+++ /dev/null
@@ -1,107 +0,0 @@
--------- @describe pkgdecl --------
-{
- "mode": "describe",
- "describe": {
- "desc": "definition of package \"describe\"",
- "pos": "testdata/src/main/describe-json.go:1:9",
- "detail": "package",
- "package": {
- "path": "describe",
- "members": [
- {
- "name": "C",
- "type": "int",
- "pos": "testdata/src/main/describe-json.go:25:6",
- "kind": "type",
- "methods": [
- {
- "name": "method (C) f()",
- "pos": "testdata/src/main/describe-json.go:28:12"
- }
- ]
- },
- {
- "name": "D",
- "type": "struct{}",
- "pos": "testdata/src/main/describe-json.go:26:6",
- "kind": "type",
- "methods": [
- {
- "name": "method (*D) f()",
- "pos": "testdata/src/main/describe-json.go:29:13"
- }
- ]
- },
- {
- "name": "I",
- "type": "interface{f()}",
- "pos": "testdata/src/main/describe-json.go:21:6",
- "kind": "type",
- "methods": [
- {
- "name": "method (I) f()",
- "pos": "testdata/src/main/describe-json.go:22:2"
- }
- ]
- },
- {
- "name": "main",
- "type": "func()",
- "pos": "testdata/src/main/describe-json.go:7:6",
- "kind": "func"
- }
- ]
- }
- }
-}-------- @describe desc-val-p --------
-{
- "mode": "describe",
- "describe": {
- "desc": "identifier",
- "pos": "testdata/src/main/describe-json.go:9:2",
- "detail": "value",
- "value": {
- "type": "*int",
- "objpos": "testdata/src/main/describe-json.go:9:2"
- }
- }
-}-------- @describe desc-val-i --------
-{
- "mode": "describe",
- "describe": {
- "desc": "identifier",
- "pos": "testdata/src/main/describe-json.go:16:8",
- "detail": "value",
- "value": {
- "type": "I",
- "objpos": "testdata/src/main/describe-json.go:12:6"
- }
- }
-}-------- @describe desc-stmt --------
-{
- "mode": "describe",
- "describe": {
- "desc": "go statement",
- "pos": "testdata/src/main/describe-json.go:18:2",
- "detail": "unknown"
- }
-}-------- @describe desc-type-C --------
-{
- "mode": "describe",
- "describe": {
- "desc": "definition of type C (size 8, align 8)",
- "pos": "testdata/src/main/describe-json.go:25:6",
- "detail": "type",
- "type": {
- "type": "C",
- "namepos": "testdata/src/main/describe-json.go:25:6",
- "namedef": "int",
- "methods": [
- {
- "name": "method (C) f()",
- "pos": "testdata/src/main/describe-json.go:28:12"
- }
- ]
- }
- }
-}
\ No newline at end of file
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe.go
deleted file mode 100644
index 69e0a754..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package describe // @describe pkgdecl "describe"
-
-// Tests of 'describe' query.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See describe.golden for expected query results.
-
-// TODO(adonovan): more coverage of the (extensive) logic.
-
-type cake float64 // @describe type-ref-builtin "float64"
-
-const c = iota // @describe const-ref-iota "iota"
-
-const pi = 3.141 // @describe const-def-pi "pi"
-const pie = cake(pi) // @describe const-def-pie "pie"
-const _ = pi // @describe const-ref-pi "pi"
-
-var global = new(string) // NB: ssa.Global is indirect, i.e. **string
-
-func main() { // @describe func-def-main "main"
- // func objects
- _ = main // @describe func-ref-main "main"
- _ = (*C).f // @describe func-ref-*C.f "..C..f"
- _ = D.f // @describe func-ref-D.f "D.f"
- _ = I.f // @describe func-ref-I.f "I.f"
- var d D // @describe type-D "D"
- var i I // @describe type-I "I"
- _ = d.f // @describe func-ref-d.f "d.f"
- _ = i.f // @describe func-ref-i.f "i.f"
-
- // var objects
- anon := func() {
- _ = d // @describe ref-lexical-d "d"
- }
- _ = anon // @describe ref-anon "anon"
- _ = global // @describe ref-global "global"
-
- // SSA affords some local flow sensitivity.
- var a, b int
- var x = &a // @describe var-def-x-1 "x"
- _ = x // @describe var-ref-x-1 "x"
- x = &b // @describe var-def-x-2 "x"
- _ = x // @describe var-ref-x-2 "x"
-
- i = new(C) // @describe var-ref-i-C "i"
- if i != nil {
- i = D{} // @describe var-ref-i-D "i"
- }
- print(i) // @describe var-ref-i "\\bi\\b"
-
- // const objects
- const localpi = 3.141 // @describe const-local-pi "localpi"
- const localpie = cake(pi) // @describe const-local-pie "localpie"
- const _ = localpi // @describe const-ref-localpi "localpi"
-
- // type objects
- type T int // @describe type-def-T "T"
- var three T = 3 // @describe type-ref-T "T"
- _ = three
-
- print(1 + 2*3) // @describe const-expr " 2.3"
- print(real(1+2i) - 3) // @describe const-expr2 "real.*3"
-
- m := map[string]*int{"a": &a}
- mapval, _ := m["a"] // @describe map-lookup,ok "m..a.."
- _ = mapval // @describe mapval "mapval"
- _ = m // @describe m "m"
-
- defer main() // @describe defer-stmt "defer"
- go main() // @describe go-stmt "go"
-
- panic(3) // @describe builtin-ref-panic "panic"
-
- var a2 int // @describe var-decl-stmt "var a2 int"
- _ = a2
- var _ int // @describe var-decl-stmt2 "var _ int"
- var _ int // @describe var-def-blank "_"
-}
-
-type I interface { // @describe def-iface-I "I"
- f() // @describe def-imethod-I.f "f"
-}
-
-type C int
-type D struct{}
-
-func (c *C) f() {}
-func (d D) f() {}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe.golden
deleted file mode 100644
index 3f305d47..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/describe.golden
+++ /dev/null
@@ -1,173 +0,0 @@
--------- @describe pkgdecl --------
-definition of package "describe"
- type C int
- method (*C) f()
- type D struct{}
- method (D) f()
- type I interface{f()}
- method (I) f()
- const c untyped int = 0
- type cake float64
- var global *string
- func main func()
- const pi untyped float = 3141/1000
- const pie cake = 1768225803696341/562949953421312
-
--------- @describe type-ref-builtin --------
-reference to built-in type float64
-
--------- @describe const-ref-iota --------
-reference to const iota untyped int of constant value 0
-
--------- @describe const-def-pi --------
-definition of const pi untyped float
-
--------- @describe const-def-pie --------
-definition of const pie cake
-
--------- @describe const-ref-pi --------
-reference to const pi untyped float of constant value 3141/1000
-defined here
-
--------- @describe func-def-main --------
-definition of func main()
-
--------- @describe func-ref-main --------
-reference to func main()
-defined here
-
--------- @describe func-ref-*C.f --------
-reference to method func (*C).f()
-defined here
-
--------- @describe func-ref-D.f --------
-reference to method func (D).f()
-defined here
-
--------- @describe func-ref-I.f --------
-reference to interface method func (I).f()
-defined here
-
--------- @describe type-D --------
-reference to type D (size 0, align 1)
-defined as struct{}
-Method set:
- method (D) f()
-
--------- @describe type-I --------
-reference to type I (size 16, align 8)
-defined as interface{f()}
-Method set:
- method (I) f()
-
--------- @describe func-ref-d.f --------
-reference to method func (D).f()
-defined here
-
--------- @describe func-ref-i.f --------
-reference to interface method func (I).f()
-defined here
-
--------- @describe ref-lexical-d --------
-reference to var d D
-defined here
-
--------- @describe ref-anon --------
-reference to var anon func()
-defined here
-
--------- @describe ref-global --------
-reference to var global *string
-defined here
-
--------- @describe var-def-x-1 --------
-definition of var x *int
-
--------- @describe var-ref-x-1 --------
-reference to var x *int
-defined here
-
--------- @describe var-def-x-2 --------
-reference to var x *int
-defined here
-
--------- @describe var-ref-x-2 --------
-reference to var x *int
-defined here
-
--------- @describe var-ref-i-C --------
-reference to var i I
-defined here
-
--------- @describe var-ref-i-D --------
-reference to var i I
-defined here
-
--------- @describe var-ref-i --------
-reference to var i I
-defined here
-
--------- @describe const-local-pi --------
-definition of const localpi untyped float
-
--------- @describe const-local-pie --------
-definition of const localpie cake
-
--------- @describe const-ref-localpi --------
-reference to const localpi untyped float of constant value 3141/1000
-defined here
-
--------- @describe type-def-T --------
-definition of type T (size 8, align 8)
-No methods.
-
--------- @describe type-ref-T --------
-reference to type T (size 8, align 8)
-defined as int
-No methods.
-
--------- @describe const-expr --------
-binary * operation of constant value 6
-
--------- @describe const-expr2 --------
-binary - operation of constant value -2
-
--------- @describe map-lookup,ok --------
-index expression of type (*int, bool)
-
--------- @describe mapval --------
-reference to var mapval *int
-defined here
-
--------- @describe m --------
-reference to var m map[string]*int
-defined here
-
--------- @describe defer-stmt --------
-defer statement
-
--------- @describe go-stmt --------
-go statement
-
--------- @describe builtin-ref-panic --------
-function call (or conversion) of type ()
-
--------- @describe var-decl-stmt --------
-definition of var a2 int
-
--------- @describe var-decl-stmt2 --------
-definition of var _ int
-
--------- @describe var-def-blank --------
-definition of var _ int
-
--------- @describe def-iface-I --------
-definition of type I (size 16, align 8)
-Method set:
- method (I) f()
-
--------- @describe def-imethod-I.f --------
-type interface{f()}
-Method set:
- method (interface{f()}) f()
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/freevars.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/freevars.go
deleted file mode 100644
index 1ce0ae6b..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/freevars.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package main
-
-// Tests of 'freevars' query.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See freevars.golden for expected query results.
-
-// TODO(adonovan): it's hard to test this query in a single line of gofmt'd code.
-
-type T struct {
- a, b int
-}
-
-type S struct {
- x int
- t T
-}
-
-func f(int) {}
-
-func main() {
- type C int
- x := 1
- const exp = 6
- if y := 2; x+y+int(C(3)) != exp { // @freevars fv1 "if.*{"
- panic("expected 6")
- }
-
- var s S
-
- for x, y := range "foo" {
- println(s.x + s.t.a + s.t.b + x + int(y)) // @freevars fv2 "print.*y."
- }
-
- f(x) // @freevars fv3 "f.x."
-
- // TODO(adonovan): enable when go/types supports labels.
-loop: // #@freevars fv-def-label "loop:"
- for {
- break loop // #@freevars fv-ref-label "break loop"
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/freevars.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/freevars.golden
deleted file mode 100644
index b9eeab21..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/freevars.golden
+++ /dev/null
@@ -1,18 +0,0 @@
--------- @freevars fv1 --------
-Free identifiers:
-type C
-const exp int
-var x int
-
--------- @freevars fv2 --------
-Free identifiers:
-var s.t.a int
-var s.t.b int
-var s.x int
-var x int
-var y rune
-
--------- @freevars fv3 --------
-Free identifiers:
-var x int
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements-json.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements-json.go
deleted file mode 100644
index d5f8102b..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements-json.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package main
-
-// Tests of 'implements' query, -output=json.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See implements.golden for expected query results.
-
-func main() {
-}
-
-type E interface{} // @implements E "E"
-
-type F interface { // @implements F "F"
- f()
-}
-
-type FG interface { // @implements FG "FG"
- f()
- g() []int // @implements slice "..int"
-}
-
-type C int // @implements C "C"
-type D struct{}
-
-func (c *C) f() {} // @implements starC ".C"
-func (d D) f() {} // @implements D "D"
-
-func (d *D) g() []int { return nil } // @implements starD ".D"
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements-json.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements-json.golden
deleted file mode 100644
index d43969b9..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements-json.golden
+++ /dev/null
@@ -1,152 +0,0 @@
--------- @implements E --------
-{
- "mode": "implements",
- "implements": {
- "type": {
- "name": "main.E",
- "pos": "testdata/src/main/implements-json.go:10:6",
- "kind": "interface"
- }
- }
-}-------- @implements F --------
-{
- "mode": "implements",
- "implements": {
- "type": {
- "name": "main.F",
- "pos": "testdata/src/main/implements-json.go:12:6",
- "kind": "interface"
- },
- "to": [
- {
- "name": "*main.C",
- "pos": "testdata/src/main/implements-json.go:21:6",
- "kind": "pointer"
- },
- {
- "name": "main.D",
- "pos": "testdata/src/main/implements-json.go:22:6",
- "kind": "struct"
- },
- {
- "name": "main.FG",
- "pos": "testdata/src/main/implements-json.go:16:6",
- "kind": "interface"
- }
- ]
- }
-}-------- @implements FG --------
-{
- "mode": "implements",
- "implements": {
- "type": {
- "name": "main.FG",
- "pos": "testdata/src/main/implements-json.go:16:6",
- "kind": "interface"
- },
- "to": [
- {
- "name": "*main.D",
- "pos": "testdata/src/main/implements-json.go:22:6",
- "kind": "pointer"
- }
- ],
- "from": [
- {
- "name": "main.F",
- "pos": "testdata/src/main/implements-json.go:12:6",
- "kind": "interface"
- }
- ]
- }
-}-------- @implements slice --------
-{
- "mode": "implements",
- "implements": {
- "type": {
- "name": "[]int",
- "pos": "-",
- "kind": "slice"
- }
- }
-}-------- @implements C --------
-{
- "mode": "implements",
- "implements": {
- "type": {
- "name": "main.C",
- "pos": "testdata/src/main/implements-json.go:21:6",
- "kind": "basic"
- },
- "fromptr": [
- {
- "name": "main.F",
- "pos": "testdata/src/main/implements-json.go:12:6",
- "kind": "interface"
- }
- ]
- }
-}-------- @implements starC --------
-{
- "mode": "implements",
- "implements": {
- "type": {
- "name": "*main.C",
- "pos": "testdata/src/main/implements-json.go:21:6",
- "kind": "pointer"
- },
- "from": [
- {
- "name": "main.F",
- "pos": "testdata/src/main/implements-json.go:12:6",
- "kind": "interface"
- }
- ]
- }
-}-------- @implements D --------
-{
- "mode": "implements",
- "implements": {
- "type": {
- "name": "main.D",
- "pos": "testdata/src/main/implements-json.go:22:6",
- "kind": "struct"
- },
- "from": [
- {
- "name": "main.F",
- "pos": "testdata/src/main/implements-json.go:12:6",
- "kind": "interface"
- }
- ],
- "fromptr": [
- {
- "name": "main.FG",
- "pos": "testdata/src/main/implements-json.go:16:6",
- "kind": "interface"
- }
- ]
- }
-}-------- @implements starD --------
-{
- "mode": "implements",
- "implements": {
- "type": {
- "name": "*main.D",
- "pos": "testdata/src/main/implements-json.go:22:6",
- "kind": "pointer"
- },
- "from": [
- {
- "name": "main.F",
- "pos": "testdata/src/main/implements-json.go:12:6",
- "kind": "interface"
- },
- {
- "name": "main.FG",
- "pos": "testdata/src/main/implements-json.go:16:6",
- "kind": "interface"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements.go
deleted file mode 100644
index 0b5ee120..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package main
-
-// Tests of 'implements' query.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See implements.golden for expected query results.
-
-import _ "lib"
-import _ "sort"
-
-func main() {
-}
-
-type E interface{} // @implements E "E"
-
-type F interface { // @implements F "F"
- f()
-}
-
-type FG interface { // @implements FG "FG"
- f()
- g() []int // @implements slice "..int"
-}
-
-type C int // @implements C "C"
-type D struct{}
-
-func (c *C) f() {} // @implements starC ".C"
-func (d D) f() {} // @implements D "D"
-
-func (d *D) g() []int { return nil } // @implements starD ".D"
-
-type sorter []int // @implements sorter "sorter"
-
-func (sorter) Len() int { return 0 }
-func (sorter) Less(i, j int) bool { return false }
-func (sorter) Swap(i, j int) {}
-
-type I interface { // @implements I "I"
- Method(*int) *int
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements.golden
deleted file mode 100644
index 01d41f6a..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/implements.golden
+++ /dev/null
@@ -1,44 +0,0 @@
--------- @implements E --------
-empty interface type main.E
-
--------- @implements F --------
-interface type main.F
- is implemented by pointer type *main.C
- is implemented by struct type main.D
- is implemented by interface type main.FG
-
--------- @implements FG --------
-interface type main.FG
- is implemented by pointer type *main.D
- implements main.F
-
--------- @implements slice --------
-slice type []int implements only interface{}
-
--------- @implements C --------
-pointer type *main.C
- implements main.F
-
--------- @implements starC --------
-pointer type *main.C
- implements main.F
-
--------- @implements D --------
-struct type main.D
- implements main.F
-pointer type *main.D
- implements main.FG
-
--------- @implements starD --------
-pointer type *main.D
- implements main.F
- implements main.FG
-
--------- @implements sorter --------
-slice type main.sorter
- implements sort.Interface
-
--------- @implements I --------
-interface type main.I
- is implemented by basic type lib.Type
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/imports.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/imports.go
deleted file mode 100644
index 2f5ffa43..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/imports.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package imports
-
-import (
- "hash/fnv" // @describe ref-pkg-import2 "fnv"
- "lib" // @describe ref-pkg-import "lib"
-)
-
-// Tests that import another package. (To make the tests run quickly,
-// we avoid using imports in all the other tests. Remember, each
-// query causes parsing and typechecking of the whole program.)
-//
-// See go.tools/oracle/oracle_test.go for explanation.
-// See imports.golden for expected query results.
-
-var a int
-
-func main() {
- const c = lib.Const // @describe ref-const "Const"
- lib.Func() // @describe ref-func "Func"
- lib.Var++ // @describe ref-var "Var"
- var t lib.Type // @describe ref-type "Type"
- p := t.Method(&a) // @describe ref-method "Method"
-
- print(*p + 1) // @pointsto p "p "
-
- var _ lib.Type // @describe ref-pkg "lib"
-
- fnv.New32()
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/imports.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/imports.golden
deleted file mode 100644
index 788a3ad9..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/imports.golden
+++ /dev/null
@@ -1,49 +0,0 @@
--------- @describe ref-pkg-import2 --------
-import of package "hash/fnv"
- func New32 func() hash.Hash32
- func New32a func() hash.Hash32
- func New64 func() hash.Hash64
- func New64a func() hash.Hash64
-
--------- @describe ref-pkg-import --------
-import of package "lib"
- const Const untyped int = 3
- func Func func()
- type Type int
- method (Type) Method(x *int) *int
- var Var int
-
--------- @describe ref-const --------
-reference to const lib.Const untyped int
-defined here
-
--------- @describe ref-func --------
-reference to func lib.Func()
-defined here
-
--------- @describe ref-var --------
-reference to var lib.Var int
-defined here
-
--------- @describe ref-type --------
-reference to type lib.Type (size 8, align 8)
-defined as int
-Method set:
- method (lib.Type) Method(x *int) *int
-
--------- @describe ref-method --------
-reference to method func (lib.Type).Method(x *int) *int
-defined here
-
--------- @pointsto p --------
-this *int may point to these objects:
- imports.a
-
--------- @describe ref-pkg --------
-reference to package "lib"
- const Const untyped int = 3
- func Func func()
- type Type int
- method (Type) Method(x *int) *int
- var Var int
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/multi.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/multi.go
deleted file mode 100644
index 54caf15d..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/multi.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package multi
-
-func g(x int) {
-}
-
-func f() {
- x := 1
- g(x) // "g(x)" is the selection for multiple queries
-}
-
-func main() {
- f()
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers-json.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers-json.go
deleted file mode 100644
index 1f5beb20..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers-json.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package peers
-
-// Tests of channel 'peers' query, -format=json.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See peers-json.golden for expected query results.
-
-func main() {
- chA := make(chan *int)
- <-chA
- select {
- case <-chA: // @peers peer-recv-chA "<-"
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers-json.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers-json.golden
deleted file mode 100644
index 80eb3c43..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers-json.golden
+++ /dev/null
@@ -1,15 +0,0 @@
--------- @peers peer-recv-chA --------
-{
- "mode": "peers",
- "peers": {
- "pos": "testdata/src/main/peers-json.go:11:7",
- "type": "chan *int",
- "allocs": [
- "testdata/src/main/peers-json.go:8:13"
- ],
- "receives": [
- "testdata/src/main/peers-json.go:9:2",
- "testdata/src/main/peers-json.go:11:7"
- ]
- }
-}
\ No newline at end of file
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers.go
deleted file mode 100644
index 65ec9076..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package peers
-
-// Tests of channel 'peers' query.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See peers.golden for expected query results.
-
-var a2 int
-
-func main() {
- chA := make(chan *int)
- a1 := 1
- chA <- &a1
-
- chA2 := make(chan *int, 2)
- if a2 == 0 {
- chA = chA2
- }
-
- chB := make(chan *int)
- b := 3
- chB <- &b
-
- <-chA // @pointsto pointsto-chA "chA"
- <-chA2 // @pointsto pointsto-chA2 "chA2"
- <-chB // @pointsto pointsto-chB "chB"
-
- select {
- case rA := <-chA: // @peers peer-recv-chA "<-"
- _ = rA // @pointsto pointsto-rA "rA"
- case rB := <-chB: // @peers peer-recv-chB "<-"
- _ = rB // @pointsto pointsto-rB "rB"
-
- case <-chA: // @peers peer-recv-chA' "<-"
-
- case chA2 <- &a2: // @peers peer-send-chA' "<-"
- }
-
- for _ = range chA {
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers.golden
deleted file mode 100644
index e6b8a65e..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/peers.golden
+++ /dev/null
@@ -1,63 +0,0 @@
--------- @pointsto pointsto-chA --------
-this chan *int may point to these objects:
- makechan
- makechan
-
--------- @pointsto pointsto-chA2 --------
-this chan *int may point to these objects:
- makechan
-
--------- @pointsto pointsto-chB --------
-this chan *int may point to these objects:
- makechan
-
--------- @peers peer-recv-chA --------
-This channel of type chan *int may be:
- allocated here
- allocated here
- sent to, here
- sent to, here
- received from, here
- received from, here
- received from, here
- received from, here
- received from, here
-
--------- @pointsto pointsto-rA --------
-this *int may point to these objects:
- peers.a2
- a1
-
--------- @peers peer-recv-chB --------
-This channel of type chan *int may be:
- allocated here
- sent to, here
- received from, here
- received from, here
-
--------- @pointsto pointsto-rB --------
-this *int may point to these objects:
- b
-
--------- @peers peer-recv-chA' --------
-This channel of type chan *int may be:
- allocated here
- allocated here
- sent to, here
- sent to, here
- received from, here
- received from, here
- received from, here
- received from, here
- received from, here
-
--------- @peers peer-send-chA' --------
-This channel of type chan *int may be:
- allocated here
- sent to, here
- received from, here
- received from, here
- received from, here
- received from, here
- received from, here
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto-json.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto-json.go
deleted file mode 100644
index 79d7d3dc..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto-json.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package pointsto
-
-// Tests of 'pointsto' queries, -format=json.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See pointsto-json.golden for expected query results.
-
-func main() { //
- var s struct{ x [3]int }
- p := &s.x[0] // @pointsto val-p "p"
- _ = p
-
- var i I = C(0)
- if i == nil {
- i = new(D)
- }
- print(i) // @pointsto val-i "\\bi\\b"
-}
-
-type I interface {
- f()
-}
-
-type C int
-type D struct{}
-
-func (c C) f() {}
-func (d *D) f() {}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto-json.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto-json.golden
deleted file mode 100644
index b3f85116..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto-json.golden
+++ /dev/null
@@ -1,34 +0,0 @@
--------- @pointsto val-p --------
-{
- "mode": "pointsto",
- "pointsto": [
- {
- "type": "*int",
- "labels": [
- {
- "pos": "testdata/src/main/pointsto-json.go:8:6",
- "desc": "s.x[*]"
- }
- ]
- }
- ]
-}-------- @pointsto val-i --------
-{
- "mode": "pointsto",
- "pointsto": [
- {
- "type": "*D",
- "namepos": "testdata/src/main/pointsto-json.go:24:6",
- "labels": [
- {
- "pos": "testdata/src/main/pointsto-json.go:14:10",
- "desc": "new"
- }
- ]
- },
- {
- "type": "C",
- "namepos": "testdata/src/main/pointsto-json.go:23:6"
- }
- ]
-}
\ No newline at end of file
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto.go
deleted file mode 100644
index 796ec942..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package pointsto
-
-// Tests of 'pointsto' query.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See pointsto.golden for expected query results.
-
-const pi = 3.141 // @pointsto const "pi"
-
-var global = new(string) // NB: ssa.Global is indirect, i.e. **string
-
-func main() {
- livecode()
-
- // func objects
- _ = main // @pointsto func-ref-main "main"
- _ = (*C).f // @pointsto func-ref-*C.f "..C..f"
- _ = D.f // @pointsto func-ref-D.f "D.f"
- _ = I.f // @pointsto func-ref-I.f "I.f"
- var d D
- var i I
- _ = d.f // @pointsto func-ref-d.f "d.f"
- _ = i.f // @pointsto func-ref-i.f "i.f"
-
- // var objects
- anon := func() {
- _ = d.f // @pointsto ref-lexical-d.f "d.f"
- }
- _ = anon // @pointsto ref-anon "anon"
- _ = global // @pointsto ref-global "global"
-
- // SSA affords some local flow sensitivity.
- var a, b int
- var x = &a // @pointsto var-def-x-1 "x"
- _ = x // @pointsto var-ref-x-1 "x"
- x = &b // @pointsto var-def-x-2 "x"
- _ = x // @pointsto var-ref-x-2 "x"
-
- i = new(C) // @pointsto var-ref-i-C "i"
- if i != nil {
- i = D{} // @pointsto var-ref-i-D "i"
- }
- print(i) // @pointsto var-ref-i "\\bi\\b"
-
- m := map[string]*int{"a": &a}
- mapval, _ := m["a"] // @pointsto map-lookup,ok "m..a.."
- _ = mapval // @pointsto mapval "mapval"
- _ = m // @pointsto m "m"
-
- panic(3) // @pointsto builtin-panic "panic"
-}
-
-func livecode() {} // @pointsto func-live "livecode"
-
-func deadcode() { // @pointsto func-dead "deadcode"
- // Pointer analysis can't run on dead code.
- var b = new(int) // @pointsto b "b"
- _ = b
-}
-
-type I interface {
- f()
-}
-
-type C int
-type D struct{}
-
-func (c *C) f() {}
-func (d D) f() {}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto.golden
deleted file mode 100644
index a4f9a5c2..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/pointsto.golden
+++ /dev/null
@@ -1,93 +0,0 @@
--------- @pointsto const --------
-
-Error: pointer analysis wants an expression of reference type; got untyped float
--------- @pointsto func-ref-main --------
-this func() may point to these objects:
- pointsto.main
-
--------- @pointsto func-ref-*C.f --------
-this func() may point to these objects:
- (*pointsto.C).f
-
--------- @pointsto func-ref-D.f --------
-this func() may point to these objects:
- (pointsto.D).f
-
--------- @pointsto func-ref-I.f --------
-this func() may point to these objects:
- (pointsto.I).f
-
--------- @pointsto func-ref-d.f --------
-this func() may point to these objects:
- (pointsto.D).f
-
--------- @pointsto func-ref-i.f --------
-this func() may point to these objects:
- (pointsto.I).f
-
--------- @pointsto ref-lexical-d.f --------
-this func() may point to these objects:
- (pointsto.D).f
-
--------- @pointsto ref-anon --------
-this func() may point to these objects:
- main$1
-
--------- @pointsto ref-global --------
-this *string may point to these objects:
- new
-
--------- @pointsto var-def-x-1 --------
-this *int may point to these objects:
- a
-
--------- @pointsto var-ref-x-1 --------
-this *int may point to these objects:
- a
-
--------- @pointsto var-def-x-2 --------
-this *int may point to these objects:
- b
-
--------- @pointsto var-ref-x-2 --------
-this *int may point to these objects:
- b
-
--------- @pointsto var-ref-i-C --------
-this I may contain these dynamic types:
- *C, may point to:
- new
-
--------- @pointsto var-ref-i-D --------
-this I may contain these dynamic types:
- D
-
--------- @pointsto var-ref-i --------
-this I may contain these dynamic types:
- *C, may point to:
- new
- D
-
--------- @pointsto map-lookup,ok --------
-
-Error: pointer analysis wants an expression of reference type; got (*int, bool)
--------- @pointsto mapval --------
-this *int may point to these objects:
- a
-
--------- @pointsto m --------
-this map[string]*int may point to these objects:
- makemap
-
--------- @pointsto builtin-panic --------
-
-Error: pointer analysis wants an expression of reference type; got ()
--------- @pointsto func-live --------
-
-Error: pointer analysis did not find expression (dead code?)
--------- @pointsto func-dead --------
-
-Error: pointer analysis did not find expression (dead code?)
--------- @pointsto b --------
-
-Error: pointer analysis did not find expression (dead code?)
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/referrers-json.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/referrers-json.go
deleted file mode 100644
index 4799e53c..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/referrers-json.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package referrers
-
-// Tests of 'referrers' query.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See referrers.golden for expected query results.
-
-import "lib"
-
-type s struct {
- f int
-}
-
-func main() {
- var v lib.Type = lib.Const // @referrers ref-package "lib"
- _ = v.Method // @referrers ref-method "Method"
- _ = v.Method
- v++ //@referrers ref-local "v"
- v++
-
- _ = s{}.f // @referrers ref-field "f"
-
- var s2 s
- s2.f = 1
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/referrers-json.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/referrers-json.golden
deleted file mode 100644
index ad7ec1d3..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/referrers-json.golden
+++ /dev/null
@@ -1,51 +0,0 @@
--------- @referrers ref-package --------
-{
- "mode": "referrers",
- "referrers": {
- "pos": "testdata/src/main/referrers-json.go:14:8",
- "objpos": "testdata/src/main/referrers-json.go:7:8",
- "desc": "package lib",
- "refs": [
- "testdata/src/main/referrers-json.go:14:8",
- "testdata/src/main/referrers-json.go:14:19"
- ]
- }
-}-------- @referrers ref-method --------
-{
- "mode": "referrers",
- "referrers": {
- "pos": "testdata/src/main/referrers-json.go:15:8",
- "objpos": "testdata/src/lib/lib.go:5:13",
- "desc": "func (lib.Type).Method(x *int) *int",
- "refs": [
- "testdata/src/main/referrers-json.go:15:8",
- "testdata/src/main/referrers-json.go:16:8"
- ]
- }
-}-------- @referrers ref-local --------
-{
- "mode": "referrers",
- "referrers": {
- "pos": "testdata/src/main/referrers-json.go:17:2",
- "objpos": "testdata/src/main/referrers-json.go:14:6",
- "desc": "var v lib.Type",
- "refs": [
- "testdata/src/main/referrers-json.go:15:6",
- "testdata/src/main/referrers-json.go:16:6",
- "testdata/src/main/referrers-json.go:17:2",
- "testdata/src/main/referrers-json.go:18:2"
- ]
- }
-}-------- @referrers ref-field --------
-{
- "mode": "referrers",
- "referrers": {
- "pos": "testdata/src/main/referrers-json.go:20:10",
- "objpos": "testdata/src/main/referrers-json.go:10:2",
- "desc": "field f int",
- "refs": [
- "testdata/src/main/referrers-json.go:20:10",
- "testdata/src/main/referrers-json.go:23:5"
- ]
- }
-}
\ No newline at end of file
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/reflection.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/reflection.go
deleted file mode 100644
index b10df0b2..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/reflection.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package reflection
-
-// This is a test of 'pointsto', but we split it into a separate file
-// so that pointsto.go doesn't have to import "reflect" each time.
-
-import "reflect"
-
-var a int
-var b bool
-
-func main() {
- m := make(map[*int]*bool)
- m[&a] = &b
-
- mrv := reflect.ValueOf(m)
- if a > 0 {
- mrv = reflect.ValueOf(&b)
- }
- if a > 0 {
- mrv = reflect.ValueOf(&a)
- }
-
- _ = mrv // @pointsto mrv "mrv"
- p1 := mrv.Interface() // @pointsto p1 "p1"
- p2 := mrv.MapKeys() // @pointsto p2 "p2"
- p3 := p2[0] // @pointsto p3 "p3"
- p4 := reflect.TypeOf(p1) // @pointsto p4 "p4"
-
- _, _, _, _ = p1, p2, p3, p4
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/reflection.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/reflection.golden
deleted file mode 100644
index 4782132b..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/reflection.golden
+++ /dev/null
@@ -1,34 +0,0 @@
--------- @pointsto mrv --------
-this reflect.Value may contain these dynamic types:
- *bool, may point to:
- reflection.b
- *int, may point to:
- reflection.a
- map[*int]*bool, may point to:
- makemap
-
--------- @pointsto p1 --------
-this interface{} may contain these dynamic types:
- *bool, may point to:
- reflection.b
- *int, may point to:
- reflection.a
- map[*int]*bool, may point to:
- makemap
-
--------- @pointsto p2 --------
-this []reflect.Value may point to these objects:
-
-
--------- @pointsto p3 --------
-this reflect.Value may contain these dynamic types:
- *int, may point to:
- reflection.a
-
--------- @pointsto p4 --------
-this reflect.Type may contain these dynamic types:
- *reflect.rtype, may point to:
- *bool
- *int
- map[*int]*bool
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what-json.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what-json.go
deleted file mode 100644
index d07a6c90..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what-json.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package what
-
-// Tests of 'what' queries, -format=json.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See what-json.golden for expected query results.
-
-func main() {
- f() // @what call "f"
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what-json.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what-json.golden
deleted file mode 100644
index 13860dde..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what-json.golden
+++ /dev/null
@@ -1,52 +0,0 @@
--------- @what call --------
-{
- "mode": "what",
- "what": {
- "enclosing": [
- {
- "desc": "identifier",
- "start": 179,
- "end": 180
- },
- {
- "desc": "function call (or conversion)",
- "start": 179,
- "end": 182
- },
- {
- "desc": "expression statement",
- "start": 179,
- "end": 182
- },
- {
- "desc": "block",
- "start": 176,
- "end": 202
- },
- {
- "desc": "function declaration",
- "start": 164,
- "end": 202
- },
- {
- "desc": "source file",
- "start": 0,
- "end": 202
- }
- ],
- "modes": [
- "callees",
- "callers",
- "callgraph",
- "callstack",
- "definition",
- "describe",
- "freevars",
- "implements",
- "pointsto",
- "referrers"
- ],
- "srcdir": "testdata/src",
- "importpath": "main"
- }
-}
\ No newline at end of file
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what.go
deleted file mode 100644
index 041e9215..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package what // @what pkgdecl "what"
-
-// Tests of 'what' queries.
-// See go.tools/oracle/oracle_test.go for explanation.
-// See what.golden for expected query results.
-
-func main() {
- f() // @what call "f"
- var ch chan int // @what var "var"
- <-ch // @what recv "ch"
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what.golden
deleted file mode 100644
index 3f832912..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/testdata/src/main/what.golden
+++ /dev/null
@@ -1,39 +0,0 @@
--------- @what pkgdecl --------
-identifier
-source file
-modes: [callgraph definition describe freevars implements pointsto referrers]
-srcdir: testdata/src
-import path: main
-
--------- @what call --------
-identifier
-function call (or conversion)
-expression statement
-block
-function declaration
-source file
-modes: [callees callers callgraph callstack definition describe freevars implements pointsto referrers]
-srcdir: testdata/src
-import path: main
-
--------- @what var --------
-variable declaration
-variable declaration statement
-block
-function declaration
-source file
-modes: [callers callgraph callstack describe freevars pointsto]
-srcdir: testdata/src
-import path: main
-
--------- @what recv --------
-identifier
-unary <- operation
-expression statement
-block
-function declaration
-source file
-modes: [callers callgraph callstack definition describe freevars implements peers pointsto referrers]
-srcdir: testdata/src
-import path: main
-
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/what.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/what.go
deleted file mode 100644
index 108bef20..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/oracle/what.go
+++ /dev/null
@@ -1,216 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package oracle
-
-import (
- "fmt"
- "go/ast"
- "go/build"
- "go/token"
- "os"
- "path/filepath"
- "sort"
- "strings"
-
- "code.google.com/p/go.tools/astutil"
- "code.google.com/p/go.tools/oracle/serial"
-)
-
-// what reports all the information about the query selection that can be
-// obtained from parsing only its containing source file.
-// It is intended to be a very low-latency query callable from GUI
-// tools, e.g. to populate a menu of options of slower queries about
-// the selected location.
-//
-func what(posFlag string, buildContext *build.Context) (*Result, error) {
- qpos, err := fastQueryPos(posFlag)
- if err != nil {
- return nil, err
- }
-
- // (ignore errors)
- srcdir, importPath, _ := guessImportPath(qpos.fset.File(qpos.start).Name(), buildContext)
-
- // Determine which query modes are applicable to the selection.
- // TODO(adonovan): refactor: make each minfo have an 'enable'
- // predicate over qpos.
- enable := map[string]bool{
- "callgraph": true, // whole program; always enabled
- "describe": true, // any syntax; always enabled
- }
-
- if qpos.end > qpos.start {
- enable["freevars"] = true // nonempty selection?
- }
-
- for _, n := range qpos.path {
- switch n := n.(type) {
- case *ast.Ident:
- enable["definition"] = true
- enable["referrers"] = true
- enable["implements"] = true
- case *ast.CallExpr:
- enable["callees"] = true
- case *ast.FuncDecl:
- enable["callers"] = true
- enable["callstack"] = true
- case *ast.SendStmt:
- enable["peers"] = true
- case *ast.UnaryExpr:
- if n.Op == token.ARROW {
- enable["peers"] = true
- }
- }
-
- // For implements, we approximate findInterestingNode.
- if _, ok := enable["implements"]; !ok {
- switch n.(type) {
- case *ast.ArrayType,
- *ast.StructType,
- *ast.FuncType,
- *ast.InterfaceType,
- *ast.MapType,
- *ast.ChanType:
- enable["implements"] = true
- }
- }
-
- // For pointsto, we approximate findInterestingNode.
- if _, ok := enable["pointsto"]; !ok {
- switch n.(type) {
- case ast.Stmt,
- *ast.ArrayType,
- *ast.StructType,
- *ast.FuncType,
- *ast.InterfaceType,
- *ast.MapType,
- *ast.ChanType:
- enable["pointsto"] = false // not an expr
-
- case ast.Expr, ast.Decl, *ast.ValueSpec:
- enable["pointsto"] = true // an expr, maybe
-
- default:
- // Comment, Field, KeyValueExpr, etc: ascend.
- }
- }
- }
-
- // If we don't have an exact selection, disable modes that need one.
- if !qpos.exact {
- for _, minfo := range modes {
- if minfo.needs&needExactPos != 0 {
- enable[minfo.name] = false
- }
- }
- }
-
- var modes []string
- for mode := range enable {
- modes = append(modes, mode)
- }
- sort.Strings(modes)
-
- return &Result{
- mode: "what",
- fset: qpos.fset,
- q: &whatResult{
- path: qpos.path,
- srcdir: srcdir,
- importPath: importPath,
- modes: modes,
- },
- }, nil
-
-}
-
-// guessImportPath finds the package containing filename, and returns
-// its source directory (an element of $GOPATH) and its import path
-// relative to it.
-//
-// TODO(adonovan): what about _test.go files that are not part of the
-// package?
-//
-func guessImportPath(filename string, buildContext *build.Context) (srcdir, importPath string, err error) {
- absFile, err := filepath.Abs(filename)
- if err != nil {
- err = fmt.Errorf("can't form absolute path of %s", filename)
- return
- }
- absFileDir := segments(filepath.Dir(absFile))
-
- // Find the innermost directory in $GOPATH that encloses filename.
- minD := 1024
- for _, gopathDir := range buildContext.SrcDirs() {
- absDir, err := filepath.Abs(gopathDir)
- if err != nil {
- continue // e.g. non-existent dir on $GOPATH
- }
- d := prefixLen(segments(absDir), absFileDir)
- // If there are multiple matches,
- // prefer the innermost enclosing directory
- // (smallest d).
- if d >= 0 && d < minD {
- minD = d
- srcdir = gopathDir
- importPath = strings.Join(absFileDir[len(absFileDir)-minD:], string(os.PathSeparator))
- }
- }
- if srcdir == "" {
- err = fmt.Errorf("can't find package for file %s", filename)
- }
- return
-}
-
-func segments(path string) []string {
- return strings.Split(path, string(os.PathSeparator))
-}
-
-// prefixLen returns the length of the remainder of y if x is a prefix
-// of y, a negative number otherwise.
-func prefixLen(x, y []string) int {
- d := len(y) - len(x)
- if d >= 0 {
- for i := range x {
- if y[i] != x[i] {
- return -1 // not a prefix
- }
- }
- }
- return d
-}
-
-type whatResult struct {
- path []ast.Node
- modes []string
- srcdir string
- importPath string
-}
-
-func (r *whatResult) display(printf printfFunc) {
- for _, n := range r.path {
- printf(n, "%s", astutil.NodeDescription(n))
- }
- printf(nil, "modes: %s", r.modes)
- printf(nil, "srcdir: %s", r.srcdir)
- printf(nil, "import path: %s", r.importPath)
-}
-
-func (r *whatResult) toSerial(res *serial.Result, fset *token.FileSet) {
- var enclosing []serial.SyntaxNode
- for _, n := range r.path {
- enclosing = append(enclosing, serial.SyntaxNode{
- Description: astutil.NodeDescription(n),
- Start: fset.Position(n.Pos()).Offset,
- End: fset.Position(n.End()).Offset,
- })
- }
- res.What = &serial.What{
- Modes: r.modes,
- SrcDir: r.srcdir,
- ImportPath: r.importPath,
- Enclosing: enclosing,
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/appengine.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/appengine.go
deleted file mode 100644
index 073b419d..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/appengine.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build appengine
-
-package playground
-
-import (
- "net/http"
-
- "appengine"
- "appengine/urlfetch"
-)
-
-func client(r *http.Request) *http.Client {
- return urlfetch.Client(appengine.NewContext(r))
-}
-
-func report(r *http.Request, err error) {
- appengine.NewContext(r).Errorf("%v", err)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/common.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/common.go
deleted file mode 100644
index 05513629..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/common.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package playground registers HTTP handlers at "/compile" and "/share" that
-// proxy requests to the golang.org playground service.
-// This package may be used unaltered on App Engine.
-package playground
-
-import (
- "bytes"
- "fmt"
- "io"
- "net/http"
-)
-
-const baseURL = "http://play.golang.org"
-
-func init() {
- http.HandleFunc("/compile", bounce)
- http.HandleFunc("/share", bounce)
-}
-
-func bounce(w http.ResponseWriter, r *http.Request) {
- b := new(bytes.Buffer)
- if err := passThru(b, r); err != nil {
- http.Error(w, "Server error.", http.StatusInternalServerError)
- report(r, err)
- return
- }
- io.Copy(w, b)
-}
-
-func passThru(w io.Writer, req *http.Request) error {
- defer req.Body.Close()
- url := baseURL + req.URL.Path
- r, err := client(req).Post(url, req.Header.Get("Content-type"), req.Body)
- if err != nil {
- return fmt.Errorf("making POST request: %v", err)
- }
- defer r.Body.Close()
- if _, err := io.Copy(w, r.Body); err != nil {
- return fmt.Errorf("copying response Body: %v", err)
- }
- return nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/local.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/local.go
deleted file mode 100644
index b114b877..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/local.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !appengine
-
-package playground
-
-import (
- "log"
- "net/http"
-)
-
-func client(r *http.Request) *http.Client {
- return http.DefaultClient
-}
-
-func report(r *http.Request, err error) {
- log.Println(err)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/socket/socket.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/socket/socket.go
deleted file mode 100644
index 66689a4f..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/playground/socket/socket.go
+++ /dev/null
@@ -1,387 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !appengine
-
-// Package socket implements an WebSocket-based playground backend.
-// Clients connect to a websocket handler and send run/kill commands, and
-// the server sends the output and exit status of the running processes.
-// Multiple clients running multiple processes may be served concurrently.
-// The wire format is JSON and is described by the Message type.
-//
-// This will not run on App Engine as WebSockets are not supported there.
-package socket
-
-import (
- "bytes"
- "encoding/json"
- "errors"
- "go/parser"
- "go/token"
- "io"
- "io/ioutil"
- "log"
- "os"
- "os/exec"
- "path/filepath"
- "runtime"
- "strconv"
- "strings"
- "sync"
- "time"
- "unicode/utf8"
-
- "code.google.com/p/go.net/websocket"
-)
-
-// RunScripts specifies whether the socket handler should execute shell scripts
-// (snippets that start with a shebang).
-var RunScripts = true
-
-// Handler implements a WebSocket handler for a client connection.
-var Handler = websocket.Handler(socketHandler)
-
-// Environ provides an environment when a binary, such as the go tool, is
-// invoked.
-var Environ func() []string = os.Environ
-
-const (
- // The maximum number of messages to send per session (avoid flooding).
- msgLimit = 1000
-
- // Batch messages sent in this interval and send as a single message.
- msgDelay = 10 * time.Millisecond
-)
-
-// Message is the wire format for the websocket connection to the browser.
-// It is used for both sending output messages and receiving commands, as
-// distinguished by the Kind field.
-type Message struct {
- Id string // client-provided unique id for the process
- Kind string // in: "run", "kill" out: "stdout", "stderr", "end"
- Body string
- Options *Options `json:",omitempty"`
-}
-
-// Options specify additional message options.
-type Options struct {
- Race bool // use -race flag when building code (for "run" only)
-}
-
-// socketHandler handles the websocket connection for a given present session.
-// It handles transcoding Messages to and from JSON format, and starting
-// and killing processes.
-func socketHandler(c *websocket.Conn) {
- in, out := make(chan *Message), make(chan *Message)
- errc := make(chan error, 1)
-
- // Decode messages from client and send to the in channel.
- go func() {
- dec := json.NewDecoder(c)
- for {
- var m Message
- if err := dec.Decode(&m); err != nil {
- errc <- err
- return
- }
- in <- &m
- }
- }()
-
- // Receive messages from the out channel and encode to the client.
- go func() {
- enc := json.NewEncoder(c)
- for m := range out {
- if err := enc.Encode(m); err != nil {
- errc <- err
- return
- }
- }
- }()
-
- // Start and kill processes and handle errors.
- proc := make(map[string]*process)
- for {
- select {
- case m := <-in:
- switch m.Kind {
- case "run":
- proc[m.Id].Kill()
- lOut := limiter(in, out)
- proc[m.Id] = startProcess(m.Id, m.Body, lOut, m.Options)
- case "kill":
- proc[m.Id].Kill()
- }
- case err := <-errc:
- if err != io.EOF {
- // A encode or decode has failed; bail.
- log.Println(err)
- }
- // Shut down any running processes.
- for _, p := range proc {
- p.Kill()
- }
- return
- }
- }
-}
-
-// process represents a running process.
-type process struct {
- id string
- out chan<- *Message
- done chan struct{} // closed when wait completes
- run *exec.Cmd
- bin string
-}
-
-// startProcess builds and runs the given program, sending its output
-// and end event as Messages on the provided channel.
-func startProcess(id, body string, out chan<- *Message, opt *Options) *process {
- p := &process{
- id: id,
- out: out,
- done: make(chan struct{}),
- }
- var err error
- if path, args := shebang(body); RunScripts && path != "" {
- err = p.startProcess(path, args, body)
- } else {
- err = p.start(body, opt)
- }
- if err != nil {
- p.end(err)
- return nil
- }
- go p.wait()
- return p
-}
-
-// Kill stops the process if it is running and waits for it to exit.
-func (p *process) Kill() {
- if p == nil {
- return
- }
- p.run.Process.Kill()
- <-p.done // block until process exits
-}
-
-// shebang looks for a shebang ('#!') at the beginning of the passed string.
-// If found, it returns the path and args after the shebang.
-// args includes the command as args[0].
-func shebang(body string) (path string, args []string) {
- body = strings.TrimSpace(body)
- if !strings.HasPrefix(body, "#!") {
- return "", nil
- }
- if i := strings.Index(body, "\n"); i >= 0 {
- body = body[:i]
- }
- fs := strings.Fields(body[2:])
- return fs[0], fs
-}
-
-// startProcess starts a given program given its path and passing the given body
-// to the command standard input.
-func (p *process) startProcess(path string, args []string, body string) error {
- cmd := &exec.Cmd{
- Path: path,
- Args: args,
- Stdin: strings.NewReader(body),
- Stdout: &messageWriter{id: p.id, kind: "stdout", out: p.out},
- Stderr: &messageWriter{id: p.id, kind: "stderr", out: p.out},
- }
- if err := cmd.Start(); err != nil {
- return err
- }
- p.run = cmd
- return nil
-}
-
-// start builds and starts the given program, sending its output to p.out,
-// and stores the running *exec.Cmd in the run field.
-func (p *process) start(body string, opt *Options) error {
- // We "go build" and then exec the binary so that the
- // resultant *exec.Cmd is a handle to the user's program
- // (rather than the go tool process).
- // This makes Kill work.
-
- bin := filepath.Join(tmpdir, "compile"+strconv.Itoa(<-uniq))
- src := bin + ".go"
- if runtime.GOOS == "windows" {
- bin += ".exe"
- }
-
- // write body to x.go
- defer os.Remove(src)
- err := ioutil.WriteFile(src, []byte(body), 0666)
- if err != nil {
- return err
- }
-
- // build x.go, creating x
- p.bin = bin // to be removed by p.end
- dir, file := filepath.Split(src)
- args := []string{"go", "build", "-tags", "OMIT"}
- if opt != nil && opt.Race {
- p.out <- &Message{
- Id: p.id, Kind: "stderr",
- Body: "Running with race detector.\n",
- }
- args = append(args, "-race")
- }
- args = append(args, "-o", bin, file)
- cmd := p.cmd(dir, args...)
- cmd.Stdout = cmd.Stderr // send compiler output to stderr
- if err := cmd.Run(); err != nil {
- return err
- }
-
- // run x
- cmd = p.cmd("", bin)
- if opt != nil && opt.Race {
- cmd.Env = append(cmd.Env, "GOMAXPROCS=2")
- }
- if err := cmd.Start(); err != nil {
- // If we failed to exec, that might be because they built
- // a non-main package instead of an executable.
- // Check and report that.
- if name, err := packageName(body); err == nil && name != "main" {
- return errors.New(`executable programs must use "package main"`)
- }
- return err
- }
- p.run = cmd
- return nil
-}
-
-// wait waits for the running process to complete
-// and sends its error state to the client.
-func (p *process) wait() {
- p.end(p.run.Wait())
- close(p.done) // unblock waiting Kill calls
-}
-
-// end sends an "end" message to the client, containing the process id and the
-// given error value. It also removes the binary.
-func (p *process) end(err error) {
- if p.bin != "" {
- defer os.Remove(p.bin)
- }
- m := &Message{Id: p.id, Kind: "end"}
- if err != nil {
- m.Body = err.Error()
- }
- // Wait for any outstanding reads to finish (potential race here).
- time.AfterFunc(msgDelay, func() { p.out <- m })
-}
-
-// cmd builds an *exec.Cmd that writes its standard output and error to the
-// process' output channel.
-func (p *process) cmd(dir string, args ...string) *exec.Cmd {
- cmd := exec.Command(args[0], args[1:]...)
- cmd.Dir = dir
- cmd.Env = Environ()
- cmd.Stdout = &messageWriter{id: p.id, kind: "stdout", out: p.out}
- cmd.Stderr = &messageWriter{id: p.id, kind: "stderr", out: p.out}
- return cmd
-}
-
-func packageName(body string) (string, error) {
- f, err := parser.ParseFile(token.NewFileSet(), "prog.go",
- strings.NewReader(body), parser.PackageClauseOnly)
- if err != nil {
- return "", err
- }
- return f.Name.String(), nil
-}
-
-// messageWriter is an io.Writer that converts all writes to Message sends on
-// the out channel with the specified id and kind.
-type messageWriter struct {
- id, kind string
- out chan<- *Message
-
- mu sync.Mutex
- buf []byte
- send *time.Timer
-}
-
-func (w *messageWriter) Write(b []byte) (n int, err error) {
- // Buffer writes that occur in a short period to send as one Message.
- w.mu.Lock()
- w.buf = append(w.buf, b...)
- if w.send == nil {
- w.send = time.AfterFunc(msgDelay, w.sendNow)
- }
- w.mu.Unlock()
- return len(b), nil
-}
-
-func (w *messageWriter) sendNow() {
- w.mu.Lock()
- body := safeString(w.buf)
- w.buf, w.send = nil, nil
- w.mu.Unlock()
- w.out <- &Message{Id: w.id, Kind: w.kind, Body: body}
-}
-
-// safeString returns b as a valid UTF-8 string.
-func safeString(b []byte) string {
- if utf8.Valid(b) {
- return string(b)
- }
- var buf bytes.Buffer
- for len(b) > 0 {
- r, size := utf8.DecodeRune(b)
- b = b[size:]
- buf.WriteRune(r)
- }
- return buf.String()
-}
-
-// limiter returns a channel that wraps dest. Messages sent to the channel are
-// sent to dest. After msgLimit Messages have been passed on, a "kill" Message
-// is sent to the kill channel, and only "end" messages are passed.
-func limiter(kill chan<- *Message, dest chan<- *Message) chan<- *Message {
- ch := make(chan *Message)
- go func() {
- n := 0
- for m := range ch {
- switch {
- case n < msgLimit || m.Kind == "end":
- dest <- m
- if m.Kind == "end" {
- return
- }
- case n == msgLimit:
- // process produced too much output. Kill it.
- kill <- &Message{Id: m.Id, Kind: "kill"}
- }
- n++
- }
- }()
- return ch
-}
-
-var tmpdir string
-
-func init() {
- // find real path to temporary directory
- var err error
- tmpdir, err = filepath.EvalSymlinks(os.TempDir())
- if err != nil {
- log.Fatal(err)
- }
-}
-
-var uniq = make(chan int) // a source of numbers for naming temporary files
-
-func init() {
- go func() {
- for i := 0; ; i++ {
- uniq <- i
- }
- }()
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/args.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/args.go
deleted file mode 100644
index 49ee1a98..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/args.go
+++ /dev/null
@@ -1,229 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import (
- "errors"
- "regexp"
- "strconv"
- "unicode/utf8"
-)
-
-// This file is stolen from go/src/cmd/godoc/codewalk.go.
-// It's an evaluator for the file address syntax implemented by acme and sam,
-// but using Go-native regular expressions.
-// To keep things reasonably close, this version uses (?m:re) for all user-provided
-// regular expressions. That is the only change to the code from codewalk.go.
-// See http://plan9.bell-labs.com/sys/doc/sam/sam.html Table II
-// for details on the syntax.
-
-// addrToByte evaluates the given address starting at offset start in data.
-// It returns the lo and hi byte offset of the matched region within data.
-func addrToByteRange(addr string, start int, data []byte) (lo, hi int, err error) {
- if addr == "" {
- lo, hi = start, len(data)
- return
- }
- var (
- dir byte
- prevc byte
- charOffset bool
- )
- lo = start
- hi = start
- for addr != "" && err == nil {
- c := addr[0]
- switch c {
- default:
- err = errors.New("invalid address syntax near " + string(c))
- case ',':
- if len(addr) == 1 {
- hi = len(data)
- } else {
- _, hi, err = addrToByteRange(addr[1:], hi, data)
- }
- return
-
- case '+', '-':
- if prevc == '+' || prevc == '-' {
- lo, hi, err = addrNumber(data, lo, hi, prevc, 1, charOffset)
- }
- dir = c
-
- case '$':
- lo = len(data)
- hi = len(data)
- if len(addr) > 1 {
- dir = '+'
- }
-
- case '#':
- charOffset = true
-
- case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
- var i int
- for i = 1; i < len(addr); i++ {
- if addr[i] < '0' || addr[i] > '9' {
- break
- }
- }
- var n int
- n, err = strconv.Atoi(addr[0:i])
- if err != nil {
- break
- }
- lo, hi, err = addrNumber(data, lo, hi, dir, n, charOffset)
- dir = 0
- charOffset = false
- prevc = c
- addr = addr[i:]
- continue
-
- case '/':
- var i, j int
- Regexp:
- for i = 1; i < len(addr); i++ {
- switch addr[i] {
- case '\\':
- i++
- case '/':
- j = i + 1
- break Regexp
- }
- }
- if j == 0 {
- j = i
- }
- pattern := addr[1:i]
- lo, hi, err = addrRegexp(data, lo, hi, dir, pattern)
- prevc = c
- addr = addr[j:]
- continue
- }
- prevc = c
- addr = addr[1:]
- }
-
- if err == nil && dir != 0 {
- lo, hi, err = addrNumber(data, lo, hi, dir, 1, charOffset)
- }
- if err != nil {
- return 0, 0, err
- }
- return lo, hi, nil
-}
-
-// addrNumber applies the given dir, n, and charOffset to the address lo, hi.
-// dir is '+' or '-', n is the count, and charOffset is true if the syntax
-// used was #n. Applying +n (or +#n) means to advance n lines
-// (or characters) after hi. Applying -n (or -#n) means to back up n lines
-// (or characters) before lo.
-// The return value is the new lo, hi.
-func addrNumber(data []byte, lo, hi int, dir byte, n int, charOffset bool) (int, int, error) {
- switch dir {
- case 0:
- lo = 0
- hi = 0
- fallthrough
-
- case '+':
- if charOffset {
- pos := hi
- for ; n > 0 && pos < len(data); n-- {
- _, size := utf8.DecodeRune(data[pos:])
- pos += size
- }
- if n == 0 {
- return pos, pos, nil
- }
- break
- }
- // find next beginning of line
- if hi > 0 {
- for hi < len(data) && data[hi-1] != '\n' {
- hi++
- }
- }
- lo = hi
- if n == 0 {
- return lo, hi, nil
- }
- for ; hi < len(data); hi++ {
- if data[hi] != '\n' {
- continue
- }
- switch n--; n {
- case 1:
- lo = hi + 1
- case 0:
- return lo, hi + 1, nil
- }
- }
-
- case '-':
- if charOffset {
- // Scan backward for bytes that are not UTF-8 continuation bytes.
- pos := lo
- for ; pos > 0 && n > 0; pos-- {
- if data[pos]&0xc0 != 0x80 {
- n--
- }
- }
- if n == 0 {
- return pos, pos, nil
- }
- break
- }
- // find earlier beginning of line
- for lo > 0 && data[lo-1] != '\n' {
- lo--
- }
- hi = lo
- if n == 0 {
- return lo, hi, nil
- }
- for ; lo >= 0; lo-- {
- if lo > 0 && data[lo-1] != '\n' {
- continue
- }
- switch n--; n {
- case 1:
- hi = lo
- case 0:
- return lo, hi, nil
- }
- }
- }
-
- return 0, 0, errors.New("address out of range")
-}
-
-// addrRegexp searches for pattern in the given direction starting at lo, hi.
-// The direction dir is '+' (search forward from hi) or '-' (search backward from lo).
-// Backward searches are unimplemented.
-func addrRegexp(data []byte, lo, hi int, dir byte, pattern string) (int, int, error) {
- // We want ^ and $ to work as in sam/acme, so use ?m.
- re, err := regexp.Compile("(?m:" + pattern + ")")
- if err != nil {
- return 0, 0, err
- }
- if dir == '-' {
- // Could implement reverse search using binary search
- // through file, but that seems like overkill.
- return 0, 0, errors.New("reverse search not implemented")
- }
- m := re.FindIndex(data[hi:])
- if len(m) > 0 {
- m[0] += hi
- m[1] += hi
- } else if hi > 0 {
- // No match. Wrap to beginning of data.
- m = re.FindIndex(data)
- }
- if len(m) == 0 {
- return 0, 0, errors.New("no match for " + pattern)
- }
- return m[0], m[1], nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/code.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/code.go
deleted file mode 100644
index 2816a879..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/code.go
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "html/template"
- "path/filepath"
- "regexp"
- "strconv"
- "strings"
-)
-
-// Is the playground available?
-var PlayEnabled = false
-
-// TOOD(adg): replace the PlayEnabled flag with something less spaghetti-like.
-// Instead this will probably be determined by a template execution Context
-// value that contains various global metadata required when rendering
-// templates.
-
-func init() {
- Register("code", parseCode)
- Register("play", parseCode)
-}
-
-type Code struct {
- Text template.HTML
- Play bool // runnable code
- FileName string // file name
- Ext string // file extension
- Raw []byte // content of the file
-}
-
-func (c Code) TemplateName() string { return "code" }
-
-// The input line is a .code or .play entry with a file name and an optional HLfoo marker on the end.
-// Anything between the file and HL (if any) is an address expression, which we treat as a string here.
-// We pick off the HL first, for easy parsing.
-var (
- highlightRE = regexp.MustCompile(`\s+HL([a-zA-Z0-9_]+)?$`)
- hlCommentRE = regexp.MustCompile(`(.+) // HL(.*)$`)
- codeRE = regexp.MustCompile(`\.(code|play)\s+((?:(?:-edit|-numbers)\s+)*)([^\s]+)(?:\s+(.*))?$`)
-)
-
-// parseCode parses a code present directive. Its syntax:
-// .code [-numbers] [-edit] [address] [highlight]
-// The directive may also be ".play" if the snippet is executable.
-func parseCode(ctx *Context, sourceFile string, sourceLine int, cmd string) (Elem, error) {
- cmd = strings.TrimSpace(cmd)
-
- // Pull off the HL, if any, from the end of the input line.
- highlight := ""
- if hl := highlightRE.FindStringSubmatchIndex(cmd); len(hl) == 4 {
- highlight = cmd[hl[2]:hl[3]]
- cmd = cmd[:hl[2]-2]
- }
-
- // Parse the remaining command line.
- // Arguments:
- // args[0]: whole match
- // args[1]: .code/.play
- // args[2]: flags ("-edit -numbers")
- // args[3]: file name
- // args[4]: optional address
- args := codeRE.FindStringSubmatch(cmd)
- if len(args) != 5 {
- return nil, fmt.Errorf("%s:%d: syntax error for .code/.play invocation", sourceFile, sourceLine)
- }
- command, flags, file, addr := args[1], args[2], args[3], strings.TrimSpace(args[4])
- play := command == "play" && PlayEnabled
-
- // Read in code file and (optionally) match address.
- filename := filepath.Join(filepath.Dir(sourceFile), file)
- textBytes, err := ctx.ReadFile(filename)
- if err != nil {
- return nil, fmt.Errorf("%s:%d: %v", sourceFile, sourceLine, err)
- }
- lo, hi, err := addrToByteRange(addr, 0, textBytes)
- if err != nil {
- return nil, fmt.Errorf("%s:%d: %v", sourceFile, sourceLine, err)
- }
-
- // Acme pattern matches can stop mid-line,
- // so run to end of line in both directions if not at line start/end.
- for lo > 0 && textBytes[lo-1] != '\n' {
- lo--
- }
- if hi > 0 {
- for hi < len(textBytes) && textBytes[hi-1] != '\n' {
- hi++
- }
- }
-
- lines := codeLines(textBytes, lo, hi)
-
- data := &codeTemplateData{
- Lines: formatLines(lines, highlight),
- Edit: strings.Contains(flags, "-edit"),
- Numbers: strings.Contains(flags, "-numbers"),
- }
-
- // Include before and after in a hidden span for playground code.
- if play {
- data.Prefix = textBytes[:lo]
- data.Suffix = textBytes[hi:]
- }
-
- var buf bytes.Buffer
- if err := codeTemplate.Execute(&buf, data); err != nil {
- return nil, err
- }
- return Code{
- Text: template.HTML(buf.String()),
- Play: play,
- FileName: filepath.Base(filename),
- Ext: filepath.Ext(filename),
- Raw: rawCode(lines),
- }, nil
-}
-
-// formatLines returns a new slice of codeLine with the given lines
-// replacing tabs with spaces and adding highlighting where needed.
-func formatLines(lines []codeLine, highlight string) []codeLine {
- formatted := make([]codeLine, len(lines))
- for i, line := range lines {
- // Replace tabs with spaces, which work better in HTML.
- line.L = strings.Replace(line.L, "\t", " ", -1)
-
- // Highlight lines that end with "// HL[highlight]"
- // and strip the magic comment.
- if m := hlCommentRE.FindStringSubmatch(line.L); m != nil {
- line.L = m[1]
- line.HL = m[2] == highlight
- }
-
- formatted[i] = line
- }
- return formatted
-}
-
-// rawCode returns the code represented by the given codeLines without any kind
-// of formatting.
-func rawCode(lines []codeLine) []byte {
- b := new(bytes.Buffer)
- for _, line := range lines {
- b.WriteString(line.L)
- b.WriteByte('\n')
- }
- return b.Bytes()
-}
-
-type codeTemplateData struct {
- Lines []codeLine
- Prefix, Suffix []byte
- Edit, Numbers bool
-}
-
-var leadingSpaceRE = regexp.MustCompile(`^[ \t]*`)
-
-var codeTemplate = template.Must(template.New("code").Funcs(template.FuncMap{
- "trimSpace": strings.TrimSpace,
- "leadingSpace": leadingSpaceRE.FindString,
-}).Parse(codeTemplateHTML))
-
-const codeTemplateHTML = `
-{{with .Prefix}}
{{end}}
-`
-
-// codeLine represents a line of code extracted from a source file.
-type codeLine struct {
- L string // The line of code.
- N int // The line number from the source file.
- HL bool // Whether the line should be highlighted.
-}
-
-// codeLines takes a source file and returns the lines that
-// span the byte range specified by start and end.
-// It discards lines that end in "OMIT".
-func codeLines(src []byte, start, end int) (lines []codeLine) {
- startLine := 1
- for i, b := range src {
- if i == start {
- break
- }
- if b == '\n' {
- startLine++
- }
- }
- s := bufio.NewScanner(bytes.NewReader(src[start:end]))
- for n := startLine; s.Scan(); n++ {
- l := s.Text()
- if strings.HasSuffix(l, "OMIT") {
- continue
- }
- lines = append(lines, codeLine{L: l, N: n})
- }
- // Trim leading and trailing blank lines.
- for len(lines) > 0 && len(lines[0].L) == 0 {
- lines = lines[1:]
- }
- for len(lines) > 0 && len(lines[len(lines)-1].L) == 0 {
- lines = lines[:len(lines)-1]
- }
- return
-}
-
-func parseArgs(name string, line int, args []string) (res []interface{}, err error) {
- res = make([]interface{}, len(args))
- for i, v := range args {
- if len(v) == 0 {
- return nil, fmt.Errorf("%s:%d bad code argument %q", name, line, v)
- }
- switch v[0] {
- case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
- n, err := strconv.Atoi(v)
- if err != nil {
- return nil, fmt.Errorf("%s:%d bad code argument %q", name, line, v)
- }
- res[i] = n
- case '/':
- if len(v) < 2 || v[len(v)-1] != '/' {
- return nil, fmt.Errorf("%s:%d bad code argument %q", name, line, v)
- }
- res[i] = v
- case '$':
- res[i] = "$"
- default:
- return nil, fmt.Errorf("%s:%d bad code argument %q", name, line, v)
- }
- }
- return
-}
-
-// parseArg returns the integer or string value of the argument and tells which it is.
-func parseArg(arg interface{}, max int) (ival int, sval string, isInt bool, err error) {
- switch n := arg.(type) {
- case int:
- if n <= 0 || n > max {
- return 0, "", false, fmt.Errorf("%d is out of range", n)
- }
- return n, "", true, nil
- case string:
- return 0, n, false, nil
- }
- return 0, "", false, fmt.Errorf("unrecognized argument %v type %T", arg, arg)
-}
-
-// match identifies the input line that matches the pattern in a code invocation.
-// If start>0, match lines starting there rather than at the beginning.
-// The return value is 1-indexed.
-func match(file string, start int, lines []string, pattern string) (int, error) {
- // $ matches the end of the file.
- if pattern == "$" {
- if len(lines) == 0 {
- return 0, fmt.Errorf("%q: empty file", file)
- }
- return len(lines), nil
- }
- // /regexp/ matches the line that matches the regexp.
- if len(pattern) > 2 && pattern[0] == '/' && pattern[len(pattern)-1] == '/' {
- re, err := regexp.Compile(pattern[1 : len(pattern)-1])
- if err != nil {
- return 0, err
- }
- for i := start; i < len(lines); i++ {
- if re.MatchString(lines[i]) {
- return i + 1, nil
- }
- }
- return 0, fmt.Errorf("%s: no match for %#q", file, pattern)
- }
- return 0, fmt.Errorf("unrecognized pattern: %q", pattern)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/doc.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/doc.go
deleted file mode 100644
index afd50e79..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/doc.go
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-/*
-The present file format
-
-Present files have the following format. The first non-blank non-comment
-line is the title, so the header looks like
-
- Title of document
- Subtitle of document
- 15:04 2 Jan 2006
- Tags: foo, bar, baz
-
- Author Name
- Job title, Company
- joe@example.com
- http://url/
- @twitter_name
-
-The subtitle, date, and tags lines are optional.
-
-The date line may be written without a time:
- 2 Jan 2006
-In this case, the time will be interpreted as 10am UTC on that date.
-
-The tags line is a comma-separated list of tags that may be used to categorize
-the document.
-
-The author section may contain a mixture of text, twitter names, and links.
-For slide presentations, only the plain text lines will be displayed on the
-first slide.
-
-Multiple presenters may be specified, separated by a blank line.
-
-After that come slides/sections, each after a blank line:
-
- * Title of slide or section (must have asterisk)
-
- Some Text
-
- ** Subsection
-
- - bullets
- - more bullets
- - a bullet with
-
- *** Sub-subsection
-
- Some More text
-
- Preformatted text
- is indented (however you like)
-
- Further Text, including invocations like:
-
- .code x.go /^func main/,/^}/
- .play y.go
- .image image.jpg
- .iframe http://foo
- .link http://foo label
- .html file.html
-
- Again, more text
-
-Blank lines are OK (not mandatory) after the title and after the
-text. Text, bullets, and .code etc. are all optional; title is
-not.
-
-Lines starting with # in column 1 are commentary.
-
-Fonts:
-
-Within the input for plain text or lists, text bracketed by font
-markers will be presented in italic, bold, or program font.
-Marker characters are _ (italic), * (bold) and ` (program font).
-Unmatched markers appear as plain text.
-Within marked text, a single marker character becomes a space
-and a doubled single marker quotes the marker character.
-
- _italic_
- *bold*
- `program`
- _this_is_all_italic_
- _Why_use_scoped__ptr_? Use plain ***ptr* instead.
-
-Inline links:
-
-Links can be included in any text with the form [[url][label]], or
-[[url]] to use the URL itself as the label.
-
-Functions:
-
-A number of template functions are available through invocations
-in the input text. Each such invocation contains a period as the
-first character on the line, followed immediately by the name of
-the function, followed by any arguments. A typical invocation might
-be
- .play demo.go /^func show/,/^}/
-(except that the ".play" must be at the beginning of the line and
-not be indented like this.)
-
-Here follows a description of the functions:
-
-code:
-
-Injects program source into the output by extracting code from files
-and injecting them as HTML-escaped
blocks. The argument is
-a file name followed by an optional address that specifies what
-section of the file to display. The address syntax is similar in
-its simplest form to that of ed, but comes from sam and is more
-general. See
- http://plan9.bell-labs.com/sys/doc/sam/sam.html Table II
-for full details. The displayed block is always rounded out to a
-full line at both ends.
-
-If no pattern is present, the entire file is displayed.
-
-Any line in the program that ends with the four characters
- OMIT
-is deleted from the source before inclusion, making it easy
-to write things like
- .code test.go /START OMIT/,/END OMIT/
-to find snippets like this
- tedious_code = boring_function()
- // START OMIT
- interesting_code = fascinating_function()
- // END OMIT
-and see only this:
- interesting_code = fascinating_function()
-
-Also, inside the displayed text a line that ends
- // HL
-will be highlighted in the display; the 'h' key in the browser will
-toggle extra emphasis of any highlighted lines. A highlighting mark
-may have a suffix word, such as
- // HLxxx
-Such highlights are enabled only if the code invocation ends with
-"HL" followed by the word:
- .code test.go /^type Foo/,/^}/ HLxxx
-
-The .code function may take one or more flags immediately preceding
-the filename. This command shows test.go in an editable text area:
- .code -edit test.go
-This command shows test.go with line numbers:
- .code -numbers test.go
-
-play:
-
-The function "play" is the same as "code" but puts a button
-on the displayed source so the program can be run from the browser.
-Although only the selected text is shown, all the source is included
-in the HTML output so it can be presented to the compiler.
-
-link:
-
-Create a hyperlink. The syntax is 1 or 2 space-separated arguments.
-The first argument is always the HTTP URL. If there is a second
-argument, it is the text label to display for this link.
-
- .link http://golang.org golang.org
-
-image:
-
-The template uses the function "image" to inject picture files.
-
-The syntax is simple: 1 or 3 space-separated arguments.
-The first argument is always the file name.
-If there are more arguments, they are the height and width;
-both must be present.
-
- .image images/betsy.jpg 100 200
-
-iframe:
-
-The function "iframe" injects iframes (pages inside pages).
-Its syntax is the same as that of image.
-
-html:
-
-The function html includes the contents of the specified file as
-unescaped HTML. This is useful for including custom HTML elements
-that cannot be created using only the slide format.
-It is your responsibilty to make sure the included HTML is valid and safe.
-
- .html file.html
-
-*/
-package present
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/html.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/html.go
deleted file mode 100644
index cca90ef4..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/html.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package present
-
-import (
- "errors"
- "html/template"
- "path/filepath"
- "strings"
-)
-
-func init() {
- Register("html", parseHTML)
-}
-
-func parseHTML(ctx *Context, fileName string, lineno int, text string) (Elem, error) {
- p := strings.Fields(text)
- if len(p) != 2 {
- return nil, errors.New("invalid .html args")
- }
- name := filepath.Join(filepath.Dir(fileName), p[1])
- b, err := ctx.ReadFile(name)
- if err != nil {
- return nil, err
- }
- return HTML{template.HTML(b)}, nil
-}
-
-type HTML struct {
- template.HTML
-}
-
-func (s HTML) TemplateName() string { return "html" }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/iframe.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/iframe.go
deleted file mode 100644
index 2f3c5e55..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/iframe.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import (
- "fmt"
- "strings"
-)
-
-func init() {
- Register("iframe", parseIframe)
-}
-
-type Iframe struct {
- URL string
- Width int
- Height int
-}
-
-func (i Iframe) TemplateName() string { return "iframe" }
-
-func parseIframe(ctx *Context, fileName string, lineno int, text string) (Elem, error) {
- args := strings.Fields(text)
- i := Iframe{URL: args[1]}
- a, err := parseArgs(fileName, lineno, args[2:])
- if err != nil {
- return nil, err
- }
- switch len(a) {
- case 0:
- // no size parameters
- case 2:
- if v, ok := a[0].(int); ok {
- i.Height = v
- }
- if v, ok := a[1].(int); ok {
- i.Width = v
- }
- default:
- return nil, fmt.Errorf("incorrect image invocation: %q", text)
- }
- return i, nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/image.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/image.go
deleted file mode 100644
index 2bab429c..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/image.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import (
- "fmt"
- "strings"
-)
-
-func init() {
- Register("image", parseImage)
-}
-
-type Image struct {
- URL string
- Width int
- Height int
-}
-
-func (i Image) TemplateName() string { return "image" }
-
-func parseImage(ctx *Context, fileName string, lineno int, text string) (Elem, error) {
- args := strings.Fields(text)
- img := Image{URL: args[1]}
- a, err := parseArgs(fileName, lineno, args[2:])
- if err != nil {
- return nil, err
- }
- switch len(a) {
- case 0:
- // no size parameters
- case 2:
- if v, ok := a[0].(int); ok {
- img.Height = v
- }
- if v, ok := a[1].(int); ok {
- img.Width = v
- }
- default:
- return nil, fmt.Errorf("incorrect image invocation: %q", text)
- }
- return img, nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/link.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/link.go
deleted file mode 100644
index 4973b96f..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/link.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import (
- "fmt"
- "log"
- "net/url"
- "strings"
-)
-
-func init() {
- Register("link", parseLink)
-}
-
-type Link struct {
- URL *url.URL
- Label string
-}
-
-func (l Link) TemplateName() string { return "link" }
-
-func parseLink(ctx *Context, fileName string, lineno int, text string) (Elem, error) {
- args := strings.Fields(text)
- url, err := url.Parse(args[1])
- if err != nil {
- return nil, err
- }
- label := ""
- if len(args) > 2 {
- label = strings.Join(args[2:], " ")
- } else {
- scheme := url.Scheme + "://"
- if url.Scheme == "mailto" {
- scheme = "mailto:"
- }
- label = strings.Replace(url.String(), scheme, "", 1)
- }
- return Link{url, label}, nil
-}
-
-func renderLink(href, text string) string {
- text = font(text)
- if text == "" {
- text = href
- }
- // Open links in new window only when their url is absolute.
- target := "_blank"
- if u, err := url.Parse(href); err != nil {
- log.Println("rendernLink parsing url: %v", err)
- } else if !u.IsAbs() || u.Scheme == "javascript" {
- target = "_self"
- }
-
- return fmt.Sprintf(`%s`, href, target, text)
-}
-
-// parseInlineLink parses an inline link at the start of s, and returns
-// a rendered HTML link and the total length of the raw inline link.
-// If no inline link is present, it returns all zeroes.
-func parseInlineLink(s string) (link string, length int) {
- if !strings.HasPrefix(s, "[[") {
- return
- }
- end := strings.Index(s, "]]")
- if end == -1 {
- return
- }
- urlEnd := strings.Index(s, "]")
- rawURL := s[2:urlEnd]
- const badURLChars = `<>"{}|\^[] ` + "`" // per RFC2396 section 2.4.3
- if strings.ContainsAny(rawURL, badURLChars) {
- return
- }
- if urlEnd == end {
- simpleUrl := ""
- url, err := url.Parse(rawURL)
- if err == nil {
- // If the URL is http://foo.com, drop the http://
- // In other words, render [[http://golang.org]] as:
- // golang.org
- if strings.HasPrefix(rawURL, url.Scheme+"://") {
- simpleUrl = strings.TrimPrefix(rawURL, url.Scheme+"://")
- } else if strings.HasPrefix(rawURL, url.Scheme+":") {
- simpleUrl = strings.TrimPrefix(rawURL, url.Scheme+":")
- }
- }
- return renderLink(rawURL, simpleUrl), end + 2
- }
- if s[urlEnd:urlEnd+2] != "][" {
- return
- }
- text := s[urlEnd+2 : end]
- return renderLink(rawURL, text), end + 2
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/link_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/link_test.go
deleted file mode 100644
index 334e72bd..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/link_test.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import "testing"
-
-func TestInlineParsing(t *testing.T) {
- var tests = []struct {
- in string
- link string
- text string
- length int
- }{
- {"[[http://golang.org]]", "http://golang.org", "golang.org", 21},
- {"[[http://golang.org][]]", "http://golang.org", "http://golang.org", 23},
- {"[[http://golang.org]] this is ignored", "http://golang.org", "golang.org", 21},
- {"[[http://golang.org][link]]", "http://golang.org", "link", 27},
- {"[[http://golang.org][two words]]", "http://golang.org", "two words", 32},
- {"[[http://golang.org][*link*]]", "http://golang.org", "link", 29},
- {"[[http://bad[url]]", "", "", 0},
- {"[[http://golang.org][a [[link]] ]]", "http://golang.org", "a [[link", 31},
- {"[[http:// *spaces* .com]]", "", "", 0},
- {"[[http://bad`char.com]]", "", "", 0},
- {" [[http://google.com]]", "", "", 0},
- {"[[mailto:gopher@golang.org][Gopher]]", "mailto:gopher@golang.org", "Gopher", 36},
- {"[[mailto:gopher@golang.org]]", "mailto:gopher@golang.org", "gopher@golang.org", 28},
- }
-
- for i, test := range tests {
- link, length := parseInlineLink(test.in)
- if length == 0 && test.length == 0 {
- continue
- }
- if a := renderLink(test.link, test.text); length != test.length || link != a {
- t.Errorf("#%d: parseInlineLink(%q):\ngot\t%q, %d\nwant\t%q, %d", i, test.in, link, length, a, test.length)
- }
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/parse.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/parse.go
deleted file mode 100644
index 449d5ed5..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/parse.go
+++ /dev/null
@@ -1,505 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import (
- "bufio"
- "bytes"
- "errors"
- "fmt"
- "html/template"
- "io"
- "io/ioutil"
- "log"
- "net/url"
- "regexp"
- "strings"
- "time"
- "unicode"
- "unicode/utf8"
-)
-
-var (
- parsers = make(map[string]ParseFunc)
- funcs = template.FuncMap{}
-)
-
-// Template returns an empty template with the action functions in its FuncMap.
-func Template() *template.Template {
- return template.New("").Funcs(funcs)
-}
-
-// Render renders the doc to the given writer using the provided template.
-func (d *Doc) Render(w io.Writer, t *template.Template) error {
- data := struct {
- *Doc
- Template *template.Template
- PlayEnabled bool
- }{d, t, PlayEnabled}
- return t.ExecuteTemplate(w, "root", data)
-}
-
-// Render renders the section to the given writer using the provided template.
-func (s *Section) Render(w io.Writer, t *template.Template) error {
- data := struct {
- *Section
- Template *template.Template
- PlayEnabled bool
- }{s, t, PlayEnabled}
- return t.ExecuteTemplate(w, "section", data)
-}
-
-type ParseFunc func(ctx *Context, fileName string, lineNumber int, inputLine string) (Elem, error)
-
-// Register binds the named action, which does not begin with a period, to the
-// specified parser to be invoked when the name, with a period, appears in the
-// present input text.
-func Register(name string, parser ParseFunc) {
- if len(name) == 0 || name[0] == ';' {
- panic("bad name in Register: " + name)
- }
- parsers["."+name] = parser
-}
-
-// Doc represents an entire document.
-type Doc struct {
- Title string
- Subtitle string
- Time time.Time
- Authors []Author
- Sections []Section
- Tags []string
-}
-
-// Author represents the person who wrote and/or is presenting the document.
-type Author struct {
- Elem []Elem
-}
-
-// TextElem returns the first text elements of the author details.
-// This is used to display the author' name, job title, and company
-// without the contact details.
-func (p *Author) TextElem() (elems []Elem) {
- for _, el := range p.Elem {
- if _, ok := el.(Text); !ok {
- break
- }
- elems = append(elems, el)
- }
- return
-}
-
-// Section represents a section of a document (such as a presentation slide)
-// comprising a title and a list of elements.
-type Section struct {
- Number []int
- Title string
- Elem []Elem
-}
-
-func (s Section) Sections() (sections []Section) {
- for _, e := range s.Elem {
- if section, ok := e.(Section); ok {
- sections = append(sections, section)
- }
- }
- return
-}
-
-// Level returns the level of the given section.
-// The document title is level 1, main section 2, etc.
-func (s Section) Level() int {
- return len(s.Number) + 1
-}
-
-// FormattedNumber returns a string containing the concatenation of the
-// numbers identifying a Section.
-func (s Section) FormattedNumber() string {
- b := &bytes.Buffer{}
- for _, n := range s.Number {
- fmt.Fprintf(b, "%v.", n)
- }
- return b.String()
-}
-
-func (s Section) TemplateName() string { return "section" }
-
-// Elem defines the interface for a present element. That is, something that
-// can provide the name of the template used to render the element.
-type Elem interface {
- TemplateName() string
-}
-
-// renderElem implements the elem template function, used to render
-// sub-templates.
-func renderElem(t *template.Template, e Elem) (template.HTML, error) {
- var data interface{} = e
- if s, ok := e.(Section); ok {
- data = struct {
- Section
- Template *template.Template
- }{s, t}
- }
- return execTemplate(t, e.TemplateName(), data)
-}
-
-func init() {
- funcs["elem"] = renderElem
-}
-
-// execTemplate is a helper to execute a template and return the output as a
-// template.HTML value.
-func execTemplate(t *template.Template, name string, data interface{}) (template.HTML, error) {
- b := new(bytes.Buffer)
- err := t.ExecuteTemplate(b, name, data)
- if err != nil {
- return "", err
- }
- return template.HTML(b.String()), nil
-}
-
-// Text represents an optionally preformatted paragraph.
-type Text struct {
- Lines []string
- Pre bool
-}
-
-func (t Text) TemplateName() string { return "text" }
-
-// List represents a bulleted list.
-type List struct {
- Bullet []string
-}
-
-func (l List) TemplateName() string { return "list" }
-
-// Lines is a helper for parsing line-based input.
-type Lines struct {
- line int // 0 indexed, so has 1-indexed number of last line returned
- text []string
-}
-
-func readLines(r io.Reader) (*Lines, error) {
- var lines []string
- s := bufio.NewScanner(r)
- for s.Scan() {
- lines = append(lines, s.Text())
- }
- if err := s.Err(); err != nil {
- return nil, err
- }
- return &Lines{0, lines}, nil
-}
-
-func (l *Lines) next() (text string, ok bool) {
- for {
- current := l.line
- l.line++
- if current >= len(l.text) {
- return "", false
- }
- text = l.text[current]
- // Lines starting with # are comments.
- if len(text) == 0 || text[0] != '#' {
- ok = true
- break
- }
- }
- return
-}
-
-func (l *Lines) back() {
- l.line--
-}
-
-func (l *Lines) nextNonEmpty() (text string, ok bool) {
- for {
- text, ok = l.next()
- if !ok {
- return
- }
- if len(text) > 0 {
- break
- }
- }
- return
-}
-
-// A Context specifies the supporting context for parsing a presentation.
-type Context struct {
- // ReadFile reads the file named by filename and returns the contents.
- ReadFile func(filename string) ([]byte, error)
-}
-
-// ParseMode represents flags for the Parse function.
-type ParseMode int
-
-const (
- // If set, parse only the title and subtitle.
- TitlesOnly ParseMode = 1
-)
-
-// Parse parses a document from r.
-func (ctx *Context) Parse(r io.Reader, name string, mode ParseMode) (*Doc, error) {
- doc := new(Doc)
- lines, err := readLines(r)
- if err != nil {
- return nil, err
- }
- err = parseHeader(doc, lines)
- if err != nil {
- return nil, err
- }
- if mode&TitlesOnly != 0 {
- return doc, nil
- }
- // Authors
- if doc.Authors, err = parseAuthors(lines); err != nil {
- return nil, err
- }
- // Sections
- if doc.Sections, err = parseSections(ctx, name, lines, []int{}, doc); err != nil {
- return nil, err
- }
- return doc, nil
-}
-
-// Parse parses a document from r. Parse reads assets used by the presentation
-// from the file system using ioutil.ReadFile.
-func Parse(r io.Reader, name string, mode ParseMode) (*Doc, error) {
- ctx := Context{ReadFile: ioutil.ReadFile}
- return ctx.Parse(r, name, mode)
-}
-
-// isHeading matches any section heading.
-var isHeading = regexp.MustCompile(`^\*+ `)
-
-// lesserHeading returns true if text is a heading of a lesser or equal level
-// than that denoted by prefix.
-func lesserHeading(text, prefix string) bool {
- return isHeading.MatchString(text) && !strings.HasPrefix(text, prefix+"*")
-}
-
-// parseSections parses Sections from lines for the section level indicated by
-// number (a nil number indicates the top level).
-func parseSections(ctx *Context, name string, lines *Lines, number []int, doc *Doc) ([]Section, error) {
- var sections []Section
- for i := 1; ; i++ {
- // Next non-empty line is title.
- text, ok := lines.nextNonEmpty()
- for ok && text == "" {
- text, ok = lines.next()
- }
- if !ok {
- break
- }
- prefix := strings.Repeat("*", len(number)+1)
- if !strings.HasPrefix(text, prefix+" ") {
- lines.back()
- break
- }
- section := Section{
- Number: append(append([]int{}, number...), i),
- Title: text[len(prefix)+1:],
- }
- text, ok = lines.nextNonEmpty()
- for ok && !lesserHeading(text, prefix) {
- var e Elem
- r, _ := utf8.DecodeRuneInString(text)
- switch {
- case unicode.IsSpace(r):
- i := strings.IndexFunc(text, func(r rune) bool {
- return !unicode.IsSpace(r)
- })
- if i < 0 {
- break
- }
- indent := text[:i]
- var s []string
- for ok && (strings.HasPrefix(text, indent) || text == "") {
- if text != "" {
- text = text[i:]
- }
- s = append(s, text)
- text, ok = lines.next()
- }
- lines.back()
- pre := strings.Join(s, "\n")
- pre = strings.Replace(pre, "\t", " ", -1) // browsers treat tabs badly
- pre = strings.TrimRightFunc(pre, unicode.IsSpace)
- e = Text{Lines: []string{pre}, Pre: true}
- case strings.HasPrefix(text, "- "):
- var b []string
- for ok && strings.HasPrefix(text, "- ") {
- b = append(b, text[2:])
- text, ok = lines.next()
- }
- lines.back()
- e = List{Bullet: b}
- case strings.HasPrefix(text, prefix+"* "):
- lines.back()
- subsecs, err := parseSections(ctx, name, lines, section.Number, doc)
- if err != nil {
- return nil, err
- }
- for _, ss := range subsecs {
- section.Elem = append(section.Elem, ss)
- }
- case strings.HasPrefix(text, "."):
- args := strings.Fields(text)
- parser := parsers[args[0]]
- if parser == nil {
- return nil, fmt.Errorf("%s:%d: unknown command %q\n", name, lines.line, text)
- }
- t, err := parser(ctx, name, lines.line, text)
- if err != nil {
- return nil, err
- }
- e = t
- default:
- var l []string
- for ok && strings.TrimSpace(text) != "" {
- if text[0] == '.' { // Command breaks text block.
- break
- }
- if strings.HasPrefix(text, `\.`) { // Backslash escapes initial period.
- text = text[1:]
- }
- l = append(l, text)
- text, ok = lines.next()
- }
- if len(l) > 0 {
- e = Text{Lines: l}
- }
- }
- if e != nil {
- section.Elem = append(section.Elem, e)
- }
- text, ok = lines.nextNonEmpty()
- }
- if isHeading.MatchString(text) {
- lines.back()
- }
- sections = append(sections, section)
- }
- return sections, nil
-}
-
-func parseHeader(doc *Doc, lines *Lines) error {
- var ok bool
- // First non-empty line starts header.
- doc.Title, ok = lines.nextNonEmpty()
- if !ok {
- return errors.New("unexpected EOF; expected title")
- }
- for {
- text, ok := lines.next()
- if !ok {
- return errors.New("unexpected EOF")
- }
- if text == "" {
- break
- }
- const tagPrefix = "Tags:"
- if strings.HasPrefix(text, tagPrefix) {
- tags := strings.Split(text[len(tagPrefix):], ",")
- for i := range tags {
- tags[i] = strings.TrimSpace(tags[i])
- }
- doc.Tags = append(doc.Tags, tags...)
- } else if t, ok := parseTime(text); ok {
- doc.Time = t
- } else if doc.Subtitle == "" {
- doc.Subtitle = text
- } else {
- return fmt.Errorf("unexpected header line: %q", text)
- }
- }
- return nil
-}
-
-func parseAuthors(lines *Lines) (authors []Author, err error) {
- // This grammar demarcates authors with blanks.
-
- // Skip blank lines.
- if _, ok := lines.nextNonEmpty(); !ok {
- return nil, errors.New("unexpected EOF")
- }
- lines.back()
-
- var a *Author
- for {
- text, ok := lines.next()
- if !ok {
- return nil, errors.New("unexpected EOF")
- }
-
- // If we find a section heading, we're done.
- if strings.HasPrefix(text, "* ") {
- lines.back()
- break
- }
-
- // If we encounter a blank we're done with this author.
- if a != nil && len(text) == 0 {
- authors = append(authors, *a)
- a = nil
- continue
- }
- if a == nil {
- a = new(Author)
- }
-
- // Parse the line. Those that
- // - begin with @ are twitter names,
- // - contain slashes are links, or
- // - contain an @ symbol are an email address.
- // The rest is just text.
- var el Elem
- switch {
- case strings.HasPrefix(text, "@"):
- el = parseURL("http://twitter.com/" + text[1:])
- case strings.Contains(text, ":"):
- el = parseURL(text)
- case strings.Contains(text, "@"):
- el = parseURL("mailto:" + text)
- }
- if l, ok := el.(Link); ok {
- l.Label = text
- el = l
- }
- if el == nil {
- el = Text{Lines: []string{text}}
- }
- a.Elem = append(a.Elem, el)
- }
- if a != nil {
- authors = append(authors, *a)
- }
- return authors, nil
-}
-
-func parseURL(text string) Elem {
- u, err := url.Parse(text)
- if err != nil {
- log.Printf("Parse(%q): %v", text, err)
- return nil
- }
- return Link{URL: u}
-}
-
-func parseTime(text string) (t time.Time, ok bool) {
- t, err := time.Parse("15:04 2 Jan 2006", text)
- if err == nil {
- return t, true
- }
- t, err = time.Parse("2 Jan 2006", text)
- if err == nil {
- // at 11am UTC it is the same date everywhere
- t = t.Add(time.Hour * 11)
- return t, true
- }
- return time.Time{}, false
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/style.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/style.go
deleted file mode 100644
index 1cd240de..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/style.go
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import (
- "bytes"
- "html"
- "html/template"
- "strings"
- "unicode"
- "unicode/utf8"
-)
-
-/*
- Fonts are demarcated by an initial and final char bracketing a
- space-delimited word, plus possibly some terminal punctuation.
- The chars are
- _ for italic
- * for bold
- ` (back quote) for fixed width.
- Inner appearances of the char become spaces. For instance,
- _this_is_italic_!
- becomes
- this is italic!
-*/
-
-func init() {
- funcs["style"] = Style
-}
-
-// Style returns s with HTML entities escaped and font indicators turned into
-// HTML font tags.
-func Style(s string) template.HTML {
- return template.HTML(font(html.EscapeString(s)))
-}
-
-// font returns s with font indicators turned into HTML font tags.
-func font(s string) string {
- if strings.IndexAny(s, "[`_*") == -1 {
- return s
- }
- words := split(s)
- var b bytes.Buffer
-Word:
- for w, word := range words {
- if len(word) < 2 {
- continue Word
- }
- if link, _ := parseInlineLink(word); link != "" {
- words[w] = link
- continue Word
- }
- const punctuation = `.,;:()!?—–'"`
- const marker = "_*`"
- // Initial punctuation is OK but must be peeled off.
- first := strings.IndexAny(word, marker)
- if first == -1 {
- continue Word
- }
- // Is the marker prefixed only by punctuation?
- for _, r := range word[:first] {
- if !strings.ContainsRune(punctuation, r) {
- continue Word
- }
- }
- open, word := word[:first], word[first:]
- char := word[0] // ASCII is OK.
- close := ""
- switch char {
- default:
- continue Word
- case '_':
- open += ""
- close = ""
- case '*':
- open += ""
- close = ""
- case '`':
- open += ""
- close = ""
- }
- // Terminal punctuation is OK but must be peeled off.
- last := strings.LastIndex(word, word[:1])
- if last == 0 {
- continue Word
- }
- head, tail := word[:last+1], word[last+1:]
- for _, r := range tail {
- if !strings.ContainsRune(punctuation, r) {
- continue Word
- }
- }
- b.Reset()
- b.WriteString(open)
- var wid int
- for i := 1; i < len(head)-1; i += wid {
- var r rune
- r, wid = utf8.DecodeRuneInString(head[i:])
- if r != rune(char) {
- // Ordinary character.
- b.WriteRune(r)
- continue
- }
- if head[i+1] != char {
- // Inner char becomes space.
- b.WriteRune(' ')
- continue
- }
- // Doubled char becomes real char.
- // Not worth worrying about "_x__".
- b.WriteByte(char)
- wid++ // Consumed two chars, both ASCII.
- }
- b.WriteString(close) // Write closing tag.
- b.WriteString(tail) // Restore trailing punctuation.
- words[w] = b.String()
- }
- return strings.Join(words, "")
-}
-
-// split is like strings.Fields but also returns the runs of spaces
-// and treats inline links as distinct words.
-func split(s string) []string {
- var (
- words = make([]string, 0, 10)
- start = 0
- )
-
- // appendWord appends the string s[start:end] to the words slice.
- // If the word contains the beginning of a link, the non-link portion
- // of the word and the entire link are appended as separate words,
- // and the start index is advanced to the end of the link.
- appendWord := func(end int) {
- if j := strings.Index(s[start:end], "[["); j > -1 {
- if _, l := parseInlineLink(s[start+j:]); l > 0 {
- // Append portion before link, if any.
- if j > 0 {
- words = append(words, s[start:start+j])
- }
- // Append link itself.
- words = append(words, s[start+j:start+j+l])
- // Advance start index to end of link.
- start = start + j + l
- return
- }
- }
- // No link; just add the word.
- words = append(words, s[start:end])
- start = end
- }
-
- wasSpace := false
- for i, r := range s {
- isSpace := unicode.IsSpace(r)
- if i > start && isSpace != wasSpace {
- appendWord(i)
- }
- wasSpace = isSpace
- }
- for start < len(s) {
- appendWord(len(s))
- }
- return words
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/style_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/style_test.go
deleted file mode 100644
index d04db72d..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/present/style_test.go
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package present
-
-import (
- "fmt"
- "reflect"
- "testing"
-)
-
-func TestSplit(t *testing.T) {
- var tests = []struct {
- in string
- out []string
- }{
- {"", []string{}},
- {" ", []string{" "}},
- {"abc", []string{"abc"}},
- {"abc def", []string{"abc", " ", "def"}},
- {"abc def ", []string{"abc", " ", "def", " "}},
- {"hey [[http://golang.org][Gophers]] around",
- []string{"hey", " ", "[[http://golang.org][Gophers]]", " ", "around"}},
- {"A [[http://golang.org/doc][two words]] link",
- []string{"A", " ", "[[http://golang.org/doc][two words]]", " ", "link"}},
- {"Visit [[http://golang.org/doc]] now",
- []string{"Visit", " ", "[[http://golang.org/doc]]", " ", "now"}},
- {"not [[http://golang.org/doc][a [[link]] ]] around",
- []string{"not", " ", "[[http://golang.org/doc][a [[link]]", " ", "]]", " ", "around"}},
- {"[[http://golang.org][foo bar]]",
- []string{"[[http://golang.org][foo bar]]"}},
- {"ends with [[http://golang.org][link]]",
- []string{"ends", " ", "with", " ", "[[http://golang.org][link]]"}},
- {"my talk ([[http://talks.golang.org/][slides here]])",
- []string{"my", " ", "talk", " ", "(", "[[http://talks.golang.org/][slides here]]", ")"}},
- }
- for _, test := range tests {
- out := split(test.in)
- if !reflect.DeepEqual(out, test.out) {
- t.Errorf("split(%q):\ngot\t%q\nwant\t%q", test.in, out, test.out)
- }
- }
-}
-
-func TestFont(t *testing.T) {
- var tests = []struct {
- in string
- out string
- }{
- {"", ""},
- {" ", " "},
- {"\tx", "\tx"},
- {"_a_", "a"},
- {"*a*", "a"},
- {"`a`", "a"},
- {"_a_b_", "a b"},
- {"_a__b_", "a_b"},
- {"_a___b_", "a_ b"},
- {"*a**b*?", "a*b?"},
- {"_a_<>_b_.", "a <> b."},
- {"(_a_)", "(a)"},
- {"((_a_), _b_, _c_).", "((a), b, c)."},
- {"(_a)", "(_a)"},
- {"(_a)", "(_a)"},
- {"_Why_use_scoped__ptr_? Use plain ***ptr* instead.", "Why use scoped_ptr? Use plain *ptr instead."},
- {"_hey_ [[http://golang.org][*Gophers*]] *around*",
- `heyGophersaround`},
- {"_hey_ [[http://golang.org][so _many_ *Gophers*]] *around*",
- `heyso manyGophersaround`},
- {"Visit [[http://golang.org]] now",
- `Visit golang.org now`},
- {"my talk ([[http://talks.golang.org/][slides here]])",
- `my talk (slides here)`},
- }
- for _, test := range tests {
- out := font(test.in)
- if out != test.out {
- t.Errorf("font(%q):\ngot\t%q\nwant\t%q", test.in, out, test.out)
- }
- }
-}
-
-func TestStyle(t *testing.T) {
- var tests = []struct {
- in string
- out string
- }{
- {"", ""},
- {" ", " "},
- {"\tx", "\tx"},
- {"_a_", "a"},
- {"*a*", "a"},
- {"`a`", "a"},
- {"_a_b_", "a b"},
- {"_a__b_", "a_b"},
- {"_a___b_", "a_ b"},
- {"*a**b*?", "a*b?"},
- {"_a_<>_b_.", "a <> b."},
- {"(_a_<>_b_)", "(a <> b)"},
- {"((_a_), _b_, _c_).", "((a), b, c)."},
- {"(_a)", "(_a)"},
- }
- for _, test := range tests {
- out := string(Style(test.in))
- if out != test.out {
- t.Errorf("style(%q):\ngot\t%q\nwant\t%q", test.in, out, test.out)
- }
- }
-}
-
-func ExampleStyle() {
- const s = "*Gophers* are _clearly_ > *cats*!"
- fmt.Println(Style(s))
- // Output: Gophers are clearly > cats!
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/README b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/README
deleted file mode 100644
index a6edb135..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/README
+++ /dev/null
@@ -1 +0,0 @@
-code.google.com/p/go.tools/refactor: libraries for refactoring tools.
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/eg.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/eg.go
deleted file mode 100644
index ebb93b5b..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/eg.go
+++ /dev/null
@@ -1,326 +0,0 @@
-// Package eg implements the example-based refactoring tool whose
-// command-line is defined in code.google.com/p/go.tools/cmd/eg.
-package eg
-
-import (
- "bytes"
- "fmt"
- "go/ast"
- "go/printer"
- "go/token"
- "os"
-
- "code.google.com/p/go.tools/go/loader"
- "code.google.com/p/go.tools/go/types"
-)
-
-const Help = `
-This tool implements example-based refactoring of expressions.
-
-The transformation is specified as a Go file defining two functions,
-'before' and 'after', of identical types. Each function body consists
-of a single statement: either a return statement with a single
-(possibly multi-valued) expression, or an expression statement. The
-'before' expression specifies a pattern and the 'after' expression its
-replacement.
-
- package P
- import ( "errors"; "fmt" )
- func before(s string) error { return fmt.Errorf("%s", s) }
- func after(s string) error { return errors.New(s) }
-
-The expression statement form is useful when the the expression has no
-result, for example:
-
- func before(msg string) { log.Fatalf("%s", msg) }
- func after(msg string) { log.Fatal(msg) }
-
-The parameters of both functions are wildcards that may match any
-expression assignable to that type. If the pattern contains multiple
-occurrences of the same parameter, each must match the same expression
-in the input for the pattern to match. If the replacement contains
-multiple occurrences of the same parameter, the expression will be
-duplicated, possibly changing the side-effects.
-
-The tool analyses all Go code in the packages specified by the
-arguments, replacing all occurrences of the pattern with the
-substitution.
-
-So, the transform above would change this input:
- err := fmt.Errorf("%s", "error: " + msg)
-to this output:
- err := errors.New("error: " + msg)
-
-Identifiers, including qualified identifiers (p.X) are considered to
-match only if they denote the same object. This allows correct
-matching even in the presence of dot imports, named imports and
-locally shadowed package names in the input program.
-
-Matching of type syntax is semantic, not syntactic: type syntax in the
-pattern matches type syntax in the input if the types are identical.
-Thus, func(x int) matches func(y int).
-
-This tool was inspired by other example-based refactoring tools,
-'gofmt -r' for Go and Refaster for Java.
-
-
-LIMITATIONS
-===========
-
-EXPRESSIVENESS
-
-Only refactorings that replace one expression with another, regardless
-of the expression's context, may be expressed. Refactoring arbitrary
-statements (or sequences of statements) is a less well-defined problem
-and is less amenable to this approach.
-
-A pattern that contains a function literal (and hence statements)
-never matches.
-
-There is no way to generalize over related types, e.g. to express that
-a wildcard may have any integer type, for example.
-
-It is not possible to replace an expression by one of a different
-type, even in contexts where this is legal, such as x in fmt.Print(x).
-
-
-SAFETY
-
-Verifying that a transformation does not introduce type errors is very
-complex in the general case. An innocuous-looking replacement of one
-constant by another (e.g. 1 to 2) may cause type errors relating to
-array types and indices, for example. The tool performs only very
-superficial checks of type preservation.
-
-
-IMPORTS
-
-Although the matching algorithm is fully aware of scoping rules, the
-replacement algorithm is not, so the replacement code may contain
-incorrect identifier syntax for imported objects if there are dot
-imports, named imports or locally shadowed package names in the input
-program.
-
-Imports are added as needed, but they are not removed as needed.
-Run 'goimports' on the modified file for now.
-
-Dot imports are forbidden in the template.
-`
-
-// TODO(adonovan): allow the tool to be invoked using relative package
-// directory names (./foo). Requires changes to go/loader.
-
-// TODO(adonovan): expand upon the above documentation as an HTML page.
-
-// TODO(adonovan): eliminate dependency on loader.PackageInfo.
-// Move its ObjectOf/IsType/TypeOf methods into go/types.
-
-// A Transformer represents a single example-based transformation.
-type Transformer struct {
- fset *token.FileSet
- verbose bool
- info loader.PackageInfo // combined type info for template/input/output ASTs
- seenInfos map[*types.Info]bool
- wildcards map[*types.Var]bool // set of parameters in func before()
- env map[string]ast.Expr // maps parameter name to wildcard binding
- importedObjs map[types.Object]*ast.SelectorExpr // objects imported by after().
- before, after ast.Expr
- allowWildcards bool
-
- // Working state of Transform():
- nsubsts int // number of substitutions made
- currentPkg *types.Package // package of current call
-}
-
-// NewTransformer returns a transformer based on the specified template,
-// a package containing "before" and "after" functions as described
-// in the package documentation.
-//
-func NewTransformer(fset *token.FileSet, template *loader.PackageInfo, verbose bool) (*Transformer, error) {
- // Check the template.
- beforeSig := funcSig(template.Pkg, "before")
- if beforeSig == nil {
- return nil, fmt.Errorf("no 'before' func found in template")
- }
- afterSig := funcSig(template.Pkg, "after")
- if afterSig == nil {
- return nil, fmt.Errorf("no 'after' func found in template")
- }
-
- // TODO(adonovan): should we also check the names of the params match?
- if !types.Identical(afterSig, beforeSig) {
- return nil, fmt.Errorf("before %s and after %s functions have different signatures",
- beforeSig, afterSig)
- }
-
- templateFile := template.Files[0]
- for _, imp := range templateFile.Imports {
- if imp.Name != nil && imp.Name.Name == "." {
- // Dot imports are currently forbidden. We
- // make the simplifying assumption that all
- // imports are regular, without local renames.
- //TODO document
- return nil, fmt.Errorf("dot-import (of %s) in template", imp.Path.Value)
- }
- }
- var beforeDecl, afterDecl *ast.FuncDecl
- for _, decl := range templateFile.Decls {
- if decl, ok := decl.(*ast.FuncDecl); ok {
- switch decl.Name.Name {
- case "before":
- beforeDecl = decl
- case "after":
- afterDecl = decl
- }
- }
- }
-
- before, err := soleExpr(beforeDecl)
- if err != nil {
- return nil, fmt.Errorf("before: %s", err)
- }
- after, err := soleExpr(afterDecl)
- if err != nil {
- return nil, fmt.Errorf("after: %s", err)
- }
-
- wildcards := make(map[*types.Var]bool)
- for i := 0; i < beforeSig.Params().Len(); i++ {
- wildcards[beforeSig.Params().At(i)] = true
- }
-
- // checkExprTypes returns an error if Tb (type of before()) is not
- // safe to replace with Ta (type of after()).
- //
- // Only superficial checks are performed, and they may result in both
- // false positives and negatives.
- //
- // Ideally, we would only require that the replacement be assignable
- // to the context of a specific pattern occurrence, but the type
- // checker doesn't record that information and it's complex to deduce.
- // A Go type cannot capture all the constraints of a given expression
- // context, which may include the size, constness, signedness,
- // namedness or constructor of its type, and even the specific value
- // of the replacement. (Consider the rule that array literal keys
- // must be unique.) So we cannot hope to prove the safety of a
- // transformation in general.
- Tb := template.TypeOf(before)
- Ta := template.TypeOf(after)
- if types.AssignableTo(Tb, Ta) {
- // safe: replacement is assignable to pattern.
- } else if tuple, ok := Tb.(*types.Tuple); ok && tuple.Len() == 0 {
- // safe: pattern has void type (must appear in an ExprStmt).
- } else {
- return nil, fmt.Errorf("%s is not a safe replacement for %s", Ta, Tb)
- }
-
- tr := &Transformer{
- fset: fset,
- verbose: verbose,
- wildcards: wildcards,
- allowWildcards: true,
- seenInfos: make(map[*types.Info]bool),
- importedObjs: make(map[types.Object]*ast.SelectorExpr),
- before: before,
- after: after,
- }
-
- // Combine type info from the template and input packages, and
- // type info for the synthesized ASTs too. This saves us
- // having to book-keep where each ast.Node originated as we
- // construct the resulting hybrid AST.
- //
- // TODO(adonovan): move type utility methods of PackageInfo to
- // types.Info, or at least into go/types.typeutil.
- tr.info.Info = types.Info{
- Types: make(map[ast.Expr]types.TypeAndValue),
- Defs: make(map[*ast.Ident]types.Object),
- Uses: make(map[*ast.Ident]types.Object),
- Selections: make(map[*ast.SelectorExpr]*types.Selection),
- }
- mergeTypeInfo(&tr.info.Info, &template.Info)
-
- // Compute set of imported objects required by after().
- // TODO reject dot-imports in pattern
- ast.Inspect(after, func(n ast.Node) bool {
- if n, ok := n.(*ast.SelectorExpr); ok {
- sel := tr.info.Selections[n]
- if sel.Kind() == types.PackageObj {
- tr.importedObjs[sel.Obj()] = n
- return false // prune
- }
- }
- return true // recur
- })
-
- return tr, nil
-}
-
-// WriteAST is a convenience function that writes AST f to the specified file.
-func WriteAST(fset *token.FileSet, filename string, f *ast.File) (err error) {
- fh, err := os.Create(filename)
- if err != nil {
- return err
- }
- defer func() {
- if err2 := fh.Close(); err != nil {
- err = err2 // prefer earlier error
- }
- }()
- return printer.Fprint(fh, fset, f)
-}
-
-// -- utilities --------------------------------------------------------
-
-// funcSig returns the signature of the specified package-level function.
-func funcSig(pkg *types.Package, name string) *types.Signature {
- if f, ok := pkg.Scope().Lookup(name).(*types.Func); ok {
- return f.Type().(*types.Signature)
- }
- return nil
-}
-
-// soleExpr returns the sole expression in the before/after template function.
-func soleExpr(fn *ast.FuncDecl) (ast.Expr, error) {
- if fn.Body == nil {
- return nil, fmt.Errorf("no body")
- }
- if len(fn.Body.List) != 1 {
- return nil, fmt.Errorf("must contain a single statement")
- }
- switch stmt := fn.Body.List[0].(type) {
- case *ast.ReturnStmt:
- if len(stmt.Results) != 1 {
- return nil, fmt.Errorf("return statement must have a single operand")
- }
- return stmt.Results[0], nil
-
- case *ast.ExprStmt:
- return stmt.X, nil
- }
-
- return nil, fmt.Errorf("must contain a single return or expression statement")
-}
-
-// mergeTypeInfo adds type info from src to dst.
-func mergeTypeInfo(dst, src *types.Info) {
- for k, v := range src.Types {
- dst.Types[k] = v
- }
- for k, v := range src.Defs {
- dst.Defs[k] = v
- }
- for k, v := range src.Uses {
- dst.Uses[k] = v
- }
- for k, v := range src.Selections {
- dst.Selections[k] = v
- }
-}
-
-// (debugging only)
-func astString(fset *token.FileSet, n ast.Node) string {
- var buf bytes.Buffer
- printer.Fprint(&buf, fset, n)
- return buf.String()
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/eg_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/eg_test.go
deleted file mode 100644
index 62b22ae6..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/eg_test.go
+++ /dev/null
@@ -1,146 +0,0 @@
-package eg_test
-
-import (
- "bytes"
- "flag"
- "go/parser"
- "go/token"
- "os"
- "os/exec"
- "path/filepath"
- "runtime"
- "strings"
- "testing"
-
- "code.google.com/p/go.tools/go/exact"
- "code.google.com/p/go.tools/go/loader"
- "code.google.com/p/go.tools/go/types"
- "code.google.com/p/go.tools/refactor/eg"
-)
-
-// TODO(adonovan): more tests:
-// - of command-line tool
-// - of all parts of syntax
-// - of applying a template to a package it imports:
-// the replacement syntax should use unqualified names for its objects.
-
-var (
- updateFlag = flag.Bool("update", false, "update the golden files")
- verboseFlag = flag.Bool("verbose", false, "show matcher information")
-)
-
-func Test(t *testing.T) {
- switch runtime.GOOS {
- case "windows":
- t.Skipf("skipping test on %q (no /usr/bin/diff)", runtime.GOOS)
- }
-
- conf := loader.Config{
- Fset: token.NewFileSet(),
- ParserMode: parser.ParseComments,
- SourceImports: true,
- }
-
- // Each entry is a single-file package.
- // (Multi-file packages aren't interesting for this test.)
- // Order matters: each non-template package is processed using
- // the preceding template package.
- for _, filename := range []string{
- "testdata/A.template",
- "testdata/A1.go",
- "testdata/A2.go",
-
- "testdata/B.template",
- "testdata/B1.go",
-
- "testdata/C.template",
- "testdata/C1.go",
-
- "testdata/D.template",
- "testdata/D1.go",
-
- "testdata/E.template",
- "testdata/E1.go",
-
- "testdata/bad_type.template",
- "testdata/no_before.template",
- "testdata/no_after_return.template",
- "testdata/type_mismatch.template",
- "testdata/expr_type_mismatch.template",
- } {
- pkgname := strings.TrimSuffix(filepath.Base(filename), ".go")
- if err := conf.CreateFromFilenames(pkgname, filename); err != nil {
- t.Fatal(err)
- }
- }
- iprog, err := conf.Load()
- if err != nil {
- t.Fatal(err)
- }
-
- var xform *eg.Transformer
- for _, info := range iprog.Created {
- file := info.Files[0]
- filename := iprog.Fset.File(file.Pos()).Name() // foo.go
-
- if strings.HasSuffix(filename, "template") {
- // a new template
- shouldFail, _ := info.Pkg.Scope().Lookup("shouldFail").(*types.Const)
- xform, err = eg.NewTransformer(iprog.Fset, info, *verboseFlag)
- if err != nil {
- if shouldFail == nil {
- t.Errorf("NewTransformer(%s): %s", filename, err)
- } else if want := exact.StringVal(shouldFail.Val()); !strings.Contains(err.Error(), want) {
- t.Errorf("NewTransformer(%s): got error %q, want error %q", filename, err, want)
- }
- } else if shouldFail != nil {
- t.Errorf("NewTransformer(%s) succeeded unexpectedly; want error %q",
- filename, shouldFail.Val())
- }
- continue
- }
-
- if xform == nil {
- t.Errorf("%s: no previous template", filename)
- continue
- }
-
- // apply previous template to this package
- n := xform.Transform(&info.Info, info.Pkg, file)
- if n == 0 {
- t.Errorf("%s: no matches", filename)
- continue
- }
-
- got := filename + "t" // foo.got
- golden := filename + "lden" // foo.golden
-
- // Write actual output to foo.got.
- if err := eg.WriteAST(iprog.Fset, got, file); err != nil {
- t.Error(err)
- }
- defer os.Remove(got)
-
- // Compare foo.got with foo.golden.
- var cmd *exec.Cmd
- switch runtime.GOOS {
- case "plan9":
- cmd = exec.Command("/bin/diff", "-c", golden, got)
- default:
- cmd = exec.Command("/usr/bin/diff", "-u", golden, got)
- }
- buf := new(bytes.Buffer)
- cmd.Stdout = buf
- cmd.Stderr = os.Stderr
- if err := cmd.Run(); err != nil {
- t.Errorf("eg tests for %s failed: %s.\n%s\n", filename, err, buf)
-
- if *updateFlag {
- t.Logf("Updating %s...", golden)
- if err := exec.Command("/bin/cp", got, golden).Run(); err != nil {
- t.Errorf("Update failed: %s", err)
- }
- }
- }
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/match.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/match.go
deleted file mode 100644
index 7476f9ac..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/match.go
+++ /dev/null
@@ -1,226 +0,0 @@
-package eg
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- "log"
- "os"
- "reflect"
-
- "code.google.com/p/go.tools/go/exact"
- "code.google.com/p/go.tools/go/loader"
- "code.google.com/p/go.tools/go/types"
-)
-
-// matchExpr reports whether pattern x matches y.
-//
-// If tr.allowWildcards, Idents in x that refer to parameters are
-// treated as wildcards, and match any y that is assignable to the
-// parameter type; matchExpr records this correspondence in tr.env.
-// Otherwise, matchExpr simply reports whether the two trees are
-// equivalent.
-//
-// A wildcard appearing more than once in the pattern must
-// consistently match the same tree.
-//
-func (tr *Transformer) matchExpr(x, y ast.Expr) bool {
- if x == nil && y == nil {
- return true
- }
- if x == nil || y == nil {
- return false
- }
- x = unparen(x)
- y = unparen(y)
-
- // Is x a wildcard? (a reference to a 'before' parameter)
- if x, ok := x.(*ast.Ident); ok && x != nil && tr.allowWildcards {
- if xobj, ok := tr.info.Uses[x].(*types.Var); ok && tr.wildcards[xobj] {
- return tr.matchWildcard(xobj, y)
- }
- }
-
- // Object identifiers (including pkg-qualified ones)
- // are handled semantically, not syntactically.
- xobj := isRef(x, &tr.info)
- yobj := isRef(y, &tr.info)
- if xobj != nil {
- return xobj == yobj
- }
- if yobj != nil {
- return false
- }
-
- // TODO(adonovan): audit: we cannot assume these ast.Exprs
- // contain non-nil pointers. e.g. ImportSpec.Name may be a
- // nil *ast.Ident.
-
- if reflect.TypeOf(x) != reflect.TypeOf(y) {
- return false
- }
- switch x := x.(type) {
- case *ast.Ident:
- log.Fatalf("unexpected Ident: %s", astString(tr.fset, x))
-
- case *ast.BasicLit:
- y := y.(*ast.BasicLit)
- xval := exact.MakeFromLiteral(x.Value, x.Kind)
- yval := exact.MakeFromLiteral(y.Value, y.Kind)
- return exact.Compare(xval, token.EQL, yval)
-
- case *ast.FuncLit:
- // func literals (and thus statement syntax) never match.
- return false
-
- case *ast.CompositeLit:
- y := y.(*ast.CompositeLit)
- return (x.Type == nil) == (y.Type == nil) &&
- (x.Type == nil || tr.matchType(x.Type, y.Type)) &&
- tr.matchExprs(x.Elts, y.Elts)
-
- case *ast.SelectorExpr:
- y := y.(*ast.SelectorExpr)
- return tr.matchExpr(x.X, y.X) &&
- tr.info.Selections[x].Obj() == tr.info.Selections[y].Obj()
-
- case *ast.IndexExpr:
- y := y.(*ast.IndexExpr)
- return tr.matchExpr(x.X, y.X) &&
- tr.matchExpr(x.Index, y.Index)
-
- case *ast.SliceExpr:
- y := y.(*ast.SliceExpr)
- return tr.matchExpr(x.X, y.X) &&
- tr.matchExpr(x.Low, y.Low) &&
- tr.matchExpr(x.High, y.High) &&
- tr.matchExpr(x.Max, y.Max) &&
- x.Slice3 == y.Slice3
-
- case *ast.TypeAssertExpr:
- y := y.(*ast.TypeAssertExpr)
- return tr.matchExpr(x.X, y.X) &&
- tr.matchType(x.Type, y.Type)
-
- case *ast.CallExpr:
- y := y.(*ast.CallExpr)
- match := tr.matchExpr // function call
- if tr.info.IsType(x.Fun) {
- match = tr.matchType // type conversion
- }
- return x.Ellipsis.IsValid() == y.Ellipsis.IsValid() &&
- match(x.Fun, y.Fun) &&
- tr.matchExprs(x.Args, y.Args)
-
- case *ast.StarExpr:
- y := y.(*ast.StarExpr)
- return tr.matchExpr(x.X, y.X)
-
- case *ast.UnaryExpr:
- y := y.(*ast.UnaryExpr)
- return x.Op == y.Op &&
- tr.matchExpr(x.X, y.X)
-
- case *ast.BinaryExpr:
- y := y.(*ast.BinaryExpr)
- return x.Op == y.Op &&
- tr.matchExpr(x.X, y.X) &&
- tr.matchExpr(x.Y, y.Y)
-
- case *ast.KeyValueExpr:
- y := y.(*ast.KeyValueExpr)
- return tr.matchExpr(x.Key, y.Key) &&
- tr.matchExpr(x.Value, y.Value)
- }
-
- panic(fmt.Sprintf("unhandled AST node type: %T", x))
-}
-
-func (tr *Transformer) matchExprs(xx, yy []ast.Expr) bool {
- if len(xx) != len(yy) {
- return false
- }
- for i := range xx {
- if !tr.matchExpr(xx[i], yy[i]) {
- return false
- }
- }
- return true
-}
-
-// matchType reports whether the two type ASTs denote identical types.
-func (tr *Transformer) matchType(x, y ast.Expr) bool {
- tx := tr.info.Types[x].Type
- ty := tr.info.Types[y].Type
- return types.Identical(tx, ty)
-}
-
-func (tr *Transformer) matchWildcard(xobj *types.Var, y ast.Expr) bool {
- name := xobj.Name()
-
- if tr.verbose {
- fmt.Fprintf(os.Stderr, "%s: wildcard %s -> %s?: ",
- tr.fset.Position(y.Pos()), name, astString(tr.fset, y))
- }
-
- // Check that y is assignable to the declared type of the param.
- if yt := tr.info.TypeOf(y); !types.AssignableTo(yt, xobj.Type()) {
- if tr.verbose {
- fmt.Fprintf(os.Stderr, "%s not assignable to %s\n", yt, xobj.Type())
- }
- return false
- }
-
- // A wildcard matches any expression.
- // If it appears multiple times in the pattern, it must match
- // the same expression each time.
- if old, ok := tr.env[name]; ok {
- // found existing binding
- tr.allowWildcards = false
- r := tr.matchExpr(old, y)
- if tr.verbose {
- fmt.Fprintf(os.Stderr, "%t secondary match, primary was %s\n",
- r, astString(tr.fset, old))
- }
- tr.allowWildcards = true
- return r
- }
-
- if tr.verbose {
- fmt.Fprintf(os.Stderr, "primary match\n")
- }
-
- tr.env[name] = y // record binding
- return true
-}
-
-// -- utilities --------------------------------------------------------
-
-// unparen returns e with any enclosing parentheses stripped.
-// TODO(adonovan): move to astutil package.
-func unparen(e ast.Expr) ast.Expr {
- for {
- p, ok := e.(*ast.ParenExpr)
- if !ok {
- break
- }
- e = p.X
- }
- return e
-}
-
-// isRef returns the object referred to by this (possibly qualified)
-// identifier, or nil if the node is not a referring identifier.
-func isRef(n ast.Node, info *loader.PackageInfo) types.Object {
- switch n := n.(type) {
- case *ast.Ident:
- return info.Uses[n]
-
- case *ast.SelectorExpr:
- sel := info.Selections[n]
- if sel.Kind() == types.PackageObj {
- return sel.Obj()
- }
- }
- return nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/rewrite.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/rewrite.go
deleted file mode 100644
index 84a8b291..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/rewrite.go
+++ /dev/null
@@ -1,340 +0,0 @@
-package eg
-
-// This file defines the AST rewriting pass.
-// Most of it was plundered directly from
-// $GOROOT/src/cmd/gofmt/rewrite.go (after convergent evolution).
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- "os"
- "reflect"
- "sort"
- "strconv"
- "strings"
-
- "code.google.com/p/go.tools/astutil"
- "code.google.com/p/go.tools/go/types"
-)
-
-// Transform applies the transformation to the specified parsed file,
-// whose type information is supplied in info, and returns the number
-// of replacements that were made.
-//
-// It mutates the AST in place (the identity of the root node is
-// unchanged), and may add nodes for which no type information is
-// available in info.
-//
-// Derived from rewriteFile in $GOROOT/src/cmd/gofmt/rewrite.go.
-//
-func (tr *Transformer) Transform(info *types.Info, pkg *types.Package, file *ast.File) int {
- if !tr.seenInfos[info] {
- tr.seenInfos[info] = true
- mergeTypeInfo(&tr.info.Info, info)
- }
- tr.currentPkg = pkg
- tr.nsubsts = 0
-
- if tr.verbose {
- fmt.Fprintf(os.Stderr, "before: %s\n", astString(tr.fset, tr.before))
- fmt.Fprintf(os.Stderr, "after: %s\n", astString(tr.fset, tr.after))
- }
-
- var f func(rv reflect.Value) reflect.Value
- f = func(rv reflect.Value) reflect.Value {
- // don't bother if val is invalid to start with
- if !rv.IsValid() {
- return reflect.Value{}
- }
-
- rv = apply(f, rv)
-
- e := rvToExpr(rv)
- if e != nil {
- savedEnv := tr.env
- tr.env = make(map[string]ast.Expr) // inefficient! Use a slice of k/v pairs
-
- if tr.matchExpr(tr.before, e) {
- if tr.verbose {
- fmt.Fprintf(os.Stderr, "%s matches %s",
- astString(tr.fset, tr.before), astString(tr.fset, e))
- if len(tr.env) > 0 {
- fmt.Fprintf(os.Stderr, " with:")
- for name, ast := range tr.env {
- fmt.Fprintf(os.Stderr, " %s->%s",
- name, astString(tr.fset, ast))
- }
- }
- fmt.Fprintf(os.Stderr, "\n")
- }
- tr.nsubsts++
-
- // Clone the replacement tree, performing parameter substitution.
- // We update all positions to n.Pos() to aid comment placement.
- rv = tr.subst(tr.env, reflect.ValueOf(tr.after),
- reflect.ValueOf(e.Pos()))
- }
- tr.env = savedEnv
- }
-
- return rv
- }
- file2 := apply(f, reflect.ValueOf(file)).Interface().(*ast.File)
-
- // By construction, the root node is unchanged.
- if file != file2 {
- panic("BUG")
- }
-
- // Add any necessary imports.
- // TODO(adonovan): remove no-longer needed imports too.
- if tr.nsubsts > 0 {
- pkgs := make(map[string]*types.Package)
- for obj := range tr.importedObjs {
- pkgs[obj.Pkg().Path()] = obj.Pkg()
- }
-
- for _, imp := range file.Imports {
- path, _ := strconv.Unquote(imp.Path.Value)
- delete(pkgs, path)
- }
- delete(pkgs, pkg.Path()) // don't import self
-
- // NB: AddImport may completely replace the AST!
- // It thus renders info and tr.info no longer relevant to file.
- var paths []string
- for path := range pkgs {
- paths = append(paths, path)
- }
- sort.Strings(paths)
- for _, path := range paths {
- astutil.AddImport(tr.fset, file, path)
- }
- }
-
- tr.currentPkg = nil
-
- return tr.nsubsts
-}
-
-// setValue is a wrapper for x.SetValue(y); it protects
-// the caller from panics if x cannot be changed to y.
-func setValue(x, y reflect.Value) {
- // don't bother if y is invalid to start with
- if !y.IsValid() {
- return
- }
- defer func() {
- if x := recover(); x != nil {
- if s, ok := x.(string); ok &&
- (strings.Contains(s, "type mismatch") || strings.Contains(s, "not assignable")) {
- // x cannot be set to y - ignore this rewrite
- return
- }
- panic(x)
- }
- }()
- x.Set(y)
-}
-
-// Values/types for special cases.
-var (
- objectPtrNil = reflect.ValueOf((*ast.Object)(nil))
- scopePtrNil = reflect.ValueOf((*ast.Scope)(nil))
-
- identType = reflect.TypeOf((*ast.Ident)(nil))
- selectorExprType = reflect.TypeOf((*ast.SelectorExpr)(nil))
- objectPtrType = reflect.TypeOf((*ast.Object)(nil))
- positionType = reflect.TypeOf(token.NoPos)
- callExprType = reflect.TypeOf((*ast.CallExpr)(nil))
- scopePtrType = reflect.TypeOf((*ast.Scope)(nil))
-)
-
-// apply replaces each AST field x in val with f(x), returning val.
-// To avoid extra conversions, f operates on the reflect.Value form.
-func apply(f func(reflect.Value) reflect.Value, val reflect.Value) reflect.Value {
- if !val.IsValid() {
- return reflect.Value{}
- }
-
- // *ast.Objects introduce cycles and are likely incorrect after
- // rewrite; don't follow them but replace with nil instead
- if val.Type() == objectPtrType {
- return objectPtrNil
- }
-
- // similarly for scopes: they are likely incorrect after a rewrite;
- // replace them with nil
- if val.Type() == scopePtrType {
- return scopePtrNil
- }
-
- switch v := reflect.Indirect(val); v.Kind() {
- case reflect.Slice:
- for i := 0; i < v.Len(); i++ {
- e := v.Index(i)
- setValue(e, f(e))
- }
- case reflect.Struct:
- for i := 0; i < v.NumField(); i++ {
- e := v.Field(i)
- setValue(e, f(e))
- }
- case reflect.Interface:
- e := v.Elem()
- setValue(v, f(e))
- }
- return val
-}
-
-// subst returns a copy of (replacement) pattern with values from env
-// substituted in place of wildcards and pos used as the position of
-// tokens from the pattern. if env == nil, subst returns a copy of
-// pattern and doesn't change the line number information.
-func (tr *Transformer) subst(env map[string]ast.Expr, pattern, pos reflect.Value) reflect.Value {
- if !pattern.IsValid() {
- return reflect.Value{}
- }
-
- // *ast.Objects introduce cycles and are likely incorrect after
- // rewrite; don't follow them but replace with nil instead
- if pattern.Type() == objectPtrType {
- return objectPtrNil
- }
-
- // similarly for scopes: they are likely incorrect after a rewrite;
- // replace them with nil
- if pattern.Type() == scopePtrType {
- return scopePtrNil
- }
-
- // Wildcard gets replaced with map value.
- if env != nil && pattern.Type() == identType {
- id := pattern.Interface().(*ast.Ident)
- if old, ok := env[id.Name]; ok {
- return tr.subst(nil, reflect.ValueOf(old), reflect.Value{})
- }
- }
-
- // Emit qualified identifiers in the pattern by appropriate
- // (possibly qualified) identifier in the input.
- //
- // The template cannot contain dot imports, so all identifiers
- // for imported objects are explicitly qualified.
- //
- // We assume (unsoundly) that there are no dot or named
- // imports in the input code, nor are any imported package
- // names shadowed, so the usual normal qualified identifier
- // syntax may be used.
- // TODO(adonovan): fix: avoid this assumption.
- //
- // A refactoring may be applied to a package referenced by the
- // template. Objects belonging to the current package are
- // denoted by unqualified identifiers.
- //
- if tr.importedObjs != nil && pattern.Type() == selectorExprType {
- obj := isRef(pattern.Interface().(*ast.SelectorExpr), &tr.info)
- if obj != nil {
- if sel, ok := tr.importedObjs[obj]; ok {
- var id ast.Expr
- if obj.Pkg() == tr.currentPkg {
- id = sel.Sel // unqualified
- } else {
- id = sel // pkg-qualified
- }
-
- // Return a clone of id.
- saved := tr.importedObjs
- tr.importedObjs = nil // break cycle
- r := tr.subst(nil, reflect.ValueOf(id), pos)
- tr.importedObjs = saved
- return r
- }
- }
- }
-
- if pos.IsValid() && pattern.Type() == positionType {
- // use new position only if old position was valid in the first place
- if old := pattern.Interface().(token.Pos); !old.IsValid() {
- return pattern
- }
- return pos
- }
-
- // Otherwise copy.
- switch p := pattern; p.Kind() {
- case reflect.Slice:
- v := reflect.MakeSlice(p.Type(), p.Len(), p.Len())
- for i := 0; i < p.Len(); i++ {
- v.Index(i).Set(tr.subst(env, p.Index(i), pos))
- }
- return v
-
- case reflect.Struct:
- v := reflect.New(p.Type()).Elem()
- for i := 0; i < p.NumField(); i++ {
- v.Field(i).Set(tr.subst(env, p.Field(i), pos))
- }
- return v
-
- case reflect.Ptr:
- v := reflect.New(p.Type()).Elem()
- if elem := p.Elem(); elem.IsValid() {
- v.Set(tr.subst(env, elem, pos).Addr())
- }
-
- // Duplicate type information for duplicated ast.Expr.
- // All ast.Node implementations are *structs,
- // so this case catches them all.
- if e := rvToExpr(v); e != nil {
- updateTypeInfo(&tr.info.Info, e, p.Interface().(ast.Expr))
- }
- return v
-
- case reflect.Interface:
- v := reflect.New(p.Type()).Elem()
- if elem := p.Elem(); elem.IsValid() {
- v.Set(tr.subst(env, elem, pos))
- }
- return v
- }
-
- return pattern
-}
-
-// -- utilitiies -------------------------------------------------------
-
-func rvToExpr(rv reflect.Value) ast.Expr {
- if rv.CanInterface() {
- if e, ok := rv.Interface().(ast.Expr); ok {
- return e
- }
- }
- return nil
-}
-
-// updateTypeInfo duplicates type information for the existing AST old
-// so that it also applies to duplicated AST new.
-func updateTypeInfo(info *types.Info, new, old ast.Expr) {
- switch new := new.(type) {
- case *ast.Ident:
- orig := old.(*ast.Ident)
- if obj, ok := info.Defs[orig]; ok {
- info.Defs[new] = obj
- }
- if obj, ok := info.Uses[orig]; ok {
- info.Uses[new] = obj
- }
-
- case *ast.SelectorExpr:
- orig := old.(*ast.SelectorExpr)
- if sel, ok := info.Selections[orig]; ok {
- info.Selections[new] = sel
- }
- }
-
- if tv, ok := info.Types[old]; ok {
- info.Types[new] = tv
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A.template
deleted file mode 100644
index f6119618..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A.template
+++ /dev/null
@@ -1,13 +0,0 @@
-// +build ignore
-
-package template
-
-// Basic test of type-aware expression refactoring.
-
-import (
- "errors"
- "fmt"
-)
-
-func before(s string) error { return fmt.Errorf("%s", s) }
-func after(s string) error { return errors.New(s) }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A1.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A1.go
deleted file mode 100644
index 9e65eb36..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A1.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// +build ignore
-
-package A1
-
-import (
- . "fmt"
- myfmt "fmt"
- "os"
- "strings"
-)
-
-func example(n int) {
- x := "foo" + strings.Repeat("\t", n)
- // Match, despite named import.
- myfmt.Errorf("%s", x)
-
- // Match, despite dot import.
- Errorf("%s", x)
-
- // Match: multiple matches in same function are possible.
- myfmt.Errorf("%s", x)
-
- // No match: wildcarded operand has the wrong type.
- myfmt.Errorf("%s", 3)
-
- // No match: function operand doesn't match.
- myfmt.Printf("%s", x)
-
- // No match again, dot import.
- Printf("%s", x)
-
- // Match.
- myfmt.Fprint(os.Stderr, myfmt.Errorf("%s", x+"foo"))
-
- // No match: though this literally matches the template,
- // fmt doesn't resolve to a package here.
- var fmt struct{ Errorf func(string, string) }
- fmt.Errorf("%s", x)
-
- // Recursive matching:
-
- // Match: both matches are well-typed, so both succeed.
- myfmt.Errorf("%s", myfmt.Errorf("%s", x+"foo").Error())
-
- // Outer match succeeds, inner doesn't: 3 has wrong type.
- myfmt.Errorf("%s", myfmt.Errorf("%s", 3).Error())
-
- // Inner match succeeds, outer doesn't: the inner replacement
- // has the wrong type (error not string).
- myfmt.Errorf("%s", myfmt.Errorf("%s", x+"foo"))
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A1.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A1.golden
deleted file mode 100644
index 4f7ba828..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A1.golden
+++ /dev/null
@@ -1,52 +0,0 @@
-// +build ignore
-
-package A1
-
-import (
- . "fmt"
- "errors"
- myfmt "fmt"
- "os"
- "strings"
-)
-
-func example(n int) {
- x := "foo" + strings.Repeat("\t", n)
- // Match, despite named import.
- errors.New(x)
-
- // Match, despite dot import.
- errors.New(x)
-
- // Match: multiple matches in same function are possible.
- errors.New(x)
-
- // No match: wildcarded operand has the wrong type.
- myfmt.Errorf("%s", 3)
-
- // No match: function operand doesn't match.
- myfmt.Printf("%s", x)
-
- // No match again, dot import.
- Printf("%s", x)
-
- // Match.
- myfmt.Fprint(os.Stderr, errors.New(x+"foo"))
-
- // No match: though this literally matches the template,
- // fmt doesn't resolve to a package here.
- var fmt struct{ Errorf func(string, string) }
- fmt.Errorf("%s", x)
-
- // Recursive matching:
-
- // Match: both matches are well-typed, so both succeed.
- errors.New(errors.New(x + "foo").Error())
-
- // Outer match succeeds, inner doesn't: 3 has wrong type.
- errors.New(myfmt.Errorf("%s", 3).Error())
-
- // Inner match succeeds, outer doesn't: the inner replacement
- // has the wrong type (error not string).
- myfmt.Errorf("%s", errors.New(x+"foo"))
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A2.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A2.go
deleted file mode 100644
index 3ae29ad7..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A2.go
+++ /dev/null
@@ -1,12 +0,0 @@
-// +build ignore
-
-package A2
-
-// This refactoring causes addition of "errors" import.
-// TODO(adonovan): fix: it should also remove "fmt".
-
-import myfmt "fmt"
-
-func example(n int) {
- myfmt.Errorf("%s", "")
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A2.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A2.golden
deleted file mode 100644
index 5c2384b7..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/A2.golden
+++ /dev/null
@@ -1,15 +0,0 @@
-// +build ignore
-
-package A2
-
-// This refactoring causes addition of "errors" import.
-// TODO(adonovan): fix: it should also remove "fmt".
-
-import (
- myfmt "fmt"
- "errors"
-)
-
-func example(n int) {
- errors.New("")
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B.template
deleted file mode 100644
index c16627bd..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B.template
+++ /dev/null
@@ -1,9 +0,0 @@
-package template
-
-// Basic test of expression refactoring.
-// (Types are not important in this case; it could be done with gofmt -r.)
-
-import "time"
-
-func before(t time.Time) time.Duration { return time.Now().Sub(t) }
-func after(t time.Time) time.Duration { return time.Since(t) }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B1.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B1.go
deleted file mode 100644
index 8b525463..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B1.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// +build ignore
-
-package B1
-
-import "time"
-
-var startup = time.Now()
-
-func example() time.Duration {
- before := time.Now()
- time.Sleep(1)
- return time.Now().Sub(before)
-}
-
-func msSinceStartup() int64 {
- return int64(time.Now().Sub(startup) / time.Millisecond)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B1.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B1.golden
deleted file mode 100644
index 4d4da218..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/B1.golden
+++ /dev/null
@@ -1,17 +0,0 @@
-// +build ignore
-
-package B1
-
-import "time"
-
-var startup = time.Now()
-
-func example() time.Duration {
- before := time.Now()
- time.Sleep(1)
- return time.Since(before)
-}
-
-func msSinceStartup() int64 {
- return int64(time.Since(startup) / time.Millisecond)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C.template
deleted file mode 100644
index f6f94d4a..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C.template
+++ /dev/null
@@ -1,10 +0,0 @@
-package template
-
-// Test of repeated use of wildcard in pattern.
-
-// NB: multiple patterns would be required to handle variants such as
-// s[:len(s)], s[x:len(s)], etc, since a wildcard can't match nothing at all.
-// TODO(adonovan): support multiple templates in a single pass.
-
-func before(s string) string { return s[:len(s)] }
-func after(s string) string { return s }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C1.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C1.go
deleted file mode 100644
index 523b3885..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C1.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// +build ignore
-
-package C1
-
-import "strings"
-
-func example() {
- x := "foo"
- println(x[:len(x)])
-
- // Match, but the transformation is not sound w.r.t. possible side effects.
- println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 3))])
-
- // No match, since second use of wildcard doesn't match first.
- println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 2))])
-
- // Recursive match demonstrating bottom-up rewrite:
- // only after the inner replacement occurs does the outer syntax match.
- println((x[:len(x)])[:len(x[:len(x)])])
- // -> (x[:len(x)])
- // -> x
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C1.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C1.golden
deleted file mode 100644
index ae7759d7..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/C1.golden
+++ /dev/null
@@ -1,22 +0,0 @@
-// +build ignore
-
-package C1
-
-import "strings"
-
-func example() {
- x := "foo"
- println(x)
-
- // Match, but the transformation is not sound w.r.t. possible side effects.
- println(strings.Repeat("*", 3))
-
- // No match, since second use of wildcard doesn't match first.
- println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 2))])
-
- // Recursive match demonstrating bottom-up rewrite:
- // only after the inner replacement occurs does the outer syntax match.
- println(x)
- // -> (x[:len(x)])
- // -> x
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D.template
deleted file mode 100644
index 6d3b6feb..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D.template
+++ /dev/null
@@ -1,8 +0,0 @@
-package template
-
-import "fmt"
-
-// Test of semantic (not syntactic) matching of basic literals.
-
-func before() (int, error) { return fmt.Println(123, "a") }
-func after() (int, error) { return fmt.Println(456, "!") }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D1.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D1.go
deleted file mode 100644
index ae0a8060..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D1.go
+++ /dev/null
@@ -1,12 +0,0 @@
-// +build ignore
-
-package D1
-
-import "fmt"
-
-func example() {
- fmt.Println(123, "a") // match
- fmt.Println(0x7b, `a`) // match
- fmt.Println(0173, "\x61") // match
- fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D1.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D1.golden
deleted file mode 100644
index 3f2dc593..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/D1.golden
+++ /dev/null
@@ -1,12 +0,0 @@
-// +build ignore
-
-package D1
-
-import "fmt"
-
-func example() {
- fmt.Println(456, "!") // match
- fmt.Println(456, "!") // match
- fmt.Println(456, "!") // match
- fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E.template
deleted file mode 100644
index 4bbbd113..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E.template
+++ /dev/null
@@ -1,12 +0,0 @@
-package template
-
-import (
- "fmt"
- "log"
- "os"
-)
-
-// Replace call to void function by call to non-void function.
-
-func before(x interface{}) { log.Fatal(x) }
-func after(x interface{}) { fmt.Fprintf(os.Stderr, "warning: %v", x) }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E1.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E1.go
deleted file mode 100644
index 3ea1793f..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E1.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// +build ignore
-
-package E1
-
-import "log"
-
-func example() {
- log.Fatal("oops") // match
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E1.golden b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E1.golden
deleted file mode 100644
index a0adfc8b..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/E1.golden
+++ /dev/null
@@ -1,13 +0,0 @@
-// +build ignore
-
-package E1
-
-import (
- "log"
- "os"
- "fmt"
-)
-
-func example() {
- fmt.Fprintf(os.Stderr, "warning: %v", "oops") // match
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/bad_type.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/bad_type.template
deleted file mode 100644
index 6d53d7e5..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/bad_type.template
+++ /dev/null
@@ -1,8 +0,0 @@
-package template
-
-// Test in which replacement has a different type.
-
-const shouldFail = "int is not a safe replacement for string"
-
-func before() interface{} { return "three" }
-func after() interface{} { return 3 }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/expr_type_mismatch.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/expr_type_mismatch.template
deleted file mode 100644
index 2c5c3f0d..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/expr_type_mismatch.template
+++ /dev/null
@@ -1,15 +0,0 @@
-package template
-
-import (
- "crypto/x509"
- "fmt"
-)
-
-// This test demonstrates a false negative: according to the language
-// rules this replacement should be ok, but types.Assignable doesn't work
-// in the expected way (elementwise assignability) for tuples.
-// Perhaps that's even a type-checker bug?
-const shouldFail = "(n int, err error) is not a safe replacement for (key interface{}, err error)"
-
-func before() (interface{}, error) { return x509.ParsePKCS8PrivateKey(nil) }
-func after() (interface{}, error) { return fmt.Print() }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/no_after_return.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/no_after_return.template
deleted file mode 100644
index 536b01e6..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/no_after_return.template
+++ /dev/null
@@ -1,6 +0,0 @@
-package template
-
-const shouldFail = "after: must contain a single statement"
-
-func before() int { return 0 }
-func after() int { println(); return 0 }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/no_before.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/no_before.template
deleted file mode 100644
index 9205e667..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/no_before.template
+++ /dev/null
@@ -1,5 +0,0 @@
-package template
-
-const shouldFail = "no 'before' func found in template"
-
-func Before() {}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/type_mismatch.template b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/type_mismatch.template
deleted file mode 100644
index 787c9a7a..00000000
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/go.tools/refactor/eg/testdata/type_mismatch.template
+++ /dev/null
@@ -1,6 +0,0 @@
-package template
-
-const shouldFail = "different signatures"
-
-func before() int { return 0 }
-func after() string { return "" }
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/analyse.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/analyse.go
index 555d521a..cdcb21fc 100644
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/analyse.go
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/analyse.go
@@ -19,7 +19,7 @@ import (
)
//Creates a Graph structure by analysing an Abstract Syntax Tree representing a parsed graph.
-func NewAnalysedGraph(graph *ast.Graph) *Graph {
+func NewAnalysedGraph(graph *ast.Graph) Interface {
g := NewGraph()
Analyse(graph, g)
return g
@@ -129,7 +129,7 @@ func (this *stmtVisitor) edgeStmt(stmt ast.EdgeStmt) ast.Visitor {
this.g.AddNode(this.graphName, dstName, this.currentNodeAttrs.Copy())
}
dstPort := stmt.EdgeRHS[i].Destination.GetPort()
- this.g.AddEdge(srcName, srcPort.String(), dstName, dstPort.String(), directed, attrs)
+ this.g.AddPortEdge(srcName, srcPort.String(), dstName, dstPort.String(), directed, attrs)
src = dst
srcPort = dstPort
srcName = dstName
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/analysewrite_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/analysewrite_test.go
index 01d80e05..c99d6025 100644
--- a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/analysewrite_test.go
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/analysewrite_test.go
@@ -50,19 +50,21 @@ func assert(t *testing.T, msg string, v1 interface{}, v2 interface{}) {
}
}
-func anal(t *testing.T, input string) *Graph {
+func anal(t *testing.T, input string) Interface {
fmt.Printf("Input: %v\n", input)
g, err := parser.ParseString(input)
check(t, err)
fmt.Printf("Parsed: %v\n", g)
- ag := NewAnalysedGraph(g)
+ ag := NewGraph()
+ Analyse(g, ag)
fmt.Printf("Analysed: %v\n", ag)
agstr := ag.String()
fmt.Printf("Written: %v\n", agstr)
g2, err := parser.ParseString(agstr)
check(t, err)
fmt.Printf("Parsed %v\n", g2)
- ag2 := NewAnalysedGraph(g2)
+ ag2 := NewEscape()
+ Analyse(g2, ag2)
fmt.Printf("Analysed %v\n", ag2)
ag2str := ag2.String()
fmt.Printf("Written: %v\n", ag2str)
@@ -70,7 +72,7 @@ func anal(t *testing.T, input string) *Graph {
return ag2
}
-func analfile(t *testing.T, filename string) *Graph {
+func analfile(t *testing.T, filename string) Interface {
f, err := os.Open(filename)
check(t, err)
all, err := ioutil.ReadAll(f)
@@ -78,7 +80,7 @@ func analfile(t *testing.T, filename string) *Graph {
return anal(t, string(all))
}
-func analtest(t *testing.T, testname string) *Graph {
+func analtest(t *testing.T, testname string) Interface {
return analfile(t, "./testdata/"+testname)
}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/escape.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/escape.go
new file mode 100644
index 00000000..8ce6ee3c
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/escape.go
@@ -0,0 +1,177 @@
+//Copyright 2013 Vastech SA (PTY) LTD
+//
+//Licensed under the Apache License, Version 2.0 (the "License");
+//you may not use this file except in compliance with the License.
+//You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing, software
+//distributed under the License is distributed on an "AS IS" BASIS,
+//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//See the License for the specific language governing permissions and
+//limitations under the License.
+
+package gographviz
+
+import (
+ "code.google.com/p/gographviz/scanner"
+ "code.google.com/p/gographviz/token"
+ "fmt"
+ "strings"
+ "text/template"
+ "unicode"
+)
+
+type Escape struct {
+ Interface
+}
+
+//Returns a graph which will try to escape some strings when required
+func NewEscape() Interface {
+ return &Escape{NewGraph()}
+}
+
+func isHtml(s string) bool {
+ if len(s) == 0 {
+ return false
+ }
+ ss := strings.TrimSpace(s)
+ if ss[0] != '<' {
+ return false
+ }
+ count := 0
+ for _, c := range ss {
+ if c == '<' {
+ count += 1
+ }
+ if c == '>' {
+ count -= 1
+ }
+ }
+ if count == 0 {
+ return true
+ }
+ return false
+}
+
+func isLetter(ch rune) bool {
+ return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' ||
+ ch >= 0x80 && unicode.IsLetter(ch) && ch != 'ε'
+}
+
+func isId(s string) bool {
+ i := 0
+ pos := false
+ for _, c := range s {
+ if i == 0 {
+ if !isLetter(c) {
+ return false
+ }
+ pos = true
+ }
+ if unicode.IsSpace(c) {
+ return false
+ }
+ if c == '-' {
+ return false
+ }
+ i++
+ }
+ return pos
+}
+
+func isDigit(ch rune) bool {
+ return '0' <= ch && ch <= '9' || ch >= 0x80 && unicode.IsDigit(ch)
+}
+
+func isNumber(s string) bool {
+ state := 0
+ for _, c := range s {
+ if state == 0 {
+ if isDigit(c) || c == '.' {
+ state = 2
+ } else if c == '-' {
+ state = 1
+ } else {
+ return false
+ }
+ } else if state == 1 {
+ if isDigit(c) || c == '.' {
+ state = 2
+ }
+ } else if c != '.' && !isDigit(c) {
+ return false
+ }
+ }
+ return (state == 2)
+}
+
+func isStringLit(s string) bool {
+ lex := &scanner.Scanner{}
+ lex.Init([]byte(s), token.DOTTokens)
+ tok, _ := lex.Scan()
+ if tok.Type != token.DOTTokens.Type("string_lit") {
+ return false
+ }
+ tok, _ = lex.Scan()
+ if tok.Type != token.EOF {
+ return false
+ }
+ return true
+}
+
+func esc(s string) string {
+ if len(s) == 0 {
+ return s
+ }
+ if isHtml(s) {
+ return s
+ }
+ ss := strings.TrimSpace(s)
+ if ss[0] == '<' {
+ return fmt.Sprintf("\"%s\"", strings.Replace(s, "\"", "\\\"", -1))
+ }
+ if isId(s) {
+ return s
+ }
+ if isNumber(s) {
+ return s
+ }
+ if isStringLit(s) {
+ return s
+ }
+ return fmt.Sprintf("\"%s\"", template.HTMLEscapeString(s))
+}
+
+func escAttrs(attrs map[string]string) map[string]string {
+ newAttrs := make(map[string]string)
+ for k, v := range attrs {
+ newAttrs[esc(k)] = esc(v)
+ }
+ return newAttrs
+}
+
+func (this *Escape) SetName(name string) {
+ this.Interface.SetName(esc(name))
+}
+
+func (this *Escape) AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string) {
+ this.Interface.AddPortEdge(esc(src), srcPort, esc(dst), dstPort, directed, escAttrs(attrs))
+}
+
+func (this *Escape) AddEdge(src, dst string, directed bool, attrs map[string]string) {
+ this.AddPortEdge(src, "", dst, "", directed, attrs)
+}
+
+func (this *Escape) AddNode(parentGraph string, name string, attrs map[string]string) {
+ this.Interface.AddNode(esc(parentGraph), esc(name), escAttrs(attrs))
+}
+
+func (this *Escape) AddAttr(parentGraph string, field, value string) {
+ this.Interface.AddAttr(esc(parentGraph), esc(field), esc(value))
+}
+
+func (this *Escape) AddSubGraph(parentGraph string, name string, attrs map[string]string) {
+ this.Interface.AddSubGraph(esc(parentGraph), esc(name), escAttrs(attrs))
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/escape_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/escape_test.go
new file mode 100644
index 00000000..f815f491
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/gographviz/escape_test.go
@@ -0,0 +1,44 @@
+//Copyright 2013 Vastech SA (PTY) LTD
+//
+//Licensed under the Apache License, Version 2.0 (the "License");
+//you may not use this file except in compliance with the License.
+//You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing, software
+//distributed under the License is distributed on an "AS IS" BASIS,
+//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//See the License for the specific language governing permissions and
+//limitations under the License.
+
+package gographviz
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestEscape(t *testing.T) {
+ g := NewEscape()
+ g.SetName("asdf adsf")
+ g.SetDir(true)
+ g.AddNode("asdf asdf", "kasdf99 99", map[string]string{
+ "7;
+ "a << b";
+ "kasdf99 99" [ " 0 {
+ m.reset(now)
+ }
+ m.active = false
+ m.tLast = 0
+ n := m.bytes
+ m.mu.Unlock()
+ return n
+}
+
+// timeRemLimit is the maximum Status.TimeRem value.
+const timeRemLimit = 999*time.Hour + 59*time.Minute + 59*time.Second
+
+// Status represents the current Monitor status. All transfer rates are in bytes
+// per second rounded to the nearest byte.
+type Status struct {
+ Active bool // Flag indicating an active transfer
+ Start time.Time // Transfer start time
+ Duration time.Duration // Time period covered by the statistics
+ Idle time.Duration // Time since the last transfer of at least 1 byte
+ Bytes int64 // Total number of bytes transferred
+ Samples int64 // Total number of samples taken
+ InstRate int64 // Instantaneous transfer rate
+ CurRate int64 // Current transfer rate (EMA of InstRate)
+ AvgRate int64 // Average transfer rate (Bytes / Duration)
+ PeakRate int64 // Maximum instantaneous transfer rate
+ BytesRem int64 // Number of bytes remaining in the transfer
+ TimeRem time.Duration // Estimated time to completion
+ Progress Percent // Overall transfer progress
+}
+
+// Status returns current transfer status information. The returned value
+// becomes static after a call to Done.
+func (m *Monitor) Status() Status {
+ m.mu.Lock()
+ now := m.update(0)
+ s := Status{
+ Active: m.active,
+ Start: clockToTime(m.start),
+ Duration: m.sLast - m.start,
+ Idle: now - m.tLast,
+ Bytes: m.bytes,
+ Samples: m.samples,
+ PeakRate: round(m.rPeak),
+ BytesRem: m.tBytes - m.bytes,
+ Progress: percentOf(float64(m.bytes), float64(m.tBytes)),
+ }
+ if s.BytesRem < 0 {
+ s.BytesRem = 0
+ }
+ if s.Duration > 0 {
+ rAvg := float64(s.Bytes) / s.Duration.Seconds()
+ s.AvgRate = round(rAvg)
+ if s.Active {
+ s.InstRate = round(m.rSample)
+ s.CurRate = round(m.rEMA)
+ if s.BytesRem > 0 {
+ if tRate := 0.8*m.rEMA + 0.2*rAvg; tRate > 0 {
+ ns := float64(s.BytesRem) / tRate * 1e9
+ if ns > float64(timeRemLimit) {
+ ns = float64(timeRemLimit)
+ }
+ s.TimeRem = clockRound(time.Duration(ns))
+ }
+ }
+ }
+ }
+ m.mu.Unlock()
+ return s
+}
+
+// Limit restricts the instantaneous (per-sample) data flow to rate bytes per
+// second. It returns the maximum number of bytes (0 <= n <= want) that may be
+// transferred immediately without exceeding the limit. If block == true, the
+// call blocks until n > 0. want is returned unmodified if want < 1, rate < 1,
+// or the transfer is inactive (after a call to Done).
+//
+// At least one byte is always allowed to be transferred in any given sampling
+// period. Thus, if the sampling rate is 100ms, the lowest achievable flow rate
+// is 10 bytes per second.
+//
+// For usage examples, see the implementation of Reader and Writer in io.go.
+func (m *Monitor) Limit(want int, rate int64, block bool) (n int) {
+ if want < 1 || rate < 1 {
+ return want
+ }
+ m.mu.Lock()
+
+ // Determine the maximum number of bytes that can be sent in one sample
+ limit := round(float64(rate) * m.sRate.Seconds())
+ if limit <= 0 {
+ limit = 1
+ }
+
+ // If block == true, wait until m.sBytes < limit
+ if now := m.update(0); block {
+ for m.sBytes >= limit && m.active {
+ now = m.waitNextSample(now)
+ }
+ }
+
+ // Make limit <= want (unlimited if the transfer is no longer active)
+ if limit -= m.sBytes; limit > int64(want) || !m.active {
+ limit = int64(want)
+ }
+ m.mu.Unlock()
+
+ if limit < 0 {
+ limit = 0
+ }
+ return int(limit)
+}
+
+// SetTransferSize specifies the total size of the data transfer, which allows
+// the Monitor to calculate the overall progress and time to completion.
+func (m *Monitor) SetTransferSize(bytes int64) {
+ if bytes < 0 {
+ bytes = 0
+ }
+ m.mu.Lock()
+ m.tBytes = bytes
+ m.mu.Unlock()
+}
+
+// update accumulates the transferred byte count for the current sample until
+// clock() - m.sLast >= m.sRate. The monitor status is updated once the current
+// sample is done.
+func (m *Monitor) update(n int) (now time.Duration) {
+ if !m.active {
+ return
+ }
+ if now = clock(); n > 0 {
+ m.tLast = now
+ }
+ m.sBytes += int64(n)
+ if sTime := now - m.sLast; sTime >= m.sRate {
+ t := sTime.Seconds()
+ if m.rSample = float64(m.sBytes) / t; m.rSample > m.rPeak {
+ m.rPeak = m.rSample
+ }
+
+ // Exponential moving average using a method similar to *nix load
+ // average calculation. Longer sampling periods carry greater weight.
+ if m.samples > 0 {
+ w := math.Exp(-t / m.rWindow)
+ m.rEMA = m.rSample + w*(m.rEMA-m.rSample)
+ } else {
+ m.rEMA = m.rSample
+ }
+ m.reset(now)
+ }
+ return
+}
+
+// reset clears the current sample state in preparation for the next sample.
+func (m *Monitor) reset(sampleTime time.Duration) {
+ m.bytes += m.sBytes
+ m.samples++
+ m.sBytes = 0
+ m.sLast = sampleTime
+}
+
+// waitNextSample sleeps for the remainder of the current sample. The lock is
+// released and reacquired during the actual sleep period, so it's possible for
+// the transfer to be inactive when this method returns.
+func (m *Monitor) waitNextSample(now time.Duration) time.Duration {
+ const minWait = 5 * time.Millisecond
+ current := m.sLast
+
+ // sleep until the last sample time changes (ideally, just one iteration)
+ for m.sLast == current && m.active {
+ d := current + m.sRate - now
+ m.mu.Unlock()
+ if d < minWait {
+ d = minWait
+ }
+ time.Sleep(d)
+ m.mu.Lock()
+ now = m.update(0)
+ }
+ return now
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/io.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/io.go
new file mode 100644
index 00000000..12a753dd
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/io.go
@@ -0,0 +1,133 @@
+//
+// Written by Maxim Khitrov (November 2012)
+//
+
+package flowcontrol
+
+import (
+ "errors"
+ "io"
+)
+
+// ErrLimit is returned by the Writer when a non-blocking write is short due to
+// the transfer rate limit.
+var ErrLimit = errors.New("flowcontrol: transfer rate limit exceeded")
+
+// Limiter is implemented by the Reader and Writer to provide a consistent
+// interface for monitoring and controlling data transfer.
+type Limiter interface {
+ Done() int64
+ Status() Status
+ SetTransferSize(bytes int64)
+ SetLimit(new int64) (old int64)
+ SetBlocking(new bool) (old bool)
+}
+
+// Reader implements io.ReadCloser with a restriction on the rate of data
+// transfer.
+type Reader struct {
+ io.Reader // Data source
+ *Monitor // Flow control monitor
+
+ limit int64 // Rate limit in bytes per second (unlimited when <= 0)
+ block bool // What to do when no new bytes can be read due to the limit
+}
+
+// NewReader restricts all Read operations on r to limit bytes per second.
+func NewReader(r io.Reader, limit int64) *Reader {
+ return &Reader{r, New(0, 0), limit, true}
+}
+
+// Read reads up to len(p) bytes into p without exceeding the current transfer
+// rate limit. It returns (0, nil) immediately if r is non-blocking and no new
+// bytes can be read at this time.
+func (r *Reader) Read(p []byte) (n int, err error) {
+ p = p[:r.Limit(len(p), r.limit, r.block)]
+ if len(p) > 0 {
+ n, err = r.IO(r.Reader.Read(p))
+ }
+ return
+}
+
+// SetLimit changes the transfer rate limit to new bytes per second and returns
+// the previous setting.
+func (r *Reader) SetLimit(new int64) (old int64) {
+ old, r.limit = r.limit, new
+ return
+}
+
+// SetBlocking changes the blocking behavior and returns the previous setting. A
+// Read call on a non-blocking reader returns immediately if no additional bytes
+// may be read at this time due to the rate limit.
+func (r *Reader) SetBlocking(new bool) (old bool) {
+ old, r.block = r.block, new
+ return
+}
+
+// Close closes the underlying reader if it implements the io.Closer interface.
+func (r *Reader) Close() error {
+ defer r.Done()
+ if c, ok := r.Reader.(io.Closer); ok {
+ return c.Close()
+ }
+ return nil
+}
+
+// Writer implements io.WriteCloser with a restriction on the rate of data
+// transfer.
+type Writer struct {
+ io.Writer // Data destination
+ *Monitor // Flow control monitor
+
+ limit int64 // Rate limit in bytes per second (unlimited when <= 0)
+ block bool // What to do when no new bytes can be written due to the limit
+}
+
+// NewWriter restricts all Write operations on w to limit bytes per second. The
+// transfer rate and the default blocking behavior (true) can be changed
+// directly on the returned *Writer.
+func NewWriter(w io.Writer, limit int64) *Writer {
+ return &Writer{w, New(0, 0), limit, true}
+}
+
+// Write writes len(p) bytes from p to the underlying data stream without
+// exceeding the current transfer rate limit. It returns (n, ErrLimit) if w is
+// non-blocking and no additional bytes can be written at this time.
+func (w *Writer) Write(p []byte) (n int, err error) {
+ var c int
+ for len(p) > 0 && err == nil {
+ s := p[:w.Limit(len(p), w.limit, w.block)]
+ if len(s) > 0 {
+ c, err = w.IO(w.Writer.Write(s))
+ } else {
+ return n, ErrLimit
+ }
+ p = p[c:]
+ n += c
+ }
+ return
+}
+
+// SetLimit changes the transfer rate limit to new bytes per second and returns
+// the previous setting.
+func (w *Writer) SetLimit(new int64) (old int64) {
+ old, w.limit = w.limit, new
+ return
+}
+
+// SetBlocking changes the blocking behavior and returns the previous setting. A
+// Write call on a non-blocking writer returns as soon as no additional bytes
+// may be written at this time due to the rate limit.
+func (w *Writer) SetBlocking(new bool) (old bool) {
+ old, w.block = w.block, new
+ return
+}
+
+// Close closes the underlying writer if it implements the io.Closer interface.
+func (w *Writer) Close() error {
+ defer w.Done()
+ if c, ok := w.Writer.(io.Closer); ok {
+ return c.Close()
+ }
+ return nil
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/io_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/io_test.go
new file mode 100644
index 00000000..31806936
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/io_test.go
@@ -0,0 +1,146 @@
+//
+// Written by Maxim Khitrov (November 2012)
+//
+
+package flowcontrol
+
+import (
+ "bytes"
+ "reflect"
+ "testing"
+ "time"
+)
+
+const (
+ _50ms = 50 * time.Millisecond
+ _100ms = 100 * time.Millisecond
+ _200ms = 200 * time.Millisecond
+ _300ms = 300 * time.Millisecond
+ _400ms = 400 * time.Millisecond
+ _500ms = 500 * time.Millisecond
+)
+
+func nextStatus(m *Monitor) Status {
+ samples := m.samples
+ for i := 0; i < 30; i++ {
+ if s := m.Status(); s.Samples != samples {
+ return s
+ }
+ time.Sleep(5 * time.Millisecond)
+ }
+ return m.Status()
+}
+
+func TestReader(t *testing.T) {
+ in := make([]byte, 100)
+ for i := range in {
+ in[i] = byte(i)
+ }
+ b := make([]byte, 100)
+ r := NewReader(bytes.NewReader(in), 100)
+ start := time.Now()
+
+ // Make sure r implements Limiter
+ _ = Limiter(r)
+
+ // 1st read of 10 bytes is performed immediately
+ if n, err := r.Read(b); n != 10 || err != nil {
+ t.Fatalf("r.Read(b) expected 10 (); got %v (%v)", n, err)
+ } else if rt := time.Since(start); rt > _50ms {
+ t.Fatalf("r.Read(b) took too long (%v)", rt)
+ }
+
+ // No new Reads allowed in the current sample
+ r.SetBlocking(false)
+ if n, err := r.Read(b); n != 0 || err != nil {
+ t.Fatalf("r.Read(b) expected 0 (); got %v (%v)", n, err)
+ } else if rt := time.Since(start); rt > _50ms {
+ t.Fatalf("r.Read(b) took too long (%v)", rt)
+ }
+
+ status := [6]Status{0: r.Status()} // No samples in the first status
+
+ // 2nd read of 10 bytes blocks until the next sample
+ r.SetBlocking(true)
+ if n, err := r.Read(b[10:]); n != 10 || err != nil {
+ t.Fatalf("r.Read(b[10:]) expected 10 (); got %v (%v)", n, err)
+ } else if rt := time.Since(start); rt < _100ms {
+ t.Fatalf("r.Read(b[10:]) returned ahead of time (%v)", rt)
+ }
+
+ status[1] = r.Status() // 1st sample
+ status[2] = nextStatus(r.Monitor) // 2nd sample
+ status[3] = nextStatus(r.Monitor) // No activity for the 3rd sample
+
+ if n := r.Done(); n != 20 {
+ t.Fatalf("r.Done() expected 20; got %v", n)
+ }
+
+ status[4] = r.Status()
+ status[5] = nextStatus(r.Monitor) // Timeout
+ start = status[0].Start
+
+ // Active, Start, Duration, Idle, Bytes, Samples, InstRate, CurRate, AvgRate, PeakRate, BytesRem, TimeRem, Progress
+ want := []Status{
+ Status{true, start, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ Status{true, start, _100ms, 0, 10, 1, 100, 100, 100, 100, 0, 0, 0},
+ Status{true, start, _200ms, _100ms, 20, 2, 100, 100, 100, 100, 0, 0, 0},
+ Status{true, start, _300ms, _200ms, 20, 3, 0, 90, 67, 100, 0, 0, 0},
+ Status{false, start, _300ms, 0, 20, 3, 0, 0, 67, 100, 0, 0, 0},
+ Status{false, start, _300ms, 0, 20, 3, 0, 0, 67, 100, 0, 0, 0},
+ }
+ for i, s := range status {
+ if !reflect.DeepEqual(&s, &want[i]) {
+ t.Errorf("r.Status(%v) expected %v; got %v", i, want[i], s)
+ }
+ }
+ if !bytes.Equal(b[:20], in[:20]) {
+ t.Errorf("r.Read() input doesn't match output")
+ }
+}
+
+func TestWriter(t *testing.T) {
+ b := make([]byte, 100)
+ for i := range b {
+ b[i] = byte(i)
+ }
+ w := NewWriter(&bytes.Buffer{}, 200)
+ start := time.Now()
+
+ // Make sure w implements Limiter
+ _ = Limiter(w)
+
+ // Non-blocking 20-byte write for the first sample returns ErrLimit
+ w.SetBlocking(false)
+ if n, err := w.Write(b); n != 20 || err != ErrLimit {
+ t.Fatalf("w.Write(b) expected 20 (ErrLimit); got %v (%v)", n, err)
+ } else if rt := time.Since(start); rt > _50ms {
+ t.Fatalf("w.Write(b) took too long (%v)", rt)
+ }
+
+ // Blocking 80-byte write
+ w.SetBlocking(true)
+ if n, err := w.Write(b[20:]); n != 80 || err != nil {
+ t.Fatalf("w.Write(b[20:]) expected 80 (); got %v (%v)", n, err)
+ } else if rt := time.Since(start); rt < _400ms {
+ t.Fatalf("w.Write(b[20:]) returned ahead of time (%v)", rt)
+ }
+
+ w.SetTransferSize(100)
+ status := []Status{w.Status(), nextStatus(w.Monitor)}
+ start = status[0].Start
+
+ // Active, Start, Duration, Idle, Bytes, Samples, InstRate, CurRate, AvgRate, PeakRate, BytesRem, TimeRem, Progress
+ want := []Status{
+ Status{true, start, _400ms, 0, 80, 4, 200, 200, 200, 200, 20, _100ms, 80000},
+ Status{true, start, _500ms, _100ms, 100, 5, 200, 200, 200, 200, 0, 0, 100000},
+ }
+ for i, s := range status {
+ if !reflect.DeepEqual(&s, &want[i]) {
+ t.Errorf("w.Status(%v) expected %v; got %v", i, want[i], s)
+ }
+ }
+ if !bytes.Equal(b, w.Writer.(*bytes.Buffer).Bytes()) {
+ t.Errorf("w.Write() input doesn't match output")
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/util.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/util.go
new file mode 100644
index 00000000..91efd881
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/flowcontrol/util.go
@@ -0,0 +1,67 @@
+//
+// Written by Maxim Khitrov (November 2012)
+//
+
+package flowcontrol
+
+import (
+ "math"
+ "strconv"
+ "time"
+)
+
+// clockRate is the resolution and precision of clock().
+const clockRate = 20 * time.Millisecond
+
+// czero is the process start time rounded down to the nearest clockRate
+// increment.
+var czero = time.Duration(time.Now().UnixNano()) / clockRate * clockRate
+
+// clock returns a low resolution timestamp relative to the process start time.
+func clock() time.Duration {
+ return time.Duration(time.Now().UnixNano())/clockRate*clockRate - czero
+}
+
+// clockToTime converts a clock() timestamp to an absolute time.Time value.
+func clockToTime(c time.Duration) time.Time {
+ return time.Unix(0, int64(czero+c))
+}
+
+// clockRound returns d rounded to the nearest clockRate increment.
+func clockRound(d time.Duration) time.Duration {
+ return (d + clockRate>>1) / clockRate * clockRate
+}
+
+// round returns x rounded to the nearest int64 (non-negative values only).
+func round(x float64) int64 {
+ if _, frac := math.Modf(x); frac >= 0.5 {
+ return int64(math.Ceil(x))
+ }
+ return int64(math.Floor(x))
+}
+
+// Percent represents a percentage in increments of 1/1000th of a percent.
+type Percent uint32
+
+// percentOf calculates what percent of the total is x.
+func percentOf(x, total float64) Percent {
+ if x < 0 || total <= 0 {
+ return 0
+ } else if p := round(x / total * 1e5); p <= math.MaxUint32 {
+ return Percent(p)
+ }
+ return Percent(math.MaxUint32)
+}
+
+func (p Percent) Float() float64 {
+ return float64(p) * 1e-3
+}
+
+func (p Percent) String() string {
+ var buf [12]byte
+ b := strconv.AppendUint(buf[:0], uint64(p)/1000, 10)
+ n := len(b)
+ b = strconv.AppendUint(b, 1000+uint64(p)%1000, 10)
+ b[n] = '.'
+ return string(append(b, '%'))
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/pbkdf2.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/pbkdf2.go
new file mode 100644
index 00000000..eafac862
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/pbkdf2.go
@@ -0,0 +1,219 @@
+//
+// Written by Maxim Khitrov (October 2012)
+//
+
+/*
+Package pbkdf2 provides an incremental version of the PBKDF2 key derivation
+algorithm, as described in RFC 2898.
+
+Password-Based Key Derivation Function 2 derives cryptographic keys of a
+specified length from the provided password and salt values. The derivation is
+performed by a CPU-bound loop, with the iteration count specified as one of the
+function parameters. The higher the iteration count, the more difficult (time
+consuming) it is for an attacker to brute-force the password/salt combination.
+
+An incremental PBKDF2 implementation allows the key derivation loop to resume
+execution from its previous state. This allows the user to derive keys after
+1000 and 2000 iterations, for example, without having to recompute the first
+1000 iterations twice. The package uses this feature to implement time-based key
+derivation functions (see Derive and Search methods), which gradually increment
+the iteration count until the time limit is reached.
+*/
+package pbkdf2
+
+import (
+ "crypto/hmac"
+ "errors"
+ "hash"
+ "runtime"
+ "time"
+)
+
+// precision determines the timing accuracy of Derive and Search methods by
+// varying the exponential growth rate of the iteration count. The derivation
+// begins with 1024 iterations and the count is incremented exponentially at the
+// rate of 1/(2^precision). The minimum precision is 0 (100% growth rate) and
+// the maximum is 10 (0.1% growth rate). The theoretical timing error is plus or
+// minus timelimit*rate/(rate+2).
+//
+// A higher precision results in more accurate timing, but at the expense of
+// having to make many additional calls to the callback function when searching
+// for a previously derived key. A precision of 4 (6.25%) is a good compromise,
+// which covers 2^32 iterations in 252 steps with a timing error of 3%.
+const precision = 4
+
+// KeyFound is returned by the PBKDF2.Search callback function to indicate that
+// the correct key was found.
+var KeyFound = errors.New("pbkdf2: key found")
+
+// ErrTimeout is returned by PBKDF2.Search when a valid key is not found in the
+// allocated time.
+var ErrTimeout = errors.New("pbkdf2: key search timeout")
+
+// Key derives a key from the password, salt, and iteration count, returning a
+// []byte of length dkLen that can be used as cryptographic key. This function
+// provides compatibility with the go.crypto/pbkdf2 package.
+func Key(pass, salt []byte, iter, dkLen int, h func() hash.Hash) []byte {
+ return New(pass, salt, dkLen, h).Next(iter)
+}
+
+type PBKDF2 struct {
+ prf hash.Hash // HMAC
+ dkLen int // Key length returned by key derivation methods
+ salt []byte // Salt value used in the first iteration
+ t []byte // Current T values (len >= dkLen, multiple of prf.Size())
+ u []byte // Current U values (same len as t)
+ iters int // Current iteration count
+}
+
+// New returns a new PBKDF2 state initialized to zero iterations.
+func New(pass, salt []byte, dkLen int, h func() hash.Hash) *PBKDF2 {
+ return &PBKDF2{prf: hmac.New(h, pass), dkLen: dkLen, salt: dup(salt)}
+}
+
+// Derive derives a new key in time d.
+func (kdf *PBKDF2) Derive(d time.Duration) []byte {
+ dk, _ := kdf.derive(d, precision, func([]byte) error { return nil })
+ return dk
+}
+
+// Search tries to find a previously derived key. The callback function f is
+// used to test the current key after each step in the derivation process. This
+// test must be reasonably fast to maintain accurate derivation timing. The
+// search stops when f returns a non-nil error or the time limit is reached. The
+// correct key is found when f returns KeyFound.
+//
+// As a general rule, Search should be given more time than Derive, especially
+// if the two operations are being performed on different computers. If Derive
+// was given 1 second, a reasonable limit for Search is 3 to 5 seconds.
+func (kdf *PBKDF2) Search(d time.Duration, f func(dk []byte) error) (dk []byte, err error) {
+ if dk, err = kdf.derive(d, precision, f); err == KeyFound {
+ err = nil
+ } else {
+ dk = nil
+ if err == nil {
+ err = ErrTimeout
+ }
+ }
+ return
+}
+
+// Next runs the key derivation algorithm for c additional iterations and
+// returns a copy of the new key.
+func (kdf *PBKDF2) Next(c int) []byte {
+ if c <= 0 {
+ panic("pbkdf2: invalid iteration count")
+ }
+ prf := kdf.prf
+ hLen := prf.Size()
+
+ if kdf.iters == 0 {
+ n := (kdf.dkLen + hLen - 1) / hLen
+ t := make([]byte, 0, 2*n*hLen)
+ for i := 1; i <= n; i++ {
+ prf.Reset()
+ prf.Write(kdf.salt)
+ prf.Write([]byte{byte(i >> 24), byte(i >> 16), byte(i >> 8), byte(i)})
+ t = prf.Sum(t)
+ }
+ kdf.t, kdf.u = t, t[len(t):cap(t)]
+ copy(kdf.u, kdf.t)
+ c--
+ kdf.iters = 1
+ }
+
+ t, u := kdf.t, kdf.u
+ for i := 0; i < c; i++ {
+ for j := 0; j < len(u); j += hLen {
+ prf.Reset()
+ prf.Write(u[j : j+hLen])
+ prf.Sum(u[:j])
+ }
+ for j, v := range u {
+ t[j] ^= v
+ }
+ }
+ kdf.iters += c
+ return dup(t[:kdf.dkLen])
+}
+
+// Salt returns a copy of the current salt value.
+func (kdf *PBKDF2) Salt() []byte {
+ return dup(kdf.salt)
+}
+
+// Size returns the derived key size.
+func (kdf *PBKDF2) Size() int {
+ return kdf.dkLen
+}
+
+// Iters returns the total number of iterations performed so far.
+func (kdf *PBKDF2) Iters() int {
+ return kdf.iters
+}
+
+// Reset returns kdf to the initial state at zero iterations. Salt and dkLen
+// parameters for subsequent iterations can be changed by passing non-nil and
+// non-zero values, respectively.
+func (kdf *PBKDF2) Reset(salt []byte, dkLen int) {
+ if dkLen > 0 {
+ kdf.dkLen = dkLen
+ }
+ if salt != nil {
+ kdf.salt = dup(salt)
+ }
+ kdf.t = nil
+ kdf.u = nil
+ kdf.iters = 0
+}
+
+// derive performs time-based key derivation.
+func (kdf *PBKDF2) derive(d time.Duration, p uint, f func(dk []byte) error) (dk []byte, err error) {
+ if p > 10 {
+ panic("pbkdf2: invalid derivation precision")
+ }
+ kdf.Reset(nil, 0)
+ ch := make(chan struct{})
+ go func() {
+ defer close(ch)
+ runtime.LockOSThread()
+ r := 1.0 / float64(uint(1)<
> p)
+ }
+ }()
+ <-ch
+ return
+}
+
+type timer struct {
+ wall time.Time
+ user time.Duration
+}
+
+// elapsed returns true when time d has elapsed from the point when the timer
+// was created. Timing is done according to the user CPU time of the current
+// thread with the wall clock time acting as a backup. Systems that don't
+// provide per-thread timing information use the process CPU time instead. The
+// wall clock time defines lower (d) and upper (2*d) limits as a workaround for
+// inaccurate CPU time accounting on some systems (e.g. Windows).
+func (t *timer) elapsed(d time.Duration) bool {
+ wall := time.Since(t.wall)
+ emin := wall >= d
+ if emin && wall < d<<1 {
+ return utime()-t.user >= d
+ }
+ return emin
+}
+
+func dup(b []byte) []byte {
+ t := make([]byte, len(b))
+ copy(t, b)
+ return t
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/pbkdf2_test.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/pbkdf2_test.go
new file mode 100644
index 00000000..9fd52bd8
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/pbkdf2_test.go
@@ -0,0 +1,85 @@
+//
+// Written by Maxim Khitrov (October 2012)
+//
+
+package pbkdf2
+
+import (
+ "bytes"
+ "crypto/sha1"
+ "crypto/sha256"
+ "fmt"
+ "testing"
+ "time"
+)
+
+func TestRFC6070(t *testing.T) {
+ tests := []struct {
+ P, S string
+ c []int
+ dkLen int
+ out string
+ }{
+ {"password", "salt", []int{1}, 20,
+ "0c 60 c8 0f 96 1f 0e 71 f3 a9 b5 24 af 60 12 06 2f e0 37 a6"},
+ {"password", "salt", []int{2}, 20,
+ "ea 6c 01 4d c7 2d 6f 8c cd 1e d9 2a ce 1d 41 f0 d8 de 89 57"},
+ {"password", "salt", []int{1, 1}, 20,
+ "ea 6c 01 4d c7 2d 6f 8c cd 1e d9 2a ce 1d 41 f0 d8 de 89 57"},
+ {"password", "salt", []int{4096}, 20,
+ "4b 00 79 01 b7 65 48 9a be ad 49 d9 26 f7 21 d0 65 a4 29 c1"},
+ {"password", "salt", []int{1, 4095}, 20,
+ "4b 00 79 01 b7 65 48 9a be ad 49 d9 26 f7 21 d0 65 a4 29 c1"},
+ {"password", "salt", []int{2048, 2048}, 20,
+ "4b 00 79 01 b7 65 48 9a be ad 49 d9 26 f7 21 d0 65 a4 29 c1"},
+ {"password", "salt", []int{4095, 1}, 20,
+ "4b 00 79 01 b7 65 48 9a be ad 49 d9 26 f7 21 d0 65 a4 29 c1"},
+ {"password", "salt", []int{1, 4094, 1}, 20,
+ "4b 00 79 01 b7 65 48 9a be ad 49 d9 26 f7 21 d0 65 a4 29 c1"},
+ //{"password", "salt", []int{16777216}, 20,
+ // "ee fe 3d 61 cd 4d a4 e4 e9 94 5b 3d 6b a2 15 8c 26 34 e9 84"},
+ {"passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", []int{4096}, 25,
+ "3d 2e ec 4f e4 1c 84 9b 80 c8 d8 36 62 c0 e4 4a 8b 29 1a 96 4c f2 f0 70 38"},
+ {"pass\x00word", "sa\x00lt", []int{4096}, 16,
+ "56 fa 6a a7 55 48 09 9d cc 37 d7 f0 34 25 e0 c3"},
+ }
+ var dk []byte
+ for _, test := range tests {
+ kdf := New([]byte(test.P), []byte(test.S), test.dkLen, sha1.New)
+ for _, c := range test.c {
+ dk = kdf.Next(c)
+ }
+ if out := fmt.Sprintf("% x", dk); out != test.out {
+ t.Errorf("kdf.Next() expected %q; got %q", test.out, out)
+ }
+ }
+}
+
+func TestKeyGen(t *testing.T) {
+ kdf := New([]byte("pass"), []byte("salt"), 10, sha256.New)
+ key := kdf.Derive(100 * time.Millisecond)
+ itr := kdf.Iters()
+
+ tryKey := func(dk []byte) error {
+ if bytes.Equal(dk, key) {
+ return KeyFound
+ }
+ return nil
+ }
+
+ d := 10 * time.Millisecond
+ dk, err := kdf.Search(d, tryKey)
+ if dk != nil || err != ErrTimeout {
+ t.Errorf("kdf.Search(%v) expected ErrTimeout; got % x (%v)", d, dk, err)
+ }
+
+ d = 200 * time.Millisecond
+ dk, err = kdf.Search(d, tryKey)
+ if !bytes.Equal(dk, key) || err != nil {
+ t.Errorf("kdf.Search(%v) expected % x; got % x (%v)", d, key, dk, err)
+ }
+
+ if kdf.Iters() != itr {
+ t.Errorf("kdf.Iters() expected %v; got %v", itr, kdf.Iters())
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_unix_proc.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_unix_proc.go
new file mode 100644
index 00000000..c88126ae
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_unix_proc.go
@@ -0,0 +1,20 @@
+//
+// Written by Maxim Khitrov (October 2012)
+//
+
+// +build !freebsd,!linux,!windows
+
+package pbkdf2
+
+import (
+ "syscall"
+ "time"
+)
+
+func utime() time.Duration {
+ var u syscall.Rusage
+ if err := syscall.Getrusage(syscall.RUSAGE_SELF, &u); err != nil {
+ panic(err)
+ }
+ return time.Duration(u.Utime.Nano())
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_unix_thread.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_unix_thread.go
new file mode 100644
index 00000000..e9b0030f
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_unix_thread.go
@@ -0,0 +1,29 @@
+//
+// Written by Maxim Khitrov (October 2012)
+//
+
+// +build freebsd linux
+
+package pbkdf2
+
+import (
+ "syscall"
+ "time"
+)
+
+var getrusage_who = syscall.RUSAGE_THREAD
+
+func init() {
+ var u syscall.Rusage
+ if syscall.Getrusage(getrusage_who, &u) == syscall.EINVAL {
+ getrusage_who = syscall.RUSAGE_SELF
+ }
+}
+
+func utime() time.Duration {
+ var u syscall.Rusage
+ if err := syscall.Getrusage(getrusage_who, &u); err != nil {
+ panic(err)
+ }
+ return time.Duration(u.Utime.Nano())
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_windows.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_windows.go
new file mode 100644
index 00000000..3451c98d
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/pbkdf2/time_windows.go
@@ -0,0 +1,64 @@
+//
+// Written by Maxim Khitrov (October 2012)
+//
+
+package pbkdf2
+
+import (
+ "syscall"
+ "time"
+ "unsafe"
+)
+
+/*
+Note: GetThreadTimes function may return inaccurate values when the calling
+thread is frequently interrupted prior to consuming all of its quantum. This
+shouldn't be a huge problem for PBKDF2 calculation since it doesn't enter any
+wait states, but some additional testing in high-load situations is needed.
+
+http://blog.kalmbachnet.de/?postid=28
+http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2004-10/0689.html
+*/
+
+var (
+ modkernel32 = syscall.MustLoadDLL("kernel32.dll")
+
+ procGetCurrentThread = modkernel32.MustFindProc("GetCurrentThread")
+ procGetThreadTimes = modkernel32.MustFindProc("GetThreadTimes")
+)
+
+func utime() time.Duration {
+ var u syscall.Rusage
+ h, _ := getCurrentThread()
+ err := getThreadTimes(h, &u.CreationTime, &u.ExitTime, &u.KernelTime, &u.UserTime)
+ if err != nil {
+ panic(err)
+ }
+ t := uint64(u.UserTime.HighDateTime)<<32 | uint64(u.UserTime.LowDateTime)
+ return time.Duration(t * 100)
+}
+
+func getCurrentThread() (pseudoHandle syscall.Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
+ pseudoHandle = syscall.Handle(r0)
+ if pseudoHandle == 0 {
+ if e1 != 0 {
+ err = error(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func getThreadTimes(handle syscall.Handle, creationTime, exitTime, kernelTime, userTime *syscall.Filetime) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetThreadTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0)
+ if int(r1) == 0 {
+ if e1 != 0 {
+ err = error(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/alert.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/alert.go
new file mode 100644
index 00000000..b48ab2a2
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/alert.go
@@ -0,0 +1,77 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "strconv"
+
+type alert uint8
+
+const (
+ // alert level
+ alertLevelWarning = 1
+ alertLevelError = 2
+)
+
+const (
+ alertCloseNotify alert = 0
+ alertUnexpectedMessage alert = 10
+ alertBadRecordMAC alert = 20
+ alertDecryptionFailed alert = 21
+ alertRecordOverflow alert = 22
+ alertDecompressionFailure alert = 30
+ alertHandshakeFailure alert = 40
+ alertBadCertificate alert = 42
+ alertUnsupportedCertificate alert = 43
+ alertCertificateRevoked alert = 44
+ alertCertificateExpired alert = 45
+ alertCertificateUnknown alert = 46
+ alertIllegalParameter alert = 47
+ alertUnknownCA alert = 48
+ alertAccessDenied alert = 49
+ alertDecodeError alert = 50
+ alertDecryptError alert = 51
+ alertProtocolVersion alert = 70
+ alertInsufficientSecurity alert = 71
+ alertInternalError alert = 80
+ alertUserCanceled alert = 90
+ alertNoRenegotiation alert = 100
+)
+
+var alertText = map[alert]string{
+ alertCloseNotify: "close notify",
+ alertUnexpectedMessage: "unexpected message",
+ alertBadRecordMAC: "bad record MAC",
+ alertDecryptionFailed: "decryption failed",
+ alertRecordOverflow: "record overflow",
+ alertDecompressionFailure: "decompression failure",
+ alertHandshakeFailure: "handshake failure",
+ alertBadCertificate: "bad certificate",
+ alertUnsupportedCertificate: "unsupported certificate",
+ alertCertificateRevoked: "revoked certificate",
+ alertCertificateExpired: "expired certificate",
+ alertCertificateUnknown: "unknown certificate",
+ alertIllegalParameter: "illegal parameter",
+ alertUnknownCA: "unknown certificate authority",
+ alertAccessDenied: "access denied",
+ alertDecodeError: "error decoding message",
+ alertDecryptError: "error decrypting message",
+ alertProtocolVersion: "protocol version not supported",
+ alertInsufficientSecurity: "insufficient security level",
+ alertInternalError: "internal error",
+ alertUserCanceled: "user canceled",
+ alertNoRenegotiation: "no renegotiation",
+}
+
+func (e alert) String() string {
+ s, ok := alertText[e]
+ if ok {
+ return s
+ }
+ return "alert(" + strconv.Itoa(int(e)) + ")"
+}
+
+func (e alert) Error() string {
+ return e.String()
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/cipher_suites.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/cipher_suites.go
new file mode 100644
index 00000000..7c8135aa
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/cipher_suites.go
@@ -0,0 +1,270 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "crypto/aes"
+ "crypto/cipher"
+ "crypto/des"
+ "crypto/hmac"
+ "crypto/rc4"
+ "crypto/sha1"
+ "crypto/x509"
+ "hash"
+)
+
+// a keyAgreement implements the client and server side of a TLS key agreement
+// protocol by generating and processing key exchange messages.
+type keyAgreement interface {
+ // On the server side, the first two methods are called in order.
+
+ // In the case that the key agreement protocol doesn't use a
+ // ServerKeyExchange message, generateServerKeyExchange can return nil,
+ // nil.
+ generateServerKeyExchange(*Config, *Certificate, *clientHelloMsg, *serverHelloMsg) (*serverKeyExchangeMsg, error)
+ processClientKeyExchange(*Config, *Certificate, *clientKeyExchangeMsg, uint16) ([]byte, error)
+
+ // On the client side, the next two methods are called in order.
+
+ // This method may not be called if the server doesn't send a
+ // ServerKeyExchange message.
+ processServerKeyExchange(*Config, *clientHelloMsg, *serverHelloMsg, *x509.Certificate, *serverKeyExchangeMsg) error
+ generateClientKeyExchange(*Config, *clientHelloMsg, *x509.Certificate) ([]byte, *clientKeyExchangeMsg, error)
+}
+
+const (
+ // suiteECDH indicates that the cipher suite involves elliptic curve
+ // Diffie-Hellman. This means that it should only be selected when the
+ // client indicates that it supports ECC with a curve and point format
+ // that we're happy with.
+ suiteECDHE = 1 << iota
+ // suiteECDSA indicates that the cipher suite involves an ECDSA
+ // signature and therefore may only be selected when the server's
+ // certificate is ECDSA. If this is not set then the cipher suite is
+ // RSA based.
+ suiteECDSA
+ // suiteTLS12 indicates that the cipher suite should only be advertised
+ // and accepted when using TLS 1.2.
+ suiteTLS12
+)
+
+// A cipherSuite is a specific combination of key agreement, cipher and MAC
+// function. All cipher suites currently assume RSA key agreement.
+type cipherSuite struct {
+ id uint16
+ // the lengths, in bytes, of the key material needed for each component.
+ keyLen int
+ macLen int
+ ivLen int
+ ka func(version uint16) keyAgreement
+ // flags is a bitmask of the suite* values, above.
+ flags int
+ cipher func(key, iv []byte, isRead bool) interface{}
+ mac func(version uint16, macKey []byte) macFunction
+ aead func(key, fixedNonce []byte) cipher.AEAD
+}
+
+var cipherSuites = []*cipherSuite{
+ // Ciphersuite order is chosen so that ECDHE comes before plain RSA
+ // and RC4 comes before AES (because of the Lucky13 attack).
+ {TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheRSAKA, suiteECDHE | suiteTLS12, nil, nil, aeadAESGCM},
+ {TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12, nil, nil, aeadAESGCM},
+ {TLS_ECDHE_RSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheRSAKA, suiteECDHE, cipherRC4, macSHA1, nil},
+ {TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherRC4, macSHA1, nil},
+ {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
+ {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
+ {TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
+ {TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
+ {TLS_RSA_WITH_RC4_128_SHA, 16, 20, 0, rsaKA, 0, cipherRC4, macSHA1, nil},
+ {TLS_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
+ {TLS_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
+ {TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, ecdheRSAKA, suiteECDHE, cipher3DES, macSHA1, nil},
+ {TLS_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, rsaKA, 0, cipher3DES, macSHA1, nil},
+}
+
+func cipherRC4(key, iv []byte, isRead bool) interface{} {
+ cipher, _ := rc4.NewCipher(key)
+ return cipher
+}
+
+func cipher3DES(key, iv []byte, isRead bool) interface{} {
+ block, _ := des.NewTripleDESCipher(key)
+ if isRead {
+ return cipher.NewCBCDecrypter(block, iv)
+ }
+ return cipher.NewCBCEncrypter(block, iv)
+}
+
+func cipherAES(key, iv []byte, isRead bool) interface{} {
+ block, _ := aes.NewCipher(key)
+ if isRead {
+ return cipher.NewCBCDecrypter(block, iv)
+ }
+ return cipher.NewCBCEncrypter(block, iv)
+}
+
+// macSHA1 returns a macFunction for the given protocol version.
+func macSHA1(version uint16, key []byte) macFunction {
+ if version == VersionSSL30 {
+ mac := ssl30MAC{
+ h: sha1.New(),
+ key: make([]byte, len(key)),
+ }
+ copy(mac.key, key)
+ return mac
+ }
+ return tls10MAC{hmac.New(sha1.New, key)}
+}
+
+type macFunction interface {
+ Size() int
+ MAC(digestBuf, seq, header, data []byte) []byte
+}
+
+// fixedNonceAEAD wraps an AEAD and prefixes a fixed portion of the nonce to
+// each call.
+type fixedNonceAEAD struct {
+ // sealNonce and openNonce are buffers where the larger nonce will be
+ // constructed. Since a seal and open operation may be running
+ // concurrently, there is a separate buffer for each.
+ sealNonce, openNonce []byte
+ aead cipher.AEAD
+}
+
+func (f *fixedNonceAEAD) NonceSize() int { return 8 }
+func (f *fixedNonceAEAD) Overhead() int { return f.aead.Overhead() }
+
+func (f *fixedNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte {
+ copy(f.sealNonce[len(f.sealNonce)-8:], nonce)
+ return f.aead.Seal(out, f.sealNonce, plaintext, additionalData)
+}
+
+func (f *fixedNonceAEAD) Open(out, nonce, plaintext, additionalData []byte) ([]byte, error) {
+ copy(f.openNonce[len(f.openNonce)-8:], nonce)
+ return f.aead.Open(out, f.openNonce, plaintext, additionalData)
+}
+
+func aeadAESGCM(key, fixedNonce []byte) cipher.AEAD {
+ aes, err := aes.NewCipher(key)
+ if err != nil {
+ panic(err)
+ }
+ aead, err := cipher.NewGCM(aes)
+ if err != nil {
+ panic(err)
+ }
+
+ nonce1, nonce2 := make([]byte, 12), make([]byte, 12)
+ copy(nonce1, fixedNonce)
+ copy(nonce2, fixedNonce)
+
+ return &fixedNonceAEAD{nonce1, nonce2, aead}
+}
+
+// ssl30MAC implements the SSLv3 MAC function, as defined in
+// www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt section 5.2.3.1
+type ssl30MAC struct {
+ h hash.Hash
+ key []byte
+}
+
+func (s ssl30MAC) Size() int {
+ return s.h.Size()
+}
+
+var ssl30Pad1 = [48]byte{0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}
+
+var ssl30Pad2 = [48]byte{0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c}
+
+func (s ssl30MAC) MAC(digestBuf, seq, header, data []byte) []byte {
+ padLength := 48
+ if s.h.Size() == 20 {
+ padLength = 40
+ }
+
+ s.h.Reset()
+ s.h.Write(s.key)
+ s.h.Write(ssl30Pad1[:padLength])
+ s.h.Write(seq)
+ s.h.Write(header[:1])
+ s.h.Write(header[3:5])
+ s.h.Write(data)
+ digestBuf = s.h.Sum(digestBuf[:0])
+
+ s.h.Reset()
+ s.h.Write(s.key)
+ s.h.Write(ssl30Pad2[:padLength])
+ s.h.Write(digestBuf)
+ return s.h.Sum(digestBuf[:0])
+}
+
+// tls10MAC implements the TLS 1.0 MAC function. RFC 2246, section 6.2.3.
+type tls10MAC struct {
+ h hash.Hash
+}
+
+func (s tls10MAC) Size() int {
+ return s.h.Size()
+}
+
+func (s tls10MAC) MAC(digestBuf, seq, header, data []byte) []byte {
+ s.h.Reset()
+ s.h.Write(seq)
+ s.h.Write(header)
+ s.h.Write(data)
+ return s.h.Sum(digestBuf[:0])
+}
+
+func rsaKA(version uint16) keyAgreement {
+ return rsaKeyAgreement{}
+}
+
+func ecdheECDSAKA(version uint16) keyAgreement {
+ return &ecdheKeyAgreement{
+ sigType: signatureECDSA,
+ version: version,
+ }
+}
+
+func ecdheRSAKA(version uint16) keyAgreement {
+ return &ecdheKeyAgreement{
+ sigType: signatureRSA,
+ version: version,
+ }
+}
+
+// mutualCipherSuite returns a cipherSuite given a list of supported
+// ciphersuites and the id requested by the peer.
+func mutualCipherSuite(have []uint16, want uint16) *cipherSuite {
+ for _, id := range have {
+ if id == want {
+ for _, suite := range cipherSuites {
+ if suite.id == want {
+ return suite
+ }
+ }
+ return nil
+ }
+ }
+ return nil
+}
+
+// A list of the possible cipher suite ids. Taken from
+// http://www.iana.org/assignments/tls-parameters/tls-parameters.xml
+const (
+ TLS_RSA_WITH_RC4_128_SHA uint16 = 0x0005
+ TLS_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x000a
+ TLS_RSA_WITH_AES_128_CBC_SHA uint16 = 0x002f
+ TLS_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0035
+ TLS_ECDHE_ECDSA_WITH_RC4_128_SHA uint16 = 0xc007
+ TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA uint16 = 0xc009
+ TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA uint16 = 0xc00a
+ TLS_ECDHE_RSA_WITH_RC4_128_SHA uint16 = 0xc011
+ TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xc012
+ TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0xc013
+ TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0xc014
+ TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02f
+ TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02b
+)
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/common.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/common.go
new file mode 100644
index 00000000..f43bb1ec
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/common.go
@@ -0,0 +1,437 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "crypto"
+ "crypto/rand"
+ "crypto/x509"
+ "io"
+ "math/big"
+ "strings"
+ "sync"
+ "time"
+)
+
+const (
+ VersionSSL30 = 0x0300
+ VersionTLS10 = 0x0301
+ VersionTLS11 = 0x0302
+ VersionTLS12 = 0x0303
+)
+
+const (
+ maxPlaintext = 16384 // maximum plaintext payload length
+ maxCiphertext = 16384 + 2048 // maximum ciphertext payload length
+ recordHeaderLen = 5 // record header length
+ maxHandshake = 65536 // maximum handshake we support (protocol max is 16 MB)
+
+ minVersion = VersionSSL30
+ maxVersion = VersionTLS12
+)
+
+// TLS record types.
+type recordType uint8
+
+const (
+ recordTypeChangeCipherSpec recordType = 20
+ recordTypeAlert recordType = 21
+ recordTypeHandshake recordType = 22
+ recordTypeApplicationData recordType = 23
+)
+
+// TLS handshake message types.
+const (
+ typeClientHello uint8 = 1
+ typeServerHello uint8 = 2
+ typeNewSessionTicket uint8 = 4
+ typeCertificate uint8 = 11
+ typeServerKeyExchange uint8 = 12
+ typeCertificateRequest uint8 = 13
+ typeServerHelloDone uint8 = 14
+ typeCertificateVerify uint8 = 15
+ typeClientKeyExchange uint8 = 16
+ typeFinished uint8 = 20
+ typeCertificateStatus uint8 = 22
+ typeNextProtocol uint8 = 67 // Not IANA assigned
+)
+
+// TLS compression types.
+const (
+ compressionNone uint8 = 0
+)
+
+// TLS extension numbers
+var (
+ extensionServerName uint16 = 0
+ extensionStatusRequest uint16 = 5
+ extensionSupportedCurves uint16 = 10
+ extensionSupportedPoints uint16 = 11
+ extensionSignatureAlgorithms uint16 = 13
+ extensionSessionTicket uint16 = 35
+ extensionNextProtoNeg uint16 = 13172 // not IANA assigned
+)
+
+// TLS Elliptic Curves
+// http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8
+var (
+ curveP256 uint16 = 23
+ curveP384 uint16 = 24
+ curveP521 uint16 = 25
+)
+
+// TLS Elliptic Curve Point Formats
+// http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-9
+var (
+ pointFormatUncompressed uint8 = 0
+)
+
+// TLS CertificateStatusType (RFC 3546)
+const (
+ statusTypeOCSP uint8 = 1
+)
+
+// Certificate types (for certificateRequestMsg)
+const (
+ certTypeRSASign = 1 // A certificate containing an RSA key
+ certTypeDSSSign = 2 // A certificate containing a DSA key
+ certTypeRSAFixedDH = 3 // A certificate containing a static DH key
+ certTypeDSSFixedDH = 4 // A certificate containing a static DH key
+
+ // See RFC4492 sections 3 and 5.5.
+ certTypeECDSASign = 64 // A certificate containing an ECDSA-capable public key, signed with ECDSA.
+ certTypeRSAFixedECDH = 65 // A certificate containing an ECDH-capable public key, signed with RSA.
+ certTypeECDSAFixedECDH = 66 // A certificate containing an ECDH-capable public key, signed with ECDSA.
+
+ // Rest of these are reserved by the TLS spec
+)
+
+// Hash functions for TLS 1.2 (See RFC 5246, section A.4.1)
+const (
+ hashSHA1 uint8 = 2
+ hashSHA256 uint8 = 4
+)
+
+// Signature algorithms for TLS 1.2 (See RFC 5246, section A.4.1)
+const (
+ signatureRSA uint8 = 1
+ signatureECDSA uint8 = 3
+)
+
+// signatureAndHash mirrors the TLS 1.2, SignatureAndHashAlgorithm struct. See
+// RFC 5246, section A.4.1.
+type signatureAndHash struct {
+ hash, signature uint8
+}
+
+// supportedSKXSignatureAlgorithms contains the signature and hash algorithms
+// that the code advertises as supported in a TLS 1.2 ClientHello.
+var supportedSKXSignatureAlgorithms = []signatureAndHash{
+ {hashSHA256, signatureRSA},
+ {hashSHA256, signatureECDSA},
+ {hashSHA1, signatureRSA},
+ {hashSHA1, signatureECDSA},
+}
+
+// supportedClientCertSignatureAlgorithms contains the signature and hash
+// algorithms that the code advertises as supported in a TLS 1.2
+// CertificateRequest.
+var supportedClientCertSignatureAlgorithms = []signatureAndHash{
+ {hashSHA256, signatureRSA},
+ {hashSHA256, signatureECDSA},
+}
+
+// ConnectionState records basic TLS details about the connection.
+type ConnectionState struct {
+ HandshakeComplete bool // TLS handshake is complete
+ DidResume bool // connection resumes a previous TLS connection
+ CipherSuite uint16 // cipher suite in use (TLS_RSA_WITH_RC4_128_SHA, ...)
+ NegotiatedProtocol string // negotiated next protocol (from Config.NextProtos)
+ NegotiatedProtocolIsMutual bool // negotiated protocol was advertised by server
+ ServerName string // server name requested by client, if any (server side only)
+ PeerCertificates []*x509.Certificate // certificate chain presented by remote peer
+ VerifiedChains [][]*x509.Certificate // verified chains built from PeerCertificates
+}
+
+// ClientAuthType declares the policy the server will follow for
+// TLS Client Authentication.
+type ClientAuthType int
+
+const (
+ NoClientCert ClientAuthType = iota
+ RequestClientCert
+ RequireAnyClientCert
+ VerifyClientCertIfGiven
+ RequireAndVerifyClientCert
+)
+
+// A Config structure is used to configure a TLS client or server. After one
+// has been passed to a TLS function it must not be modified.
+type Config struct {
+ // Rand provides the source of entropy for nonces and RSA blinding.
+ // If Rand is nil, TLS uses the cryptographic random reader in package
+ // crypto/rand.
+ Rand io.Reader
+
+ // Time returns the current time as the number of seconds since the epoch.
+ // If Time is nil, TLS uses time.Now.
+ Time func() time.Time
+
+ // Certificates contains one or more certificate chains
+ // to present to the other side of the connection.
+ // Server configurations must include at least one certificate.
+ Certificates []Certificate
+
+ // NameToCertificate maps from a certificate name to an element of
+ // Certificates. Note that a certificate name can be of the form
+ // '*.example.com' and so doesn't have to be a domain name as such.
+ // See Config.BuildNameToCertificate
+ // The nil value causes the first element of Certificates to be used
+ // for all connections.
+ NameToCertificate map[string]*Certificate
+
+ // RootCAs defines the set of root certificate authorities
+ // that clients use when verifying server certificates.
+ // If RootCAs is nil, TLS uses the host's root CA set.
+ RootCAs *x509.CertPool
+
+ // NextProtos is a list of supported, application level protocols.
+ NextProtos []string
+
+ // ServerName is included in the client's handshake to support virtual
+ // hosting.
+ ServerName string
+
+ // ClientAuth determines the server's policy for
+ // TLS Client Authentication. The default is NoClientCert.
+ ClientAuth ClientAuthType
+
+ // ClientCAs defines the set of root certificate authorities
+ // that servers use if required to verify a client certificate
+ // by the policy in ClientAuth.
+ ClientCAs *x509.CertPool
+
+ // InsecureSkipVerify controls whether a client verifies the
+ // server's certificate chain and host name.
+ // If InsecureSkipVerify is true, TLS accepts any certificate
+ // presented by the server and any host name in that certificate.
+ // In this mode, TLS is susceptible to man-in-the-middle attacks.
+ // This should be used only for testing.
+ InsecureSkipVerify bool
+
+ // CipherSuites is a list of supported cipher suites. If CipherSuites
+ // is nil, TLS uses a list of suites supported by the implementation.
+ CipherSuites []uint16
+
+ // PreferServerCipherSuites controls whether the server selects the
+ // client's most preferred ciphersuite, or the server's most preferred
+ // ciphersuite. If true then the server's preference, as expressed in
+ // the order of elements in CipherSuites, is used.
+ PreferServerCipherSuites bool
+
+ // SessionTicketsDisabled may be set to true to disable session ticket
+ // (resumption) support.
+ SessionTicketsDisabled bool
+
+ // SessionTicketKey is used by TLS servers to provide session
+ // resumption. See RFC 5077. If zero, it will be filled with
+ // random data before the first server handshake.
+ //
+ // If multiple servers are terminating connections for the same host
+ // they should all have the same SessionTicketKey. If the
+ // SessionTicketKey leaks, previously recorded and future TLS
+ // connections using that key are compromised.
+ SessionTicketKey [32]byte
+
+ // MinVersion contains the minimum SSL/TLS version that is acceptable.
+ // If zero, then SSLv3 is taken as the minimum.
+ MinVersion uint16
+
+ // MaxVersion contains the maximum SSL/TLS version that is acceptable.
+ // If zero, then the maximum version supported by this package is used,
+ // which is currently TLS 1.2.
+ MaxVersion uint16
+
+ serverInitOnce sync.Once // guards calling (*Config).serverInit
+}
+
+func (c *Config) serverInit() {
+ if c.SessionTicketsDisabled {
+ return
+ }
+
+ // If the key has already been set then we have nothing to do.
+ for _, b := range c.SessionTicketKey {
+ if b != 0 {
+ return
+ }
+ }
+
+ if _, err := io.ReadFull(c.rand(), c.SessionTicketKey[:]); err != nil {
+ c.SessionTicketsDisabled = true
+ }
+}
+
+func (c *Config) rand() io.Reader {
+ r := c.Rand
+ if r == nil {
+ return rand.Reader
+ }
+ return r
+}
+
+func (c *Config) time() time.Time {
+ t := c.Time
+ if t == nil {
+ t = time.Now
+ }
+ return t()
+}
+
+func (c *Config) cipherSuites() []uint16 {
+ s := c.CipherSuites
+ if s == nil {
+ s = defaultCipherSuites()
+ }
+ return s
+}
+
+func (c *Config) minVersion() uint16 {
+ if c == nil || c.MinVersion == 0 {
+ return minVersion
+ }
+ return c.MinVersion
+}
+
+func (c *Config) maxVersion() uint16 {
+ if c == nil || c.MaxVersion == 0 {
+ return maxVersion
+ }
+ return c.MaxVersion
+}
+
+// mutualVersion returns the protocol version to use given the advertised
+// version of the peer.
+func (c *Config) mutualVersion(vers uint16) (uint16, bool) {
+ minVersion := c.minVersion()
+ maxVersion := c.maxVersion()
+
+ if vers < minVersion {
+ return 0, false
+ }
+ if vers > maxVersion {
+ vers = maxVersion
+ }
+ return vers, true
+}
+
+// getCertificateForName returns the best certificate for the given name,
+// defaulting to the first element of c.Certificates if there are no good
+// options.
+func (c *Config) getCertificateForName(name string) *Certificate {
+ if len(c.Certificates) == 1 || c.NameToCertificate == nil {
+ // There's only one choice, so no point doing any work.
+ return &c.Certificates[0]
+ }
+
+ name = strings.ToLower(name)
+ for len(name) > 0 && name[len(name)-1] == '.' {
+ name = name[:len(name)-1]
+ }
+
+ if cert, ok := c.NameToCertificate[name]; ok {
+ return cert
+ }
+
+ // try replacing labels in the name with wildcards until we get a
+ // match.
+ labels := strings.Split(name, ".")
+ for i := range labels {
+ labels[i] = "*"
+ candidate := strings.Join(labels, ".")
+ if cert, ok := c.NameToCertificate[candidate]; ok {
+ return cert
+ }
+ }
+
+ // If nothing matches, return the first certificate.
+ return &c.Certificates[0]
+}
+
+// BuildNameToCertificate parses c.Certificates and builds c.NameToCertificate
+// from the CommonName and SubjectAlternateName fields of each of the leaf
+// certificates.
+func (c *Config) BuildNameToCertificate() {
+ c.NameToCertificate = make(map[string]*Certificate)
+ for i := range c.Certificates {
+ cert := &c.Certificates[i]
+ x509Cert, err := x509.ParseCertificate(cert.Certificate[0])
+ if err != nil {
+ continue
+ }
+ if len(x509Cert.Subject.CommonName) > 0 {
+ c.NameToCertificate[x509Cert.Subject.CommonName] = cert
+ }
+ for _, san := range x509Cert.DNSNames {
+ c.NameToCertificate[san] = cert
+ }
+ }
+}
+
+// A Certificate is a chain of one or more certificates, leaf first.
+type Certificate struct {
+ Certificate [][]byte
+ PrivateKey crypto.PrivateKey // supported types: *rsa.PrivateKey, *ecdsa.PrivateKey
+ // OCSPStaple contains an optional OCSP response which will be served
+ // to clients that request it.
+ OCSPStaple []byte
+ // Leaf is the parsed form of the leaf certificate, which may be
+ // initialized using x509.ParseCertificate to reduce per-handshake
+ // processing for TLS clients doing client authentication. If nil, the
+ // leaf certificate will be parsed as needed.
+ Leaf *x509.Certificate
+}
+
+// A TLS record.
+type record struct {
+ contentType recordType
+ major, minor uint8
+ payload []byte
+}
+
+type handshakeMessage interface {
+ marshal() []byte
+ unmarshal([]byte) bool
+}
+
+// TODO(jsing): Make these available to both crypto/x509 and crypto/tls.
+type dsaSignature struct {
+ R, S *big.Int
+}
+
+type ecdsaSignature dsaSignature
+
+var emptyConfig Config
+
+func defaultConfig() *Config {
+ return &emptyConfig
+}
+
+var (
+ once sync.Once
+ varDefaultCipherSuites []uint16
+)
+
+func defaultCipherSuites() []uint16 {
+ once.Do(initDefaultCipherSuites)
+ return varDefaultCipherSuites
+}
+
+func initDefaultCipherSuites() {
+ varDefaultCipherSuites = make([]uint16, len(cipherSuites))
+ for i, suite := range cipherSuites {
+ varDefaultCipherSuites[i] = suite.id
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/conn.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/conn.go
new file mode 100644
index 00000000..334f227b
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/conn.go
@@ -0,0 +1,1006 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// TLS low level connection and record layer
+
+package main
+
+import (
+ "bytes"
+ "crypto/cipher"
+ "crypto/subtle"
+ "crypto/x509"
+ "errors"
+ "io"
+ "net"
+ "sync"
+ "time"
+)
+
+// A Conn represents a secured connection.
+// It implements the net.Conn interface.
+type Conn struct {
+ // constant
+ conn net.Conn
+ isClient bool
+
+ // constant after handshake; protected by handshakeMutex
+ handshakeMutex sync.Mutex // handshakeMutex < in.Mutex, out.Mutex, errMutex
+ vers uint16 // TLS version
+ haveVers bool // version has been negotiated
+ config *Config // configuration passed to constructor
+ handshakeComplete bool
+ didResume bool // whether this connection was a session resumption
+ cipherSuite uint16
+ ocspResponse []byte // stapled OCSP response
+ peerCertificates []*x509.Certificate
+ // verifiedChains contains the certificate chains that we built, as
+ // opposed to the ones presented by the server.
+ verifiedChains [][]*x509.Certificate
+ // serverName contains the server name indicated by the client, if any.
+ serverName string
+
+ clientProtocol string
+ clientProtocolFallback bool
+
+ // first permanent error
+ connErr
+
+ // input/output
+ in, out halfConn // in.Mutex < out.Mutex
+ rawInput *block // raw input, right off the wire
+ input *block // application data waiting to be read
+ hb *block // heartbeat data waiting to be read
+ hand bytes.Buffer // handshake data waiting to be read
+
+ tmp [16]byte
+}
+
+type connErr struct {
+ mu sync.Mutex
+ value error
+}
+
+func (e *connErr) setError(err error) error {
+ e.mu.Lock()
+ defer e.mu.Unlock()
+
+ if e.value == nil {
+ e.value = err
+ }
+ return err
+}
+
+func (e *connErr) error() error {
+ e.mu.Lock()
+ defer e.mu.Unlock()
+ return e.value
+}
+
+// Access to net.Conn methods.
+// Cannot just embed net.Conn because that would
+// export the struct field too.
+
+// LocalAddr returns the local network address.
+func (c *Conn) LocalAddr() net.Addr {
+ return c.conn.LocalAddr()
+}
+
+// RemoteAddr returns the remote network address.
+func (c *Conn) RemoteAddr() net.Addr {
+ return c.conn.RemoteAddr()
+}
+
+// SetDeadline sets the read and write deadlines associated with the connection.
+// A zero value for t means Read and Write will not time out.
+// After a Write has timed out, the TLS state is corrupt and all future writes will return the same error.
+func (c *Conn) SetDeadline(t time.Time) error {
+ return c.conn.SetDeadline(t)
+}
+
+// SetReadDeadline sets the read deadline on the underlying connection.
+// A zero value for t means Read will not time out.
+func (c *Conn) SetReadDeadline(t time.Time) error {
+ return c.conn.SetReadDeadline(t)
+}
+
+// SetWriteDeadline sets the write deadline on the underlying conneciton.
+// A zero value for t means Write will not time out.
+// After a Write has timed out, the TLS state is corrupt and all future writes will return the same error.
+func (c *Conn) SetWriteDeadline(t time.Time) error {
+ return c.conn.SetWriteDeadline(t)
+}
+
+// A halfConn represents one direction of the record layer
+// connection, either sending or receiving.
+type halfConn struct {
+ sync.Mutex
+ version uint16 // protocol version
+ cipher interface{} // cipher algorithm
+ mac macFunction
+ seq [8]byte // 64-bit sequence number
+ bfree *block // list of free blocks
+
+ nextCipher interface{} // next encryption state
+ nextMac macFunction // next MAC algorithm
+
+ // used to save allocating a new buffer for each MAC.
+ inDigestBuf, outDigestBuf []byte
+}
+
+// prepareCipherSpec sets the encryption and MAC states
+// that a subsequent changeCipherSpec will use.
+func (hc *halfConn) prepareCipherSpec(version uint16, cipher interface{}, mac macFunction) {
+ hc.version = version
+ hc.nextCipher = cipher
+ hc.nextMac = mac
+}
+
+// changeCipherSpec changes the encryption and MAC states
+// to the ones previously passed to prepareCipherSpec.
+func (hc *halfConn) changeCipherSpec() error {
+ if hc.nextCipher == nil {
+ return alertInternalError
+ }
+ hc.cipher = hc.nextCipher
+ hc.mac = hc.nextMac
+ hc.nextCipher = nil
+ hc.nextMac = nil
+ for i := range hc.seq {
+ hc.seq[i] = 0
+ }
+ return nil
+}
+
+// incSeq increments the sequence number.
+func (hc *halfConn) incSeq() {
+ for i := 7; i >= 0; i-- {
+ hc.seq[i]++
+ if hc.seq[i] != 0 {
+ return
+ }
+ }
+
+ // Not allowed to let sequence number wrap.
+ // Instead, must renegotiate before it does.
+ // Not likely enough to bother.
+ panic("TLS: sequence number wraparound")
+}
+
+// resetSeq resets the sequence number to zero.
+func (hc *halfConn) resetSeq() {
+ for i := range hc.seq {
+ hc.seq[i] = 0
+ }
+}
+
+// removePadding returns an unpadded slice, in constant time, which is a prefix
+// of the input. It also returns a byte which is equal to 255 if the padding
+// was valid and 0 otherwise. See RFC 2246, section 6.2.3.2
+func removePadding(payload []byte) ([]byte, byte) {
+ if len(payload) < 1 {
+ return payload, 0
+ }
+
+ paddingLen := payload[len(payload)-1]
+ t := uint(len(payload)-1) - uint(paddingLen)
+ // if len(payload) >= (paddingLen - 1) then the MSB of t is zero
+ good := byte(int32(^t) >> 31)
+
+ toCheck := 255 // the maximum possible padding length
+ // The length of the padded data is public, so we can use an if here
+ if toCheck+1 > len(payload) {
+ toCheck = len(payload) - 1
+ }
+
+ for i := 0; i < toCheck; i++ {
+ t := uint(paddingLen) - uint(i)
+ // if i <= paddingLen then the MSB of t is zero
+ mask := byte(int32(^t) >> 31)
+ b := payload[len(payload)-1-i]
+ good &^= mask&paddingLen ^ mask&b
+ }
+
+ // We AND together the bits of good and replicate the result across
+ // all the bits.
+ good &= good << 4
+ good &= good << 2
+ good &= good << 1
+ good = uint8(int8(good) >> 7)
+
+ toRemove := good&paddingLen + 1
+ return payload[:len(payload)-int(toRemove)], good
+}
+
+// removePaddingSSL30 is a replacement for removePadding in the case that the
+// protocol version is SSLv3. In this version, the contents of the padding
+// are random and cannot be checked.
+func removePaddingSSL30(payload []byte) ([]byte, byte) {
+ if len(payload) < 1 {
+ return payload, 0
+ }
+
+ paddingLen := int(payload[len(payload)-1]) + 1
+ if paddingLen > len(payload) {
+ return payload, 0
+ }
+
+ return payload[:len(payload)-paddingLen], 255
+}
+
+func roundUp(a, b int) int {
+ return a + (b-a%b)%b
+}
+
+// cbcMode is an interface for block ciphers using cipher block chaining.
+type cbcMode interface {
+ cipher.BlockMode
+ SetIV([]byte)
+}
+
+// decrypt checks and strips the mac and decrypts the data in b. Returns a
+// success boolean, the number of bytes to skip from the start of the record in
+// order to get the application payload, and an optional alert value.
+func (hc *halfConn) decrypt(b *block) (ok bool, prefixLen int, alertValue alert) {
+ // pull out payload
+ payload := b.data[recordHeaderLen:]
+
+ macSize := 0
+ if hc.mac != nil {
+ macSize = hc.mac.Size()
+ }
+
+ paddingGood := byte(255)
+ explicitIVLen := 0
+
+ // decrypt
+ if hc.cipher != nil {
+ switch c := hc.cipher.(type) {
+ case cipher.Stream:
+ c.XORKeyStream(payload, payload)
+ case cipher.AEAD:
+ explicitIVLen = 8
+ if len(payload) < explicitIVLen {
+ return false, 0, alertBadRecordMAC
+ }
+ nonce := payload[:8]
+ payload = payload[8:]
+
+ var additionalData [13]byte
+ copy(additionalData[:], hc.seq[:])
+ copy(additionalData[8:], b.data[:3])
+ n := len(payload) - c.Overhead()
+ additionalData[11] = byte(n >> 8)
+ additionalData[12] = byte(n)
+ var err error
+ payload, err = c.Open(payload[:0], nonce, payload, additionalData[:])
+ if err != nil {
+ return false, 0, alertBadRecordMAC
+ }
+ b.resize(recordHeaderLen + explicitIVLen + len(payload))
+ case cbcMode:
+ blockSize := c.BlockSize()
+ if hc.version >= VersionTLS11 {
+ explicitIVLen = blockSize
+ }
+
+ if len(payload)%blockSize != 0 || len(payload) < roundUp(explicitIVLen+macSize+1, blockSize) {
+ return false, 0, alertBadRecordMAC
+ }
+
+ if explicitIVLen > 0 {
+ c.SetIV(payload[:explicitIVLen])
+ payload = payload[explicitIVLen:]
+ }
+ c.CryptBlocks(payload, payload)
+ if hc.version == VersionSSL30 {
+ payload, paddingGood = removePaddingSSL30(payload)
+ } else {
+ payload, paddingGood = removePadding(payload)
+ }
+ b.resize(recordHeaderLen + explicitIVLen + len(payload))
+
+ // note that we still have a timing side-channel in the
+ // MAC check, below. An attacker can align the record
+ // so that a correct padding will cause one less hash
+ // block to be calculated. Then they can iteratively
+ // decrypt a record by breaking each byte. See
+ // "Password Interception in a SSL/TLS Channel", Brice
+ // Canvel et al.
+ //
+ // However, our behavior matches OpenSSL, so we leak
+ // only as much as they do.
+ default:
+ panic("unknown cipher type")
+ }
+ }
+
+ // check, strip mac
+ if hc.mac != nil {
+ if len(payload) < macSize {
+ return false, 0, alertBadRecordMAC
+ }
+
+ // strip mac off payload, b.data
+ n := len(payload) - macSize
+ b.data[3] = byte(n >> 8)
+ b.data[4] = byte(n)
+ b.resize(recordHeaderLen + explicitIVLen + n)
+ remoteMAC := payload[n:]
+ localMAC := hc.mac.MAC(hc.inDigestBuf, hc.seq[0:], b.data[:recordHeaderLen], payload[:n])
+
+ if subtle.ConstantTimeCompare(localMAC, remoteMAC) != 1 || paddingGood != 255 {
+ return false, 0, alertBadRecordMAC
+ }
+ hc.inDigestBuf = localMAC
+ }
+ hc.incSeq()
+
+ return true, recordHeaderLen + explicitIVLen, 0
+}
+
+// padToBlockSize calculates the needed padding block, if any, for a payload.
+// On exit, prefix aliases payload and extends to the end of the last full
+// block of payload. finalBlock is a fresh slice which contains the contents of
+// any suffix of payload as well as the needed padding to make finalBlock a
+// full block.
+func padToBlockSize(payload []byte, blockSize int) (prefix, finalBlock []byte) {
+ overrun := len(payload) % blockSize
+ paddingLen := blockSize - overrun
+ prefix = payload[:len(payload)-overrun]
+ finalBlock = make([]byte, blockSize)
+ copy(finalBlock, payload[len(payload)-overrun:])
+ for i := overrun; i < blockSize; i++ {
+ finalBlock[i] = byte(paddingLen - 1)
+ }
+ return
+}
+
+// encrypt encrypts and macs the data in b.
+func (hc *halfConn) encrypt(b *block, explicitIVLen int) (bool, alert) {
+ // mac
+ if hc.mac != nil {
+ mac := hc.mac.MAC(hc.outDigestBuf, hc.seq[0:], b.data[:recordHeaderLen], b.data[recordHeaderLen+explicitIVLen:])
+
+ n := len(b.data)
+ b.resize(n + len(mac))
+ copy(b.data[n:], mac)
+ hc.outDigestBuf = mac
+ }
+
+ payload := b.data[recordHeaderLen:]
+
+ // encrypt
+ if hc.cipher != nil {
+ switch c := hc.cipher.(type) {
+ case cipher.Stream:
+ c.XORKeyStream(payload, payload)
+ case cipher.AEAD:
+ payloadLen := len(b.data) - recordHeaderLen - explicitIVLen
+ b.resize(len(b.data) + c.Overhead())
+ nonce := b.data[recordHeaderLen : recordHeaderLen+explicitIVLen]
+ payload := b.data[recordHeaderLen+explicitIVLen:]
+ payload = payload[:payloadLen]
+
+ var additionalData [13]byte
+ copy(additionalData[:], hc.seq[:])
+ copy(additionalData[8:], b.data[:3])
+ additionalData[11] = byte(payloadLen >> 8)
+ additionalData[12] = byte(payloadLen)
+
+ c.Seal(payload[:0], nonce, payload, additionalData[:])
+ case cbcMode:
+ blockSize := c.BlockSize()
+ if explicitIVLen > 0 {
+ c.SetIV(payload[:explicitIVLen])
+ payload = payload[explicitIVLen:]
+ }
+ prefix, finalBlock := padToBlockSize(payload, blockSize)
+ b.resize(recordHeaderLen + explicitIVLen + len(prefix) + len(finalBlock))
+ c.CryptBlocks(b.data[recordHeaderLen+explicitIVLen:], prefix)
+ c.CryptBlocks(b.data[recordHeaderLen+explicitIVLen+len(prefix):], finalBlock)
+ default:
+ panic("unknown cipher type")
+ }
+ }
+
+ // update length to include MAC and any block padding needed.
+ n := len(b.data) - recordHeaderLen
+ b.data[3] = byte(n >> 8)
+ b.data[4] = byte(n)
+ hc.incSeq()
+
+ return true, 0
+}
+
+// A block is a simple data buffer.
+type block struct {
+ data []byte
+ off int // index for Read
+ link *block
+}
+
+// resize resizes block to be n bytes, growing if necessary.
+func (b *block) resize(n int) {
+ if n > cap(b.data) {
+ b.reserve(n)
+ }
+ b.data = b.data[0:n]
+}
+
+// reserve makes sure that block contains a capacity of at least n bytes.
+func (b *block) reserve(n int) {
+ if cap(b.data) >= n {
+ return
+ }
+ m := cap(b.data)
+ if m == 0 {
+ m = 1024
+ }
+ for m < n {
+ m *= 2
+ }
+ data := make([]byte, len(b.data), m)
+ copy(data, b.data)
+ b.data = data
+}
+
+// readFromUntil reads from r into b until b contains at least n bytes
+// or else returns an error.
+func (b *block) readFromUntil(r io.Reader, n int) error {
+ // quick case
+ if len(b.data) >= n {
+ return nil
+ }
+
+ // read until have enough.
+ b.reserve(n)
+ for {
+ m, err := r.Read(b.data[len(b.data):cap(b.data)])
+ b.data = b.data[0 : len(b.data)+m]
+ if len(b.data) >= n {
+ break
+ }
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (b *block) Read(p []byte) (n int, err error) {
+ n = copy(p, b.data[b.off:])
+ b.off += n
+ return
+}
+
+// newBlock allocates a new block, from hc's free list if possible.
+func (hc *halfConn) newBlock() *block {
+ b := hc.bfree
+ if b == nil {
+ return new(block)
+ }
+ hc.bfree = b.link
+ b.link = nil
+ b.resize(0)
+ return b
+}
+
+// freeBlock returns a block to hc's free list.
+// The protocol is such that each side only has a block or two on
+// its free list at a time, so there's no need to worry about
+// trimming the list, etc.
+func (hc *halfConn) freeBlock(b *block) {
+ b.link = hc.bfree
+ hc.bfree = b
+}
+
+// splitBlock splits a block after the first n bytes,
+// returning a block with those n bytes and a
+// block with the remainder. the latter may be nil.
+func (hc *halfConn) splitBlock(b *block, n int) (*block, *block) {
+ if len(b.data) <= n {
+ return b, nil
+ }
+ bb := hc.newBlock()
+ bb.resize(len(b.data) - n)
+ copy(bb.data, b.data[n:])
+ b.data = b.data[0:n]
+ return b, bb
+}
+
+// readRecord reads the next TLS record from the connection
+// and updates the record layer state.
+// c.in.Mutex <= L; c.input == nil.
+func (c *Conn) readRecord(want recordType) error {
+ // Caller must be in sync with connection:
+ // handshake data if handshake not yet completed,
+ // else application data. (We don't support renegotiation.)
+ switch want {
+ default:
+ return c.sendAlert(alertInternalError)
+ case recordTypeHandshake, recordTypeChangeCipherSpec:
+ if c.handshakeComplete {
+ return c.sendAlert(alertInternalError)
+ }
+ case recordTypeApplicationData, recordTypeHeartbeat:
+ if !c.handshakeComplete {
+ return c.sendAlert(alertInternalError)
+ }
+ }
+
+Again:
+ if c.rawInput == nil {
+ c.rawInput = c.in.newBlock()
+ }
+ b := c.rawInput
+
+ // Read header, payload.
+ if err := b.readFromUntil(c.conn, recordHeaderLen); err != nil {
+ // RFC suggests that EOF without an alertCloseNotify is
+ // an error, but popular web sites seem to do this,
+ // so we can't make it an error.
+ // if err == io.EOF {
+ // err = io.ErrUnexpectedEOF
+ // }
+ if e, ok := err.(net.Error); !ok || !e.Temporary() {
+ c.setError(err)
+ }
+ return err
+ }
+ typ := recordType(b.data[0])
+
+ // No valid TLS record has a type of 0x80, however SSLv2 handshakes
+ // start with a uint16 length where the MSB is set and the first record
+ // is always < 256 bytes long. Therefore typ == 0x80 strongly suggests
+ // an SSLv2 client.
+ if want == recordTypeHandshake && typ == 0x80 {
+ c.sendAlert(alertProtocolVersion)
+ return errors.New("tls: unsupported SSLv2 handshake received")
+ }
+
+ vers := uint16(b.data[1])<<8 | uint16(b.data[2])
+ n := int(b.data[3])<<8 | int(b.data[4])
+ if c.haveVers && vers != c.vers {
+ return c.sendAlert(alertProtocolVersion)
+ }
+ if n > maxCiphertext {
+ return c.sendAlert(alertRecordOverflow)
+ }
+ if !c.haveVers {
+ // First message, be extra suspicious:
+ // this might not be a TLS client.
+ // Bail out before reading a full 'body', if possible.
+ // The current max version is 3.1.
+ // If the version is >= 16.0, it's probably not real.
+ // Similarly, a clientHello message encodes in
+ // well under a kilobyte. If the length is >= 12 kB,
+ // it's probably not real.
+ if (typ != recordTypeAlert && typ != want) || vers >= 0x1000 || n >= 0x3000 {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+ }
+ if err := b.readFromUntil(c.conn, recordHeaderLen+n); err != nil {
+ if err == io.EOF {
+ err = io.ErrUnexpectedEOF
+ }
+ if e, ok := err.(net.Error); !ok || !e.Temporary() {
+ c.setError(err)
+ }
+ return err
+ }
+
+ // Process message.
+ b, c.rawInput = c.in.splitBlock(b, recordHeaderLen+n)
+ ok, off, err := c.in.decrypt(b)
+ if !ok {
+ return c.sendAlert(err)
+ }
+ b.off = off
+ data := b.data[b.off:]
+ if len(data) > maxPlaintext {
+ c.sendAlert(alertRecordOverflow)
+ c.in.freeBlock(b)
+ return c.error()
+ }
+
+ switch typ {
+ default:
+ c.sendAlert(alertUnexpectedMessage)
+
+ case recordTypeAlert:
+ if len(data) != 2 {
+ c.sendAlert(alertUnexpectedMessage)
+ break
+ }
+ if alert(data[1]) == alertCloseNotify {
+ c.setError(io.EOF)
+ break
+ }
+ switch data[0] {
+ case alertLevelWarning:
+ // drop on the floor
+ c.in.freeBlock(b)
+ goto Again
+ case alertLevelError:
+ c.setError(&net.OpError{Op: "remote error", Err: alert(data[1])})
+ default:
+ c.sendAlert(alertUnexpectedMessage)
+ }
+
+ case recordTypeChangeCipherSpec:
+ if typ != want || len(data) != 1 || data[0] != 1 {
+ c.sendAlert(alertUnexpectedMessage)
+ break
+ }
+ err := c.in.changeCipherSpec()
+ if err != nil {
+ c.sendAlert(err.(alert))
+ }
+
+ case recordTypeHeartbeat:
+ if typ != want {
+ c.sendAlert(alertUnexpectedMessage)
+ break
+ }
+ c.hb = b
+ b = nil
+
+ case recordTypeApplicationData:
+ if typ != want {
+ c.sendAlert(alertUnexpectedMessage)
+ break
+ }
+ c.input = b
+ b = nil
+
+ case recordTypeHandshake:
+ // TODO(rsc): Should at least pick off connection close.
+ if typ != want {
+ return c.sendAlert(alertNoRenegotiation)
+ }
+ c.hand.Write(data)
+ }
+
+ if b != nil {
+ c.in.freeBlock(b)
+ }
+ return c.error()
+}
+
+// sendAlert sends a TLS alert message.
+// c.out.Mutex <= L.
+func (c *Conn) sendAlertLocked(err alert) error {
+ switch err {
+ case alertNoRenegotiation, alertCloseNotify:
+ c.tmp[0] = alertLevelWarning
+ default:
+ c.tmp[0] = alertLevelError
+ }
+ c.tmp[1] = byte(err)
+ c.writeRecord(recordTypeAlert, c.tmp[0:2])
+ // closeNotify is a special case in that it isn't an error:
+ if err != alertCloseNotify {
+ return c.setError(&net.OpError{Op: "local error", Err: err})
+ }
+ return nil
+}
+
+// sendAlert sends a TLS alert message.
+// L < c.out.Mutex.
+func (c *Conn) sendAlert(err alert) error {
+ c.out.Lock()
+ defer c.out.Unlock()
+ return c.sendAlertLocked(err)
+}
+
+// writeRecord writes a TLS record with the given type and payload
+// to the connection and updates the record layer state.
+// c.out.Mutex <= L.
+func (c *Conn) writeRecord(typ recordType, data []byte) (n int, err error) {
+ b := c.out.newBlock()
+ for len(data) > 0 {
+ m := len(data)
+ if m > maxPlaintext {
+ m = maxPlaintext
+ }
+ explicitIVLen := 0
+ explicitIVIsSeq := false
+
+ var cbc cbcMode
+ if c.out.version >= VersionTLS11 {
+ var ok bool
+ if cbc, ok = c.out.cipher.(cbcMode); ok {
+ explicitIVLen = cbc.BlockSize()
+ }
+ }
+ if explicitIVLen == 0 {
+ if _, ok := c.out.cipher.(cipher.AEAD); ok {
+ explicitIVLen = 8
+ // The AES-GCM construction in TLS has an
+ // explicit nonce so that the nonce can be
+ // random. However, the nonce is only 8 bytes
+ // which is too small for a secure, random
+ // nonce. Therefore we use the sequence number
+ // as the nonce.
+ explicitIVIsSeq = true
+ }
+ }
+ b.resize(recordHeaderLen + explicitIVLen + m)
+ b.data[0] = byte(typ)
+ vers := c.vers
+ if vers == 0 {
+ // Some TLS servers fail if the record version is
+ // greater than TLS 1.0 for the initial ClientHello.
+ vers = VersionTLS10
+ }
+ b.data[1] = byte(vers >> 8)
+ b.data[2] = byte(vers)
+ b.data[3] = byte(m >> 8)
+ b.data[4] = byte(m)
+ if explicitIVLen > 0 {
+ explicitIV := b.data[recordHeaderLen : recordHeaderLen+explicitIVLen]
+ if explicitIVIsSeq {
+ copy(explicitIV, c.out.seq[:])
+ } else {
+ if _, err = io.ReadFull(c.config.rand(), explicitIV); err != nil {
+ break
+ }
+ }
+ }
+ copy(b.data[recordHeaderLen+explicitIVLen:], data)
+ c.out.encrypt(b, explicitIVLen)
+ _, err = c.conn.Write(b.data)
+ if err != nil {
+ break
+ }
+ n += m
+ data = data[m:]
+ }
+ c.out.freeBlock(b)
+
+ if typ == recordTypeChangeCipherSpec {
+ err = c.out.changeCipherSpec()
+ if err != nil {
+ // Cannot call sendAlert directly,
+ // because we already hold c.out.Mutex.
+ c.tmp[0] = alertLevelError
+ c.tmp[1] = byte(err.(alert))
+ c.writeRecord(recordTypeAlert, c.tmp[0:2])
+ return n, c.setError(&net.OpError{Op: "local error", Err: err})
+ }
+ }
+ return
+}
+
+// readHandshake reads the next handshake message from
+// the record layer.
+// c.in.Mutex < L; c.out.Mutex < L.
+func (c *Conn) readHandshake() (interface{}, error) {
+ for c.hand.Len() < 4 {
+ if err := c.error(); err != nil {
+ return nil, err
+ }
+ if err := c.readRecord(recordTypeHandshake); err != nil {
+ return nil, err
+ }
+ }
+
+ data := c.hand.Bytes()
+ n := int(data[1])<<16 | int(data[2])<<8 | int(data[3])
+ if n > maxHandshake {
+ c.sendAlert(alertInternalError)
+ return nil, c.error()
+ }
+ for c.hand.Len() < 4+n {
+ if err := c.error(); err != nil {
+ return nil, err
+ }
+ if err := c.readRecord(recordTypeHandshake); err != nil {
+ return nil, err
+ }
+ }
+ data = c.hand.Next(4 + n)
+ var m handshakeMessage
+ switch data[0] {
+ case typeClientHello:
+ m = new(clientHelloMsg)
+ case typeServerHello:
+ m = new(serverHelloMsg)
+ case typeCertificate:
+ m = new(certificateMsg)
+ case typeCertificateRequest:
+ m = &certificateRequestMsg{
+ hasSignatureAndHash: c.vers >= VersionTLS12,
+ }
+ case typeCertificateStatus:
+ m = new(certificateStatusMsg)
+ case typeServerKeyExchange:
+ m = new(serverKeyExchangeMsg)
+ case typeServerHelloDone:
+ m = new(serverHelloDoneMsg)
+ case typeClientKeyExchange:
+ m = new(clientKeyExchangeMsg)
+ case typeCertificateVerify:
+ m = &certificateVerifyMsg{
+ hasSignatureAndHash: c.vers >= VersionTLS12,
+ }
+ case typeNextProtocol:
+ m = new(nextProtoMsg)
+ case typeFinished:
+ m = new(finishedMsg)
+ default:
+ c.sendAlert(alertUnexpectedMessage)
+ return nil, alertUnexpectedMessage
+ }
+
+ // The handshake message unmarshallers
+ // expect to be able to keep references to data,
+ // so pass in a fresh copy that won't be overwritten.
+ data = append([]byte(nil), data...)
+
+ if !m.unmarshal(data) {
+ c.sendAlert(alertUnexpectedMessage)
+ return nil, alertUnexpectedMessage
+ }
+ return m, nil
+}
+
+// Write writes data to the connection.
+func (c *Conn) Write(b []byte) (int, error) {
+ if err := c.error(); err != nil {
+ return 0, err
+ }
+
+ if err := c.Handshake(); err != nil {
+ return 0, c.setError(err)
+ }
+
+ c.out.Lock()
+ defer c.out.Unlock()
+
+ if !c.handshakeComplete {
+ return 0, alertInternalError
+ }
+
+ // SSL 3.0 and TLS 1.0 are susceptible to a chosen-plaintext
+ // attack when using block mode ciphers due to predictable IVs.
+ // This can be prevented by splitting each Application Data
+ // record into two records, effectively randomizing the IV.
+ //
+ // http://www.openssl.org/~bodo/tls-cbc.txt
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=665814
+ // http://www.imperialviolet.org/2012/01/15/beastfollowup.html
+
+ var m int
+ if len(b) > 1 && c.vers <= VersionTLS10 {
+ if _, ok := c.out.cipher.(cipher.BlockMode); ok {
+ n, err := c.writeRecord(recordTypeApplicationData, b[:1])
+ if err != nil {
+ return n, c.setError(err)
+ }
+ m, b = 1, b[1:]
+ }
+ }
+
+ n, err := c.writeRecord(recordTypeApplicationData, b)
+ return n + m, c.setError(err)
+}
+
+// Read can be made to time out and return a net.Error with Timeout() == true
+// after a fixed time limit; see SetDeadline and SetReadDeadline.
+func (c *Conn) Read(b []byte) (n int, err error) {
+ if err = c.Handshake(); err != nil {
+ return
+ }
+
+ c.in.Lock()
+ defer c.in.Unlock()
+
+ // Some OpenSSL servers send empty records in order to randomize the
+ // CBC IV. So this loop ignores a limited number of empty records.
+ const maxConsecutiveEmptyRecords = 100
+ for emptyRecordCount := 0; emptyRecordCount <= maxConsecutiveEmptyRecords; emptyRecordCount++ {
+ for c.input == nil && c.error() == nil {
+ if err := c.readRecord(recordTypeApplicationData); err != nil {
+ // Soft error, like EAGAIN
+ return 0, err
+ }
+ }
+ if err := c.error(); err != nil {
+ return 0, err
+ }
+
+ n, err = c.input.Read(b)
+ if c.input.off >= len(c.input.data) {
+ c.in.freeBlock(c.input)
+ c.input = nil
+ }
+
+ if n != 0 || err != nil {
+ return n, err
+ }
+ }
+
+ return 0, io.ErrNoProgress
+}
+
+// Close closes the connection.
+func (c *Conn) Close() error {
+ var alertErr error
+
+ c.handshakeMutex.Lock()
+ defer c.handshakeMutex.Unlock()
+ if c.handshakeComplete {
+ alertErr = c.sendAlert(alertCloseNotify)
+ }
+
+ if err := c.conn.Close(); err != nil {
+ return err
+ }
+ return alertErr
+}
+
+// Handshake runs the client or server handshake
+// protocol if it has not yet been run.
+// Most uses of this package need not call Handshake
+// explicitly: the first Read or Write will call it automatically.
+func (c *Conn) Handshake() error {
+ c.handshakeMutex.Lock()
+ defer c.handshakeMutex.Unlock()
+ if err := c.error(); err != nil {
+ return err
+ }
+ if c.handshakeComplete {
+ return nil
+ }
+ if c.isClient {
+ return c.clientHandshake()
+ }
+ return c.serverHandshake()
+}
+
+// ConnectionState returns basic TLS details about the connection.
+func (c *Conn) ConnectionState() ConnectionState {
+ c.handshakeMutex.Lock()
+ defer c.handshakeMutex.Unlock()
+
+ var state ConnectionState
+ state.HandshakeComplete = c.handshakeComplete
+ if c.handshakeComplete {
+ state.NegotiatedProtocol = c.clientProtocol
+ state.DidResume = c.didResume
+ state.NegotiatedProtocolIsMutual = !c.clientProtocolFallback
+ state.CipherSuite = c.cipherSuite
+ state.PeerCertificates = c.peerCertificates
+ state.VerifiedChains = c.verifiedChains
+ state.ServerName = c.serverName
+ }
+
+ return state
+}
+
+// OCSPResponse returns the stapled OCSP response from the TLS server, if
+// any. (Only valid for client connections.)
+func (c *Conn) OCSPResponse() []byte {
+ c.handshakeMutex.Lock()
+ defer c.handshakeMutex.Unlock()
+
+ return c.ocspResponse
+}
+
+// VerifyHostname checks that the peer certificate chain is valid for
+// connecting to host. If so, it returns nil; if not, it returns an error
+// describing the problem.
+func (c *Conn) VerifyHostname(host string) error {
+ c.handshakeMutex.Lock()
+ defer c.handshakeMutex.Unlock()
+ if !c.isClient {
+ return errors.New("VerifyHostname called on TLS server connection")
+ }
+ if !c.handshakeComplete {
+ return errors.New("TLS handshake has not yet been performed")
+ }
+ return c.peerCertificates[0].VerifyHostname(host)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_client.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_client.go
new file mode 100644
index 00000000..ed8b3130
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_client.go
@@ -0,0 +1,411 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "bytes"
+ "crypto/ecdsa"
+ "crypto/rsa"
+ "crypto/subtle"
+ "crypto/x509"
+ "encoding/asn1"
+ "errors"
+ "io"
+ "strconv"
+)
+
+func (c *Conn) clientHandshake() error {
+ if c.config == nil {
+ c.config = defaultConfig()
+ }
+
+ hello := &clientHelloMsg{
+ vers: c.config.maxVersion(),
+ compressionMethods: []uint8{compressionNone},
+ random: make([]byte, 32),
+ ocspStapling: true,
+ serverName: c.config.ServerName,
+ supportedCurves: []uint16{curveP256, curveP384, curveP521},
+ supportedPoints: []uint8{pointFormatUncompressed},
+ nextProtoNeg: len(c.config.NextProtos) > 0,
+ }
+
+ possibleCipherSuites := c.config.cipherSuites()
+ hello.cipherSuites = make([]uint16, 0, len(possibleCipherSuites))
+
+NextCipherSuite:
+ for _, suiteId := range possibleCipherSuites {
+ for _, suite := range cipherSuites {
+ if suite.id != suiteId {
+ continue
+ }
+ // Don't advertise TLS 1.2-only cipher suites unless
+ // we're attempting TLS 1.2.
+ if hello.vers < VersionTLS12 && suite.flags&suiteTLS12 != 0 {
+ continue
+ }
+ hello.cipherSuites = append(hello.cipherSuites, suiteId)
+ continue NextCipherSuite
+ }
+ }
+
+ t := uint32(c.config.time().Unix())
+ hello.random[0] = byte(t >> 24)
+ hello.random[1] = byte(t >> 16)
+ hello.random[2] = byte(t >> 8)
+ hello.random[3] = byte(t)
+ _, err := io.ReadFull(c.config.rand(), hello.random[4:])
+ if err != nil {
+ c.sendAlert(alertInternalError)
+ return errors.New("short read from Rand")
+ }
+
+ if hello.vers >= VersionTLS12 {
+ hello.signatureAndHashes = supportedSKXSignatureAlgorithms
+ }
+
+ c.writeRecord(recordTypeHandshake, hello.marshal())
+
+ msg, err := c.readHandshake()
+ if err != nil {
+ return err
+ }
+ serverHello, ok := msg.(*serverHelloMsg)
+ if !ok {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+
+ vers, ok := c.config.mutualVersion(serverHello.vers)
+ if !ok || vers < VersionTLS10 {
+ // TLS 1.0 is the minimum version supported as a client.
+ return c.sendAlert(alertProtocolVersion)
+ }
+ c.vers = vers
+ c.haveVers = true
+
+ finishedHash := newFinishedHash(c.vers)
+ finishedHash.Write(hello.marshal())
+ finishedHash.Write(serverHello.marshal())
+
+ if serverHello.compressionMethod != compressionNone {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+
+ if !hello.nextProtoNeg && serverHello.nextProtoNeg {
+ c.sendAlert(alertHandshakeFailure)
+ return errors.New("server advertised unrequested NPN")
+ }
+
+ suite := mutualCipherSuite(c.config.cipherSuites(), serverHello.cipherSuite)
+ if suite == nil {
+ return c.sendAlert(alertHandshakeFailure)
+ }
+
+ msg, err = c.readHandshake()
+ if err != nil {
+ return err
+ }
+ certMsg, ok := msg.(*certificateMsg)
+ if !ok || len(certMsg.certificates) == 0 {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+ finishedHash.Write(certMsg.marshal())
+
+ certs := make([]*x509.Certificate, len(certMsg.certificates))
+ for i, asn1Data := range certMsg.certificates {
+ cert, err := x509.ParseCertificate(asn1Data)
+ if err != nil {
+ c.sendAlert(alertBadCertificate)
+ return errors.New("failed to parse certificate from server: " + err.Error())
+ }
+ certs[i] = cert
+ }
+
+ if !c.config.InsecureSkipVerify {
+ opts := x509.VerifyOptions{
+ Roots: c.config.RootCAs,
+ CurrentTime: c.config.time(),
+ DNSName: c.config.ServerName,
+ Intermediates: x509.NewCertPool(),
+ }
+
+ for i, cert := range certs {
+ if i == 0 {
+ continue
+ }
+ opts.Intermediates.AddCert(cert)
+ }
+ c.verifiedChains, err = certs[0].Verify(opts)
+ if err != nil {
+ c.sendAlert(alertBadCertificate)
+ return err
+ }
+ }
+
+ switch certs[0].PublicKey.(type) {
+ case *rsa.PublicKey, *ecdsa.PublicKey:
+ break
+ default:
+ return c.sendAlert(alertUnsupportedCertificate)
+ }
+
+ c.peerCertificates = certs
+
+ if serverHello.ocspStapling {
+ msg, err = c.readHandshake()
+ if err != nil {
+ return err
+ }
+ cs, ok := msg.(*certificateStatusMsg)
+ if !ok {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+ finishedHash.Write(cs.marshal())
+
+ if cs.statusType == statusTypeOCSP {
+ c.ocspResponse = cs.response
+ }
+ }
+
+ msg, err = c.readHandshake()
+ if err != nil {
+ return err
+ }
+
+ keyAgreement := suite.ka(c.vers)
+
+ skx, ok := msg.(*serverKeyExchangeMsg)
+ if ok {
+ finishedHash.Write(skx.marshal())
+ err = keyAgreement.processServerKeyExchange(c.config, hello, serverHello, certs[0], skx)
+ if err != nil {
+ c.sendAlert(alertUnexpectedMessage)
+ return err
+ }
+
+ msg, err = c.readHandshake()
+ if err != nil {
+ return err
+ }
+ }
+
+ var chainToSend *Certificate
+ var certRequested bool
+ certReq, ok := msg.(*certificateRequestMsg)
+ if ok {
+ certRequested = true
+
+ // RFC 4346 on the certificateAuthorities field:
+ // A list of the distinguished names of acceptable certificate
+ // authorities. These distinguished names may specify a desired
+ // distinguished name for a root CA or for a subordinate CA;
+ // thus, this message can be used to describe both known roots
+ // and a desired authorization space. If the
+ // certificate_authorities list is empty then the client MAY
+ // send any certificate of the appropriate
+ // ClientCertificateType, unless there is some external
+ // arrangement to the contrary.
+
+ finishedHash.Write(certReq.marshal())
+
+ var rsaAvail, ecdsaAvail bool
+ for _, certType := range certReq.certificateTypes {
+ switch certType {
+ case certTypeRSASign:
+ rsaAvail = true
+ case certTypeECDSASign:
+ ecdsaAvail = true
+ }
+ }
+
+ // We need to search our list of client certs for one
+ // where SignatureAlgorithm is RSA and the Issuer is in
+ // certReq.certificateAuthorities
+ findCert:
+ for i, chain := range c.config.Certificates {
+ if !rsaAvail && !ecdsaAvail {
+ continue
+ }
+
+ for j, cert := range chain.Certificate {
+ x509Cert := chain.Leaf
+ // parse the certificate if this isn't the leaf
+ // node, or if chain.Leaf was nil
+ if j != 0 || x509Cert == nil {
+ if x509Cert, err = x509.ParseCertificate(cert); err != nil {
+ c.sendAlert(alertInternalError)
+ return errors.New("tls: failed to parse client certificate #" + strconv.Itoa(i) + ": " + err.Error())
+ }
+ }
+
+ switch {
+ case rsaAvail && x509Cert.PublicKeyAlgorithm == x509.RSA:
+ case ecdsaAvail && x509Cert.PublicKeyAlgorithm == x509.ECDSA:
+ default:
+ continue findCert
+ }
+
+ if len(certReq.certificateAuthorities) == 0 {
+ // they gave us an empty list, so just take the
+ // first RSA cert from c.config.Certificates
+ chainToSend = &chain
+ break findCert
+ }
+
+ for _, ca := range certReq.certificateAuthorities {
+ if bytes.Equal(x509Cert.RawIssuer, ca) {
+ chainToSend = &chain
+ break findCert
+ }
+ }
+ }
+ }
+
+ msg, err = c.readHandshake()
+ if err != nil {
+ return err
+ }
+ }
+
+ shd, ok := msg.(*serverHelloDoneMsg)
+ if !ok {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+ finishedHash.Write(shd.marshal())
+
+ // If the server requested a certificate then we have to send a
+ // Certificate message, even if it's empty because we don't have a
+ // certificate to send.
+ if certRequested {
+ certMsg = new(certificateMsg)
+ if chainToSend != nil {
+ certMsg.certificates = chainToSend.Certificate
+ }
+ finishedHash.Write(certMsg.marshal())
+ c.writeRecord(recordTypeHandshake, certMsg.marshal())
+ }
+
+ preMasterSecret, ckx, err := keyAgreement.generateClientKeyExchange(c.config, hello, certs[0])
+ if err != nil {
+ c.sendAlert(alertInternalError)
+ return err
+ }
+ if ckx != nil {
+ finishedHash.Write(ckx.marshal())
+ c.writeRecord(recordTypeHandshake, ckx.marshal())
+ }
+
+ if chainToSend != nil {
+ var signed []byte
+ certVerify := &certificateVerifyMsg{
+ hasSignatureAndHash: c.vers >= VersionTLS12,
+ }
+
+ switch key := c.config.Certificates[0].PrivateKey.(type) {
+ case *ecdsa.PrivateKey:
+ digest, _, hashId := finishedHash.hashForClientCertificate(signatureECDSA)
+ r, s, err := ecdsa.Sign(c.config.rand(), key, digest)
+ if err == nil {
+ signed, err = asn1.Marshal(ecdsaSignature{r, s})
+ }
+ certVerify.signatureAndHash.signature = signatureECDSA
+ certVerify.signatureAndHash.hash = hashId
+ case *rsa.PrivateKey:
+ digest, hashFunc, hashId := finishedHash.hashForClientCertificate(signatureRSA)
+ signed, err = rsa.SignPKCS1v15(c.config.rand(), key, hashFunc, digest)
+ certVerify.signatureAndHash.signature = signatureRSA
+ certVerify.signatureAndHash.hash = hashId
+ default:
+ err = errors.New("unknown private key type")
+ }
+ if err != nil {
+ return c.sendAlert(alertInternalError)
+ }
+ certVerify.signature = signed
+
+ finishedHash.Write(certVerify.marshal())
+ c.writeRecord(recordTypeHandshake, certVerify.marshal())
+ }
+
+ masterSecret := masterFromPreMasterSecret(c.vers, preMasterSecret, hello.random, serverHello.random)
+ clientMAC, serverMAC, clientKey, serverKey, clientIV, serverIV :=
+ keysFromMasterSecret(c.vers, masterSecret, hello.random, serverHello.random, suite.macLen, suite.keyLen, suite.ivLen)
+
+ var clientCipher interface{}
+ var clientHash macFunction
+ if suite.cipher != nil {
+ clientCipher = suite.cipher(clientKey, clientIV, false /* not for reading */)
+ clientHash = suite.mac(c.vers, clientMAC)
+ } else {
+ clientCipher = suite.aead(clientKey, clientIV)
+ }
+ c.out.prepareCipherSpec(c.vers, clientCipher, clientHash)
+ c.writeRecord(recordTypeChangeCipherSpec, []byte{1})
+
+ if serverHello.nextProtoNeg {
+ nextProto := new(nextProtoMsg)
+ proto, fallback := mutualProtocol(c.config.NextProtos, serverHello.nextProtos)
+ nextProto.proto = proto
+ c.clientProtocol = proto
+ c.clientProtocolFallback = fallback
+
+ finishedHash.Write(nextProto.marshal())
+ c.writeRecord(recordTypeHandshake, nextProto.marshal())
+ }
+
+ finished := new(finishedMsg)
+ finished.verifyData = finishedHash.clientSum(masterSecret)
+ finishedHash.Write(finished.marshal())
+ c.writeRecord(recordTypeHandshake, finished.marshal())
+
+ var serverCipher interface{}
+ var serverHash macFunction
+ if suite.cipher != nil {
+ serverCipher = suite.cipher(serverKey, serverIV, true /* for reading */)
+ serverHash = suite.mac(c.vers, serverMAC)
+ } else {
+ serverCipher = suite.aead(serverKey, serverIV)
+ }
+ c.in.prepareCipherSpec(c.vers, serverCipher, serverHash)
+ c.readRecord(recordTypeChangeCipherSpec)
+ if err := c.error(); err != nil {
+ return err
+ }
+
+ msg, err = c.readHandshake()
+ if err != nil {
+ return err
+ }
+ serverFinished, ok := msg.(*finishedMsg)
+ if !ok {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+
+ verify := finishedHash.serverSum(masterSecret)
+ if len(verify) != len(serverFinished.verifyData) ||
+ subtle.ConstantTimeCompare(verify, serverFinished.verifyData) != 1 {
+ return c.sendAlert(alertHandshakeFailure)
+ }
+
+ c.handshakeComplete = true
+ c.cipherSuite = suite.id
+ return nil
+}
+
+// mutualProtocol finds the mutual Next Protocol Negotiation protocol given the
+// set of client and server supported protocols. The set of client supported
+// protocols must not be empty. It returns the resulting protocol and flag
+// indicating if the fallback case was reached.
+func mutualProtocol(clientProtos, serverProtos []string) (string, bool) {
+ for _, s := range serverProtos {
+ for _, c := range clientProtos {
+ if s == c {
+ return s, false
+ }
+ }
+ }
+
+ return clientProtos[0], true
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_messages.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_messages.go
new file mode 100644
index 00000000..ffa92f97
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_messages.go
@@ -0,0 +1,1293 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "bytes"
+
+type clientHelloMsg struct {
+ raw []byte
+ vers uint16
+ random []byte
+ sessionId []byte
+ cipherSuites []uint16
+ compressionMethods []uint8
+ nextProtoNeg bool
+ serverName string
+ ocspStapling bool
+ supportedCurves []uint16
+ supportedPoints []uint8
+ ticketSupported bool
+ sessionTicket []uint8
+ signatureAndHashes []signatureAndHash
+}
+
+func (m *clientHelloMsg) equal(i interface{}) bool {
+ m1, ok := i.(*clientHelloMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ m.vers == m1.vers &&
+ bytes.Equal(m.random, m1.random) &&
+ bytes.Equal(m.sessionId, m1.sessionId) &&
+ eqUint16s(m.cipherSuites, m1.cipherSuites) &&
+ bytes.Equal(m.compressionMethods, m1.compressionMethods) &&
+ m.nextProtoNeg == m1.nextProtoNeg &&
+ m.serverName == m1.serverName &&
+ m.ocspStapling == m1.ocspStapling &&
+ eqUint16s(m.supportedCurves, m1.supportedCurves) &&
+ bytes.Equal(m.supportedPoints, m1.supportedPoints) &&
+ m.ticketSupported == m1.ticketSupported &&
+ bytes.Equal(m.sessionTicket, m1.sessionTicket) &&
+ eqSignatureAndHashes(m.signatureAndHashes, m1.signatureAndHashes)
+}
+
+func (m *clientHelloMsg) marshal() []byte {
+ if m.raw != nil {
+ return m.raw
+ }
+
+ length := 2 + 32 + 1 + len(m.sessionId) + 2 + len(m.cipherSuites)*2 + 1 + len(m.compressionMethods)
+ numExtensions := 0
+ extensionsLength := 0
+ if m.nextProtoNeg {
+ numExtensions++
+ }
+ if m.ocspStapling {
+ extensionsLength += 1 + 2 + 2
+ numExtensions++
+ }
+ if len(m.serverName) > 0 {
+ extensionsLength += 5 + len(m.serverName)
+ numExtensions++
+ }
+ if len(m.supportedCurves) > 0 {
+ extensionsLength += 2 + 2*len(m.supportedCurves)
+ numExtensions++
+ }
+ if len(m.supportedPoints) > 0 {
+ extensionsLength += 1 + len(m.supportedPoints)
+ numExtensions++
+ }
+ if m.ticketSupported {
+ extensionsLength += len(m.sessionTicket)
+ numExtensions++
+ }
+ if len(m.signatureAndHashes) > 0 {
+ extensionsLength += 2 + 2*len(m.signatureAndHashes)
+ numExtensions++
+ }
+ if numExtensions > 0 {
+ extensionsLength += 4 * numExtensions
+ length += 2 + extensionsLength
+ }
+
+ x := make([]byte, 4+length)
+ x[0] = typeClientHello
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+ x[4] = uint8(m.vers >> 8)
+ x[5] = uint8(m.vers)
+ copy(x[6:38], m.random)
+ x[38] = uint8(len(m.sessionId))
+ copy(x[39:39+len(m.sessionId)], m.sessionId)
+ y := x[39+len(m.sessionId):]
+ y[0] = uint8(len(m.cipherSuites) >> 7)
+ y[1] = uint8(len(m.cipherSuites) << 1)
+ for i, suite := range m.cipherSuites {
+ y[2+i*2] = uint8(suite >> 8)
+ y[3+i*2] = uint8(suite)
+ }
+ z := y[2+len(m.cipherSuites)*2:]
+ z[0] = uint8(len(m.compressionMethods))
+ copy(z[1:], m.compressionMethods)
+
+ z = z[1+len(m.compressionMethods):]
+ if numExtensions > 0 {
+ z[0] = byte(extensionsLength >> 8)
+ z[1] = byte(extensionsLength)
+ z = z[2:]
+ }
+ if m.nextProtoNeg {
+ z[0] = byte(extensionNextProtoNeg >> 8)
+ z[1] = byte(extensionNextProtoNeg)
+ // The length is always 0
+ z = z[4:]
+ }
+ if len(m.serverName) > 0 {
+ z[0] = byte(extensionServerName >> 8)
+ z[1] = byte(extensionServerName)
+ l := len(m.serverName) + 5
+ z[2] = byte(l >> 8)
+ z[3] = byte(l)
+ z = z[4:]
+
+ // RFC 3546, section 3.1
+ //
+ // struct {
+ // NameType name_type;
+ // select (name_type) {
+ // case host_name: HostName;
+ // } name;
+ // } ServerName;
+ //
+ // enum {
+ // host_name(0), (255)
+ // } NameType;
+ //
+ // opaque HostName<1..2^16-1>;
+ //
+ // struct {
+ // ServerName server_name_list<1..2^16-1>
+ // } ServerNameList;
+
+ z[0] = byte((len(m.serverName) + 3) >> 8)
+ z[1] = byte(len(m.serverName) + 3)
+ z[3] = byte(len(m.serverName) >> 8)
+ z[4] = byte(len(m.serverName))
+ copy(z[5:], []byte(m.serverName))
+ z = z[l:]
+ }
+ if m.ocspStapling {
+ // RFC 4366, section 3.6
+ z[0] = byte(extensionStatusRequest >> 8)
+ z[1] = byte(extensionStatusRequest)
+ z[2] = 0
+ z[3] = 5
+ z[4] = 1 // OCSP type
+ // Two zero valued uint16s for the two lengths.
+ z = z[9:]
+ }
+ if len(m.supportedCurves) > 0 {
+ // http://tools.ietf.org/html/rfc4492#section-5.5.1
+ z[0] = byte(extensionSupportedCurves >> 8)
+ z[1] = byte(extensionSupportedCurves)
+ l := 2 + 2*len(m.supportedCurves)
+ z[2] = byte(l >> 8)
+ z[3] = byte(l)
+ l -= 2
+ z[4] = byte(l >> 8)
+ z[5] = byte(l)
+ z = z[6:]
+ for _, curve := range m.supportedCurves {
+ z[0] = byte(curve >> 8)
+ z[1] = byte(curve)
+ z = z[2:]
+ }
+ }
+ if len(m.supportedPoints) > 0 {
+ // http://tools.ietf.org/html/rfc4492#section-5.5.2
+ z[0] = byte(extensionSupportedPoints >> 8)
+ z[1] = byte(extensionSupportedPoints)
+ l := 1 + len(m.supportedPoints)
+ z[2] = byte(l >> 8)
+ z[3] = byte(l)
+ l--
+ z[4] = byte(l)
+ z = z[5:]
+ for _, pointFormat := range m.supportedPoints {
+ z[0] = byte(pointFormat)
+ z = z[1:]
+ }
+ }
+ if m.ticketSupported {
+ // http://tools.ietf.org/html/rfc5077#section-3.2
+ z[0] = byte(extensionSessionTicket >> 8)
+ z[1] = byte(extensionSessionTicket)
+ l := len(m.sessionTicket)
+ z[2] = byte(l >> 8)
+ z[3] = byte(l)
+ z = z[4:]
+ copy(z, m.sessionTicket)
+ z = z[len(m.sessionTicket):]
+ }
+ if len(m.signatureAndHashes) > 0 {
+ // https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1
+ z[0] = byte(extensionSignatureAlgorithms >> 8)
+ z[1] = byte(extensionSignatureAlgorithms)
+ l := 2 + 2*len(m.signatureAndHashes)
+ z[2] = byte(l >> 8)
+ z[3] = byte(l)
+ z = z[4:]
+
+ l -= 2
+ z[0] = byte(l >> 8)
+ z[1] = byte(l)
+ z = z[2:]
+ for _, sigAndHash := range m.signatureAndHashes {
+ z[0] = sigAndHash.hash
+ z[1] = sigAndHash.signature
+ z = z[2:]
+ }
+ }
+
+ m.raw = x
+
+ return x
+}
+
+func (m *clientHelloMsg) unmarshal(data []byte) bool {
+ if len(data) < 42 {
+ return false
+ }
+ m.raw = data
+ m.vers = uint16(data[4])<<8 | uint16(data[5])
+ m.random = data[6:38]
+ sessionIdLen := int(data[38])
+ if sessionIdLen > 32 || len(data) < 39+sessionIdLen {
+ return false
+ }
+ m.sessionId = data[39 : 39+sessionIdLen]
+ data = data[39+sessionIdLen:]
+ if len(data) < 2 {
+ return false
+ }
+ // cipherSuiteLen is the number of bytes of cipher suite numbers. Since
+ // they are uint16s, the number must be even.
+ cipherSuiteLen := int(data[0])<<8 | int(data[1])
+ if cipherSuiteLen%2 == 1 || len(data) < 2+cipherSuiteLen {
+ return false
+ }
+ numCipherSuites := cipherSuiteLen / 2
+ m.cipherSuites = make([]uint16, numCipherSuites)
+ for i := 0; i < numCipherSuites; i++ {
+ m.cipherSuites[i] = uint16(data[2+2*i])<<8 | uint16(data[3+2*i])
+ }
+ data = data[2+cipherSuiteLen:]
+ if len(data) < 1 {
+ return false
+ }
+ compressionMethodsLen := int(data[0])
+ if len(data) < 1+compressionMethodsLen {
+ return false
+ }
+ m.compressionMethods = data[1 : 1+compressionMethodsLen]
+
+ data = data[1+compressionMethodsLen:]
+
+ m.nextProtoNeg = false
+ m.serverName = ""
+ m.ocspStapling = false
+ m.ticketSupported = false
+ m.sessionTicket = nil
+ m.signatureAndHashes = nil
+
+ if len(data) == 0 {
+ // ClientHello is optionally followed by extension data
+ return true
+ }
+ if len(data) < 2 {
+ return false
+ }
+
+ extensionsLength := int(data[0])<<8 | int(data[1])
+ data = data[2:]
+ if extensionsLength != len(data) {
+ return false
+ }
+
+ for len(data) != 0 {
+ if len(data) < 4 {
+ return false
+ }
+ extension := uint16(data[0])<<8 | uint16(data[1])
+ length := int(data[2])<<8 | int(data[3])
+ data = data[4:]
+ if len(data) < length {
+ return false
+ }
+
+ switch extension {
+ case extensionServerName:
+ if length < 2 {
+ return false
+ }
+ numNames := int(data[0])<<8 | int(data[1])
+ d := data[2:]
+ for i := 0; i < numNames; i++ {
+ if len(d) < 3 {
+ return false
+ }
+ nameType := d[0]
+ nameLen := int(d[1])<<8 | int(d[2])
+ d = d[3:]
+ if len(d) < nameLen {
+ return false
+ }
+ if nameType == 0 {
+ m.serverName = string(d[0:nameLen])
+ break
+ }
+ d = d[nameLen:]
+ }
+ case extensionNextProtoNeg:
+ if length > 0 {
+ return false
+ }
+ m.nextProtoNeg = true
+ case extensionStatusRequest:
+ m.ocspStapling = length > 0 && data[0] == statusTypeOCSP
+ case extensionSupportedCurves:
+ // http://tools.ietf.org/html/rfc4492#section-5.5.1
+ if length < 2 {
+ return false
+ }
+ l := int(data[0])<<8 | int(data[1])
+ if l%2 == 1 || length != l+2 {
+ return false
+ }
+ numCurves := l / 2
+ m.supportedCurves = make([]uint16, numCurves)
+ d := data[2:]
+ for i := 0; i < numCurves; i++ {
+ m.supportedCurves[i] = uint16(d[0])<<8 | uint16(d[1])
+ d = d[2:]
+ }
+ case extensionSupportedPoints:
+ // http://tools.ietf.org/html/rfc4492#section-5.5.2
+ if length < 1 {
+ return false
+ }
+ l := int(data[0])
+ if length != l+1 {
+ return false
+ }
+ m.supportedPoints = make([]uint8, l)
+ copy(m.supportedPoints, data[1:])
+ case extensionSessionTicket:
+ // http://tools.ietf.org/html/rfc5077#section-3.2
+ m.ticketSupported = true
+ m.sessionTicket = data[:length]
+ case extensionSignatureAlgorithms:
+ // https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1
+ if length < 2 || length&1 != 0 {
+ return false
+ }
+ l := int(data[0])<<8 | int(data[1])
+ if l != length-2 {
+ return false
+ }
+ n := l / 2
+ d := data[2:]
+ m.signatureAndHashes = make([]signatureAndHash, n)
+ for i := range m.signatureAndHashes {
+ m.signatureAndHashes[i].hash = d[0]
+ m.signatureAndHashes[i].signature = d[1]
+ d = d[2:]
+ }
+ }
+ data = data[length:]
+ }
+
+ return true
+}
+
+type serverHelloMsg struct {
+ raw []byte
+ vers uint16
+ random []byte
+ sessionId []byte
+ cipherSuite uint16
+ compressionMethod uint8
+ nextProtoNeg bool
+ nextProtos []string
+ ocspStapling bool
+ ticketSupported bool
+}
+
+func (m *serverHelloMsg) equal(i interface{}) bool {
+ m1, ok := i.(*serverHelloMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ m.vers == m1.vers &&
+ bytes.Equal(m.random, m1.random) &&
+ bytes.Equal(m.sessionId, m1.sessionId) &&
+ m.cipherSuite == m1.cipherSuite &&
+ m.compressionMethod == m1.compressionMethod &&
+ m.nextProtoNeg == m1.nextProtoNeg &&
+ eqStrings(m.nextProtos, m1.nextProtos) &&
+ m.ocspStapling == m1.ocspStapling &&
+ m.ticketSupported == m1.ticketSupported
+}
+
+func (m *serverHelloMsg) marshal() []byte {
+ if m.raw != nil {
+ return m.raw
+ }
+
+ length := 38 + len(m.sessionId)
+ numExtensions := 0
+ extensionsLength := 0
+
+ nextProtoLen := 0
+ if m.nextProtoNeg {
+ numExtensions++
+ for _, v := range m.nextProtos {
+ nextProtoLen += len(v)
+ }
+ nextProtoLen += len(m.nextProtos)
+ extensionsLength += nextProtoLen
+ }
+ if m.ocspStapling {
+ numExtensions++
+ }
+ if m.ticketSupported {
+ numExtensions++
+ }
+ if numExtensions > 0 {
+ extensionsLength += 4 * numExtensions
+ length += 2 + extensionsLength
+ }
+
+ x := make([]byte, 4+length)
+ x[0] = typeServerHello
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+ x[4] = uint8(m.vers >> 8)
+ x[5] = uint8(m.vers)
+ copy(x[6:38], m.random)
+ x[38] = uint8(len(m.sessionId))
+ copy(x[39:39+len(m.sessionId)], m.sessionId)
+ z := x[39+len(m.sessionId):]
+ z[0] = uint8(m.cipherSuite >> 8)
+ z[1] = uint8(m.cipherSuite)
+ z[2] = uint8(m.compressionMethod)
+
+ z = z[3:]
+ if numExtensions > 0 {
+ z[0] = byte(extensionsLength >> 8)
+ z[1] = byte(extensionsLength)
+ z = z[2:]
+ }
+ if m.nextProtoNeg {
+ z[0] = byte(extensionNextProtoNeg >> 8)
+ z[1] = byte(extensionNextProtoNeg)
+ z[2] = byte(nextProtoLen >> 8)
+ z[3] = byte(nextProtoLen)
+ z = z[4:]
+
+ for _, v := range m.nextProtos {
+ l := len(v)
+ if l > 255 {
+ l = 255
+ }
+ z[0] = byte(l)
+ copy(z[1:], []byte(v[0:l]))
+ z = z[1+l:]
+ }
+ }
+ if m.ocspStapling {
+ z[0] = byte(extensionStatusRequest >> 8)
+ z[1] = byte(extensionStatusRequest)
+ z = z[4:]
+ }
+ if m.ticketSupported {
+ z[0] = byte(extensionSessionTicket >> 8)
+ z[1] = byte(extensionSessionTicket)
+ z = z[4:]
+ }
+
+ m.raw = x
+
+ return x
+}
+
+func (m *serverHelloMsg) unmarshal(data []byte) bool {
+ if len(data) < 42 {
+ return false
+ }
+ m.raw = data
+ m.vers = uint16(data[4])<<8 | uint16(data[5])
+ m.random = data[6:38]
+ sessionIdLen := int(data[38])
+ if sessionIdLen > 32 || len(data) < 39+sessionIdLen {
+ return false
+ }
+ m.sessionId = data[39 : 39+sessionIdLen]
+ data = data[39+sessionIdLen:]
+ if len(data) < 3 {
+ return false
+ }
+ m.cipherSuite = uint16(data[0])<<8 | uint16(data[1])
+ m.compressionMethod = data[2]
+ data = data[3:]
+
+ m.nextProtoNeg = false
+ m.nextProtos = nil
+ m.ocspStapling = false
+ m.ticketSupported = false
+
+ if len(data) == 0 {
+ // ServerHello is optionally followed by extension data
+ return true
+ }
+ if len(data) < 2 {
+ return false
+ }
+
+ extensionsLength := int(data[0])<<8 | int(data[1])
+ data = data[2:]
+ if len(data) != extensionsLength {
+ return false
+ }
+
+ for len(data) != 0 {
+ if len(data) < 4 {
+ return false
+ }
+ extension := uint16(data[0])<<8 | uint16(data[1])
+ length := int(data[2])<<8 | int(data[3])
+ data = data[4:]
+ if len(data) < length {
+ return false
+ }
+
+ switch extension {
+ case extensionNextProtoNeg:
+ m.nextProtoNeg = true
+ d := data[:length]
+ for len(d) > 0 {
+ l := int(d[0])
+ d = d[1:]
+ if l == 0 || l > len(d) {
+ return false
+ }
+ m.nextProtos = append(m.nextProtos, string(d[:l]))
+ d = d[l:]
+ }
+ case extensionStatusRequest:
+ if length > 0 {
+ return false
+ }
+ m.ocspStapling = true
+ case extensionSessionTicket:
+ if length > 0 {
+ return false
+ }
+ m.ticketSupported = true
+ }
+ data = data[length:]
+ }
+
+ return true
+}
+
+type certificateMsg struct {
+ raw []byte
+ certificates [][]byte
+}
+
+func (m *certificateMsg) equal(i interface{}) bool {
+ m1, ok := i.(*certificateMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ eqByteSlices(m.certificates, m1.certificates)
+}
+
+func (m *certificateMsg) marshal() (x []byte) {
+ if m.raw != nil {
+ return m.raw
+ }
+
+ var i int
+ for _, slice := range m.certificates {
+ i += len(slice)
+ }
+
+ length := 3 + 3*len(m.certificates) + i
+ x = make([]byte, 4+length)
+ x[0] = typeCertificate
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+
+ certificateOctets := length - 3
+ x[4] = uint8(certificateOctets >> 16)
+ x[5] = uint8(certificateOctets >> 8)
+ x[6] = uint8(certificateOctets)
+
+ y := x[7:]
+ for _, slice := range m.certificates {
+ y[0] = uint8(len(slice) >> 16)
+ y[1] = uint8(len(slice) >> 8)
+ y[2] = uint8(len(slice))
+ copy(y[3:], slice)
+ y = y[3+len(slice):]
+ }
+
+ m.raw = x
+ return
+}
+
+func (m *certificateMsg) unmarshal(data []byte) bool {
+ if len(data) < 7 {
+ return false
+ }
+
+ m.raw = data
+ certsLen := uint32(data[4])<<16 | uint32(data[5])<<8 | uint32(data[6])
+ if uint32(len(data)) != certsLen+7 {
+ return false
+ }
+
+ numCerts := 0
+ d := data[7:]
+ for certsLen > 0 {
+ if len(d) < 4 {
+ return false
+ }
+ certLen := uint32(d[0])<<16 | uint32(d[1])<<8 | uint32(d[2])
+ if uint32(len(d)) < 3+certLen {
+ return false
+ }
+ d = d[3+certLen:]
+ certsLen -= 3 + certLen
+ numCerts++
+ }
+
+ m.certificates = make([][]byte, numCerts)
+ d = data[7:]
+ for i := 0; i < numCerts; i++ {
+ certLen := uint32(d[0])<<16 | uint32(d[1])<<8 | uint32(d[2])
+ m.certificates[i] = d[3 : 3+certLen]
+ d = d[3+certLen:]
+ }
+
+ return true
+}
+
+type serverKeyExchangeMsg struct {
+ raw []byte
+ key []byte
+}
+
+func (m *serverKeyExchangeMsg) equal(i interface{}) bool {
+ m1, ok := i.(*serverKeyExchangeMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ bytes.Equal(m.key, m1.key)
+}
+
+func (m *serverKeyExchangeMsg) marshal() []byte {
+ if m.raw != nil {
+ return m.raw
+ }
+ length := len(m.key)
+ x := make([]byte, length+4)
+ x[0] = typeServerKeyExchange
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+ copy(x[4:], m.key)
+
+ m.raw = x
+ return x
+}
+
+func (m *serverKeyExchangeMsg) unmarshal(data []byte) bool {
+ m.raw = data
+ if len(data) < 4 {
+ return false
+ }
+ m.key = data[4:]
+ return true
+}
+
+type certificateStatusMsg struct {
+ raw []byte
+ statusType uint8
+ response []byte
+}
+
+func (m *certificateStatusMsg) equal(i interface{}) bool {
+ m1, ok := i.(*certificateStatusMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ m.statusType == m1.statusType &&
+ bytes.Equal(m.response, m1.response)
+}
+
+func (m *certificateStatusMsg) marshal() []byte {
+ if m.raw != nil {
+ return m.raw
+ }
+
+ var x []byte
+ if m.statusType == statusTypeOCSP {
+ x = make([]byte, 4+4+len(m.response))
+ x[0] = typeCertificateStatus
+ l := len(m.response) + 4
+ x[1] = byte(l >> 16)
+ x[2] = byte(l >> 8)
+ x[3] = byte(l)
+ x[4] = statusTypeOCSP
+
+ l -= 4
+ x[5] = byte(l >> 16)
+ x[6] = byte(l >> 8)
+ x[7] = byte(l)
+ copy(x[8:], m.response)
+ } else {
+ x = []byte{typeCertificateStatus, 0, 0, 1, m.statusType}
+ }
+
+ m.raw = x
+ return x
+}
+
+func (m *certificateStatusMsg) unmarshal(data []byte) bool {
+ m.raw = data
+ if len(data) < 5 {
+ return false
+ }
+ m.statusType = data[4]
+
+ m.response = nil
+ if m.statusType == statusTypeOCSP {
+ if len(data) < 8 {
+ return false
+ }
+ respLen := uint32(data[5])<<16 | uint32(data[6])<<8 | uint32(data[7])
+ if uint32(len(data)) != 4+4+respLen {
+ return false
+ }
+ m.response = data[8:]
+ }
+ return true
+}
+
+type serverHelloDoneMsg struct{}
+
+func (m *serverHelloDoneMsg) equal(i interface{}) bool {
+ _, ok := i.(*serverHelloDoneMsg)
+ return ok
+}
+
+func (m *serverHelloDoneMsg) marshal() []byte {
+ x := make([]byte, 4)
+ x[0] = typeServerHelloDone
+ return x
+}
+
+func (m *serverHelloDoneMsg) unmarshal(data []byte) bool {
+ return len(data) == 4
+}
+
+type clientKeyExchangeMsg struct {
+ raw []byte
+ ciphertext []byte
+}
+
+func (m *clientKeyExchangeMsg) equal(i interface{}) bool {
+ m1, ok := i.(*clientKeyExchangeMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ bytes.Equal(m.ciphertext, m1.ciphertext)
+}
+
+func (m *clientKeyExchangeMsg) marshal() []byte {
+ if m.raw != nil {
+ return m.raw
+ }
+ length := len(m.ciphertext)
+ x := make([]byte, length+4)
+ x[0] = typeClientKeyExchange
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+ copy(x[4:], m.ciphertext)
+
+ m.raw = x
+ return x
+}
+
+func (m *clientKeyExchangeMsg) unmarshal(data []byte) bool {
+ m.raw = data
+ if len(data) < 4 {
+ return false
+ }
+ l := int(data[1])<<16 | int(data[2])<<8 | int(data[3])
+ if l != len(data)-4 {
+ return false
+ }
+ m.ciphertext = data[4:]
+ return true
+}
+
+type finishedMsg struct {
+ raw []byte
+ verifyData []byte
+}
+
+func (m *finishedMsg) equal(i interface{}) bool {
+ m1, ok := i.(*finishedMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ bytes.Equal(m.verifyData, m1.verifyData)
+}
+
+func (m *finishedMsg) marshal() (x []byte) {
+ if m.raw != nil {
+ return m.raw
+ }
+
+ x = make([]byte, 4+len(m.verifyData))
+ x[0] = typeFinished
+ x[3] = byte(len(m.verifyData))
+ copy(x[4:], m.verifyData)
+ m.raw = x
+ return
+}
+
+func (m *finishedMsg) unmarshal(data []byte) bool {
+ m.raw = data
+ if len(data) < 4 {
+ return false
+ }
+ m.verifyData = data[4:]
+ return true
+}
+
+type nextProtoMsg struct {
+ raw []byte
+ proto string
+}
+
+func (m *nextProtoMsg) equal(i interface{}) bool {
+ m1, ok := i.(*nextProtoMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ m.proto == m1.proto
+}
+
+func (m *nextProtoMsg) marshal() []byte {
+ if m.raw != nil {
+ return m.raw
+ }
+ l := len(m.proto)
+ if l > 255 {
+ l = 255
+ }
+
+ padding := 32 - (l+2)%32
+ length := l + padding + 2
+ x := make([]byte, length+4)
+ x[0] = typeNextProtocol
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+
+ y := x[4:]
+ y[0] = byte(l)
+ copy(y[1:], []byte(m.proto[0:l]))
+ y = y[1+l:]
+ y[0] = byte(padding)
+
+ m.raw = x
+
+ return x
+}
+
+func (m *nextProtoMsg) unmarshal(data []byte) bool {
+ m.raw = data
+
+ if len(data) < 5 {
+ return false
+ }
+ data = data[4:]
+ protoLen := int(data[0])
+ data = data[1:]
+ if len(data) < protoLen {
+ return false
+ }
+ m.proto = string(data[0:protoLen])
+ data = data[protoLen:]
+
+ if len(data) < 1 {
+ return false
+ }
+ paddingLen := int(data[0])
+ data = data[1:]
+ if len(data) != paddingLen {
+ return false
+ }
+
+ return true
+}
+
+type certificateRequestMsg struct {
+ raw []byte
+ // hasSignatureAndHash indicates whether this message includes a list
+ // of signature and hash functions. This change was introduced with TLS
+ // 1.2.
+ hasSignatureAndHash bool
+
+ certificateTypes []byte
+ signatureAndHashes []signatureAndHash
+ certificateAuthorities [][]byte
+}
+
+func (m *certificateRequestMsg) equal(i interface{}) bool {
+ m1, ok := i.(*certificateRequestMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ bytes.Equal(m.certificateTypes, m1.certificateTypes) &&
+ eqByteSlices(m.certificateAuthorities, m1.certificateAuthorities) &&
+ eqSignatureAndHashes(m.signatureAndHashes, m1.signatureAndHashes)
+}
+
+func (m *certificateRequestMsg) marshal() (x []byte) {
+ if m.raw != nil {
+ return m.raw
+ }
+
+ // See http://tools.ietf.org/html/rfc4346#section-7.4.4
+ length := 1 + len(m.certificateTypes) + 2
+ casLength := 0
+ for _, ca := range m.certificateAuthorities {
+ casLength += 2 + len(ca)
+ }
+ length += casLength
+
+ if m.hasSignatureAndHash {
+ length += 2 + 2*len(m.signatureAndHashes)
+ }
+
+ x = make([]byte, 4+length)
+ x[0] = typeCertificateRequest
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+
+ x[4] = uint8(len(m.certificateTypes))
+
+ copy(x[5:], m.certificateTypes)
+ y := x[5+len(m.certificateTypes):]
+
+ if m.hasSignatureAndHash {
+ n := len(m.signatureAndHashes) * 2
+ y[0] = uint8(n >> 8)
+ y[1] = uint8(n)
+ y = y[2:]
+ for _, sigAndHash := range m.signatureAndHashes {
+ y[0] = sigAndHash.hash
+ y[1] = sigAndHash.signature
+ y = y[2:]
+ }
+ }
+
+ y[0] = uint8(casLength >> 8)
+ y[1] = uint8(casLength)
+ y = y[2:]
+ for _, ca := range m.certificateAuthorities {
+ y[0] = uint8(len(ca) >> 8)
+ y[1] = uint8(len(ca))
+ y = y[2:]
+ copy(y, ca)
+ y = y[len(ca):]
+ }
+
+ m.raw = x
+ return
+}
+
+func (m *certificateRequestMsg) unmarshal(data []byte) bool {
+ m.raw = data
+
+ if len(data) < 5 {
+ return false
+ }
+
+ length := uint32(data[1])<<16 | uint32(data[2])<<8 | uint32(data[3])
+ if uint32(len(data))-4 != length {
+ return false
+ }
+
+ numCertTypes := int(data[4])
+ data = data[5:]
+ if numCertTypes == 0 || len(data) <= numCertTypes {
+ return false
+ }
+
+ m.certificateTypes = make([]byte, numCertTypes)
+ if copy(m.certificateTypes, data) != numCertTypes {
+ return false
+ }
+
+ data = data[numCertTypes:]
+
+ if m.hasSignatureAndHash {
+ if len(data) < 2 {
+ return false
+ }
+ sigAndHashLen := uint16(data[0])<<8 | uint16(data[1])
+ data = data[2:]
+ if sigAndHashLen&1 != 0 {
+ return false
+ }
+ if len(data) < int(sigAndHashLen) {
+ return false
+ }
+ numSigAndHash := sigAndHashLen / 2
+ m.signatureAndHashes = make([]signatureAndHash, numSigAndHash)
+ for i := range m.signatureAndHashes {
+ m.signatureAndHashes[i].hash = data[0]
+ m.signatureAndHashes[i].signature = data[1]
+ data = data[2:]
+ }
+ }
+
+ if len(data) < 2 {
+ return false
+ }
+ casLength := uint16(data[0])<<8 | uint16(data[1])
+ data = data[2:]
+ if len(data) < int(casLength) {
+ return false
+ }
+ cas := make([]byte, casLength)
+ copy(cas, data)
+ data = data[casLength:]
+
+ m.certificateAuthorities = nil
+ for len(cas) > 0 {
+ if len(cas) < 2 {
+ return false
+ }
+ caLen := uint16(cas[0])<<8 | uint16(cas[1])
+ cas = cas[2:]
+
+ if len(cas) < int(caLen) {
+ return false
+ }
+
+ m.certificateAuthorities = append(m.certificateAuthorities, cas[:caLen])
+ cas = cas[caLen:]
+ }
+ if len(data) > 0 {
+ return false
+ }
+
+ return true
+}
+
+type certificateVerifyMsg struct {
+ raw []byte
+ hasSignatureAndHash bool
+ signatureAndHash signatureAndHash
+ signature []byte
+}
+
+func (m *certificateVerifyMsg) equal(i interface{}) bool {
+ m1, ok := i.(*certificateVerifyMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ m.hasSignatureAndHash == m1.hasSignatureAndHash &&
+ m.signatureAndHash.hash == m1.signatureAndHash.hash &&
+ m.signatureAndHash.signature == m1.signatureAndHash.signature &&
+ bytes.Equal(m.signature, m1.signature)
+}
+
+func (m *certificateVerifyMsg) marshal() (x []byte) {
+ if m.raw != nil {
+ return m.raw
+ }
+
+ // See http://tools.ietf.org/html/rfc4346#section-7.4.8
+ siglength := len(m.signature)
+ length := 2 + siglength
+ if m.hasSignatureAndHash {
+ length += 2
+ }
+ x = make([]byte, 4+length)
+ x[0] = typeCertificateVerify
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+ y := x[4:]
+ if m.hasSignatureAndHash {
+ y[0] = m.signatureAndHash.hash
+ y[1] = m.signatureAndHash.signature
+ y = y[2:]
+ }
+ y[0] = uint8(siglength >> 8)
+ y[1] = uint8(siglength)
+ copy(y[2:], m.signature)
+
+ m.raw = x
+
+ return
+}
+
+func (m *certificateVerifyMsg) unmarshal(data []byte) bool {
+ m.raw = data
+
+ if len(data) < 6 {
+ return false
+ }
+
+ length := uint32(data[1])<<16 | uint32(data[2])<<8 | uint32(data[3])
+ if uint32(len(data))-4 != length {
+ return false
+ }
+
+ data = data[4:]
+ if m.hasSignatureAndHash {
+ m.signatureAndHash.hash = data[0]
+ m.signatureAndHash.signature = data[1]
+ data = data[2:]
+ }
+
+ if len(data) < 2 {
+ return false
+ }
+ siglength := int(data[0])<<8 + int(data[1])
+ data = data[2:]
+ if len(data) != siglength {
+ return false
+ }
+
+ m.signature = data
+
+ return true
+}
+
+type newSessionTicketMsg struct {
+ raw []byte
+ ticket []byte
+}
+
+func (m *newSessionTicketMsg) equal(i interface{}) bool {
+ m1, ok := i.(*newSessionTicketMsg)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(m.raw, m1.raw) &&
+ bytes.Equal(m.ticket, m1.ticket)
+}
+
+func (m *newSessionTicketMsg) marshal() (x []byte) {
+ if m.raw != nil {
+ return m.raw
+ }
+
+ // See http://tools.ietf.org/html/rfc5077#section-3.3
+ ticketLen := len(m.ticket)
+ length := 2 + 4 + ticketLen
+ x = make([]byte, 4+length)
+ x[0] = typeNewSessionTicket
+ x[1] = uint8(length >> 16)
+ x[2] = uint8(length >> 8)
+ x[3] = uint8(length)
+ x[8] = uint8(ticketLen >> 8)
+ x[9] = uint8(ticketLen)
+ copy(x[10:], m.ticket)
+
+ m.raw = x
+
+ return
+}
+
+func (m *newSessionTicketMsg) unmarshal(data []byte) bool {
+ m.raw = data
+
+ if len(data) < 10 {
+ return false
+ }
+
+ length := uint32(data[1])<<16 | uint32(data[2])<<8 | uint32(data[3])
+ if uint32(len(data))-4 != length {
+ return false
+ }
+
+ ticketLen := int(data[8])<<8 + int(data[9])
+ if len(data)-10 != ticketLen {
+ return false
+ }
+
+ m.ticket = data[10:]
+
+ return true
+}
+
+func eqUint16s(x, y []uint16) bool {
+ if len(x) != len(y) {
+ return false
+ }
+ for i, v := range x {
+ if y[i] != v {
+ return false
+ }
+ }
+ return true
+}
+
+func eqStrings(x, y []string) bool {
+ if len(x) != len(y) {
+ return false
+ }
+ for i, v := range x {
+ if y[i] != v {
+ return false
+ }
+ }
+ return true
+}
+
+func eqByteSlices(x, y [][]byte) bool {
+ if len(x) != len(y) {
+ return false
+ }
+ for i, v := range x {
+ if !bytes.Equal(v, y[i]) {
+ return false
+ }
+ }
+ return true
+}
+
+func eqSignatureAndHashes(x, y []signatureAndHash) bool {
+ if len(x) != len(y) {
+ return false
+ }
+ for i, v := range x {
+ v2 := y[i]
+ if v.hash != v2.hash || v.signature != v2.signature {
+ return false
+ }
+ }
+ return true
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_server.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_server.go
new file mode 100644
index 00000000..f722bc2a
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/handshake_server.go
@@ -0,0 +1,638 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "crypto"
+ "crypto/ecdsa"
+ "crypto/rsa"
+ "crypto/subtle"
+ "crypto/x509"
+ "encoding/asn1"
+ "errors"
+ "io"
+)
+
+// serverHandshakeState contains details of a server handshake in progress.
+// It's discarded once the handshake has completed.
+type serverHandshakeState struct {
+ c *Conn
+ clientHello *clientHelloMsg
+ hello *serverHelloMsg
+ suite *cipherSuite
+ ellipticOk bool
+ ecdsaOk bool
+ sessionState *sessionState
+ finishedHash finishedHash
+ masterSecret []byte
+ certsFromClient [][]byte
+ cert *Certificate
+}
+
+// serverHandshake performs a TLS handshake as a server.
+func (c *Conn) serverHandshake() error {
+ config := c.config
+
+ // If this is the first server handshake, we generate a random key to
+ // encrypt the tickets with.
+ config.serverInitOnce.Do(config.serverInit)
+
+ hs := serverHandshakeState{
+ c: c,
+ }
+ isResume, err := hs.readClientHello()
+ if err != nil {
+ return err
+ }
+
+ // For an overview of TLS handshaking, see https://tools.ietf.org/html/rfc5246#section-7.3
+ if isResume {
+ // The client has included a session ticket and so we do an abbreviated handshake.
+ if err := hs.doResumeHandshake(); err != nil {
+ return err
+ }
+ if err := hs.establishKeys(); err != nil {
+ return err
+ }
+ if err := hs.sendFinished(); err != nil {
+ return err
+ }
+ if err := hs.readFinished(); err != nil {
+ return err
+ }
+ c.didResume = true
+ } else {
+ // The client didn't include a session ticket, or it wasn't
+ // valid so we do a full handshake.
+ if err := hs.doFullHandshake(); err != nil {
+ return err
+ }
+ if err := hs.establishKeys(); err != nil {
+ return err
+ }
+ if err := hs.readFinished(); err != nil {
+ return err
+ }
+ if err := hs.sendSessionTicket(); err != nil {
+ return err
+ }
+ if err := hs.sendFinished(); err != nil {
+ return err
+ }
+ }
+ c.handshakeComplete = true
+
+ return nil
+}
+
+// readClientHello reads a ClientHello message from the client and decides
+// whether we will perform session resumption.
+func (hs *serverHandshakeState) readClientHello() (isResume bool, err error) {
+ config := hs.c.config
+ c := hs.c
+
+ msg, err := c.readHandshake()
+ if err != nil {
+ return false, err
+ }
+ var ok bool
+ hs.clientHello, ok = msg.(*clientHelloMsg)
+ if !ok {
+ return false, c.sendAlert(alertUnexpectedMessage)
+ }
+ c.vers, ok = config.mutualVersion(hs.clientHello.vers)
+ if !ok {
+ return false, c.sendAlert(alertProtocolVersion)
+ }
+ c.haveVers = true
+
+ hs.finishedHash = newFinishedHash(c.vers)
+ hs.finishedHash.Write(hs.clientHello.marshal())
+
+ hs.hello = new(serverHelloMsg)
+
+ supportedCurve := false
+Curves:
+ for _, curve := range hs.clientHello.supportedCurves {
+ switch curve {
+ case curveP256, curveP384, curveP521:
+ supportedCurve = true
+ break Curves
+ }
+ }
+
+ supportedPointFormat := false
+ for _, pointFormat := range hs.clientHello.supportedPoints {
+ if pointFormat == pointFormatUncompressed {
+ supportedPointFormat = true
+ break
+ }
+ }
+ hs.ellipticOk = supportedCurve && supportedPointFormat
+
+ foundCompression := false
+ // We only support null compression, so check that the client offered it.
+ for _, compression := range hs.clientHello.compressionMethods {
+ if compression == compressionNone {
+ foundCompression = true
+ break
+ }
+ }
+
+ if !foundCompression {
+ return false, c.sendAlert(alertHandshakeFailure)
+ }
+
+ hs.hello.vers = c.vers
+ t := uint32(config.time().Unix())
+ hs.hello.random = make([]byte, 32)
+ hs.hello.random[0] = byte(t >> 24)
+ hs.hello.random[1] = byte(t >> 16)
+ hs.hello.random[2] = byte(t >> 8)
+ hs.hello.random[3] = byte(t)
+ _, err = io.ReadFull(config.rand(), hs.hello.random[4:])
+ if err != nil {
+ return false, c.sendAlert(alertInternalError)
+ }
+ hs.hello.compressionMethod = compressionNone
+ if len(hs.clientHello.serverName) > 0 {
+ c.serverName = hs.clientHello.serverName
+ }
+ // Although sending an empty NPN extension is reasonable, Firefox has
+ // had a bug around this. Best to send nothing at all if
+ // config.NextProtos is empty. See
+ // https://code.google.com/p/go/issues/detail?id=5445.
+ if hs.clientHello.nextProtoNeg && len(config.NextProtos) > 0 {
+ hs.hello.nextProtoNeg = true
+ hs.hello.nextProtos = config.NextProtos
+ }
+
+ if len(config.Certificates) == 0 {
+ return false, c.sendAlert(alertInternalError)
+ }
+ hs.cert = &config.Certificates[0]
+ if len(hs.clientHello.serverName) > 0 {
+ hs.cert = config.getCertificateForName(hs.clientHello.serverName)
+ }
+
+ _, hs.ecdsaOk = hs.cert.PrivateKey.(*ecdsa.PrivateKey)
+
+ if hs.checkForResumption() {
+ return true, nil
+ }
+
+ var preferenceList, supportedList []uint16
+ if c.config.PreferServerCipherSuites {
+ preferenceList = c.config.cipherSuites()
+ supportedList = hs.clientHello.cipherSuites
+ } else {
+ preferenceList = hs.clientHello.cipherSuites
+ supportedList = c.config.cipherSuites()
+ }
+
+ for _, id := range preferenceList {
+ if hs.suite = c.tryCipherSuite(id, supportedList, c.vers, hs.ellipticOk, hs.ecdsaOk); hs.suite != nil {
+ break
+ }
+ }
+
+ if hs.suite == nil {
+ return false, c.sendAlert(alertHandshakeFailure)
+ }
+
+ return false, nil
+}
+
+// checkForResumption returns true if we should perform resumption on this connection.
+func (hs *serverHandshakeState) checkForResumption() bool {
+ c := hs.c
+
+ var ok bool
+ if hs.sessionState, ok = c.decryptTicket(hs.clientHello.sessionTicket); !ok {
+ return false
+ }
+
+ if hs.sessionState.vers > hs.clientHello.vers {
+ return false
+ }
+ if vers, ok := c.config.mutualVersion(hs.sessionState.vers); !ok || vers != hs.sessionState.vers {
+ return false
+ }
+
+ cipherSuiteOk := false
+ // Check that the client is still offering the ciphersuite in the session.
+ for _, id := range hs.clientHello.cipherSuites {
+ if id == hs.sessionState.cipherSuite {
+ cipherSuiteOk = true
+ break
+ }
+ }
+ if !cipherSuiteOk {
+ return false
+ }
+
+ // Check that we also support the ciphersuite from the session.
+ hs.suite = c.tryCipherSuite(hs.sessionState.cipherSuite, c.config.cipherSuites(), hs.sessionState.vers, hs.ellipticOk, hs.ecdsaOk)
+ if hs.suite == nil {
+ return false
+ }
+
+ sessionHasClientCerts := len(hs.sessionState.certificates) != 0
+ needClientCerts := c.config.ClientAuth == RequireAnyClientCert || c.config.ClientAuth == RequireAndVerifyClientCert
+ if needClientCerts && !sessionHasClientCerts {
+ return false
+ }
+ if sessionHasClientCerts && c.config.ClientAuth == NoClientCert {
+ return false
+ }
+
+ return true
+}
+
+func (hs *serverHandshakeState) doResumeHandshake() error {
+ c := hs.c
+
+ hs.hello.cipherSuite = hs.suite.id
+ // We echo the client's session ID in the ServerHello to let it know
+ // that we're doing a resumption.
+ hs.hello.sessionId = hs.clientHello.sessionId
+ hs.finishedHash.Write(hs.hello.marshal())
+ c.writeRecord(recordTypeHandshake, hs.hello.marshal())
+
+ if len(hs.sessionState.certificates) > 0 {
+ if _, err := hs.processCertsFromClient(hs.sessionState.certificates); err != nil {
+ return err
+ }
+ }
+
+ hs.masterSecret = hs.sessionState.masterSecret
+
+ return nil
+}
+
+func (hs *serverHandshakeState) doFullHandshake() error {
+ config := hs.c.config
+ c := hs.c
+
+ if hs.clientHello.ocspStapling && len(hs.cert.OCSPStaple) > 0 {
+ hs.hello.ocspStapling = true
+ }
+
+ hs.hello.ticketSupported = hs.clientHello.ticketSupported && !config.SessionTicketsDisabled
+ hs.hello.cipherSuite = hs.suite.id
+ hs.finishedHash.Write(hs.hello.marshal())
+ c.writeRecord(recordTypeHandshake, hs.hello.marshal())
+
+ certMsg := new(certificateMsg)
+ certMsg.certificates = hs.cert.Certificate
+ hs.finishedHash.Write(certMsg.marshal())
+ c.writeRecord(recordTypeHandshake, certMsg.marshal())
+
+ if hs.hello.ocspStapling {
+ certStatus := new(certificateStatusMsg)
+ certStatus.statusType = statusTypeOCSP
+ certStatus.response = hs.cert.OCSPStaple
+ hs.finishedHash.Write(certStatus.marshal())
+ c.writeRecord(recordTypeHandshake, certStatus.marshal())
+ }
+
+ keyAgreement := hs.suite.ka(c.vers)
+ skx, err := keyAgreement.generateServerKeyExchange(config, hs.cert, hs.clientHello, hs.hello)
+ if err != nil {
+ c.sendAlert(alertHandshakeFailure)
+ return err
+ }
+ if skx != nil {
+ hs.finishedHash.Write(skx.marshal())
+ c.writeRecord(recordTypeHandshake, skx.marshal())
+ }
+
+ if config.ClientAuth >= RequestClientCert {
+ // Request a client certificate
+ certReq := new(certificateRequestMsg)
+ certReq.certificateTypes = []byte{
+ byte(certTypeRSASign),
+ byte(certTypeECDSASign),
+ }
+ if c.vers >= VersionTLS12 {
+ certReq.hasSignatureAndHash = true
+ certReq.signatureAndHashes = supportedClientCertSignatureAlgorithms
+ }
+
+ // An empty list of certificateAuthorities signals to
+ // the client that it may send any certificate in response
+ // to our request. When we know the CAs we trust, then
+ // we can send them down, so that the client can choose
+ // an appropriate certificate to give to us.
+ if config.ClientCAs != nil {
+ certReq.certificateAuthorities = config.ClientCAs.Subjects()
+ }
+ hs.finishedHash.Write(certReq.marshal())
+ c.writeRecord(recordTypeHandshake, certReq.marshal())
+ }
+
+ helloDone := new(serverHelloDoneMsg)
+ hs.finishedHash.Write(helloDone.marshal())
+ c.writeRecord(recordTypeHandshake, helloDone.marshal())
+
+ var pub crypto.PublicKey // public key for client auth, if any
+
+ msg, err := c.readHandshake()
+ if err != nil {
+ return err
+ }
+
+ var ok bool
+ // If we requested a client certificate, then the client must send a
+ // certificate message, even if it's empty.
+ if config.ClientAuth >= RequestClientCert {
+ if certMsg, ok = msg.(*certificateMsg); !ok {
+ return c.sendAlert(alertHandshakeFailure)
+ }
+ hs.finishedHash.Write(certMsg.marshal())
+
+ if len(certMsg.certificates) == 0 {
+ // The client didn't actually send a certificate
+ switch config.ClientAuth {
+ case RequireAnyClientCert, RequireAndVerifyClientCert:
+ c.sendAlert(alertBadCertificate)
+ return errors.New("tls: client didn't provide a certificate")
+ }
+ }
+
+ pub, err = hs.processCertsFromClient(certMsg.certificates)
+ if err != nil {
+ return err
+ }
+
+ msg, err = c.readHandshake()
+ if err != nil {
+ return err
+ }
+ }
+
+ // Get client key exchange
+ ckx, ok := msg.(*clientKeyExchangeMsg)
+ if !ok {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+ hs.finishedHash.Write(ckx.marshal())
+
+ // If we received a client cert in response to our certificate request message,
+ // the client will send us a certificateVerifyMsg immediately after the
+ // clientKeyExchangeMsg. This message is a digest of all preceding
+ // handshake-layer messages that is signed using the private key corresponding
+ // to the client's certificate. This allows us to verify that the client is in
+ // possession of the private key of the certificate.
+ if len(c.peerCertificates) > 0 {
+ msg, err = c.readHandshake()
+ if err != nil {
+ return err
+ }
+ certVerify, ok := msg.(*certificateVerifyMsg)
+ if !ok {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+
+ switch key := pub.(type) {
+ case *ecdsa.PublicKey:
+ ecdsaSig := new(ecdsaSignature)
+ if _, err = asn1.Unmarshal(certVerify.signature, ecdsaSig); err != nil {
+ break
+ }
+ if ecdsaSig.R.Sign() <= 0 || ecdsaSig.S.Sign() <= 0 {
+ err = errors.New("ECDSA signature contained zero or negative values")
+ break
+ }
+ digest, _, _ := hs.finishedHash.hashForClientCertificate(signatureECDSA)
+ if !ecdsa.Verify(key, digest, ecdsaSig.R, ecdsaSig.S) {
+ err = errors.New("ECDSA verification failure")
+ break
+ }
+ case *rsa.PublicKey:
+ digest, hashFunc, _ := hs.finishedHash.hashForClientCertificate(signatureRSA)
+ err = rsa.VerifyPKCS1v15(key, hashFunc, digest, certVerify.signature)
+ }
+ if err != nil {
+ c.sendAlert(alertBadCertificate)
+ return errors.New("could not validate signature of connection nonces: " + err.Error())
+ }
+
+ hs.finishedHash.Write(certVerify.marshal())
+ }
+
+ preMasterSecret, err := keyAgreement.processClientKeyExchange(config, hs.cert, ckx, c.vers)
+ if err != nil {
+ c.sendAlert(alertHandshakeFailure)
+ return err
+ }
+ hs.masterSecret = masterFromPreMasterSecret(c.vers, preMasterSecret, hs.clientHello.random, hs.hello.random)
+
+ return nil
+}
+
+func (hs *serverHandshakeState) establishKeys() error {
+ c := hs.c
+
+ clientMAC, serverMAC, clientKey, serverKey, clientIV, serverIV :=
+ keysFromMasterSecret(c.vers, hs.masterSecret, hs.clientHello.random, hs.hello.random, hs.suite.macLen, hs.suite.keyLen, hs.suite.ivLen)
+
+ var clientCipher, serverCipher interface{}
+ var clientHash, serverHash macFunction
+
+ if hs.suite.aead == nil {
+ clientCipher = hs.suite.cipher(clientKey, clientIV, true /* for reading */)
+ clientHash = hs.suite.mac(c.vers, clientMAC)
+ serverCipher = hs.suite.cipher(serverKey, serverIV, false /* not for reading */)
+ serverHash = hs.suite.mac(c.vers, serverMAC)
+ } else {
+ clientCipher = hs.suite.aead(clientKey, clientIV)
+ serverCipher = hs.suite.aead(serverKey, serverIV)
+ }
+
+ c.in.prepareCipherSpec(c.vers, clientCipher, clientHash)
+ c.out.prepareCipherSpec(c.vers, serverCipher, serverHash)
+
+ return nil
+}
+
+func (hs *serverHandshakeState) readFinished() error {
+ c := hs.c
+
+ c.readRecord(recordTypeChangeCipherSpec)
+ if err := c.error(); err != nil {
+ return err
+ }
+
+ if hs.hello.nextProtoNeg {
+ msg, err := c.readHandshake()
+ if err != nil {
+ return err
+ }
+ nextProto, ok := msg.(*nextProtoMsg)
+ if !ok {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+ hs.finishedHash.Write(nextProto.marshal())
+ c.clientProtocol = nextProto.proto
+ }
+
+ msg, err := c.readHandshake()
+ if err != nil {
+ return err
+ }
+ clientFinished, ok := msg.(*finishedMsg)
+ if !ok {
+ return c.sendAlert(alertUnexpectedMessage)
+ }
+
+ verify := hs.finishedHash.clientSum(hs.masterSecret)
+ if len(verify) != len(clientFinished.verifyData) ||
+ subtle.ConstantTimeCompare(verify, clientFinished.verifyData) != 1 {
+ return c.sendAlert(alertHandshakeFailure)
+ }
+
+ hs.finishedHash.Write(clientFinished.marshal())
+ return nil
+}
+
+func (hs *serverHandshakeState) sendSessionTicket() error {
+ if !hs.hello.ticketSupported {
+ return nil
+ }
+
+ c := hs.c
+ m := new(newSessionTicketMsg)
+
+ var err error
+ state := sessionState{
+ vers: c.vers,
+ cipherSuite: hs.suite.id,
+ masterSecret: hs.masterSecret,
+ certificates: hs.certsFromClient,
+ }
+ m.ticket, err = c.encryptTicket(&state)
+ if err != nil {
+ return err
+ }
+
+ hs.finishedHash.Write(m.marshal())
+ c.writeRecord(recordTypeHandshake, m.marshal())
+
+ return nil
+}
+
+func (hs *serverHandshakeState) sendFinished() error {
+ c := hs.c
+
+ c.writeRecord(recordTypeChangeCipherSpec, []byte{1})
+
+ finished := new(finishedMsg)
+ finished.verifyData = hs.finishedHash.serverSum(hs.masterSecret)
+ hs.finishedHash.Write(finished.marshal())
+ c.writeRecord(recordTypeHandshake, finished.marshal())
+
+ c.cipherSuite = hs.suite.id
+
+ return nil
+}
+
+// processCertsFromClient takes a chain of client certificates either from a
+// Certificates message or from a sessionState and verifies them. It returns
+// the public key of the leaf certificate.
+func (hs *serverHandshakeState) processCertsFromClient(certificates [][]byte) (crypto.PublicKey, error) {
+ c := hs.c
+
+ hs.certsFromClient = certificates
+ certs := make([]*x509.Certificate, len(certificates))
+ var err error
+ for i, asn1Data := range certificates {
+ if certs[i], err = x509.ParseCertificate(asn1Data); err != nil {
+ c.sendAlert(alertBadCertificate)
+ return nil, errors.New("tls: failed to parse client certificate: " + err.Error())
+ }
+ }
+
+ if c.config.ClientAuth >= VerifyClientCertIfGiven && len(certs) > 0 {
+ opts := x509.VerifyOptions{
+ Roots: c.config.ClientCAs,
+ CurrentTime: c.config.time(),
+ Intermediates: x509.NewCertPool(),
+ KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
+ }
+
+ for _, cert := range certs[1:] {
+ opts.Intermediates.AddCert(cert)
+ }
+
+ chains, err := certs[0].Verify(opts)
+ if err != nil {
+ c.sendAlert(alertBadCertificate)
+ return nil, errors.New("tls: failed to verify client's certificate: " + err.Error())
+ }
+
+ ok := false
+ for _, ku := range certs[0].ExtKeyUsage {
+ if ku == x509.ExtKeyUsageClientAuth {
+ ok = true
+ break
+ }
+ }
+ if !ok {
+ c.sendAlert(alertHandshakeFailure)
+ return nil, errors.New("tls: client's certificate's extended key usage doesn't permit it to be used for client authentication")
+ }
+
+ c.verifiedChains = chains
+ }
+
+ if len(certs) > 0 {
+ var pub crypto.PublicKey
+ switch key := certs[0].PublicKey.(type) {
+ case *ecdsa.PublicKey, *rsa.PublicKey:
+ pub = key
+ default:
+ return nil, c.sendAlert(alertUnsupportedCertificate)
+ }
+ c.peerCertificates = certs
+ return pub, nil
+ }
+
+ return nil, nil
+}
+
+// tryCipherSuite returns a cipherSuite with the given id if that cipher suite
+// is acceptable to use.
+func (c *Conn) tryCipherSuite(id uint16, supportedCipherSuites []uint16, version uint16, ellipticOk, ecdsaOk bool) *cipherSuite {
+ for _, supported := range supportedCipherSuites {
+ if id == supported {
+ var candidate *cipherSuite
+
+ for _, s := range cipherSuites {
+ if s.id == id {
+ candidate = s
+ break
+ }
+ }
+ if candidate == nil {
+ continue
+ }
+ // Don't select a ciphersuite which we can't
+ // support for this client.
+ if (candidate.flags&suiteECDHE != 0) && !ellipticOk {
+ continue
+ }
+ if (candidate.flags&suiteECDSA != 0) != ecdsaOk {
+ continue
+ }
+ if version < VersionTLS12 && candidate.flags&suiteTLS12 != 0 {
+ continue
+ }
+ return candidate
+ }
+ }
+
+ return nil
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/key_agreement.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/key_agreement.go
new file mode 100644
index 00000000..c53473a6
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/key_agreement.go
@@ -0,0 +1,400 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "crypto"
+ "crypto/ecdsa"
+ "crypto/elliptic"
+ "crypto/md5"
+ "crypto/rsa"
+ "crypto/sha1"
+ "crypto/sha256"
+ "crypto/x509"
+ "encoding/asn1"
+ "errors"
+ "io"
+ "math/big"
+)
+
+// rsaKeyAgreement implements the standard TLS key agreement where the client
+// encrypts the pre-master secret to the server's public key.
+type rsaKeyAgreement struct{}
+
+func (ka rsaKeyAgreement) generateServerKeyExchange(config *Config, cert *Certificate, clientHello *clientHelloMsg, hello *serverHelloMsg) (*serverKeyExchangeMsg, error) {
+ return nil, nil
+}
+
+func (ka rsaKeyAgreement) processClientKeyExchange(config *Config, cert *Certificate, ckx *clientKeyExchangeMsg, version uint16) ([]byte, error) {
+ preMasterSecret := make([]byte, 48)
+ _, err := io.ReadFull(config.rand(), preMasterSecret[2:])
+ if err != nil {
+ return nil, err
+ }
+
+ if len(ckx.ciphertext) < 2 {
+ return nil, errors.New("bad ClientKeyExchange")
+ }
+
+ ciphertext := ckx.ciphertext
+ if version != VersionSSL30 {
+ ciphertextLen := int(ckx.ciphertext[0])<<8 | int(ckx.ciphertext[1])
+ if ciphertextLen != len(ckx.ciphertext)-2 {
+ return nil, errors.New("bad ClientKeyExchange")
+ }
+ ciphertext = ckx.ciphertext[2:]
+ }
+
+ err = rsa.DecryptPKCS1v15SessionKey(config.rand(), cert.PrivateKey.(*rsa.PrivateKey), ciphertext, preMasterSecret)
+ if err != nil {
+ return nil, err
+ }
+ // We don't check the version number in the premaster secret. For one,
+ // by checking it, we would leak information about the validity of the
+ // encrypted pre-master secret. Secondly, it provides only a small
+ // benefit against a downgrade attack and some implementations send the
+ // wrong version anyway. See the discussion at the end of section
+ // 7.4.7.1 of RFC 4346.
+ return preMasterSecret, nil
+}
+
+func (ka rsaKeyAgreement) processServerKeyExchange(config *Config, clientHello *clientHelloMsg, serverHello *serverHelloMsg, cert *x509.Certificate, skx *serverKeyExchangeMsg) error {
+ return errors.New("unexpected ServerKeyExchange")
+}
+
+func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello *clientHelloMsg, cert *x509.Certificate) ([]byte, *clientKeyExchangeMsg, error) {
+ preMasterSecret := make([]byte, 48)
+ preMasterSecret[0] = byte(clientHello.vers >> 8)
+ preMasterSecret[1] = byte(clientHello.vers)
+ _, err := io.ReadFull(config.rand(), preMasterSecret[2:])
+ if err != nil {
+ return nil, nil, err
+ }
+
+ encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret)
+ if err != nil {
+ return nil, nil, err
+ }
+ ckx := new(clientKeyExchangeMsg)
+ ckx.ciphertext = make([]byte, len(encrypted)+2)
+ ckx.ciphertext[0] = byte(len(encrypted) >> 8)
+ ckx.ciphertext[1] = byte(len(encrypted))
+ copy(ckx.ciphertext[2:], encrypted)
+ return preMasterSecret, ckx, nil
+}
+
+// sha1Hash calculates a SHA1 hash over the given byte slices.
+func sha1Hash(slices [][]byte) []byte {
+ hsha1 := sha1.New()
+ for _, slice := range slices {
+ hsha1.Write(slice)
+ }
+ return hsha1.Sum(nil)
+}
+
+// md5SHA1Hash implements TLS 1.0's hybrid hash function which consists of the
+// concatenation of an MD5 and SHA1 hash.
+func md5SHA1Hash(slices [][]byte) []byte {
+ md5sha1 := make([]byte, md5.Size+sha1.Size)
+ hmd5 := md5.New()
+ for _, slice := range slices {
+ hmd5.Write(slice)
+ }
+ copy(md5sha1, hmd5.Sum(nil))
+ copy(md5sha1[md5.Size:], sha1Hash(slices))
+ return md5sha1
+}
+
+// sha256Hash implements TLS 1.2's hash function.
+func sha256Hash(slices [][]byte) []byte {
+ h := sha256.New()
+ for _, slice := range slices {
+ h.Write(slice)
+ }
+ return h.Sum(nil)
+}
+
+// hashForServerKeyExchange hashes the given slices and returns their digest
+// and the identifier of the hash function used. The hashFunc argument is only
+// used for >= TLS 1.2 and precisely identifies the hash function to use.
+func hashForServerKeyExchange(sigType, hashFunc uint8, version uint16, slices ...[]byte) ([]byte, crypto.Hash, error) {
+ if version >= VersionTLS12 {
+ switch hashFunc {
+ case hashSHA256:
+ return sha256Hash(slices), crypto.SHA256, nil
+ case hashSHA1:
+ return sha1Hash(slices), crypto.SHA1, nil
+ default:
+ return nil, crypto.Hash(0), errors.New("tls: unknown hash function used by peer")
+ }
+ }
+ if sigType == signatureECDSA {
+ return sha1Hash(slices), crypto.SHA1, nil
+ }
+ return md5SHA1Hash(slices), crypto.MD5SHA1, nil
+}
+
+// pickTLS12HashForSignature returns a TLS 1.2 hash identifier for signing a
+// ServerKeyExchange given the signature type being used and the client's
+// advertized list of supported signature and hash combinations.
+func pickTLS12HashForSignature(sigType uint8, clientSignatureAndHashes []signatureAndHash) (uint8, error) {
+ if len(clientSignatureAndHashes) == 0 {
+ // If the client didn't specify any signature_algorithms
+ // extension then we can assume that it supports SHA1. See
+ // http://tools.ietf.org/html/rfc5246#section-7.4.1.4.1
+ return hashSHA1, nil
+ }
+
+ for _, sigAndHash := range clientSignatureAndHashes {
+ if sigAndHash.signature != sigType {
+ continue
+ }
+ switch sigAndHash.hash {
+ case hashSHA1, hashSHA256:
+ return sigAndHash.hash, nil
+ }
+ }
+
+ return 0, errors.New("tls: client doesn't support any common hash functions")
+}
+
+// ecdheRSAKeyAgreement implements a TLS key agreement where the server
+// generates a ephemeral EC public/private key pair and signs it. The
+// pre-master secret is then calculated using ECDH. The signature may
+// either be ECDSA or RSA.
+type ecdheKeyAgreement struct {
+ version uint16
+ sigType uint8
+ privateKey []byte
+ curve elliptic.Curve
+ x, y *big.Int
+}
+
+func (ka *ecdheKeyAgreement) generateServerKeyExchange(config *Config, cert *Certificate, clientHello *clientHelloMsg, hello *serverHelloMsg) (*serverKeyExchangeMsg, error) {
+ var curveid uint16
+
+Curve:
+ for _, c := range clientHello.supportedCurves {
+ switch c {
+ case curveP256:
+ ka.curve = elliptic.P256()
+ curveid = c
+ break Curve
+ case curveP384:
+ ka.curve = elliptic.P384()
+ curveid = c
+ break Curve
+ case curveP521:
+ ka.curve = elliptic.P521()
+ curveid = c
+ break Curve
+ }
+ }
+
+ if curveid == 0 {
+ return nil, errors.New("tls: no supported elliptic curves offered")
+ }
+
+ var x, y *big.Int
+ var err error
+ ka.privateKey, x, y, err = elliptic.GenerateKey(ka.curve, config.rand())
+ if err != nil {
+ return nil, err
+ }
+ ecdhePublic := elliptic.Marshal(ka.curve, x, y)
+
+ // http://tools.ietf.org/html/rfc4492#section-5.4
+ serverECDHParams := make([]byte, 1+2+1+len(ecdhePublic))
+ serverECDHParams[0] = 3 // named curve
+ serverECDHParams[1] = byte(curveid >> 8)
+ serverECDHParams[2] = byte(curveid)
+ serverECDHParams[3] = byte(len(ecdhePublic))
+ copy(serverECDHParams[4:], ecdhePublic)
+
+ var tls12HashId uint8
+ if ka.version >= VersionTLS12 {
+ if tls12HashId, err = pickTLS12HashForSignature(ka.sigType, clientHello.signatureAndHashes); err != nil {
+ return nil, err
+ }
+ }
+
+ digest, hashFunc, err := hashForServerKeyExchange(ka.sigType, tls12HashId, ka.version, clientHello.random, hello.random, serverECDHParams)
+ if err != nil {
+ return nil, err
+ }
+ var sig []byte
+ switch ka.sigType {
+ case signatureECDSA:
+ privKey, ok := cert.PrivateKey.(*ecdsa.PrivateKey)
+ if !ok {
+ return nil, errors.New("ECDHE ECDSA requires an ECDSA server private key")
+ }
+ r, s, err := ecdsa.Sign(config.rand(), privKey, digest)
+ if err != nil {
+ return nil, errors.New("failed to sign ECDHE parameters: " + err.Error())
+ }
+ sig, err = asn1.Marshal(ecdsaSignature{r, s})
+ case signatureRSA:
+ privKey, ok := cert.PrivateKey.(*rsa.PrivateKey)
+ if !ok {
+ return nil, errors.New("ECDHE RSA requires a RSA server private key")
+ }
+ sig, err = rsa.SignPKCS1v15(config.rand(), privKey, hashFunc, digest)
+ if err != nil {
+ return nil, errors.New("failed to sign ECDHE parameters: " + err.Error())
+ }
+ default:
+ return nil, errors.New("unknown ECDHE signature algorithm")
+ }
+
+ skx := new(serverKeyExchangeMsg)
+ sigAndHashLen := 0
+ if ka.version >= VersionTLS12 {
+ sigAndHashLen = 2
+ }
+ skx.key = make([]byte, len(serverECDHParams)+sigAndHashLen+2+len(sig))
+ copy(skx.key, serverECDHParams)
+ k := skx.key[len(serverECDHParams):]
+ if ka.version >= VersionTLS12 {
+ k[0] = tls12HashId
+ k[1] = ka.sigType
+ k = k[2:]
+ }
+ k[0] = byte(len(sig) >> 8)
+ k[1] = byte(len(sig))
+ copy(k[2:], sig)
+
+ return skx, nil
+}
+
+func (ka *ecdheKeyAgreement) processClientKeyExchange(config *Config, cert *Certificate, ckx *clientKeyExchangeMsg, version uint16) ([]byte, error) {
+ if len(ckx.ciphertext) == 0 || int(ckx.ciphertext[0]) != len(ckx.ciphertext)-1 {
+ return nil, errors.New("bad ClientKeyExchange")
+ }
+ x, y := elliptic.Unmarshal(ka.curve, ckx.ciphertext[1:])
+ if x == nil {
+ return nil, errors.New("bad ClientKeyExchange")
+ }
+ x, _ = ka.curve.ScalarMult(x, y, ka.privateKey)
+ preMasterSecret := make([]byte, (ka.curve.Params().BitSize+7)>>3)
+ xBytes := x.Bytes()
+ copy(preMasterSecret[len(preMasterSecret)-len(xBytes):], xBytes)
+
+ return preMasterSecret, nil
+}
+
+var errServerKeyExchange = errors.New("invalid ServerKeyExchange")
+
+func (ka *ecdheKeyAgreement) processServerKeyExchange(config *Config, clientHello *clientHelloMsg, serverHello *serverHelloMsg, cert *x509.Certificate, skx *serverKeyExchangeMsg) error {
+ if len(skx.key) < 4 {
+ return errServerKeyExchange
+ }
+ if skx.key[0] != 3 { // named curve
+ return errors.New("server selected unsupported curve")
+ }
+ curveid := uint16(skx.key[1])<<8 | uint16(skx.key[2])
+
+ switch curveid {
+ case curveP256:
+ ka.curve = elliptic.P256()
+ case curveP384:
+ ka.curve = elliptic.P384()
+ case curveP521:
+ ka.curve = elliptic.P521()
+ default:
+ return errors.New("server selected unsupported curve")
+ }
+
+ publicLen := int(skx.key[3])
+ if publicLen+4 > len(skx.key) {
+ return errServerKeyExchange
+ }
+ ka.x, ka.y = elliptic.Unmarshal(ka.curve, skx.key[4:4+publicLen])
+ if ka.x == nil {
+ return errServerKeyExchange
+ }
+ serverECDHParams := skx.key[:4+publicLen]
+
+ sig := skx.key[4+publicLen:]
+ if len(sig) < 2 {
+ return errServerKeyExchange
+ }
+
+ var tls12HashId uint8
+ if ka.version >= VersionTLS12 {
+ // handle SignatureAndHashAlgorithm
+ var sigAndHash []uint8
+ sigAndHash, sig = sig[:2], sig[2:]
+ if sigAndHash[1] != ka.sigType {
+ return errServerKeyExchange
+ }
+ tls12HashId = sigAndHash[0]
+ if len(sig) < 2 {
+ return errServerKeyExchange
+ }
+ }
+ sigLen := int(sig[0])<<8 | int(sig[1])
+ if sigLen+2 != len(sig) {
+ return errServerKeyExchange
+ }
+ sig = sig[2:]
+
+ digest, hashFunc, err := hashForServerKeyExchange(ka.sigType, tls12HashId, ka.version, clientHello.random, serverHello.random, serverECDHParams)
+ if err != nil {
+ return err
+ }
+ switch ka.sigType {
+ case signatureECDSA:
+ pubKey, ok := cert.PublicKey.(*ecdsa.PublicKey)
+ if !ok {
+ return errors.New("ECDHE ECDSA requires a ECDSA server public key")
+ }
+ ecdsaSig := new(ecdsaSignature)
+ if _, err := asn1.Unmarshal(sig, ecdsaSig); err != nil {
+ return err
+ }
+ if ecdsaSig.R.Sign() <= 0 || ecdsaSig.S.Sign() <= 0 {
+ return errors.New("ECDSA signature contained zero or negative values")
+ }
+ if !ecdsa.Verify(pubKey, digest, ecdsaSig.R, ecdsaSig.S) {
+ return errors.New("ECDSA verification failure")
+ }
+ case signatureRSA:
+ pubKey, ok := cert.PublicKey.(*rsa.PublicKey)
+ if !ok {
+ return errors.New("ECDHE RSA requires a RSA server public key")
+ }
+ if err := rsa.VerifyPKCS1v15(pubKey, hashFunc, digest, sig); err != nil {
+ return err
+ }
+ default:
+ return errors.New("unknown ECDHE signature algorithm")
+ }
+
+ return nil
+}
+
+func (ka *ecdheKeyAgreement) generateClientKeyExchange(config *Config, clientHello *clientHelloMsg, cert *x509.Certificate) ([]byte, *clientKeyExchangeMsg, error) {
+ if ka.curve == nil {
+ return nil, nil, errors.New("missing ServerKeyExchange message")
+ }
+ priv, mx, my, err := elliptic.GenerateKey(ka.curve, config.rand())
+ if err != nil {
+ return nil, nil, err
+ }
+ x, _ := ka.curve.ScalarMult(ka.x, ka.y, priv)
+ preMasterSecret := make([]byte, (ka.curve.Params().BitSize+7)>>3)
+ xBytes := x.Bytes()
+ copy(preMasterSecret[len(preMasterSecret)-len(xBytes):], xBytes)
+
+ serialized := elliptic.Marshal(ka.curve, mx, my)
+
+ ckx := new(clientKeyExchangeMsg)
+ ckx.ciphertext = make([]byte, 1+len(serialized))
+ ckx.ciphertext[0] = byte(len(serialized))
+ copy(ckx.ciphertext[1:], serialized)
+
+ return preMasterSecret, ckx, nil
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/main.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/main.go
new file mode 100644
index 00000000..0b43ce8e
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/main.go
@@ -0,0 +1,151 @@
+package main
+
+import (
+ "crypto/rand"
+ "encoding/hex"
+ "flag"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net"
+ "os"
+ "time"
+)
+
+const disclaimer = `
+This program was written to help system administrators test their servers for
+the OpenSSL "heartbleed" vulnerability. The author is not responsible for any
+damages as a result of using this tool (may eat your data, etc.) or for any
+misuse of this tool for malicious purposes.
+`
+
+var (
+ nbytes = flag.Int("n", 16, "number of bytes to request")
+ output = flag.String("o", "", "write binary data to the specified file")
+ quiet = flag.Bool("q", false, "quiet, use exit code to report server status (0=safe)")
+ timeout = flag.Duration("t", 5*time.Second, "i/o timeout")
+)
+
+func init() {
+ flag.Usage = func() {
+ fmt.Fprintf(os.Stderr, "usage: %s [options] host:port\n\n", os.Args[0])
+ flag.PrintDefaults()
+ fmt.Fprintf(os.Stderr, disclaimer)
+ }
+ if flag.Parse(); flag.NArg() != 1 {
+ flag.Usage()
+ os.Exit(2)
+ }
+}
+
+func main() {
+ c, err := Dial("tcp", flag.Arg(0), &Config{InsecureSkipVerify: true})
+ if err != nil {
+ panic(err)
+ }
+ defer c.Close()
+
+ info("Connected to %s", flag.Arg(0))
+ c.SetDeadline(time.Now().Add(*timeout))
+
+ if _, err := c.Heartbeat(nil); err != nil {
+ info("Server does not support TLS heartbeats :)")
+ if isTimeout(err) || isUnexpected(err) {
+ return
+ }
+ panic(err)
+ }
+
+ info("Server supports TLS heartbeats, requesting %d bytes...", *nbytes)
+ b, err := c.Heartbleed(*nbytes)
+ if len(b) == 0 && err != nil {
+ info("Server is not vulnerable :)")
+ if err == io.EOF || isTimeout(err) {
+ return
+ }
+ panic(err)
+ }
+
+ if *output != "" {
+ ioutil.WriteFile(*output, b, 0666)
+ }
+ if !*quiet {
+ w := hex.Dumper(os.Stdout)
+ w.Write(b)
+ w.Close()
+ }
+ info("Server is vulnerable :(")
+ if err != nil {
+ panic(err)
+ }
+ os.Exit(1)
+}
+
+func info(format string, a ...interface{}) {
+ if !*quiet {
+ fmt.Fprintf(os.Stderr, format+"\n", a...)
+ }
+}
+
+func isTimeout(err error) bool {
+ e, ok := err.(net.Error)
+ return ok && e.Timeout()
+}
+
+func isUnexpected(err error) bool {
+ e, ok := err.(*net.OpError)
+ return ok && e.Err == alertUnexpectedMessage
+}
+
+func (c *Conn) Heartbeat(b []byte) ([]byte, error) {
+ io.ReadFull(rand.Reader, c.tmp[:16])
+ return c.heartbeat(len(b), b, c.tmp[:16])
+}
+
+func (c *Conn) Heartbleed(n int) ([]byte, error) {
+ return c.heartbeat(n, nil, nil)
+}
+
+const (
+ recordTypeHeartbeat recordType = 24
+ heartbeatRequest byte = 1
+ heartbeatResponse byte = 2
+)
+
+func (c *Conn) heartbeat(n int, payload, padding []byte) ([]byte, error) {
+ if err := c.Handshake(); err != nil {
+ return nil, err
+ }
+
+ buf := make([]byte, 3, 3+len(payload)+len(padding))
+ buf[0] = heartbeatRequest
+ buf[1] = byte(n >> 8)
+ buf[2] = byte(n)
+ buf = append(append(buf, payload...), padding...)
+
+ c.out.Lock()
+ defer c.out.Unlock()
+ c.writeRecord(recordTypeHeartbeat, buf)
+
+ const maxConsecutiveEmptyRecords = 100
+ for emptyRecordCount := 0; emptyRecordCount <= maxConsecutiveEmptyRecords; emptyRecordCount++ {
+ for c.hb == nil && c.error() == nil {
+ if err := c.readRecord(recordTypeHeartbeat); err != nil {
+ // Soft error, like EAGAIN
+ return nil, err
+ }
+ }
+ var b []byte
+ if c.hb != nil {
+ b = c.hb.data[c.hb.off:]
+ c.hb = nil
+ if len(b) < 1+2+16 || b[0] != heartbeatResponse {
+ b = nil
+ } else {
+ b = b[3 : len(b)-16]
+ }
+ }
+ return b, c.error()
+ }
+ return nil, io.ErrNoProgress
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/prf.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/prf.go
new file mode 100644
index 00000000..36ca210c
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/prf.go
@@ -0,0 +1,291 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "crypto"
+ "crypto/hmac"
+ "crypto/md5"
+ "crypto/sha1"
+ "crypto/sha256"
+ "hash"
+)
+
+// Split a premaster secret in two as specified in RFC 4346, section 5.
+func splitPreMasterSecret(secret []byte) (s1, s2 []byte) {
+ s1 = secret[0 : (len(secret)+1)/2]
+ s2 = secret[len(secret)/2:]
+ return
+}
+
+// pHash implements the P_hash function, as defined in RFC 4346, section 5.
+func pHash(result, secret, seed []byte, hash func() hash.Hash) {
+ h := hmac.New(hash, secret)
+ h.Write(seed)
+ a := h.Sum(nil)
+
+ j := 0
+ for j < len(result) {
+ h.Reset()
+ h.Write(a)
+ h.Write(seed)
+ b := h.Sum(nil)
+ todo := len(b)
+ if j+todo > len(result) {
+ todo = len(result) - j
+ }
+ copy(result[j:j+todo], b)
+ j += todo
+
+ h.Reset()
+ h.Write(a)
+ a = h.Sum(nil)
+ }
+}
+
+// prf10 implements the TLS 1.0 pseudo-random function, as defined in RFC 2246, section 5.
+func prf10(result, secret, label, seed []byte) {
+ hashSHA1 := sha1.New
+ hashMD5 := md5.New
+
+ labelAndSeed := make([]byte, len(label)+len(seed))
+ copy(labelAndSeed, label)
+ copy(labelAndSeed[len(label):], seed)
+
+ s1, s2 := splitPreMasterSecret(secret)
+ pHash(result, s1, labelAndSeed, hashMD5)
+ result2 := make([]byte, len(result))
+ pHash(result2, s2, labelAndSeed, hashSHA1)
+
+ for i, b := range result2 {
+ result[i] ^= b
+ }
+}
+
+// prf12 implements the TLS 1.2 pseudo-random function, as defined in RFC 5246, section 5.
+func prf12(result, secret, label, seed []byte) {
+ labelAndSeed := make([]byte, len(label)+len(seed))
+ copy(labelAndSeed, label)
+ copy(labelAndSeed[len(label):], seed)
+
+ pHash(result, secret, labelAndSeed, sha256.New)
+}
+
+// prf30 implements the SSL 3.0 pseudo-random function, as defined in
+// www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt section 6.
+func prf30(result, secret, label, seed []byte) {
+ hashSHA1 := sha1.New()
+ hashMD5 := md5.New()
+
+ done := 0
+ i := 0
+ // RFC5246 section 6.3 says that the largest PRF output needed is 128
+ // bytes. Since no more ciphersuites will be added to SSLv3, this will
+ // remain true. Each iteration gives us 16 bytes so 10 iterations will
+ // be sufficient.
+ var b [11]byte
+ for done < len(result) {
+ for j := 0; j <= i; j++ {
+ b[j] = 'A' + byte(i)
+ }
+
+ hashSHA1.Reset()
+ hashSHA1.Write(b[:i+1])
+ hashSHA1.Write(secret)
+ hashSHA1.Write(seed)
+ digest := hashSHA1.Sum(nil)
+
+ hashMD5.Reset()
+ hashMD5.Write(secret)
+ hashMD5.Write(digest)
+
+ done += copy(result[done:], hashMD5.Sum(nil))
+ i++
+ }
+}
+
+const (
+ tlsRandomLength = 32 // Length of a random nonce in TLS 1.1.
+ masterSecretLength = 48 // Length of a master secret in TLS 1.1.
+ finishedVerifyLength = 12 // Length of verify_data in a Finished message.
+)
+
+var masterSecretLabel = []byte("master secret")
+var keyExpansionLabel = []byte("key expansion")
+var clientFinishedLabel = []byte("client finished")
+var serverFinishedLabel = []byte("server finished")
+
+func prfForVersion(version uint16) func(result, secret, label, seed []byte) {
+ switch version {
+ case VersionSSL30:
+ return prf30
+ case VersionTLS10, VersionTLS11:
+ return prf10
+ case VersionTLS12:
+ return prf12
+ default:
+ panic("unknown version")
+ }
+}
+
+// masterFromPreMasterSecret generates the master secret from the pre-master
+// secret. See http://tools.ietf.org/html/rfc5246#section-8.1
+func masterFromPreMasterSecret(version uint16, preMasterSecret, clientRandom, serverRandom []byte) []byte {
+ var seed [tlsRandomLength * 2]byte
+ copy(seed[0:len(clientRandom)], clientRandom)
+ copy(seed[len(clientRandom):], serverRandom)
+ masterSecret := make([]byte, masterSecretLength)
+ prfForVersion(version)(masterSecret, preMasterSecret, masterSecretLabel, seed[0:])
+ return masterSecret
+}
+
+// keysFromMasterSecret generates the connection keys from the master
+// secret, given the lengths of the MAC key, cipher key and IV, as defined in
+// RFC 2246, section 6.3.
+func keysFromMasterSecret(version uint16, masterSecret, clientRandom, serverRandom []byte, macLen, keyLen, ivLen int) (clientMAC, serverMAC, clientKey, serverKey, clientIV, serverIV []byte) {
+ var seed [tlsRandomLength * 2]byte
+ copy(seed[0:len(clientRandom)], serverRandom)
+ copy(seed[len(serverRandom):], clientRandom)
+
+ n := 2*macLen + 2*keyLen + 2*ivLen
+ keyMaterial := make([]byte, n)
+ prfForVersion(version)(keyMaterial, masterSecret, keyExpansionLabel, seed[0:])
+ clientMAC = keyMaterial[:macLen]
+ keyMaterial = keyMaterial[macLen:]
+ serverMAC = keyMaterial[:macLen]
+ keyMaterial = keyMaterial[macLen:]
+ clientKey = keyMaterial[:keyLen]
+ keyMaterial = keyMaterial[keyLen:]
+ serverKey = keyMaterial[:keyLen]
+ keyMaterial = keyMaterial[keyLen:]
+ clientIV = keyMaterial[:ivLen]
+ keyMaterial = keyMaterial[ivLen:]
+ serverIV = keyMaterial[:ivLen]
+ return
+}
+
+func newFinishedHash(version uint16) finishedHash {
+ if version >= VersionTLS12 {
+ return finishedHash{sha256.New(), sha256.New(), nil, nil, version}
+ }
+ return finishedHash{sha1.New(), sha1.New(), md5.New(), md5.New(), version}
+}
+
+// A finishedHash calculates the hash of a set of handshake messages suitable
+// for including in a Finished message.
+type finishedHash struct {
+ client hash.Hash
+ server hash.Hash
+
+ // Prior to TLS 1.2, an additional MD5 hash is required.
+ clientMD5 hash.Hash
+ serverMD5 hash.Hash
+
+ version uint16
+}
+
+func (h finishedHash) Write(msg []byte) (n int, err error) {
+ h.client.Write(msg)
+ h.server.Write(msg)
+
+ if h.version < VersionTLS12 {
+ h.clientMD5.Write(msg)
+ h.serverMD5.Write(msg)
+ }
+ return len(msg), nil
+}
+
+// finishedSum30 calculates the contents of the verify_data member of a SSLv3
+// Finished message given the MD5 and SHA1 hashes of a set of handshake
+// messages.
+func finishedSum30(md5, sha1 hash.Hash, masterSecret []byte, magic [4]byte) []byte {
+ md5.Write(magic[:])
+ md5.Write(masterSecret)
+ md5.Write(ssl30Pad1[:])
+ md5Digest := md5.Sum(nil)
+
+ md5.Reset()
+ md5.Write(masterSecret)
+ md5.Write(ssl30Pad2[:])
+ md5.Write(md5Digest)
+ md5Digest = md5.Sum(nil)
+
+ sha1.Write(magic[:])
+ sha1.Write(masterSecret)
+ sha1.Write(ssl30Pad1[:40])
+ sha1Digest := sha1.Sum(nil)
+
+ sha1.Reset()
+ sha1.Write(masterSecret)
+ sha1.Write(ssl30Pad2[:40])
+ sha1.Write(sha1Digest)
+ sha1Digest = sha1.Sum(nil)
+
+ ret := make([]byte, len(md5Digest)+len(sha1Digest))
+ copy(ret, md5Digest)
+ copy(ret[len(md5Digest):], sha1Digest)
+ return ret
+}
+
+var ssl3ClientFinishedMagic = [4]byte{0x43, 0x4c, 0x4e, 0x54}
+var ssl3ServerFinishedMagic = [4]byte{0x53, 0x52, 0x56, 0x52}
+
+// clientSum returns the contents of the verify_data member of a client's
+// Finished message.
+func (h finishedHash) clientSum(masterSecret []byte) []byte {
+ if h.version == VersionSSL30 {
+ return finishedSum30(h.clientMD5, h.client, masterSecret, ssl3ClientFinishedMagic)
+ }
+
+ out := make([]byte, finishedVerifyLength)
+ if h.version >= VersionTLS12 {
+ seed := h.client.Sum(nil)
+ prf12(out, masterSecret, clientFinishedLabel, seed)
+ } else {
+ seed := make([]byte, 0, md5.Size+sha1.Size)
+ seed = h.clientMD5.Sum(seed)
+ seed = h.client.Sum(seed)
+ prf10(out, masterSecret, clientFinishedLabel, seed)
+ }
+ return out
+}
+
+// serverSum returns the contents of the verify_data member of a server's
+// Finished message.
+func (h finishedHash) serverSum(masterSecret []byte) []byte {
+ if h.version == VersionSSL30 {
+ return finishedSum30(h.serverMD5, h.server, masterSecret, ssl3ServerFinishedMagic)
+ }
+
+ out := make([]byte, finishedVerifyLength)
+ if h.version >= VersionTLS12 {
+ seed := h.server.Sum(nil)
+ prf12(out, masterSecret, serverFinishedLabel, seed)
+ } else {
+ seed := make([]byte, 0, md5.Size+sha1.Size)
+ seed = h.serverMD5.Sum(seed)
+ seed = h.server.Sum(seed)
+ prf10(out, masterSecret, serverFinishedLabel, seed)
+ }
+ return out
+}
+
+// hashForClientCertificate returns a digest, hash function, and TLS 1.2 hash
+// id suitable for signing by a TLS client certificate.
+func (h finishedHash) hashForClientCertificate(sigType uint8) ([]byte, crypto.Hash, uint8) {
+ if h.version >= VersionTLS12 {
+ digest := h.server.Sum(nil)
+ return digest, crypto.SHA256, hashSHA256
+ }
+ if sigType == signatureECDSA {
+ digest := h.server.Sum(nil)
+ return digest, crypto.SHA1, hashSHA1
+ }
+
+ digest := make([]byte, 0, 36)
+ digest = h.serverMD5.Sum(digest)
+ digest = h.server.Sum(digest)
+ return digest, crypto.MD5SHA1, 0 /* not specified in TLS 1.2. */
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/ticket.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/ticket.go
new file mode 100644
index 00000000..70e91cfc
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/ticket.go
@@ -0,0 +1,182 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "bytes"
+ "crypto/aes"
+ "crypto/cipher"
+ "crypto/hmac"
+ "crypto/sha256"
+ "crypto/subtle"
+ "errors"
+ "io"
+)
+
+// sessionState contains the information that is serialized into a session
+// ticket in order to later resume a connection.
+type sessionState struct {
+ vers uint16
+ cipherSuite uint16
+ masterSecret []byte
+ certificates [][]byte
+}
+
+func (s *sessionState) equal(i interface{}) bool {
+ s1, ok := i.(*sessionState)
+ if !ok {
+ return false
+ }
+
+ if s.vers != s1.vers ||
+ s.cipherSuite != s1.cipherSuite ||
+ !bytes.Equal(s.masterSecret, s1.masterSecret) {
+ return false
+ }
+
+ if len(s.certificates) != len(s1.certificates) {
+ return false
+ }
+
+ for i := range s.certificates {
+ if !bytes.Equal(s.certificates[i], s1.certificates[i]) {
+ return false
+ }
+ }
+
+ return true
+}
+
+func (s *sessionState) marshal() []byte {
+ length := 2 + 2 + 2 + len(s.masterSecret) + 2
+ for _, cert := range s.certificates {
+ length += 4 + len(cert)
+ }
+
+ ret := make([]byte, length)
+ x := ret
+ x[0] = byte(s.vers >> 8)
+ x[1] = byte(s.vers)
+ x[2] = byte(s.cipherSuite >> 8)
+ x[3] = byte(s.cipherSuite)
+ x[4] = byte(len(s.masterSecret) >> 8)
+ x[5] = byte(len(s.masterSecret))
+ x = x[6:]
+ copy(x, s.masterSecret)
+ x = x[len(s.masterSecret):]
+
+ x[0] = byte(len(s.certificates) >> 8)
+ x[1] = byte(len(s.certificates))
+ x = x[2:]
+
+ for _, cert := range s.certificates {
+ x[0] = byte(len(cert) >> 24)
+ x[1] = byte(len(cert) >> 16)
+ x[2] = byte(len(cert) >> 8)
+ x[3] = byte(len(cert))
+ copy(x[4:], cert)
+ x = x[4+len(cert):]
+ }
+
+ return ret
+}
+
+func (s *sessionState) unmarshal(data []byte) bool {
+ if len(data) < 8 {
+ return false
+ }
+
+ s.vers = uint16(data[0])<<8 | uint16(data[1])
+ s.cipherSuite = uint16(data[2])<<8 | uint16(data[3])
+ masterSecretLen := int(data[4])<<8 | int(data[5])
+ data = data[6:]
+ if len(data) < masterSecretLen {
+ return false
+ }
+
+ s.masterSecret = data[:masterSecretLen]
+ data = data[masterSecretLen:]
+
+ if len(data) < 2 {
+ return false
+ }
+
+ numCerts := int(data[0])<<8 | int(data[1])
+ data = data[2:]
+
+ s.certificates = make([][]byte, numCerts)
+ for i := range s.certificates {
+ if len(data) < 4 {
+ return false
+ }
+ certLen := int(data[0])<<24 | int(data[1])<<16 | int(data[2])<<8 | int(data[3])
+ data = data[4:]
+ if certLen < 0 {
+ return false
+ }
+ if len(data) < certLen {
+ return false
+ }
+ s.certificates[i] = data[:certLen]
+ data = data[certLen:]
+ }
+
+ if len(data) > 0 {
+ return false
+ }
+
+ return true
+}
+
+func (c *Conn) encryptTicket(state *sessionState) ([]byte, error) {
+ serialized := state.marshal()
+ encrypted := make([]byte, aes.BlockSize+len(serialized)+sha256.Size)
+ iv := encrypted[:aes.BlockSize]
+ macBytes := encrypted[len(encrypted)-sha256.Size:]
+
+ if _, err := io.ReadFull(c.config.rand(), iv); err != nil {
+ return nil, err
+ }
+ block, err := aes.NewCipher(c.config.SessionTicketKey[:16])
+ if err != nil {
+ return nil, errors.New("tls: failed to create cipher while encrypting ticket: " + err.Error())
+ }
+ cipher.NewCTR(block, iv).XORKeyStream(encrypted[aes.BlockSize:], serialized)
+
+ mac := hmac.New(sha256.New, c.config.SessionTicketKey[16:32])
+ mac.Write(encrypted[:len(encrypted)-sha256.Size])
+ mac.Sum(macBytes[:0])
+
+ return encrypted, nil
+}
+
+func (c *Conn) decryptTicket(encrypted []byte) (*sessionState, bool) {
+ if len(encrypted) < aes.BlockSize+sha256.Size {
+ return nil, false
+ }
+
+ iv := encrypted[:aes.BlockSize]
+ macBytes := encrypted[len(encrypted)-sha256.Size:]
+
+ mac := hmac.New(sha256.New, c.config.SessionTicketKey[16:32])
+ mac.Write(encrypted[:len(encrypted)-sha256.Size])
+ expected := mac.Sum(nil)
+
+ if subtle.ConstantTimeCompare(macBytes, expected) != 1 {
+ return nil, false
+ }
+
+ block, err := aes.NewCipher(c.config.SessionTicketKey[:16])
+ if err != nil {
+ return nil, false
+ }
+ ciphertext := encrypted[aes.BlockSize : len(encrypted)-sha256.Size]
+ plaintext := ciphertext
+ cipher.NewCTR(block, iv).XORKeyStream(plaintext, ciphertext)
+
+ state := new(sessionState)
+ ok := state.unmarshal(plaintext)
+ return state, ok
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/tls.go b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/tls.go
new file mode 100644
index 00000000..c8574bb4
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/code.google.com/p/mxk/go1/tlshb/tls.go
@@ -0,0 +1,225 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package tls partially implements TLS 1.2, as specified in RFC 5246.
+package main
+
+import (
+ "crypto"
+ "crypto/ecdsa"
+ "crypto/rsa"
+ "crypto/x509"
+ "encoding/pem"
+ "errors"
+ "io/ioutil"
+ "net"
+ "strings"
+)
+
+// Server returns a new TLS server side connection
+// using conn as the underlying transport.
+// The configuration config must be non-nil and must have
+// at least one certificate.
+func Server(conn net.Conn, config *Config) *Conn {
+ return &Conn{conn: conn, config: config}
+}
+
+// Client returns a new TLS client side connection
+// using conn as the underlying transport.
+// Client interprets a nil configuration as equivalent to
+// the zero configuration; see the documentation of Config
+// for the defaults.
+func Client(conn net.Conn, config *Config) *Conn {
+ return &Conn{conn: conn, config: config, isClient: true}
+}
+
+// A listener implements a network listener (net.Listener) for TLS connections.
+type listener struct {
+ net.Listener
+ config *Config
+}
+
+// Accept waits for and returns the next incoming TLS connection.
+// The returned connection c is a *tls.Conn.
+func (l *listener) Accept() (c net.Conn, err error) {
+ c, err = l.Listener.Accept()
+ if err != nil {
+ return
+ }
+ c = Server(c, l.config)
+ return
+}
+
+// NewListener creates a Listener which accepts connections from an inner
+// Listener and wraps each connection with Server.
+// The configuration config must be non-nil and must have
+// at least one certificate.
+func NewListener(inner net.Listener, config *Config) net.Listener {
+ l := new(listener)
+ l.Listener = inner
+ l.config = config
+ return l
+}
+
+// Listen creates a TLS listener accepting connections on the
+// given network address using net.Listen.
+// The configuration config must be non-nil and must have
+// at least one certificate.
+func Listen(network, laddr string, config *Config) (net.Listener, error) {
+ if config == nil || len(config.Certificates) == 0 {
+ return nil, errors.New("tls.Listen: no certificates in configuration")
+ }
+ l, err := net.Listen(network, laddr)
+ if err != nil {
+ return nil, err
+ }
+ return NewListener(l, config), nil
+}
+
+// Dial connects to the given network address using net.Dial
+// and then initiates a TLS handshake, returning the resulting
+// TLS connection.
+// Dial interprets a nil configuration as equivalent to
+// the zero configuration; see the documentation of Config
+// for the defaults.
+func Dial(network, addr string, config *Config) (*Conn, error) {
+ raddr := addr
+ c, err := net.Dial(network, raddr)
+ if err != nil {
+ return nil, err
+ }
+
+ colonPos := strings.LastIndex(raddr, ":")
+ if colonPos == -1 {
+ colonPos = len(raddr)
+ }
+ hostname := raddr[:colonPos]
+
+ if config == nil {
+ config = defaultConfig()
+ }
+ // If no ServerName is set, infer the ServerName
+ // from the hostname we're connecting to.
+ if config.ServerName == "" {
+ // Make a copy to avoid polluting argument or default.
+ c := *config
+ c.ServerName = hostname
+ config = &c
+ }
+ conn := Client(c, config)
+ if err = conn.Handshake(); err != nil {
+ c.Close()
+ return nil, err
+ }
+ return conn, nil
+}
+
+// LoadX509KeyPair reads and parses a public/private key pair from a pair of
+// files. The files must contain PEM encoded data.
+func LoadX509KeyPair(certFile, keyFile string) (cert Certificate, err error) {
+ certPEMBlock, err := ioutil.ReadFile(certFile)
+ if err != nil {
+ return
+ }
+ keyPEMBlock, err := ioutil.ReadFile(keyFile)
+ if err != nil {
+ return
+ }
+ return X509KeyPair(certPEMBlock, keyPEMBlock)
+}
+
+// X509KeyPair parses a public/private key pair from a pair of
+// PEM encoded data.
+func X509KeyPair(certPEMBlock, keyPEMBlock []byte) (cert Certificate, err error) {
+ var certDERBlock *pem.Block
+ for {
+ certDERBlock, certPEMBlock = pem.Decode(certPEMBlock)
+ if certDERBlock == nil {
+ break
+ }
+ if certDERBlock.Type == "CERTIFICATE" {
+ cert.Certificate = append(cert.Certificate, certDERBlock.Bytes)
+ }
+ }
+
+ if len(cert.Certificate) == 0 {
+ err = errors.New("crypto/tls: failed to parse certificate PEM data")
+ return
+ }
+
+ var keyDERBlock *pem.Block
+ for {
+ keyDERBlock, keyPEMBlock = pem.Decode(keyPEMBlock)
+ if keyDERBlock == nil {
+ err = errors.New("crypto/tls: failed to parse key PEM data")
+ return
+ }
+ if keyDERBlock.Type == "PRIVATE KEY" || strings.HasSuffix(keyDERBlock.Type, " PRIVATE KEY") {
+ break
+ }
+ }
+
+ cert.PrivateKey, err = parsePrivateKey(keyDERBlock.Bytes)
+ if err != nil {
+ return
+ }
+
+ // We don't need to parse the public key for TLS, but we so do anyway
+ // to check that it looks sane and matches the private key.
+ x509Cert, err := x509.ParseCertificate(cert.Certificate[0])
+ if err != nil {
+ return
+ }
+
+ switch pub := x509Cert.PublicKey.(type) {
+ case *rsa.PublicKey:
+ priv, ok := cert.PrivateKey.(*rsa.PrivateKey)
+ if !ok {
+ err = errors.New("crypto/tls: private key type does not match public key type")
+ return
+ }
+ if pub.N.Cmp(priv.N) != 0 {
+ err = errors.New("crypto/tls: private key does not match public key")
+ return
+ }
+ case *ecdsa.PublicKey:
+ priv, ok := cert.PrivateKey.(*ecdsa.PrivateKey)
+ if !ok {
+ err = errors.New("crypto/tls: private key type does not match public key type")
+ return
+
+ }
+ if pub.X.Cmp(priv.X) != 0 || pub.Y.Cmp(priv.Y) != 0 {
+ err = errors.New("crypto/tls: private key does not match public key")
+ return
+ }
+ default:
+ err = errors.New("crypto/tls: unknown public key algorithm")
+ return
+ }
+
+ return
+}
+
+// Attempt to parse the given private key DER block. OpenSSL 0.9.8 generates
+// PKCS#1 private keys by default, while OpenSSL 1.0.0 generates PKCS#8 keys.
+// OpenSSL ecparam generates SEC1 EC private keys for ECDSA. We try all three.
+func parsePrivateKey(der []byte) (crypto.PrivateKey, error) {
+ if key, err := x509.ParsePKCS1PrivateKey(der); err == nil {
+ return key, nil
+ }
+ if key, err := x509.ParsePKCS8PrivateKey(der); err == nil {
+ switch key := key.(type) {
+ case *rsa.PrivateKey, *ecdsa.PrivateKey:
+ return key, nil
+ default:
+ return nil, errors.New("crypto/tls: found unknown private key type in PKCS#8 wrapping")
+ }
+ }
+ if key, err := x509.ParseECPrivateKey(der); err == nil {
+ return key, nil
+ }
+
+ return nil, errors.New("crypto/tls: failed to parse private key")
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/.gitignore b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/.gitignore
deleted file mode 100644
index 00268614..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/.gitignore
+++ /dev/null
@@ -1,22 +0,0 @@
-# Compiled Object files, Static and Dynamic libs (Shared Objects)
-*.o
-*.a
-*.so
-
-# Folders
-_obj
-_test
-
-# Architecture specific extensions/prefixes
-*.[568vq]
-[568vq].out
-
-*.cgo1.go
-*.cgo2.c
-_cgo_defun.c
-_cgo_gotypes.go
-_cgo_export.*
-
-_testmain.go
-
-*.exe
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/.travis.yml b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/.travis.yml
deleted file mode 100644
index 4f2ee4d9..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/.travis.yml
+++ /dev/null
@@ -1 +0,0 @@
-language: go
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/AUTHORS b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/AUTHORS
deleted file mode 100644
index 998341c9..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/AUTHORS
+++ /dev/null
@@ -1,5 +0,0 @@
-# List of gocov authors.
-
-Andrew Wilkins
-Dave Cheney
-Greg Ward
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/LICENSE b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/LICENSE
deleted file mode 100644
index 10b716ce..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2012 The Gocov Authors.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/README.md b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/README.md
deleted file mode 100644
index 8b2e3ef5..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/README.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# gocov
-
-Coverage reporting tool for The Go Programming Language
-
-[](https://drone.io/github.com/axw/gocov/latest)
-
-## Installation
-
-```go get github.com/axw/gocov/gocov```
-
-## Usage
-
-There are currently four gocov commands: ```test```, ```convert```, ```report``` and ```annotate```.
-
-#### gocov test
-
-Running `gocov test [args...]` will run `go test [args...]` with
-an implicit `-coverprofile` added, and then output the result of
-`gocov convert` with the profile.
-
-#### gocov convert
-
-Running `gocov convert ` will convert a coverage
-profile generated by `go tool cover` to gocov's JSON interchange
-format. For example:
-
- go test -coverprofile=c.out
- gocov convert c.out | gocov annotate -
-
-#### gocov report
-
-Running `gocov report ` will generate a textual
-report from the coverage data output by `gocov convert`. It is
-assumed that the source code has not changed in between.
-
-Output from ```gocov test``` is printed to stdout so users can
-pipe the output to ```gocov report``` to view a summary of the test
-coverage, for example: -
-
- gocov test | gocov report
-
-#### gocov annotate
-
-Running `gocov annotate `
-will generate a source listing of the specified function, annotating
-it with coverage information, such as which lines have been missed.
-
-## Related tools
-
-[GoCovGUI](http://github.com/nsf/gocovgui/):
-A simple GUI wrapper for the gocov coverage analysis tool.
-
-[gocov-html](https://github.com/matm/gocov-html):
-A simple helper tool for generating HTML output from gocov.
-
-[gocov-xml](https://github.com/AlekSi/gocov-xml):
-A simple helper tool for generating XML output in Cobertura format for CIs like Jenkins and others from gocov.
-
-[goveralls](https://github.com/mattn/goveralls):
-Go integration for Coveralls.io continuous code coverage tracking system.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov.go b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov.go
deleted file mode 100644
index 6e94ca7d..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov.go
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2012 The Gocov Authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-// Package gocov is a code coverage analysis tool for Go.
-package gocov
-
-import (
- "fmt"
-)
-
-type Package struct {
- // Name is the canonical path of the package.
- Name string
-
- // Functions is a list of functions registered with this package.
- Functions []*Function
-}
-
-type Function struct {
- // Name is the name of the function. If the function has a receiver, the
- // name will be of the form T.N, where T is the type and N is the name.
- Name string
-
- // File is the full path to the file in which the function is defined.
- File string
-
- // Start is the start offset of the function's signature.
- Start int
-
- // End is the end offset of the function.
- End int
-
- // statements registered with this function.
- Statements []*Statement
-}
-
-type Statement struct {
- // Start is the start offset of the statement.
- Start int
-
- // End is the end offset of the statement.
- End int
-
- // Reached is the number of times the statement was reached.
- Reached int64
-}
-
-// Accumulate will accumulate the coverage information from the provided
-// Package into this Package.
-func (p *Package) Accumulate(p2 *Package) error {
- if p.Name != p2.Name {
- return fmt.Errorf("Names do not match: %q != %q", p.Name, p2.Name)
- }
- if len(p.Functions) != len(p2.Functions) {
- return fmt.Errorf("Function counts do not match: %d != %d", len(p.Functions), len(p2.Functions))
- }
- for i, f := range p.Functions {
- err := f.Accumulate(p2.Functions[i])
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-// Accumulate will accumulate the coverage information from the provided
-// Function into this Function.
-func (f *Function) Accumulate(f2 *Function) error {
- if f.Name != f2.Name {
- return fmt.Errorf("Names do not match: %q != %q", f.Name, f2.Name)
- }
- if f.File != f2.File {
- return fmt.Errorf("Files do not match: %q != %q", f.File, f2.File)
- }
- if f.Start != f2.Start || f.End != f2.End {
- return fmt.Errorf("Source ranges do not match: %d-%d != %d-%d", f.Start, f.End, f2.Start, f2.End)
- }
- if len(f.Statements) != len(f2.Statements) {
- return fmt.Errorf("Number of statements do not match: %d != %d", len(f.Statements), len(f2.Statements))
- }
- for i, s := range f.Statements {
- err := s.Accumulate(f2.Statements[i])
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-// Accumulate will accumulate the coverage information from the provided
-// Statement into this Statement.
-func (s *Statement) Accumulate(s2 *Statement) error {
- if s.Start != s2.Start || s.End != s2.End {
- return fmt.Errorf("Source ranges do not match: %d-%d != %d-%d", s.Start, s.End, s2.Start, s2.End)
- }
- s.Reached += s2.Reached
- return nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/annotate.go b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/annotate.go
deleted file mode 100644
index a0c612e2..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/annotate.go
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright (c) 2012 The Gocov Authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-package main
-
-import (
- "flag"
- "fmt"
- "go/token"
- "io/ioutil"
- "math"
- "os"
- "regexp"
- "sort"
- "strings"
-
- "github.com/axw/gocov"
-)
-
-const (
- hitPrefix = " "
- missPrefix = "MISS"
- RED = "\x1b[31;1m"
- GREEN = "\x1b[32;1m"
- NONE = "\x1b[0m"
-)
-
-var (
- annotateFlags = flag.NewFlagSet("annotate", flag.ExitOnError)
- annotateCeilingFlag = annotateFlags.Float64(
- "ceiling", 101,
- "Annotate only functions whose coverage is less than the specified percentage")
- annotateColorFlag = annotateFlags.Bool(
- "color", false,
- "Differentiate coverage with color")
-)
-
-type packageList []*gocov.Package
-type functionList []*gocov.Function
-
-func (l packageList) Len() int {
- return len(l)
-}
-
-func (l packageList) Less(i, j int) bool {
- return l[i].Name < l[j].Name
-}
-
-func (l packageList) Swap(i, j int) {
- l[i], l[j] = l[j], l[i]
-}
-
-func (l functionList) Len() int {
- return len(l)
-}
-
-func (l functionList) Less(i, j int) bool {
- return l[i].Name < l[j].Name
-}
-
-func (l functionList) Swap(i, j int) {
- l[i], l[j] = l[j], l[i]
-}
-
-type annotator struct {
- fset *token.FileSet
- files map[string]*token.File
-}
-
-func percentReached(fn *gocov.Function) float64 {
- if len(fn.Statements) == 0 {
- return 0
- }
- var reached int
- for _, stmt := range fn.Statements {
- if stmt.Reached > 0 {
- reached++
- }
- }
- return float64(reached) / float64(len(fn.Statements)) * 100
-}
-
-func annotateSource() (rc int) {
- annotateFlags.Parse(os.Args[2:])
- if annotateFlags.NArg() == 0 {
- fmt.Fprintf(os.Stderr, "missing coverage file\n")
- return 1
- }
-
- var data []byte
- var err error
- if filename := annotateFlags.Arg(0); filename == "-" {
- data, err = ioutil.ReadAll(os.Stdin)
- } else {
- data, err = ioutil.ReadFile(filename)
- }
- if err != nil {
- fmt.Fprintf(os.Stderr, "failed to read coverage file: %s\n", err)
- return 1
- }
-
- packages, err := unmarshalJson(data)
- if err != nil {
- fmt.Fprintf(
- os.Stderr, "failed to unmarshal coverage data: %s\n", err)
- return 1
- }
-
- // Sort packages, functions by name.
- sort.Sort(packageList(packages))
- for _, pkg := range packages {
- sort.Sort(functionList(pkg.Functions))
- }
-
- a := &annotator{}
- a.fset = token.NewFileSet()
- a.files = make(map[string]*token.File)
-
- var regexps []*regexp.Regexp
- for _, arg := range annotateFlags.Args()[1:] {
- re, err := regexp.Compile(arg)
- if err != nil {
- fmt.Fprintf(os.Stderr, "warning: failed to compile %q as a regular expression, ignoring\n", arg)
- } else {
- regexps = append(regexps, re)
- }
- }
- if len(regexps) == 0 {
- regexps = append(regexps, regexp.MustCompile("."))
- }
- for _, pkg := range packages {
- for _, fn := range pkg.Functions {
- if percentReached(fn) >= *annotateCeilingFlag {
- continue
- }
- name := pkg.Name + "/" + fn.Name
- for _, regexp := range regexps {
- if regexp.FindStringIndex(name) != nil {
- err := a.printFunctionSource(fn)
- if err != nil {
- fmt.Fprintf(os.Stderr, "warning: failed to annotate function %q\n", name)
- }
- break
- }
- }
- }
- }
- return
-}
-
-func (a *annotator) printFunctionSource(fn *gocov.Function) error {
- // Load the file for line information. Probably overkill, maybe
- // just compute the lines from offsets in here.
- setContent := false
- file := a.files[fn.File]
- if file == nil {
- info, err := os.Stat(fn.File)
- if err != nil {
- return err
- }
- file = a.fset.AddFile(fn.File, a.fset.Base(), int(info.Size()))
- setContent = true
- }
-
- data, err := ioutil.ReadFile(fn.File)
- if err != nil {
- return err
- }
- if setContent {
- // This processes the content and records line number info.
- file.SetLinesForContent(data)
- }
-
- statements := fn.Statements[:]
- lineno := file.Line(file.Pos(fn.Start))
- lines := strings.Split(string(data)[fn.Start:fn.End], "\n")
- linenoWidth := int(math.Log10(float64(lineno+len(lines)))) + 1
- fmt.Println()
- for i, line := range lines {
- // Go through statements one at a time, seeing if we've hit
- // them or not.
- //
- // The prefix approach isn't perfect, as it doesn't
- // distinguish multiple statements per line. It'll have to
- // do for now. We could do fancy ANSI colouring later.
- lineno := lineno + i
- statementFound := false
- hit := false
- for j := 0; j < len(statements); j++ {
- start := file.Line(file.Pos(statements[j].Start))
- // FIXME instrumentation no longer records statements
- // in line order, as function literals are processed
- // after the body of a function. If/when that's changed,
- // we can go back to checking just the first statement
- // in each loop.
- if start == lineno {
- statementFound = true
- if !hit && statements[j].Reached > 0 {
- hit = true
- }
- statements = append(statements[:j], statements[j+1:]...)
- }
- }
- if *annotateColorFlag {
- color := NONE
- if statementFound && !hit {
- color = RED
- }
- fmt.Printf("%s%*d \t%s%s\n", color, linenoWidth, lineno, line, NONE)
- } else {
- hitmiss := hitPrefix
- if statementFound && !hit {
- hitmiss = missPrefix
- }
- fmt.Printf("%*d %s\t%s\n", linenoWidth, lineno, hitmiss, line)
- }
- }
- fmt.Println()
-
- return nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/convert.go b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/convert.go
deleted file mode 100644
index 0132e75b..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/convert.go
+++ /dev/null
@@ -1,316 +0,0 @@
-// Copyright (c) 2013 The Gocov Authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-package main
-
-import (
- "fmt"
- "go/ast"
- "go/build"
- "go/parser"
- "go/token"
- "path/filepath"
-
- "code.google.com/p/go.tools/cover"
-
- "github.com/axw/gocov"
- "github.com/axw/gocov/gocovutil"
-)
-
-func convertProfiles(filenames ...string) error {
- var ps gocovutil.Packages
- for i := range filenames {
- converter := converter{
- packages: make(map[string]*gocov.Package),
- }
- profiles, err := cover.ParseProfiles(filenames[i])
- if err != nil {
- return err
- }
- for _, p := range profiles {
- if err := converter.convertProfile(p); err != nil {
- return err
- }
- }
-
- for _, pkg := range converter.packages {
- ps.AddPackage(pkg)
- }
- }
- bytes, err := marshalJson(ps)
- if err != nil {
- return err
- }
- fmt.Println(string(bytes))
- return nil
-}
-
-type converter struct {
- packages map[string]*gocov.Package
-}
-
-// wrapper for gocov.Statement
-type statement struct {
- *gocov.Statement
- *StmtExtent
-}
-
-func (c *converter) convertProfile(p *cover.Profile) error {
- file, pkgpath, err := findFile(p.FileName)
- if err != nil {
- return err
- }
- pkg := c.packages[pkgpath]
- if pkg == nil {
- pkg = &gocov.Package{Name: pkgpath}
- c.packages[pkgpath] = pkg
- }
- // Find function and statement extents; create corresponding
- // gocov.Functions and gocov.Statements, and keep a separate
- // slice of gocov.Statements so we can match them with profile
- // blocks.
- extents, err := findFuncs(file)
- if err != nil {
- return err
- }
- var stmts []statement
- for _, fe := range extents {
- f := &gocov.Function{
- Name: fe.name,
- File: file,
- Start: fe.startOffset,
- End: fe.endOffset,
- }
- for _, se := range fe.stmts {
- s := statement{
- Statement: &gocov.Statement{Start: se.startOffset, End: se.endOffset},
- StmtExtent: se,
- }
- f.Statements = append(f.Statements, s.Statement)
- stmts = append(stmts, s)
- }
- pkg.Functions = append(pkg.Functions, f)
- }
- // For each profile block in the file, find the statement(s) it
- // covers and increment the Reached field(s).
- blocks := p.Blocks
- for len(stmts) > 0 {
- s := stmts[0]
- for i, b := range blocks {
- if b.StartLine > s.endLine || (b.StartLine == s.endLine && b.StartCol >= s.endCol) {
- // Past the end of the statement
- stmts = stmts[1:]
- blocks = blocks[i:]
- break
- }
- if b.EndLine < s.startLine || (b.EndLine == s.startLine && b.EndCol <= s.startCol) {
- // Before the beginning of the statement
- continue
- }
- s.Reached += int64(b.Count)
- stmts = stmts[1:]
- break
- }
- }
- return nil
-}
-
-// findFile finds the location of the named file in GOROOT, GOPATH etc.
-func findFile(file string) (filename string, pkgpath string, err error) {
- dir, file := filepath.Split(file)
- if dir != "" {
- dir = dir[:len(dir)-1] // drop trailing '/'
- }
- pkg, err := build.Import(dir, ".", build.FindOnly)
- if err != nil {
- return "", "", fmt.Errorf("can't find %q: %v", file, err)
- }
- return filepath.Join(pkg.Dir, file), pkg.ImportPath, nil
-}
-
-// findFuncs parses the file and returns a slice of FuncExtent descriptors.
-func findFuncs(name string) ([]*FuncExtent, error) {
- fset := token.NewFileSet()
- parsedFile, err := parser.ParseFile(fset, name, nil, 0)
- if err != nil {
- return nil, err
- }
- visitor := &FuncVisitor{fset: fset}
- ast.Walk(visitor, parsedFile)
- return visitor.funcs, nil
-}
-
-type extent struct {
- startOffset int
- startLine int
- startCol int
- endOffset int
- endLine int
- endCol int
-}
-
-// FuncExtent describes a function's extent in the source by file and position.
-type FuncExtent struct {
- extent
- name string
- stmts []*StmtExtent
-}
-
-// StmtExtent describes a statements's extent in the source by file and position.
-type StmtExtent extent
-
-// FuncVisitor implements the visitor that builds the function position list for a file.
-type FuncVisitor struct {
- fset *token.FileSet
- funcs []*FuncExtent
-}
-
-// Visit implements the ast.Visitor interface.
-func (v *FuncVisitor) Visit(node ast.Node) ast.Visitor {
- var body *ast.BlockStmt
- var name string
- switch n := node.(type) {
- case *ast.FuncLit:
- body = n.Body
- case *ast.FuncDecl:
- body = n.Body
- name = n.Name.Name
- // Function name is prepended with "T." if there is a receiver, where
- // T is the type of the receiver, dereferenced if it is a pointer.
- if n.Recv != nil {
- field := n.Recv.List[0]
- switch recv := field.Type.(type) {
- case *ast.StarExpr:
- name = recv.X.(*ast.Ident).Name + "." + name
- case *ast.Ident:
- name = recv.Name + "." + name
- }
- }
- }
- if body != nil {
- start := v.fset.Position(node.Pos())
- end := v.fset.Position(node.End())
- if name == "" {
- name = fmt.Sprintf("@%d:%d", start.Line, start.Column)
- }
- fe := &FuncExtent{
- name: name,
- extent: extent{
- startOffset: start.Offset,
- startLine: start.Line,
- startCol: start.Column,
- endOffset: end.Offset,
- endLine: end.Line,
- endCol: end.Column,
- },
- }
- v.funcs = append(v.funcs, fe)
- sv := StmtVisitor{fset: v.fset, function: fe}
- sv.VisitStmt(body)
- }
- return v
-}
-
-type StmtVisitor struct {
- fset *token.FileSet
- function *FuncExtent
-}
-
-func (v *StmtVisitor) VisitStmt(s ast.Stmt) {
- var statements *[]ast.Stmt
- switch s := s.(type) {
- case *ast.BlockStmt:
- statements = &s.List
- case *ast.CaseClause:
- statements = &s.Body
- case *ast.CommClause:
- statements = &s.Body
- case *ast.ForStmt:
- if s.Init != nil {
- v.VisitStmt(s.Init)
- }
- if s.Post != nil {
- v.VisitStmt(s.Post)
- }
- v.VisitStmt(s.Body)
- case *ast.IfStmt:
- if s.Init != nil {
- v.VisitStmt(s.Init)
- }
- v.VisitStmt(s.Body)
- if s.Else != nil {
- // Code copied from go.tools/cmd/cover, to deal with "if x {} else if y {}"
- const backupToElse = token.Pos(len("else ")) // The AST doesn't remember the else location. We can make an accurate guess.
- switch stmt := s.Else.(type) {
- case *ast.IfStmt:
- block := &ast.BlockStmt{
- Lbrace: stmt.If - backupToElse, // So the covered part looks like it starts at the "else".
- List: []ast.Stmt{stmt},
- Rbrace: stmt.End(),
- }
- s.Else = block
- case *ast.BlockStmt:
- stmt.Lbrace -= backupToElse // So the block looks like it starts at the "else".
- default:
- panic("unexpected node type in if")
- }
- v.VisitStmt(s.Else)
- }
- case *ast.LabeledStmt:
- v.VisitStmt(s.Stmt)
- case *ast.RangeStmt:
- v.VisitStmt(s.Body)
- case *ast.SelectStmt:
- v.VisitStmt(s.Body)
- case *ast.SwitchStmt:
- if s.Init != nil {
- v.VisitStmt(s.Init)
- }
- v.VisitStmt(s.Body)
- case *ast.TypeSwitchStmt:
- if s.Init != nil {
- v.VisitStmt(s.Init)
- }
- v.VisitStmt(s.Assign)
- v.VisitStmt(s.Body)
- }
- if statements == nil {
- return
- }
- for i := 0; i < len(*statements); i++ {
- s := (*statements)[i]
- switch s.(type) {
- case *ast.CaseClause, *ast.CommClause, *ast.BlockStmt:
- break
- default:
- start, end := v.fset.Position(s.Pos()), v.fset.Position(s.End())
- se := &StmtExtent{
- startOffset: start.Offset,
- startLine: start.Line,
- startCol: start.Column,
- endOffset: end.Offset,
- endLine: end.Line,
- endCol: end.Column,
- }
- v.function.stmts = append(v.function.stmts, se)
- }
- v.VisitStmt(s)
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/main.go b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/main.go
deleted file mode 100644
index 3c0685e6..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/main.go
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2012 The Gocov Authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-package main
-
-import (
- "encoding/json"
- "flag"
- "fmt"
- "os"
-
- "github.com/axw/gocov"
-)
-
-func usage() {
- fmt.Fprintf(os.Stderr, "Usage:\n\n\tgocov command [arguments]\n\n")
- fmt.Fprintf(os.Stderr, "The commands are:\n\n")
- fmt.Fprintf(os.Stderr, "\tannotate\n")
- fmt.Fprintf(os.Stderr, "\tconvert\n")
- fmt.Fprintf(os.Stderr, "\treport\n")
- fmt.Fprintf(os.Stderr, "\ttest\n")
- fmt.Fprintf(os.Stderr, "\n")
- flag.PrintDefaults()
- os.Exit(2)
-}
-
-func marshalJson(packages []*gocov.Package) ([]byte, error) {
- return json.Marshal(struct{ Packages []*gocov.Package }{packages})
-}
-
-func unmarshalJson(data []byte) (packages []*gocov.Package, err error) {
- result := &struct{ Packages []*gocov.Package }{}
- err = json.Unmarshal(data, result)
- if err == nil {
- packages = result.Packages
- }
- return
-}
-
-func main() {
- flag.Usage = usage
- flag.Parse()
-
- command := ""
- if flag.NArg() > 0 {
- command = flag.Arg(0)
- switch command {
- case "convert":
- if flag.NArg() <= 1 {
- fmt.Fprintln(os.Stderr, "missing cover profile")
- os.Exit(1)
- }
- if err := convertProfiles(flag.Args()[1:]...); err != nil {
- fmt.Fprintln(os.Stderr, "error: %v", err)
- os.Exit(1)
- }
- case "annotate":
- os.Exit(annotateSource())
- case "report":
- os.Exit(reportCoverage())
- case "test":
- if err := runTests(flag.Args()[1:]); err != nil {
- fmt.Fprintln(os.Stderr, "error: %v", err)
- os.Exit(1)
- }
- default:
- fmt.Fprintf(os.Stderr, "Unknown command: %#q\n\n", command)
- usage()
- }
- } else {
- usage()
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/report.go b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/report.go
deleted file mode 100644
index 6f633d49..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/report.go
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright (c) 2012 The Gocov Authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-package main
-
-import (
- "flag"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
- "sort"
- "strings"
- "text/tabwriter"
-
- "github.com/axw/gocov"
-)
-
-type report struct {
- packages []*gocov.Package
-}
-
-type reportFunction struct {
- *gocov.Function
- statementsReached int
-}
-
-type reportFunctionList []reportFunction
-
-func (l reportFunctionList) Len() int {
- return len(l)
-}
-
-// TODO make sort method configurable?
-func (l reportFunctionList) Less(i, j int) bool {
- var left, right float64
- if len(l[i].Statements) > 0 {
- left = float64(l[i].statementsReached) / float64(len(l[i].Statements))
- }
- if len(l[j].Statements) > 0 {
- right = float64(l[j].statementsReached) / float64(len(l[j].Statements))
- }
- if left < right {
- return true
- }
- return left == right && len(l[i].Statements) < len(l[j].Statements)
-}
-
-func (l reportFunctionList) Swap(i, j int) {
- l[i], l[j] = l[j], l[i]
-}
-
-type reverse struct {
- sort.Interface
-}
-
-func (r reverse) Less(i, j int) bool {
- return r.Interface.Less(j, i)
-}
-
-// NewReport creates a new report.
-func newReport() (r *report) {
- r = &report{}
- return
-}
-
-// AddPackage adds a package's coverage information to the report.
-func (r *report) addPackage(p *gocov.Package) {
- i := sort.Search(len(r.packages), func(i int) bool {
- return r.packages[i].Name >= p.Name
- })
- if i < len(r.packages) && r.packages[i].Name == p.Name {
- r.packages[i].Accumulate(p)
- } else {
- head := r.packages[:i]
- tail := append([]*gocov.Package{p}, r.packages[i:]...)
- r.packages = append(head, tail...)
- }
-}
-
-// Clear clears the coverage information from the report.
-func (r *report) clear() {
- r.packages = nil
-}
-
-// PrintReport prints a coverage report to the given writer.
-func printReport(w io.Writer, r *report) {
- w = tabwriter.NewWriter(w, 0, 8, 0, '\t', 0)
- //fmt.Fprintln(w, "Package\tFunction\tStatements\t")
- //fmt.Fprintln(w, "-------\t--------\t---------\t")
- for _, pkg := range r.packages {
- printPackage(w, pkg)
- fmt.Fprintln(w)
- }
-}
-
-func printPackage(w io.Writer, pkg *gocov.Package) {
- functions := make(reportFunctionList, len(pkg.Functions))
- for i, fn := range pkg.Functions {
- reached := 0
- for _, stmt := range fn.Statements {
- if stmt.Reached > 0 {
- reached++
- }
- }
- functions[i] = reportFunction{fn, reached}
- }
- sort.Sort(reverse{functions})
-
- var longestFunctionName int
- var totalStatements, totalReached int
- for _, fn := range functions {
- reached := fn.statementsReached
- totalStatements += len(fn.Statements)
- totalReached += reached
- var stmtPercent float64 = 0
- if len(fn.Statements) > 0 {
- stmtPercent = float64(reached) / float64(len(fn.Statements)) * 100
- }
- if len(fn.Name) > longestFunctionName {
- longestFunctionName = len(fn.Name)
- }
- fmt.Fprintf(w, "%s/%s\t %s\t %.2f%% (%d/%d)\n",
- pkg.Name, filepath.Base(fn.File), fn.Name, stmtPercent,
- reached, len(fn.Statements))
- }
-
- var funcPercent float64
- if totalStatements > 0 {
- funcPercent = float64(totalReached) / float64(totalStatements) * 100
- }
- summaryLine := strings.Repeat("-", longestFunctionName)
- fmt.Fprintf(w, "%s\t %s\t %.2f%% (%d/%d)\n",
- pkg.Name, summaryLine, funcPercent,
- totalReached, totalStatements)
-}
-
-func reportCoverage() (rc int) {
- files := make([]*os.File, 0, 1)
- if flag.NArg() > 1 {
- for _, name := range flag.Args()[1:] {
- file, err := os.Open(name)
- if err != nil {
- fmt.Fprintf(os.Stderr, "failed to open file (%s): %s\n", name, err)
- } else {
- files = append(files, file)
- }
- }
- } else {
- files = append(files, os.Stdin)
- }
- report := newReport()
- for _, file := range files {
- data, err := ioutil.ReadAll(file)
- if err != nil {
- fmt.Fprintf(os.Stderr, "failed to read coverage file: %s\n", err)
- return 1
- }
- packages, err := unmarshalJson(data)
- if err != nil {
- fmt.Fprintf(
- os.Stderr, "failed to unmarshal coverage data: %s\n", err)
- return 1
- }
- for _, pkg := range packages {
- report.addPackage(pkg)
- }
- if file != os.Stdin {
- file.Close()
- }
- }
- fmt.Println()
- printReport(os.Stdout, report)
- return 0
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/test.go b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/test.go
deleted file mode 100644
index d7230786..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov/test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2013 The Gocov Authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-package main
-
-import (
- "io/ioutil"
- "os"
- "os/exec"
-)
-
-func runTests(args []string) error {
- coverprofile, err := ioutil.TempFile("", "gocov")
- if err != nil {
- return err
- }
- coverprofile.Close()
- defer os.Remove(coverprofile.Name())
- args = append([]string{
- "test", "-coverprofile", coverprofile.Name(),
- }, args...)
- cmd := exec.Command("go", args...)
- cmd.Stdin = os.Stdin
- cmd.Stdout = os.Stderr
- cmd.Stderr = os.Stderr
- if err := cmd.Run(); err != nil {
- return err
- }
- return convertProfiles(coverprofile.Name())
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov_test.go
deleted file mode 100644
index 021bfc63..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocov_test.go
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright (c) 2012 The Gocov Authors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-
-package gocov
-
-import "testing"
-
-func registerPackage(name string) *Package {
- return &Package{Name: name}
-}
-
-func registerFunction(p *Package, name, file string, startOffset, endOffset int) *Function {
- f := &Function{Name: name, File: file, Start: startOffset, End: endOffset}
- p.Functions = append(p.Functions, f)
- return f
-}
-
-func registerStatement(f *Function, startOffset, endOffset int) *Statement {
- s := &Statement{Start: startOffset, End: endOffset}
- f.Statements = append(f.Statements, s)
- return s
-}
-
-func TestAccumulatePackage(t *testing.T) {
- p1_1 := registerPackage("p1")
- p1_2 := registerPackage("p1")
- p2 := registerPackage("p2")
- p3 := registerPackage("p1")
- registerFunction(p3, "f", "file.go", 0, 1)
- p4 := registerPackage("p1")
- registerFunction(p4, "f", "file.go", 1, 2)
-
- var tests = [...]struct {
- a, b *Package
- expectPass bool
- }{
- // Should work: everything is the same.
- {p1_1, p1_2, true},
- // Should fail: name is different.
- {p1_1, p2, false},
- // Should fail: numbers of functions are different.
- {p1_1, p3, false},
- // Should fail: functions are different.
- {p3, p4, false},
- }
-
- for _, test := range tests {
- err := test.a.Accumulate(test.b)
- if test.expectPass {
- if err != nil {
- t.Error(err)
- }
- } else {
- if err == nil {
- t.Error("Expected an error")
- }
- }
- }
-}
-
-func TestAccumulateFunction(t *testing.T) {
- p := registerPackage("p1")
- f1_1 := registerFunction(p, "f1", "file.go", 0, 1)
- f1_2 := registerFunction(p, "f1", "file.go", 0, 1)
- f2 := registerFunction(p, "f2", "file.go", 0, 1)
- f3 := registerFunction(p, "f1", "file2.go", 0, 1)
- f4 := registerFunction(p, "f1", "file.go", 2, 3)
- f5 := registerFunction(p, "f1", "file.go", 0, 1)
- registerStatement(f5, 0, 1)
- f6 := registerFunction(p, "f1", "file.go", 0, 1)
- registerStatement(f6, 2, 3)
-
- var tests = [...]struct {
- a, b *Function
- expectPass bool
- }{
- // Should work: everything is the same.
- {f1_1, f1_2, true},
- // Should fail: names are different.
- {f1_1, f2, false},
- // Should fail: files are different.
- {f1_1, f3, false},
- // Should fail: ranges are different.
- {f1_1, f4, false},
- // Should fail: numbers of statements are different.
- {f1_1, f5, false},
- // Should fail: all the same, except statement values.
- {f5, f6, false},
- }
-
- for _, test := range tests {
- err := test.a.Accumulate(test.b)
- if test.expectPass {
- if err != nil {
- t.Error(err)
- }
- } else {
- if err == nil {
- t.Error("Expected an error")
- }
- }
- }
-}
-
-func TestAccumulateStatement(t *testing.T) {
- p := registerPackage("p1")
- f := registerFunction(p, "f1", "file.go", 0, 1)
- s1_1 := registerStatement(f, 0, 1)
- s1_2 := registerStatement(f, 0, 1)
- s2 := registerStatement(f, 2, 3)
-
- // Should work: ranges are the same.
- if err := s1_1.Accumulate(s1_2); err != nil {
- t.Error(err)
- }
-
- // Should fail: ranges are not the same.
- if err := s1_1.Accumulate(s2); err == nil {
- t.Errorf("Expected an error")
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocovutil/packages.go b/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocovutil/packages.go
deleted file mode 100644
index 9b407c67..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/axw/gocov/gocovutil/packages.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package gocovutil
-
-import (
- "encoding/json"
- "github.com/axw/gocov"
- "io/ioutil"
- "os"
- "sort"
-)
-
-// Packages represents a set of gocov.Package structures.
-// The "AddPackage" method may be used to merge package
-// coverage results into the set.
-type Packages []*gocov.Package
-
-// AddPackage adds a package's coverage information to the
-func (ps *Packages) AddPackage(p *gocov.Package) {
- i := sort.Search(len(*ps), func(i int) bool {
- return (*ps)[i].Name >= p.Name
- })
- if i < len(*ps) && (*ps)[i].Name == p.Name {
- (*ps)[i].Accumulate(p)
- } else {
- head := (*ps)[:i]
- tail := append([]*gocov.Package{p}, (*ps)[i:]...)
- *ps = append(head, tail...)
- }
-}
-
-// ReadPackages takes a list of filenames and parses their
-// contents as a Packages object.
-//
-// The special filename "-" may be used to indicate standard input.
-// Duplicate filenames are ignored.
-func ReadPackages(filenames []string) (ps Packages, err error) {
- copy_ := make([]string, len(filenames))
- copy(copy_, filenames)
- filenames = copy_
- sort.Strings(filenames)
-
- // Eliminate duplicates.
- unique := []string{filenames[0]}
- if len(filenames) > 1 {
- for _, f := range filenames[1:] {
- if f != unique[len(unique)-1] {
- unique = append(unique, f)
- }
- }
- }
-
- // Open files.
- var files []*os.File
- for _, f := range filenames {
- if f == "-" {
- files = append(files, os.Stdin)
- } else {
- file, err := os.Open(f)
- if err != nil {
- return nil, err
- }
- defer file.Close()
- files = append(files, os.Stdin)
- }
- }
-
- // Parse the files, accumulate Packages.
- for _, file := range files {
- data, err := ioutil.ReadAll(file)
- if err != nil {
- return nil, err
- }
- result := &struct{ Packages []*gocov.Package }{}
- err = json.Unmarshal(data, result)
- if err != nil {
- return nil, err
- }
- for _, p := range result.Packages {
- ps.AddPackage(p)
- }
- }
- return ps, nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/LICENSE b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/LICENSE
deleted file mode 100644
index 65d761bc..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (c) 2013 The Go Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/README b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/README
deleted file mode 100644
index c763bdd2..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/README
+++ /dev/null
@@ -1,59 +0,0 @@
-Golint is a linter for Go source code.
-
-To install, run
- go get github.com/golang/lint/golint
-
-Invoke golint with one or more filenames or directories.
-The output of this tool is a list of suggestions in Vim quickfix format,
-which is accepted by lots of different editors.
-
-Golint differs from gofmt. Gofmt reformats Go source code, whereas
-golint prints out style mistakes.
-
-Golint differs from govet. Govet is concerned with correctness, whereas
-golint is concerned with coding style. Golint is in use at Google, and it
-seeks to match the accepted style of the open source Go project.
-
-The suggestions made by golint are exactly that: suggestions.
-Golint is not perfect, and has both false positives and false negatives.
-Do not treat its output as a gold standard. We will not be adding pragmas
-or other knobs to suppress specific warnings, so do not expect or require
-code to be completely "lint-free".
-In short, this tool is not, and will never be, trustworthy enough for its
-suggestions to be enforced automatically, for example as part of a build process.
-
-If you find an established style that is frequently violated, and which
-you think golint could statically check, file an issue at
- https://github.com/golang/lint/issues
-
-
-Contributions
--------------
-Contributions to this project are welcome, though please send mail before
-starting work on anything major. Contributors retain their copyright, so we
-need you to fill out a short form before we can accept your contribution:
- https://developers.google.com/open-source/cla/individual
-
-
-Vim
----
-Add this to your ~/.vimrc:
- set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim
-If you have multiple entries in your GOPATH, replace $GOPATH with the right value.
-
-Running :Lint will run golint on the current file and populate the quickfix list.
-
-Optionally, add this to your ~/.vimrc to automatically run golint on :w
- autocmd BufWritePost,FileWritePost *.go execute 'Lint' | cwindow
-
-
-Emacs
------
-Add this to your .emacs file:
- (add-to-list 'load-path (concat (getenv "GOPATH") "/src/github.com/golang/lint/misc/emacs"))
- (require 'golint)
-If you have multiple entries in your GOPATH, replace $GOPATH with the right value.
-
-Running M-x golint will run golint on the current file.
-For more usage, see Compilation-Mode:
- http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/golint/golint.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/golint/golint.go
deleted file mode 100644
index c5fd1e73..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/golint/golint.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2013 The Go Authors. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file or at
-// https://developers.google.com/open-source/licenses/bsd.
-
-// golint lints the Go source files named on its command line.
-package main
-
-import (
- "flag"
- "fmt"
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
-
- "github.com/golang/lint"
-)
-
-var minConfidence = flag.Float64("min_confidence", 0.8, "minimum confidence of a problem to print it")
-
-func main() {
- flag.Parse()
-
- for _, filename := range flag.Args() {
- if isDir(filename) {
- lintDir(filename)
- } else {
- lintFile(filename)
- }
- }
-}
-
-func isDir(filename string) bool {
- fi, err := os.Stat(filename)
- return err == nil && fi.IsDir()
-}
-
-func lintFile(filename string) {
- src, err := ioutil.ReadFile(filename)
- if err != nil {
- fmt.Fprintln(os.Stderr, err)
- return
- }
-
- l := new(lint.Linter)
- ps, err := l.Lint(filename, src)
- if err != nil {
- fmt.Fprintf(os.Stderr, "%v:%v\n", filename, err)
- return
- }
- for _, p := range ps {
- if p.Confidence >= *minConfidence {
- fmt.Printf("%s:%v: %s\n", filename, p.Position, p.Text)
- }
- }
-}
-
-func lintDir(dirname string) {
- filepath.Walk(dirname, func(path string, info os.FileInfo, err error) error {
- if err == nil && !info.IsDir() && strings.HasSuffix(path, ".go") {
- lintFile(path)
- }
- return err
- })
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/lint.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/lint.go
deleted file mode 100644
index 54907f88..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/lint.go
+++ /dev/null
@@ -1,1051 +0,0 @@
-// Copyright (c) 2013 The Go Authors. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file or at
-// https://developers.google.com/open-source/licenses/bsd.
-
-// Package lint contains a linter for Go source code.
-package lint
-
-import (
- "bytes"
- "fmt"
- "go/ast"
- "go/parser"
- "go/printer"
- "go/token"
- "regexp"
- "strconv"
- "strings"
- "unicode"
- "unicode/utf8"
-)
-
-const styleGuideBase = "http://golang.org/s/comments"
-
-// A Linter lints Go source code.
-type Linter struct {
-}
-
-// Problem represents a problem in some source code.
-type Problem struct {
- Position token.Position // position in source file
- Text string // the prose that describes the problem
- Link string // (optional) the link to the style guide for the problem
- Confidence float64 // a value in (0,1] estimating the confidence in this problem's correctness
- LineText string // the source line
-}
-
-func (p *Problem) String() string {
- if p.Link != "" {
- return p.Text + "\n\n" + p.Link
- }
- return p.Text
-}
-
-// Lint lints src.
-func (l *Linter) Lint(filename string, src []byte) ([]Problem, error) {
- fset := token.NewFileSet()
- f, err := parser.ParseFile(fset, "", src, parser.ParseComments)
- if err != nil {
- return nil, err
- }
- return (&file{fset: fset, f: f, src: src, filename: filename}).lint(), nil
-}
-
-// file represents a file being linted.
-type file struct {
- fset *token.FileSet
- f *ast.File
- src []byte
- filename string
-
- // sortable is the set of types in the file that implement sort.Interface.
- sortable map[string]bool
- // main is whether this file is in a "main" package.
- main bool
-
- problems []Problem
-}
-
-func (f *file) isTest() bool { return strings.HasSuffix(f.filename, "_test.go") }
-
-func (f *file) lint() []Problem {
- f.scanSortable()
- f.main = f.isMain()
-
- f.lintPackageComment()
- f.lintImports()
- f.lintBlankImports()
- f.lintExported()
- f.lintNames()
- f.lintVarDecls()
- f.lintElses()
- f.lintRanges()
- f.lintErrorf()
- f.lintErrors()
- f.lintErrorStrings()
- f.lintReceiverNames()
- f.lintIncDec()
- f.lintMake()
-
- return f.problems
-}
-
-func (f *file) errorf(n ast.Node, confidence float64, link, format string, a ...interface{}) {
- p := f.fset.Position(n.Pos())
- f.problems = append(f.problems, Problem{
- Position: p,
- Text: fmt.Sprintf(format, a...),
- Link: link,
- Confidence: confidence,
- LineText: srcLine(f.src, p),
- })
-}
-
-func (f *file) scanSortable() {
- f.sortable = make(map[string]bool)
-
- // bitfield for which methods exist on each type.
- const (
- Len = 1 << iota
- Less
- Swap
- )
- nmap := map[string]int{"Len": Len, "Less": Less, "Swap": Swap}
- has := make(map[string]int)
- f.walk(func(n ast.Node) bool {
- fn, ok := n.(*ast.FuncDecl)
- if !ok || fn.Recv == nil {
- return true
- }
- // TODO(dsymonds): We could check the signature to be more precise.
- recv := receiverType(fn)
- if i, ok := nmap[fn.Name.Name]; ok {
- has[recv] |= i
- }
- return false
- })
- for typ, ms := range has {
- if ms == Len|Less|Swap {
- f.sortable[typ] = true
- }
- }
-}
-
-func (f *file) isMain() bool {
- if f.f.Name.Name == "main" {
- return true
- }
- return false
-}
-
-// lintPackageComment checks package comments. It complains if
-// there is no package comment, or if it is not of the right form.
-// This has a notable false positive in that a package comment
-// could rightfully appear in a different file of the same package,
-// but that's not easy to fix since this linter is file-oriented.
-func (f *file) lintPackageComment() {
- if f.isTest() {
- return
- }
-
- const link = styleGuideBase + "#Package_Comments"
- if f.f.Doc == nil {
- f.errorf(f.f, 0.2, link, "should have a package comment, unless it's in another file for this package")
- return
- }
- s := f.f.Doc.Text()
- prefix := "Package " + f.f.Name.Name + " "
- if ts := strings.TrimLeft(s, " \t"); ts != s {
- f.errorf(f.f.Doc, 1, link, "package comment should not have leading space")
- s = ts
- }
- // Only non-main packages need to keep to this form.
- if f.f.Name.Name != "main" && !strings.HasPrefix(s, prefix) {
- f.errorf(f.f.Doc, 1, link, `package comment should be of the form "%s..."`, prefix)
- }
-}
-
-// lintBlankImports complains if a non-main package has blank imports that are
-// not documented.
-func (f *file) lintBlankImports() {
- // In package main and in tests, we don't complain about blank imports.
- if f.main || f.isTest() {
- return
- }
-
- // The first element of each contiguous group of blank imports should have
- // an explanatory comment of some kind.
- for i, imp := range f.f.Imports {
- pos := f.fset.Position(imp.Pos())
-
- if !isBlank(imp.Name) {
- continue // Ignore non-blank imports.
- }
- if i > 0 {
- prev := f.f.Imports[i-1]
- prevPos := f.fset.Position(prev.Pos())
- if isBlank(prev.Name) && prevPos.Line+1 == pos.Line {
- continue // A subsequent blank in a group.
- }
- }
-
- // This is the first blank import of a group.
- if imp.Doc == nil && imp.Comment == nil {
- link := ""
- f.errorf(imp, 1, link, "a blank import should be only in a main or test package, or have a comment justifying it")
- }
- }
-}
-
-// lintImports examines import blocks.
-func (f *file) lintImports() {
-
- for i, is := range f.f.Imports {
- _ = i
- if is.Name != nil && is.Name.Name == "." && !f.isTest() {
- f.errorf(is, 1, styleGuideBase+"#Import_Dot", "should not use dot imports")
- }
-
- }
-
-}
-
-const docCommentsLink = styleGuideBase + "#Doc_Comments"
-
-// lintExported examines the doc comments of exported names.
-// It complains if any required doc comments are missing,
-// or if they are not of the right form. The exact rules are in
-// lintFuncDoc, lintTypeDoc and lintValueSpecDoc; this function
-// also tracks the GenDecl structure being traversed to permit
-// doc comments for constants to be on top of the const block.
-func (f *file) lintExported() {
- if f.isTest() {
- return
- }
-
- var lastGen *ast.GenDecl // last GenDecl entered.
-
- // Set of GenDecls that have already had missing comments flagged.
- genDeclMissingComments := make(map[*ast.GenDecl]bool)
-
- f.walk(func(node ast.Node) bool {
- switch v := node.(type) {
- case *ast.GenDecl:
- if v.Tok == token.IMPORT {
- return false
- }
- // token.CONST, token.TYPE or token.VAR
- lastGen = v
- return true
- case *ast.FuncDecl:
- f.lintFuncDoc(v)
- // Don't proceed inside funcs.
- return false
- case *ast.TypeSpec:
- // inside a GenDecl, which usually has the doc
- doc := v.Doc
- if doc == nil {
- doc = lastGen.Doc
- }
- f.lintTypeDoc(v, doc)
- // Don't proceed inside types.
- return false
- case *ast.ValueSpec:
- f.lintValueSpecDoc(v, lastGen, genDeclMissingComments)
- return false
- }
- return true
- })
-}
-
-var allCapsRE = regexp.MustCompile(`^[A-Z0-9_]+$`)
-
-// lintNames examines all names in the file.
-// It complains if any use underscores or incorrect known initialisms.
-func (f *file) lintNames() {
- // Package names need slightly different handling than other names.
- if strings.Contains(f.f.Name.Name, "_") && !strings.HasSuffix(f.f.Name.Name, "_test") {
- f.errorf(f.f, 1, "http://golang.org/doc/effective_go.html#package-names", "don't use an underscore in package name")
- }
-
- check := func(id *ast.Ident, thing string) {
- if id.Name == "_" {
- return
- }
-
- // Handle two common styles from other languages that don't belong in Go.
- if len(id.Name) >= 5 && allCapsRE.MatchString(id.Name) && strings.Contains(id.Name, "_") {
- f.errorf(id, 0.8, styleGuideBase+"#Mixed_Caps", "don't use ALL_CAPS in Go names; use CamelCase")
- return
- }
- if len(id.Name) > 2 && id.Name[0] == 'k' && id.Name[1] >= 'A' && id.Name[1] <= 'Z' {
- should := string(id.Name[1]+'a'-'A') + id.Name[2:]
- f.errorf(id, 0.8, "", "don't use leading k in Go names; %s %s should be %s", thing, id.Name, should)
- }
-
- should := lintName(id.Name)
- if id.Name == should {
- return
- }
- if len(id.Name) > 2 && strings.Contains(id.Name[1:], "_") {
- f.errorf(id, 0.9, "http://golang.org/doc/effective_go.html#mixed-caps", "don't use underscores in Go names; %s %s should be %s", thing, id.Name, should)
- return
- }
- f.errorf(id, 0.8, styleGuideBase+"#Initialisms", "%s %s should be %s", thing, id.Name, should)
- }
- checkList := func(fl *ast.FieldList, thing string) {
- if fl == nil {
- return
- }
- for _, f := range fl.List {
- for _, id := range f.Names {
- check(id, thing)
- }
- }
- }
- f.walk(func(node ast.Node) bool {
- switch v := node.(type) {
- case *ast.AssignStmt:
- if v.Tok == token.ASSIGN {
- return true
- }
- for _, exp := range v.Lhs {
- if id, ok := exp.(*ast.Ident); ok {
- check(id, "var")
- }
- }
- case *ast.FuncDecl:
- if f.isTest() && (strings.HasPrefix(v.Name.Name, "Example") || strings.HasPrefix(v.Name.Name, "Test")) {
- return true
- }
- check(v.Name, "func")
-
- thing := "func"
- if v.Recv != nil {
- thing = "method"
- }
- checkList(v.Type.Params, thing+" parameter")
- checkList(v.Type.Results, thing+" result")
- case *ast.GenDecl:
- if v.Tok == token.IMPORT {
- return true
- }
- var thing string
- switch v.Tok {
- case token.CONST:
- thing = "const"
- case token.TYPE:
- thing = "type"
- case token.VAR:
- thing = "var"
- }
- for _, spec := range v.Specs {
- switch s := spec.(type) {
- case *ast.TypeSpec:
- check(s.Name, thing)
- case *ast.ValueSpec:
- for _, id := range s.Names {
- check(id, thing)
- }
- }
- }
- case *ast.InterfaceType:
- // Do not check interface method names.
- // They are often constrainted by the method names of concrete types.
- for _, x := range v.Methods.List {
- ft, ok := x.Type.(*ast.FuncType)
- if !ok { // might be an embedded interface name
- continue
- }
- checkList(ft.Params, "interface method parameter")
- checkList(ft.Results, "interface method result")
- }
- case *ast.RangeStmt:
- if v.Tok == token.ASSIGN {
- return true
- }
- if id, ok := v.Key.(*ast.Ident); ok {
- check(id, "range var")
- }
- if id, ok := v.Value.(*ast.Ident); ok {
- check(id, "range var")
- }
- case *ast.StructType:
- for _, f := range v.Fields.List {
- for _, id := range f.Names {
- check(id, "struct field")
- }
- }
- }
- return true
- })
-}
-
-// lintName returns a different name if it should be different.
-func lintName(name string) (should string) {
- // Fast path for simple cases: "_" and all lowercase.
- if name == "_" {
- return name
- }
- allLower := true
- for _, r := range name {
- if !unicode.IsLower(r) {
- allLower = false
- break
- }
- }
- if allLower {
- return name
- }
-
- // Split camelCase at any lower->upper transition, and split on underscores.
- // Check each word for common initialisms.
- runes := []rune(name)
- w, i := 0, 0 // index of start of word, scan
- for i+1 <= len(runes) {
- eow := false // whether we hit the end of a word
- if i+1 == len(runes) {
- eow = true
- } else if runes[i+1] == '_' {
- // underscore; shift the remainder forward over any run of underscores
- eow = true
- n := 1
- for i+n+1 < len(runes) && runes[i+n+1] == '_' {
- n++
- }
- copy(runes[i+1:], runes[i+n+1:])
- runes = runes[:len(runes)-n]
- } else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) {
- // lower->non-lower
- eow = true
- }
- i++
- if !eow {
- continue
- }
-
- // [w,i) is a word.
- word := string(runes[w:i])
- if u := strings.ToUpper(word); commonInitialisms[u] {
- // Keep consistent case, which is lowercase only at the start.
- if w == 0 && unicode.IsLower(runes[w]) {
- u = strings.ToLower(u)
- }
- // All the common initialisms are ASCII,
- // so we can replace the bytes exactly.
- copy(runes[w:], []rune(u))
- } else if w > 0 && strings.ToLower(word) == word {
- // already all lowercase, and not the first word, so uppercase the first character.
- runes[w] = unicode.ToUpper(runes[w])
- }
- w = i
- }
- return string(runes)
-}
-
-// commonInitialisms is a set of common initialisms.
-// Only add entries that are highly unlikely to be non-initialisms.
-// For instance, "ID" is fine (Freudian code is rare), but "AND" is not.
-var commonInitialisms = map[string]bool{
- "API": true,
- "ASCII": true,
- "CPU": true,
- "CSS": true,
- "DNS": true,
- "EOF": true,
- "HTML": true,
- "HTTP": true,
- "HTTPS": true,
- "ID": true,
- "IP": true,
- "JSON": true,
- "LHS": true,
- "QPS": true,
- "RAM": true,
- "RHS": true,
- "RPC": true,
- "SLA": true,
- "SSH": true,
- "TLS": true,
- "TTL": true,
- "UI": true,
- "UID": true,
- "URL": true,
- "UTF8": true,
- "VM": true,
- "XML": true,
-}
-
-// lintTypeDoc examines the doc comment on a type.
-// It complains if they are missing from an exported type,
-// or if they are not of the standard form.
-func (f *file) lintTypeDoc(t *ast.TypeSpec, doc *ast.CommentGroup) {
- if !ast.IsExported(t.Name.Name) {
- return
- }
- if doc == nil {
- f.errorf(t, 1, docCommentsLink, "exported type %v should have comment or be unexported", t.Name)
- return
- }
-
- s := doc.Text()
- articles := [...]string{"A", "An", "The"}
- for _, a := range articles {
- if strings.HasPrefix(s, a+" ") {
- s = s[len(a)+1:]
- break
- }
- }
- if !strings.HasPrefix(s, t.Name.Name+" ") {
- f.errorf(doc, 1, docCommentsLink, `comment on exported type %v should be of the form "%v ..." (with optional leading article)`, t.Name, t.Name)
- }
-}
-
-var commonMethods = map[string]bool{
- "Error": true,
- "Read": true,
- "ServeHTTP": true,
- "String": true,
- "Write": true,
-}
-
-// lintFuncDoc examines doc comments on functions and methods.
-// It complains if they are missing, or not of the right form.
-// It has specific exclusions for well-known methods (see commonMethods above).
-func (f *file) lintFuncDoc(fn *ast.FuncDecl) {
- if !ast.IsExported(fn.Name.Name) {
- // func is unexported
- return
- }
- kind := "function"
- name := fn.Name.Name
- if fn.Recv != nil {
- // method
- kind = "method"
- recv := receiverType(fn)
- if !ast.IsExported(recv) {
- // receiver is unexported
- return
- }
- if commonMethods[name] {
- return
- }
- switch name {
- case "Len", "Less", "Swap":
- if f.sortable[recv] {
- return
- }
- }
- name = recv + "." + name
- }
- if fn.Doc == nil {
- f.errorf(fn, 1, docCommentsLink, "exported %s %s should have comment or be unexported", kind, name)
- return
- }
- s := fn.Doc.Text()
- prefix := fn.Name.Name + " "
- if !strings.HasPrefix(s, prefix) {
- f.errorf(fn.Doc, 1, docCommentsLink, `comment on exported %s %s should be of the form "%s..."`, kind, name, prefix)
- }
-}
-
-// lintValueSpecDoc examines package-global variables and constants.
-// It complains if they are not individually declared,
-// or if they are not suitably documented in the right form (unless they are in a block that is commented).
-func (f *file) lintValueSpecDoc(vs *ast.ValueSpec, gd *ast.GenDecl, genDeclMissingComments map[*ast.GenDecl]bool) {
- kind := "var"
- if gd.Tok == token.CONST {
- kind = "const"
- }
-
- if len(vs.Names) > 1 {
- // Check that none are exported except for the first.
- for _, n := range vs.Names[1:] {
- if ast.IsExported(n.Name) {
- f.errorf(vs, 1, "", "exported %s %s should have its own declaration", kind, n.Name)
- return
- }
- }
- }
-
- // Only one name.
- name := vs.Names[0].Name
- if !ast.IsExported(name) {
- return
- }
-
- if vs.Doc == nil {
- if gd.Doc == nil && !genDeclMissingComments[gd] {
- block := ""
- if kind == "const" && gd.Lparen.IsValid() {
- block = " (or a comment on this block)"
- }
- f.errorf(vs, 1, docCommentsLink, "exported %s %s should have comment%s or be unexported", kind, name, block)
- genDeclMissingComments[gd] = true
- }
- return
- }
- prefix := name + " "
- if !strings.HasPrefix(vs.Doc.Text(), prefix) {
- f.errorf(vs.Doc, 1, docCommentsLink, `comment on exported %s %s should be of the form "%s..."`, kind, name, prefix)
- }
-}
-
-// zeroLiteral is a set of ast.BasicLit values that are zero values.
-// It is not exhaustive.
-var zeroLiteral = map[string]bool{
- "false": true, // bool
- // runes
- `'\x00'`: true,
- `'\000'`: true,
- // strings
- `""`: true,
- "``": true,
- // numerics
- "0": true,
- "0.": true,
- "0.0": true,
- "0i": true,
-}
-
-// lintVarDecls examines variable declarations. It complains about declarations with
-// redundant LHS types that can be inferred from the RHS.
-func (f *file) lintVarDecls() {
- var lastGen *ast.GenDecl // last GenDecl entered.
-
- f.walk(func(node ast.Node) bool {
- switch v := node.(type) {
- case *ast.GenDecl:
- if v.Tok != token.CONST && v.Tok != token.VAR {
- return false
- }
- lastGen = v
- return true
- case *ast.ValueSpec:
- if lastGen.Tok == token.CONST {
- return false
- }
- if len(v.Names) > 1 || v.Type == nil || len(v.Values) == 0 {
- return false
- }
- rhs := v.Values[0]
- // An underscore var appears in a common idiom for compile-time interface satisfaction,
- // as in "var _ Interface = (*Concrete)(nil)".
- if isIdent(v.Names[0], "_") {
- return false
- }
- // If the RHS is a zero value, suggest dropping it.
- zero := false
- if lit, ok := rhs.(*ast.BasicLit); ok {
- zero = zeroLiteral[lit.Value]
- } else if isIdent(rhs, "nil") {
- zero = true
- }
- if zero {
- f.errorf(rhs, 0.9, "", "should drop = %s from declaration of var %s; it is the zero value", f.render(rhs), v.Names[0])
- return false
- }
- // If the LHS type is an interface, don't warn, since it is probably a
- // concrete type on the RHS. Note that our feeble lexical check here
- // will only pick up interface{} and other literal interface types;
- // that covers most of the cases we care to exclude right now.
- // TODO(dsymonds): Use typechecker to make this heuristic more accurate.
- if _, ok := v.Type.(*ast.InterfaceType); ok {
- return false
- }
- // If the RHS is an untyped const, only warn if the LHS type is its default type.
- if defType, ok := isUntypedConst(rhs); ok && !isIdent(v.Type, defType) {
- return false
- }
- f.errorf(v.Type, 0.8, "", "should omit type %s from declaration of var %s; it will be inferred from the right-hand side", f.render(v.Type), v.Names[0])
- return false
- }
- return true
- })
-}
-
-// lintElses examines else blocks. It complains about any else block whose if block ends in a return.
-func (f *file) lintElses() {
- // We don't want to flag if { } else if { } else { } constructions.
- // They will appear as an IfStmt whose Else field is also an IfStmt.
- // Record such a node so we ignore it when we visit it.
- ignore := make(map[*ast.IfStmt]bool)
-
- f.walk(func(node ast.Node) bool {
- ifStmt, ok := node.(*ast.IfStmt)
- if !ok || ifStmt.Else == nil {
- return true
- }
- if ignore[ifStmt] {
- return true
- }
- if elseif, ok := ifStmt.Else.(*ast.IfStmt); ok {
- ignore[elseif] = true
- return true
- }
- if _, ok := ifStmt.Else.(*ast.BlockStmt); !ok {
- // only care about elses without conditions
- return true
- }
- if len(ifStmt.Body.List) == 0 {
- return true
- }
- shortDecl := false // does the if statement have a ":=" initialization statement?
- if ifStmt.Init != nil {
- if as, ok := ifStmt.Init.(*ast.AssignStmt); ok && as.Tok == token.DEFINE {
- shortDecl = true
- }
- }
- lastStmt := ifStmt.Body.List[len(ifStmt.Body.List)-1]
- if _, ok := lastStmt.(*ast.ReturnStmt); ok {
- extra := ""
- if shortDecl {
- extra = " (move short variable declaration to its own line if necessary)"
- }
- f.errorf(ifStmt.Else, 1, styleGuideBase+"#Indent_Error_Flow", "if block ends with a return statement, so drop this else and outdent its block"+extra)
- }
- return true
- })
-}
-
-// lintRanges examines range clauses. It complains about redundant constructions.
-func (f *file) lintRanges() {
- f.walk(func(node ast.Node) bool {
- rs, ok := node.(*ast.RangeStmt)
- if !ok {
- return true
- }
- if rs.Value == nil {
- // for x = range m { ... }
- return true // single var form
- }
- if !isIdent(rs.Value, "_") {
- // for ?, y = range m { ... }
- return true
- }
-
- f.errorf(rs.Value, 1, "", "should omit 2nd value from range; this loop is equivalent to `for %s %s range ...`", f.render(rs.Key), rs.Tok)
- return true
- })
-}
-
-// lintErrorf examines errors.New calls. It complains if its only argument is an fmt.Sprintf invocation.
-func (f *file) lintErrorf() {
- f.walk(func(node ast.Node) bool {
- ce, ok := node.(*ast.CallExpr)
- if !ok {
- return true
- }
- if !isPkgDot(ce.Fun, "errors", "New") || len(ce.Args) != 1 {
- return true
- }
- arg := ce.Args[0]
- ce, ok = arg.(*ast.CallExpr)
- if !ok || !isPkgDot(ce.Fun, "fmt", "Sprintf") {
- return true
- }
- f.errorf(node, 1, "", "should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...)")
- return true
- })
-}
-
-// lintErrors examines global error vars. It complains if they aren't named in the standard way.
-func (f *file) lintErrors() {
- for _, decl := range f.f.Decls {
- gd, ok := decl.(*ast.GenDecl)
- if !ok || gd.Tok != token.VAR {
- continue
- }
- for _, spec := range gd.Specs {
- spec := spec.(*ast.ValueSpec)
- if len(spec.Names) != 1 || len(spec.Values) != 1 {
- continue
- }
- ce, ok := spec.Values[0].(*ast.CallExpr)
- if !ok {
- continue
- }
- if !isPkgDot(ce.Fun, "errors", "New") && !isPkgDot(ce.Fun, "fmt", "Errorf") {
- continue
- }
-
- id := spec.Names[0]
- prefix := "err"
- if id.IsExported() {
- prefix = "Err"
- }
- if !strings.HasPrefix(id.Name, prefix) {
- f.errorf(id, 0.9, "", "error var %s should have name of the form %sFoo", id.Name, prefix)
- }
- }
- }
-}
-
-func lintCapAndPunct(s string) (isCap, isPunct bool) {
- first, firstN := utf8.DecodeRuneInString(s)
- last, _ := utf8.DecodeLastRuneInString(s)
- isPunct = last == '.' || last == ':' || last == '!'
- isCap = unicode.IsUpper(first)
- if isCap && len(s) > firstN {
- // Don't flag strings starting with something that looks like an initialism.
- if second, _ := utf8.DecodeRuneInString(s[firstN:]); unicode.IsUpper(second) {
- isCap = false
- }
- }
- return
-}
-
-// lintErrorStrings examines error strings. It complains if they are capitalized or end in punctuation.
-func (f *file) lintErrorStrings() {
- f.walk(func(node ast.Node) bool {
- ce, ok := node.(*ast.CallExpr)
- if !ok {
- return true
- }
- if !isPkgDot(ce.Fun, "errors", "New") && !isPkgDot(ce.Fun, "fmt", "Errorf") {
- return true
- }
- if len(ce.Args) < 1 {
- return true
- }
- str, ok := ce.Args[0].(*ast.BasicLit)
- if !ok || str.Kind != token.STRING {
- return true
- }
- s, _ := strconv.Unquote(str.Value) // can assume well-formed Go
- if s == "" {
- return true
- }
- isCap, isPunct := lintCapAndPunct(s)
- var msg string
- switch {
- case isCap && isPunct:
- msg = "error strings should not be capitalized and should not end with punctuation"
- case isCap:
- msg = "error strings should not be capitalized"
- case isPunct:
- msg = "error strings should not end with punctuation"
- default:
- return true
- }
- f.errorf(str, 0.8, styleGuideBase+"#Error_Strings", msg)
- return true
- })
-}
-
-var badReceiverNames = map[string]bool{
- "me": true,
- "this": true,
- "self": true,
-}
-
-// lintReceiverNames examines receiver names. It complains about inconsistent
-// names used for the same type and names such as "this".
-func (f *file) lintReceiverNames() {
- typeReceiver := map[string]string{}
- f.walk(func(n ast.Node) bool {
- fn, ok := n.(*ast.FuncDecl)
- if !ok || fn.Recv == nil {
- return true
- }
- names := fn.Recv.List[0].Names
- if len(names) < 1 {
- return true
- }
- name := names[0].Name
- const link = styleGuideBase + "#Receiver_Names"
- if badReceiverNames[name] {
- f.errorf(n, 1, link, `receiver name should be a reflection of its identity; don't use generic names such as "me", "this", or "self"`)
- return true
- }
- recv := receiverType(fn)
- if prev, ok := typeReceiver[recv]; ok && prev != name {
- f.errorf(n, 1, link, "receiver name %s should be consistent with previous receiver name %s for %s", name, prev, recv)
- return true
- }
- typeReceiver[recv] = name
- return true
- })
-}
-
-// lintIncDec examines statements that increment or decrement a variable.
-// It complains if they don't use x++ or x--.
-func (f *file) lintIncDec() {
- f.walk(func(n ast.Node) bool {
- as, ok := n.(*ast.AssignStmt)
- if !ok {
- return true
- }
- if len(as.Lhs) != 1 {
- return true
- }
- if !isOne(as.Rhs[0]) {
- return true
- }
- var suffix string
- switch as.Tok {
- case token.ADD_ASSIGN:
- suffix = "++"
- case token.SUB_ASSIGN:
- suffix = "--"
- default:
- return true
- }
- f.errorf(as, 0.8, "", "should replace %s with %s%s", f.render(as), f.render(as.Lhs[0]), suffix)
- return true
- })
-}
-
-// lineMake examines statements that declare and initialize a variable with make.
-// It complains if they are constructing a zero element slice.
-func (f *file) lintMake() {
- f.walk(func(n ast.Node) bool {
- as, ok := n.(*ast.AssignStmt)
- if !ok {
- return true
- }
- // Only want single var := assignment statements.
- if len(as.Lhs) != 1 || as.Tok != token.DEFINE {
- return true
- }
- ce, ok := as.Rhs[0].(*ast.CallExpr)
- if !ok {
- return true
- }
- // Check if ce is make([]T, 0).
- if !isIdent(ce.Fun, "make") || len(ce.Args) != 2 || !isZero(ce.Args[1]) {
- return true
- }
- at, ok := ce.Args[0].(*ast.ArrayType)
- if !ok || at.Len != nil {
- return true
- }
- f.errorf(as, 0.8, "", `can probably use "var %s %s" instead`, f.render(as.Lhs[0]), f.render(at))
- return true
- })
-}
-
-func receiverType(fn *ast.FuncDecl) string {
- switch e := fn.Recv.List[0].Type.(type) {
- case *ast.Ident:
- return e.Name
- case *ast.StarExpr:
- return e.X.(*ast.Ident).Name
- }
- panic(fmt.Sprintf("unknown method receiver AST node type %T", fn.Recv.List[0].Type))
-}
-
-func (f *file) walk(fn func(ast.Node) bool) {
- ast.Walk(walker(fn), f.f)
-}
-
-func (f *file) render(x interface{}) string {
- var buf bytes.Buffer
- if err := printer.Fprint(&buf, f.fset, x); err != nil {
- panic(err)
- }
- return buf.String()
-}
-
-func (f *file) debugRender(x interface{}) string {
- var buf bytes.Buffer
- if err := ast.Fprint(&buf, f.fset, x, nil); err != nil {
- panic(err)
- }
- return buf.String()
-}
-
-// walker adapts a function to satisfy the ast.Visitor interface.
-// The function return whether the walk should proceed into the node's children.
-type walker func(ast.Node) bool
-
-func (w walker) Visit(node ast.Node) ast.Visitor {
- if w(node) {
- return w
- }
- return nil
-}
-
-func isIdent(expr ast.Expr, ident string) bool {
- id, ok := expr.(*ast.Ident)
- return ok && id.Name == ident
-}
-
-// isBlank returns whether id is the blank identifier "_".
-// If id == nil, the answer is false.
-func isBlank(id *ast.Ident) bool { return id != nil && id.Name == "_" }
-
-func isPkgDot(expr ast.Expr, pkg, name string) bool {
- sel, ok := expr.(*ast.SelectorExpr)
- return ok && isIdent(sel.X, pkg) && isIdent(sel.Sel, name)
-}
-
-func isZero(expr ast.Expr) bool {
- lit, ok := expr.(*ast.BasicLit)
- return ok && lit.Kind == token.INT && lit.Value == "0"
-}
-
-func isOne(expr ast.Expr) bool {
- lit, ok := expr.(*ast.BasicLit)
- return ok && lit.Kind == token.INT && lit.Value == "1"
-}
-
-var basicLitKindTypes = map[token.Token]string{
- token.FLOAT: "float64",
- token.IMAG: "complex128",
- token.CHAR: "rune",
- token.STRING: "string",
-}
-
-// isUntypedConst reports whether expr is an untyped constant,
-// and indicates what its default type is.
-func isUntypedConst(expr ast.Expr) (defType string, ok bool) {
- if isIntLiteral(expr) {
- return "int", true
- }
- if bl, ok := expr.(*ast.BasicLit); ok {
- if dt, ok := basicLitKindTypes[bl.Kind]; ok {
- return dt, true
- }
- }
- return "", false
-}
-
-func isIntLiteral(expr ast.Expr) bool {
- // Either a BasicLit with Kind token.INT,
- // or some combination of a UnaryExpr with Op token.SUB (for "-")
- // or a ParenExpr (for "()").
-Loop:
- for {
- switch v := expr.(type) {
- case *ast.UnaryExpr:
- if v.Op == token.SUB {
- expr = v.X
- continue Loop
- }
- case *ast.ParenExpr:
- expr = v.X
- continue Loop
- case *ast.BasicLit:
- if v.Kind == token.INT {
- return true
- }
- }
- return false
- }
-}
-
-// srcLine returns the complete line at p, including the terminating newline.
-func srcLine(src []byte, p token.Position) string {
- // Run to end of line in both directions if not at line start/end.
- lo, hi := p.Offset, p.Offset+1
- for lo > 0 && src[lo-1] != '\n' {
- lo--
- }
- for hi < len(src) && src[hi-1] != '\n' {
- hi++
- }
- return string(src[lo:hi])
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/lint_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/lint_test.go
deleted file mode 100644
index 12e3afb8..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/lint_test.go
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright (c) 2013 The Go Authors. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file or at
-// https://developers.google.com/open-source/licenses/bsd.
-
-package lint
-
-import (
- "bytes"
- "flag"
- "go/parser"
- "go/printer"
- "go/token"
- "io/ioutil"
- "path"
- "regexp"
- "strings"
- "testing"
-)
-
-var lintMatch = flag.String("lint.match", "", "restrict testdata matches to this pattern")
-
-func TestAll(t *testing.T) {
- l := new(Linter)
- rx, err := regexp.Compile(*lintMatch)
- if err != nil {
- t.Fatalf("Bad -lint.match value %q: %v", *lintMatch, err)
- }
-
- baseDir := "testdata"
- fis, err := ioutil.ReadDir(baseDir)
- if err != nil {
- t.Fatalf("ioutil.ReadDir: %v", err)
- }
- if len(fis) == 0 {
- t.Fatalf("no files in %v", baseDir)
- }
- for _, fi := range fis {
- if !rx.MatchString(fi.Name()) {
- continue
- }
- //t.Logf("Testing %s", fi.Name())
- src, err := ioutil.ReadFile(path.Join(baseDir, fi.Name()))
- if err != nil {
- t.Fatalf("Failed reading %s: %v", fi.Name(), err)
- }
-
- ins := parseInstructions(t, fi.Name(), src)
- if ins == nil {
- t.Errorf("Test file %v does not have instructions", fi.Name())
- continue
- }
-
- ps, err := l.Lint(fi.Name(), src)
- if err != nil {
- t.Errorf("Linting %s: %v", fi.Name(), err)
- continue
- }
-
- for _, in := range ins {
- ok := false
- for i, p := range ps {
- if p.Position.Line != in.Line {
- continue
- }
- if in.Match.MatchString(p.Text) {
- // remove this problem from ps
- copy(ps[i:], ps[i+1:])
- ps = ps[:len(ps)-1]
-
- //t.Logf("/%v/ matched at %s:%d", in.Match, fi.Name(), in.Line)
- ok = true
- break
- }
- }
- if !ok {
- t.Errorf("Lint failed at %s:%d; /%v/ did not match", fi.Name(), in.Line, in.Match)
- }
- }
- for _, p := range ps {
- t.Errorf("Unexpected problem at %s:%d: %v", fi.Name(), p.Position.Line, p.Text)
- }
- }
-}
-
-type instruction struct {
- Line int // the line number this applies to
- Match *regexp.Regexp // what pattern to match
-}
-
-// parseInstructions parses instructions from the comments in a Go source file.
-// It returns nil if none were parsed.
-func parseInstructions(t *testing.T, filename string, src []byte) []instruction {
- fset := token.NewFileSet()
- f, err := parser.ParseFile(fset, filename, src, parser.ParseComments)
- if err != nil {
- t.Fatalf("Test file %v does not parse: %v", filename, err)
- }
- var ins []instruction
- for _, cg := range f.Comments {
- ln := fset.Position(cg.Pos()).Line
- raw := cg.Text()
- for _, line := range strings.Split(raw, "\n") {
- if line == "" || strings.HasPrefix(line, "#") {
- continue
- }
- if line == "OK" && ins == nil {
- // so our return value will be non-nil
- ins = make([]instruction, 0)
- continue
- }
- if strings.Contains(line, "MATCH") {
- a, b := strings.Index(line, "/"), strings.LastIndex(line, "/")
- if a == -1 || a == b {
- t.Fatalf("Malformed match instruction %q at %v:%d", line, filename, ln)
- }
- pat := line[a+1 : b]
- rx, err := regexp.Compile(pat)
- if err != nil {
- t.Fatalf("Bad match pattern %q at %v:%d: %v", pat, filename, ln, err)
- }
- ins = append(ins, instruction{
- Line: ln,
- Match: rx,
- })
- }
- }
- }
- return ins
-}
-
-func render(fset *token.FileSet, x interface{}) string {
- var buf bytes.Buffer
- if err := printer.Fprint(&buf, fset, x); err != nil {
- panic(err)
- }
- return buf.String()
-}
-
-func TestLine(t *testing.T) {
- tests := []struct {
- src string
- offset int
- want string
- }{
- {"single line file", 5, "single line file"},
- {"single line file with newline\n", 5, "single line file with newline\n"},
- {"first\nsecond\nthird\n", 2, "first\n"},
- {"first\nsecond\nthird\n", 9, "second\n"},
- {"first\nsecond\nthird\n", 14, "third\n"},
- {"first\nsecond\nthird with no newline", 16, "third with no newline"},
- {"first byte\n", 0, "first byte\n"},
- }
- for _, test := range tests {
- got := srcLine([]byte(test.src), token.Position{Offset: test.offset})
- if got != test.want {
- t.Errorf("srcLine(%q, offset=%d) = %q, want %q", test.src, test.offset, got, test.want)
- }
- }
-}
-
-func TestLintName(t *testing.T) {
- tests := []struct {
- name, want string
- }{
- {"foo_bar", "fooBar"},
- {"foo_bar_baz", "fooBarBaz"},
- {"Foo_bar", "FooBar"},
- {"foo_WiFi", "fooWiFi"},
- {"id", "id"},
- {"Id", "ID"},
- {"foo_id", "fooID"},
- {"fooId", "fooID"},
- {"fooUid", "fooUID"},
- {"idFoo", "idFoo"},
- {"uidFoo", "uidFoo"},
- {"midIdDle", "midIDDle"},
- {"APIProxy", "APIProxy"},
- {"ApiProxy", "APIProxy"},
- {"apiProxy", "apiProxy"},
- {"_Leading", "_Leading"},
- {"___Leading", "_Leading"},
- {"trailing_", "trailing"},
- {"trailing___", "trailing"},
- {"a_b", "aB"},
- {"a__b", "aB"},
- {"a___b", "aB"},
- {"Rpc1150", "RPC1150"},
- }
- for _, test := range tests {
- got := lintName(test.name)
- if got != test.want {
- t.Errorf("lintName(%q) = %q, want %q", test.name, got, test.want)
- }
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/misc/emacs/golint.el b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/misc/emacs/golint.el
deleted file mode 100644
index de729df6..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/misc/emacs/golint.el
+++ /dev/null
@@ -1,51 +0,0 @@
-;;; golint.el --- lint for the Go source code
-
-;; Copyright 2013 The Go Authors. All rights reserved.
-;; Use of this source code is governed by a BSD-style
-;; license that can be found in the LICENSE file.
-
-;; URL: https://github.com/golang/lint
-
-;;; Commentary:
-
-;; To install golint, add the following lines to your .emacs file:
-;; (add-to-list 'load-path "PATH CONTAINING golint.el" t)
-;; (require 'golint)
-;;
-;; After this, type M-x golint on Go source code.
-;;
-;; Usage:
-;; C-x `
-;; Jump directly to the line in your code which caused the first message.
-;;
-;; For more usage, see Compilation-Mode:
-;; http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html
-
-;;; Code:
-(require 'compile)
-
-(defun go-lint-buffer-name (mode)
- "*Golint*")
-
-(defun golint-process-setup ()
- "Setup compilation variables and buffer for `golint'."
- (run-hooks 'golint-setup-hook))
-
-(define-compilation-mode golint-mode "golint"
- "Golint is a linter for Go source code."
- (set (make-local-variable 'compilation-scroll-output) nil)
- (set (make-local-variable 'compilation-disable-input) t)
- (set (make-local-variable 'compilation-process-setup-function)
- 'golint-process-setup)
-)
-
-;;;###autoload
-(defun golint ()
- "Run golint on the current file and populate the fix list. Pressing C-x ` will jump directly to the line in your code which caused the first message."
- (interactive)
- (compilation-start (concat "golint " buffer-file-name)
- 'golint-mode))
-
-(provide 'golint)
-
-;;; golint.el ends here
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/misc/vim/ftplugin/go/lint.vim b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/misc/vim/ftplugin/go/lint.vim
deleted file mode 100644
index 7dffd181..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/misc/vim/ftplugin/go/lint.vim
+++ /dev/null
@@ -1,31 +0,0 @@
-" Copyright 2013 The Go Authors. All rights reserved.
-" Use of this source code is governed by a BSD-style
-" license that can be found in the LICENSE file.
-"
-" lint.vim: Vim command to lint Go files with golint.
-"
-" https://github.com/golang/lint
-"
-" This filetype plugin add a new commands for go buffers:
-"
-" :Lint
-"
-" Run golint for the current Go file.
-"
-if exists("b:did_ftplugin_go_lint")
- finish
-endif
-
-if !executable("golint")
- finish
-endif
-
-command! -buffer Lint call s:GoLint()
-
-function! s:GoLint() abort
- cexpr system('golint ' . shellescape(expand('%')))
-endfunction
-
-let b:did_ftplugin_go_lint = 1
-
-" vim:ts=4:sw=4:et
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/4.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/4.go
deleted file mode 100644
index 2303a9a3..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/4.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Test that exported names have correct comments.
-
-// Package pkg does something.
-package pkg
-
-import "time"
-
-type T int // MATCH /exported type T.*should.*comment.*or.*unexport/
-
-func (T) F() {} // MATCH /exported method T\.F.*should.*comment.*or.*unexport/
-
-// this is a nice type.
-// MATCH /comment.*exported type U.*should.*form.*"U ..."/
-type U string
-
-// this is a neat function.
-// MATCH /comment.*exported method U\.G.*should.*form.*"G ..."/
-func (U) G() {}
-
-// A V is a string.
-type V string
-
-// V.H has a pointer receiver
-
-func (*V) H() {} // MATCH /exported method V\.H.*should.*comment.*or.*unexport/
-
-var W = "foo" // MATCH /exported var W.*should.*comment.*or.*unexport/
-
-const X = "bar" // MATCH /exported const X.*should.*comment.*or.*unexport/
-
-var Y, Z int // MATCH /exported var Z.*own declaration/
-
-// Location should be okay, since the other var name is an underscore.
-var Location, _ = time.LoadLocation("Europe/Istanbul") // not Constantinople
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/5_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/5_test.go
deleted file mode 100644
index af174587..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/5_test.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// This file ends in _test.go, so we should not warn about doc comments.
-// OK
-
-package pkg
-
-import "testing"
-
-type H int
-
-func TestSomething(t *testing.T) {
-}
-
-func TestSomething_suffix(t *testing.T) {
-}
-
-func ExampleBuffer_reader() {
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-lib.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-lib.go
deleted file mode 100644
index edac0d75..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-lib.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Test that blank imports in library packages are flagged.
-
-// Package foo ...
-package foo
-
-// The instructions need to go before the imports below so they will not be
-// mistaken for documentation.
-
-/* MATCH /blank import/ */ import _ "encoding/json"
-
-import (
- "fmt"
- /* MATCH /blank import/ */ _ "os"
-
- /* MATCH /blank import/ */ _ "net/http"
- _ "path"
-)
-
-import _ "encoding/base64" // Don't gripe about this
-
-import (
- // Don't gripe about these next two lines.
- _ "compress/zlib"
- _ "syscall"
-
- /* MATCH /blank import/ */ _ "path/filepath"
-)
-
-import (
- "go/ast"
- _ "go/scanner" // Don't gripe about this or the following line.
- _ "go/token"
-)
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-lib_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-lib_test.go
deleted file mode 100644
index 0307985f..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-lib_test.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Test that blank imports in test packages are not flagged.
-// OK
-
-// Package foo ...
-package foo
-
-// These are essentially the same imports as in the "library" package, but
-// these should not trigger the warning because this is a test.
-
-import _ "encoding/json"
-
-import (
- "fmt"
- "testing"
-
- _ "os"
-
- _ "net/http"
- _ "path"
-)
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-main.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-main.go
deleted file mode 100644
index 9b72b1cb..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/blank-import-main.go
+++ /dev/null
@@ -1,12 +0,0 @@
-// Test that blank imports in package main are not flagged.
-// OK
-
-// Binary foo ...
-package main
-
-import _ "fmt"
-
-import (
- "os"
- _ "path"
-)
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/common-methods.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/common-methods.go
deleted file mode 100644
index c0bb1363..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/common-methods.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Test that we don't nag for comments on common methods.
-// OK
-
-// Package pkg ...
-package pkg
-
-import "net/http"
-
-// T is ...
-type T int
-
-func (T) Error() string { return "" }
-func (T) String() string { return "" }
-func (T) ServeHTTP(w http.ResponseWriter, r *http.Request) {}
-func (T) Read(p []byte) (n int, err error) { return 0, nil }
-func (T) Write(p []byte) (n int, err error) { return 0, nil }
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/const-block.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/const-block.go
deleted file mode 100644
index 4b89d6f6..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/const-block.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Test for docs in const blocks
-
-// Package foo ...
-package foo
-
-const (
- // Prefix for something.
- // MATCH /InlineWhatever.*form/
- InlineWhatever = "blah"
-
- Whatsit = "missing_comment" // MATCH /Whatsit.*should have comment.*block/
-
- // We should only warn once per block for missing comments,
- // but always complain about malformed comments.
-
- WhosYourDaddy = "another_missing_one"
-
- // Something
- // MATCH /WhatDoesHeDo.*form/
- WhatDoesHeDo = "it's not a tumor!"
-)
-
-// These shouldn't need doc comments.
-const (
- Alpha = "a"
- Beta = "b"
- Gamma = "g"
-)
-
-// The comment on the previous const block shouldn't flow through to here.
-
-const UndocAgain = 6 // MATCH /UndocAgain.*should have comment/
-
-const (
- SomeUndocumented = 7 // MATCH /SomeUndocumented.*should have comment.*block/
-)
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/else-multi.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/else-multi.go
deleted file mode 100644
index 98f39a3e..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/else-multi.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// Test of return+else warning; should not trigger on multi-branch if/else.
-// OK
-
-// Package pkg ...
-package pkg
-
-import "log"
-
-func f(x int) bool {
- if x == 0 {
- log.Print("x is zero")
- } else if x > 0 {
- return true
- } else {
- log.Printf("non-positive x: %d", x)
- }
- return false
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/else.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/else.go
deleted file mode 100644
index 515c043d..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/else.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Test of return+else warning.
-
-// Package pkg ...
-package pkg
-
-import "log"
-
-func f(x int) bool {
- if x > 0 {
- return true
- } else { // MATCH /if.*return.*else.*outdent/
- log.Printf("non-positive x: %d", x)
- }
- return false
-}
-
-func g(f func() bool) string {
- if ok := f(); ok {
- return "it's okay"
- } else { // MATCH /if.*return.*else.*outdent.*short.*var.*declaration/
- return "it's NOT okay!"
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/errorf.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/errorf.go
deleted file mode 100644
index 768fb8ce..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/errorf.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Test for not using fmt.Errorf.
-
-// Package foo ...
-package foo
-
-import (
- "errors"
- "fmt"
-)
-
-func f(x int) error {
- if x > 10 {
- return errors.New(fmt.Sprintf("something %d", x)) // MATCH /should replace.*errors\.New\(fmt\.Sprintf\(\.\.\.\)\).*fmt\.Errorf\(\.\.\.\)/
- }
- if x > 5 {
- return errors.New(g("blah")) // ok
- }
- if x > 4 {
- return errors.New("something else") // ok
- }
- return nil
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/errors.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/errors.go
deleted file mode 100644
index 2882738e..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/errors.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Test for naming errors.
-
-// Package foo ...
-package foo
-
-import (
- "errors"
- "fmt"
-)
-
-var unexp = errors.New("some unexported error") // MATCH /error var.*unexp.*errFoo/
-
-// Exp ...
-var Exp = errors.New("some exported error") // MATCH /error var.*Exp.*ErrFoo/
-
-var (
- e1 = fmt.Errorf("blah %d", 4) // MATCH /error var.*e1.*errFoo/
- // E2 ...
- E2 = fmt.Errorf("blah %d", 5) // MATCH /error var.*E2.*ErrFoo/
-)
-
-func f() {
- var whatever = errors.New("ok") // ok
-}
-
-// Check for the error strings themselves.
-
-func g(x int) error {
- if x < 1 {
- return fmt.Errorf("This %d is too low", x) // MATCH /error strings.*not be capitalized/
- } else if x == 0 {
- return fmt.Errorf("XML time") // ok
- }
- return errors.New(`too much stuff.`) // MATCH /error strings.*not end with punctuation/
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/import-dot.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/import-dot.go
deleted file mode 100644
index bb4c2675..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/import-dot.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// Test that dot imports are flagged.
-
-// Package pkg ...
-package pkg
-
-import . "fmt" // MATCH /dot import/
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/inc.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/inc.go
deleted file mode 100644
index 3868beea..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/inc.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// Test for use of x++ and x--.
-
-// Package pkg ...
-package pkg
-
-func addOne(x int) int {
- x += 1 // MATCH /x\+\+/
- return x
-}
-
-func subOneInLoop(y int) {
- for ; y > 0; y -= 1 { // MATCH /y--/
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/make.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/make.go
deleted file mode 100644
index 5211375f..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/make.go
+++ /dev/null
@@ -1,10 +0,0 @@
-// Test for pointless make() calls.
-
-// Package pkg ...
-package pkg
-
-func f() {
- x := make([]T, 0) // MATCH /var x \[\]T/
- y := make([]somepkg.Foo_Bar, 0) // MATCH /var y \[\]somepkg.Foo_Bar/
- z = make([]T, 0) // ok, because we don't know where z is declared
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/names.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/names.go
deleted file mode 100644
index ca7ffde6..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/names.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// Test for name linting.
-
-// Package pkg_with_underscores ...
-package pkg_with_underscores // MATCH /underscore.*package name/
-
-var var_name int // MATCH /underscore.*var.*var_name/
-
-type t_wow struct { // MATCH /underscore.*type.*t_wow/
- x_damn int // MATCH /underscore.*field.*x_damn/
- Url *url.URL // MATCH /struct field.*Url.*URL/
-}
-
-const fooId = "blah" // MATCH /fooId.*fooID/
-
-func f_it() { // MATCH /underscore.*func.*f_it/
- more_underscore := 4 // MATCH /underscore.*var.*more_underscore/
- if isEof := (err == io.EOF); isEof { // MATCH /var.*isEof.*isEOF/
- more_underscore = 7 // should be okay
- }
-
- x := foo_proto.Blah{} // should be okay
-
- for _, theIp := range ips { // MATCH /range var.*theIp.*theIP/
- }
-
- switch myJson := g(); { // MATCH /var.*myJson.*myJSON/
- }
- switch tApi := x.(type) { // MATCH /var.*tApi.*tAPI/
- }
-
- select {
- case qId := <-c: // MATCH /var.*qId.*qID/
- }
-}
-
-// Common styles in other languages that don't belong in Go.
-const (
- CPP_CONST = 1 // MATCH /ALL_CAPS.*CamelCase/
- kLeadingKay = 2 // MATCH /k.*leadingKay/
-
- HTML = 3 // okay; no underscore
- X509B = 4 // ditto
-)
-
-func f(bad_name int) {} // MATCH /underscore.*func parameter.*bad_name/
-func g() (no_way int) {} // MATCH /underscore.*func result.*no_way/
-func (t *t_wow) f(more_under string) {} // MATCH /underscore.*method parameter.*more_under/
-func (t *t_wow) g() (still_more string) {} // MATCH /underscore.*method result.*still_more/
-
-type i interface {
- CheckHtml() string // okay; interface method names are often constrained by the concrete types' method names
-
- F(foo_bar int) // MATCH /foo_bar.*fooBar/
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc1.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc1.go
deleted file mode 100644
index 8197a8ee..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc1.go
+++ /dev/null
@@ -1,3 +0,0 @@
-// Test of missing package comment.
-
-package foo // MATCH /should.*package comment.*unless/
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc2.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc2.go
deleted file mode 100644
index c61febd0..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc2.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// Test of package comment in an incorrect form.
-
-// Some random package doc that isn't in the right form.
-// MATCH /package comment should.*form.*"Package testdata .*"/
-package testdata
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc3.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc3.go
deleted file mode 100644
index 95e814e0..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc3.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// Test of block package comment.
-// OK
-
-/*
-Package foo is pretty sweet.
-*/
-package foo
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc4.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc4.go
deleted file mode 100644
index 23448dec..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-doc4.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// Test of block package comment with leading space.
-
-/*
- Package foo is pretty sweet.
-MATCH /package comment.*leading space/
-*/
-package foo
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-main.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-main.go
deleted file mode 100644
index c261945d..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/pkg-main.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// Test of package comment for package main.
-// OK
-
-// This binary does something awesome.
-package main
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/range.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/range.go
deleted file mode 100644
index e8629edc..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/range.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Test for range construction.
-
-// Package foo ...
-package foo
-
-func f() {
- // with :=
- for x, _ := range m { // MATCH /should omit 2nd value.*range.*equivalent.*for x := range/
- }
- // with =
- for y, _ = range m { // MATCH /should omit 2nd value.*range.*equivalent.*for y = range/
- }
-
- // all OK:
- for x := range m {
- }
- for x, y := range m {
- }
- for _, y := range m {
- }
- for x = range m {
- }
- for x, y = range m {
- }
- for _, y = range m {
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/receiver-names.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/receiver-names.go
deleted file mode 100644
index 58f567da..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/receiver-names.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Test for bad receiver names.
-
-// Package foo ...
-package foo
-
-type foo struct{}
-
-func (this foo) f1() { // MATCH /should be a reflection of its identity/
-}
-
-func (self foo) f2() { // MATCH /should be a reflection of its identity/
-}
-
-func (f foo) f3() {
-}
-
-func (foo) f4() {
-}
-
-type bar struct{}
-
-func (b bar) f1() {
-}
-
-func (b bar) f2() {
-}
-
-func (a bar) f3() { // MATCH /receiver name a should be consistent with previous receiver name b for bar/
-}
-
-func (a *bar) f4() { // MATCH /receiver name a should be consistent with previous receiver name b for bar/
-}
-
-func (b *bar) f5() {
-}
-
-func (bar) f6() {
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/sort.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/sort.go
deleted file mode 100644
index c0990494..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/sort.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Test that we don't ask for comments on sort.Interface methods.
-
-// Package pkg ...
-package pkg
-
-// T is ...
-type T []int
-
-// Len by itself should get documented.
-
-func (t T) Len() int { return len(t) } // MATCH /exported method T\.Len.*should.*comment/
-
-// U is ...
-type U []int
-
-func (u U) Len() int { return len(u) }
-func (u U) Less(i, j int) bool { return u[i] < u[j] }
-func (u U) Swap(i, j int) { u[i], u[j] = u[j], u[i] }
-
-func (u U) Other() {} // MATCH /exported method U\.Other.*should.*comment/
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/var-decl.go b/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/var-decl.go
deleted file mode 100644
index bbc687c3..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/golang/lint/testdata/var-decl.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// Test for redundant type declaration.
-
-// Package foo ...
-package foo
-
-import "fmt"
-import "net/http"
-
-var mux *http.ServeMux = http.NewServeMux() // MATCH /should.*\*http\.ServeMux.*inferred/
-var myInt int = 7 // MATCH /should.*int.*myInt.*inferred/
-
-var myZeroInt int = 0 // MATCH /should.*= 0.*myZeroInt.*zero value/
-var myZeroFlt float32 = 0. // MATCH /should.*= 0\..*myZeroFlt.*zero value/
-var myZeroF64 float64 = 0.0 // MATCH /should.*= 0\..*myZeroF64.*zero value/
-var myZeroImg complex = 0i // MATCH /should.*= 0i.*myZeroImg.*zero value/
-var myZeroStr string = "" // MATCH /should.*= "".*myZeroStr.*zero value/
-var myZeroRaw string = `` // MATCH /should.*= ``.*myZeroRaw.*zero value/
-var myZeroPtr *Q = nil // MATCH /should.*= nil.*myZeroPtr.*zero value/
-var myZeroRune rune = '\x00' // MATCH /should.*= '\\x00'.*myZeroRune.*zero value/
-var myZeroRune2 rune = '\000' // MATCH /should.*= '\\000'.*myZeroRune2.*zero value/
-
-// No warning because there's no type on the LHS
-var x = 0
-
-// This shouldn't get a warning because there's no initial values.
-var str fmt.Stringer
-
-// No warning because this is a const.
-const x uint64 = 7
-
-// No warnings because the RHS is an ideal int, and the LHS is a different int type.
-var userID int64 = 1235
-var negID int64 = -1
-var parenID int64 = (17)
-var crazyID int64 = -(-(-(-9)))
-
-// Same, but for strings and floats.
-type stringT string
-type floatT float64
-
-var stringV stringT = "abc"
-var floatV floatT = 123.45
-
-// No warning because the LHS names an interface type.
-var data interface{} = googleIPs
-
-// No warning because it's a common idiom for interface satisfaction.
-var _ Server = (*serverImpl)(nil)
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/.gitignore b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/.gitignore
deleted file mode 100644
index 705db8c8..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*~
-/goveralls
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/README.md b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/README.md
deleted file mode 100644
index 4c951b48..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/README.md
+++ /dev/null
@@ -1,65 +0,0 @@
-goveralls
-=========
-
-[Go](http://golang.org) integration for [Coveralls.io](http://coveralls.io)
-continuous code coverage tracking system.
-
-# Installation
-
-`goveralls` requires a working Go installation (Go1 or higher).
-
-```bash
-$ go get github.com/mattn/goveralls
-```
-
-
-# Usage
-
-First you will need an API token. It is found at the bottom of your
-repository's page when you are logged in to Coveralls.io. Each repo has its
-own token.
-
-```bash
-$ cd $GOPATH/src/github.com/yourusername/yourpackage
-$ goveralls -repotoken your_repos_coveralls_token
-```
-
-# Continuous Integration
-
-There is no need to run `go test` separately, as `goveralls` runs the entire
-test suite.
-
-## Travis CI
-
- go get code.google.com/p/go.tools/cmd/cover
- go get github.com/mattn/goveralls
- go test -covermode=count -coverprofile=profile.cov
- goveralls -coverprofile=profile.cov -service=travis-ci
-
-## Drone.io
-
-Store your Coveralls API token in `Enviornment Variables`:
-
-```
-COVERALLS_TOKEN=your_token_goes_here
-```
-
-Replace the `go test` line in your `Commands` with these lines:
-
-```
-go get github.com/axw/gocov/gocov
-go get github.com/mattn/goveralls
-goveralls -service drone.io -repotoken $COVERALLS_TOKEN
-```
-
-You can use the `-v` flag to see verbose output from the test suite:
-
-```
-goveralls -v -service drone.io -repotoken $COVERALLS_TOKEN
-```
-
-
-# License
-
-under the MIT License: http://mattn.mit-license.org/2013
-
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gitinfo.go b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gitinfo.go
deleted file mode 100644
index c502ba01..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gitinfo.go
+++ /dev/null
@@ -1,99 +0,0 @@
-package main
-
-import (
- "log"
- "os"
- "os/exec"
- "regexp"
- "strings"
-)
-
-var remotesRE = regexp.MustCompile(`^(\S+)\s+(\S+)`)
-
-// A Head object encapsulates information about the HEAD revision of a git repo.
-type Head struct {
- Id string `json:"id"`
- AuthorName string `json:"author_name,omitempty"`
- AuthorEmail string `json:"author_email,omitempty"`
- CommitterName string `json:"committer_name,omitempty"`
- CommitterEmail string `json:"committer_email,omitempty"`
- Message string `json:"message"`
-}
-
-// A Remote object encapsulates information about a remote of a git repo.
-type Remote struct {
- Name string `json:"name"`
- Url string `json:"url"`
-}
-
-// A Git object encapsulates information about a git repo.
-type Git struct {
- Head Head `json:"head"`
- Branch string `json:"branch"`
- Remotes []*Remote `json:"remotes,omitempty"`
-}
-
-// collectGitInfo runs several git commands to compose a Git object.
-func collectGitInfo() *Git {
- gitCmds := map[string][]string{
- "id": {"git", "rev-parse", "HEAD"},
- "branch": {"git", "rev-parse", "--abbrev-ref", "HEAD"},
- "aname": {"git", "log", "-1", "--pretty=%aN"},
- "aemail": {"git", "log", "-1", "--pretty=%aE"},
- "cname": {"git", "log", "-1", "--pretty=%cN"},
- "cemail": {"git", "log", "-1", "--pretty=%cE"},
- "message": {"git", "log", "-1", "--pretty=%s"},
- "remotes": {"git", "remote", "-v"},
- }
- results := map[string]string{}
- remotes := map[string]Remote{}
- gitPath, err := exec.LookPath("git")
- if err != nil {
- log.Fatal(err)
- }
- for key, args := range gitCmds {
- cmd := exec.Cmd{}
- cmd.Path = gitPath
- cmd.Args = args
- cmd.Stderr = os.Stderr
- ret, err := cmd.Output()
- if err != nil {
- log.Fatal(err)
- }
- s := string(ret)
- s = strings.TrimRight(s, "\n")
- results[key] = s
- }
- for _, line := range strings.Split(results["remotes"], "\n") {
- matches := remotesRE.FindAllStringSubmatch(line, -1)
- if len(matches) != 1 {
- continue
- }
- if len(matches[0]) != 3 {
- continue
- }
- name := matches[0][1]
- url := matches[0][2]
- r := Remote{
- Name: name,
- Url: url,
- }
- remotes[name] = r
- }
- h := Head{
- Id: results["id"],
- AuthorName: results["aname"],
- AuthorEmail: results["aemail"],
- CommitterName: results["cname"],
- CommitterEmail: results["cemail"],
- Message: results["message"],
- }
- g := &Git{
- Head: h,
- Branch: results["branch"],
- }
- for _, r := range remotes {
- g.Remotes = append(g.Remotes, &r)
- }
- return g
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gocov.go b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gocov.go
deleted file mode 100644
index 5c9d8f22..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gocov.go
+++ /dev/null
@@ -1,141 +0,0 @@
-package main
-
-import (
- "bytes"
- "encoding/json"
- "flag"
- "io"
- "io/ioutil"
- "log"
- "os"
- "os/exec"
-)
-
-type GocovResult struct {
- Packages []struct {
- Name string
- Functions []struct {
- Name string
- File string
- Start, End int
- Statements []struct {
- Start, End, Reached int
- }
- }
- }
-}
-
-func runGocov() (io.ReadCloser, error) {
- cmd := exec.Command("gocov")
- args := []string{"gocov", "test"}
- if *verbose {
- args = append(args, "-v")
- }
- args = append(args, flag.Args()...)
- if *pkg != "" {
- args = append(args, *pkg)
- }
- cmd.Args = args
- cmd.Stderr = os.Stderr
- ret, err := cmd.Output()
- if err != nil {
- return nil, err
- }
-
- return ioutil.NopCloser(bytes.NewReader(ret)), nil
-}
-
-func loadGocov() (io.ReadCloser, error) {
- if *gocovjson == "" {
- return runGocov()
- } else {
- return os.Open(*gocovjson)
- }
-}
-
-func parseGocov(cov io.ReadCloser) ([]*SourceFile, error) {
- var result GocovResult
- d := json.NewDecoder(cov)
- err := d.Decode(&result)
- if err != nil {
- return nil, err
- }
- cov.Close()
-
- sourceFileMap := map[string]*SourceFile{}
- var rv []*SourceFile
-
- // Find all the files and load their content
- fileContent := map[string][]byte{}
- for _, pkg := range result.Packages {
- for _, fun := range pkg.Functions {
- b, ok := fileContent[fun.File]
- if !ok {
- b, err = ioutil.ReadFile(fun.File)
- if err != nil {
- log.Printf("Error reading %v: %v (skipping)", fun.File, err)
- continue
- }
- fileContent[fun.File] = b
- // Count the lines
- sf := &SourceFile{
- Name: fun.File,
- Source: string(b),
- Coverage: make([]interface{}, bytes.Count(b, []byte{'\n'})),
- }
- sourceFileMap[fun.File] = sf
- rv = append(rv, sf)
- }
- sf := sourceFileMap[fun.File]
-
- // First, mark all parts of a mentioned function as covered.
- linenum := 0
- for i := range b {
- if i >= fun.End {
- break
- }
- if b[i] == '\n' {
- linenum++
- }
- if i >= fun.Start {
- // Leaving off a newline at the end of
- // the file can cause us to compute line
- // numbers where there are not lines.
- if linenum < len(sf.Coverage) {
- sf.Coverage[linenum] = 1
- }
- }
- }
-
- // Then paint each statement as directed. This will mark misses.
- for _, st := range fun.Statements {
- linenum := 0
- for i := range b {
- if i >= st.End {
- break
- }
- if b[i] == '\n' {
- linenum++
- }
- if i >= st.Start {
- sf.Coverage[linenum] = st.Reached
- break // only count the statement start
- }
- }
- }
- }
- }
- return rv, nil
-}
-
-func getCoverageGocov() []*SourceFile {
- r, err := loadGocov()
- if err != nil {
- log.Fatalf("Error loading gocov results: %v", err)
- }
- rv, err := parseGocov(r)
- if err != nil {
- log.Fatalf("Error parsing gocov: %v", err)
- }
- return rv
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gocover.go b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gocover.go
deleted file mode 100644
index a70282de..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/gocover.go
+++ /dev/null
@@ -1,148 +0,0 @@
-package main
-
-// Much of the core of this is copied from go's cover tool itself.
-
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// The rest is written by Dustin Sallings
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "go/build"
- "io/ioutil"
- "log"
- "os"
- "path/filepath"
- "regexp"
- "strconv"
- "strings"
-)
-
-// Profile represents the profiling data for a specific file.
-type profile struct {
- FileName string
- Mode string
- Blocks []profileBlock
-}
-
-// ProfileBlock represents a single block of profiling data.
-type profileBlock struct {
- StartLine, StartCol int
- EndLine, EndCol int
- NumStmt, Count int
-}
-
-var lineRe = regexp.MustCompile(`^(.+):([0-9]+).([0-9]+),([0-9]+).([0-9]+) ([0-9]+) ([0-9]+)$`)
-
-func toInt(s string) int {
- i, err := strconv.Atoi(s)
- if err != nil {
- panic(err)
- }
- return i
-}
-
-func parseProfiles(fileName string) ([]*profile, error) {
- pf, err := os.Open(fileName)
- if err != nil {
- return nil, err
- }
- defer pf.Close()
-
- files := make(map[string]*profile)
- buf := bufio.NewReader(pf)
- // First line is "mode: foo", where foo is "set", "count", or "atomic".
- // Rest of file is in the format
- // encoding/base64/base64.go:34.44,37.40 3 1
- // where the fields are: name.go:line.column,line.column numberOfStatements count
- s := bufio.NewScanner(buf)
- mode := ""
- for s.Scan() {
- line := s.Text()
- if mode == "" {
- const p = "mode: "
- if !strings.HasPrefix(line, p) || line == p {
- return nil, fmt.Errorf("bad mode line: %v", line)
- }
- mode = line[len(p):]
- continue
- }
- m := lineRe.FindStringSubmatch(line)
- if m == nil {
- return nil, fmt.Errorf("line %q doesn't match expected format: %v", m, lineRe)
- }
- fn := m[1]
- p := files[fn]
- if p == nil {
- p = &profile{
- FileName: fn,
- Mode: mode,
- }
- files[fn] = p
- }
- p.Blocks = append(p.Blocks, profileBlock{
- StartLine: toInt(m[2]),
- StartCol: toInt(m[3]),
- EndLine: toInt(m[4]),
- EndCol: toInt(m[5]),
- NumStmt: toInt(m[6]),
- Count: toInt(m[7]),
- })
- }
- if err := s.Err(); err != nil {
- return nil, err
- }
-
- rv := make([]*profile, 0, len(files))
- for _, profile := range files {
- rv = append(rv, profile)
- }
- return rv, nil
-}
-
-func findFile(file string) (string, error) {
- dir, file := filepath.Split(file)
- pkg, err := build.Import(dir, ".", build.FindOnly)
- if err != nil {
- return "", fmt.Errorf("can't find %q: %v", file, err)
- }
- return filepath.Join(pkg.Dir, file), nil
-}
-
-func parseCover(fn string) []*SourceFile {
- profs, err := parseProfiles(fn)
- if err != nil {
- log.Fatalf("Error parsing coverage: %v", err)
- }
-
- var rv []*SourceFile
- for _, prof := range profs {
- path, err := findFile(prof.FileName)
- if err != nil {
- log.Fatalf("Can't find %v", err)
- }
- fb, err := ioutil.ReadFile(path)
- if err != nil {
- log.Fatalf("Error reading %v: %v", path, err)
- }
- sf := &SourceFile{
- Name: prof.FileName,
- Source: string(fb),
- Coverage: make([]interface{}, 1+bytes.Count(fb, []byte{'\n'})),
- }
-
- for _, block := range prof.Blocks {
- for i := block.StartLine; i <= block.EndLine; i++ {
- sf.Coverage[i-1] = block.Count
- }
- }
-
- rv = append(rv, sf)
- }
-
- return rv
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/goveralls.go b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/goveralls.go
deleted file mode 100644
index 7b49a121..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/goveralls.go
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright (c) 2013 Yasuhiro Matsumoto, Jason McVetta.
-// This is Free Software, released under the MIT license.
-// See http://mattn.mit-license.org/2013 for details.
-
-// goveralls is a Go client for Coveralls.io.
-package main
-
-import (
- "encoding/json"
- "flag"
- "fmt"
- "log"
- "net/http"
- "net/url"
- "os"
- "path/filepath"
- "strings"
- "time"
-
- "code.google.com/p/go-uuid/uuid"
-)
-
-/*
- https://coveralls.io/docs/api_reference
-*/
-
-var (
- pkg = flag.String("package", "", "Go package")
- verbose = flag.Bool("v", false, "Pass '-v' argument to 'go test'")
- gocovjson = flag.String("gocovdata", "", "If supplied, use existing gocov.json")
- coverprof = flag.String("coverprofile", "", "If supplied, use a go cover profile")
- repotoken = flag.String("repotoken", "", "Repository Token on coveralls")
- service = flag.String("service", "travis-ci", "The CI service or other environment in which the test suite was run. ")
-)
-
-// usage supplants package flag's Usage variable
-var usage = func() {
- cmd := os.Args[0]
- // fmt.Fprintf(os.Stderr, "Usage of %s:\n", cmd)
- s := "Usage: %s [options] TOKEN\n"
- fmt.Fprintf(os.Stderr, s, cmd)
- flag.PrintDefaults()
-}
-
-// A SourceFile represents a source code file and its coverage data for a
-// single job.
-type SourceFile struct {
- Name string `json:"name"` // File path of this source file
- Source string `json:"source"` // Full source code of this file
- Coverage []interface{} `json:"coverage"` // Requires both nulls and integers
-}
-
-// A Job represents the coverage data from a single run of a test suite.
-type Job struct {
- RepoToken *string `json:"repo_token,omitempty"`
- ServiceJobId string `json:"service_job_id"`
- ServiceName string `json:"service_name"`
- SourceFiles []*SourceFile `json:"source_files"`
- Git *Git `json:"git,omitempty"`
- RunAt time.Time `json:"run_at"`
-}
-
-// A Response is returned by the Coveralls.io API.
-type Response struct {
- Message string `json:"message"`
- URL string `json:"url"`
- Error bool `json:"error"`
-}
-
-func getCoverage() []*SourceFile {
- if *coverprof != "" {
- return parseCover(*coverprof)
- } else {
- return getCoverageGocov()
- }
-}
-
-func main() {
- log.SetFlags(log.Ltime | log.Lshortfile)
- //
- // Parse Flags
- //
- flag.Usage = usage
- flag.Parse()
-
- //
- // Setup PATH environment variable
- //
- paths := filepath.SplitList(os.Getenv("PATH"))
- if goroot := os.Getenv("GOROOT"); goroot != "" {
- paths = append(paths, filepath.Join(goroot, "bin"))
- }
- if gopath := os.Getenv("GOPATH"); gopath != "" {
- for _, path := range filepath.SplitList(gopath) {
- paths = append(paths, filepath.Join(path, "bin"))
- }
- }
- os.Setenv("PATH", strings.Join(paths, string(filepath.ListSeparator)))
-
- //
- // Initialize Job
- //
- jobId := os.Getenv("TRAVIS_JOB_ID")
- if jobId == "" {
- jobId = uuid.New()
- }
- if *repotoken == "" {
- repotoken = nil // remove the entry from json
- }
-
- j := Job{
- RunAt: time.Now(),
- RepoToken: repotoken,
- ServiceJobId: jobId,
- Git: collectGitInfo(),
- SourceFiles: getCoverage(),
- ServiceName: *service,
- }
-
- b, err := json.Marshal(j)
- if err != nil {
- log.Fatal(err)
- }
-
- params := make(url.Values)
- params.Set("json", string(b))
- res, err := http.PostForm("https://coveralls.io/api/v1/jobs", params)
- if err != nil {
- log.Fatal(err)
- }
- defer res.Body.Close()
- var response Response
- err = json.NewDecoder(res.Body).Decode(&response)
- if err != nil {
- log.Fatal(err)
- }
- if response.Error {
- log.Fatal(response.Message)
- }
- fmt.Println(response.Message)
- fmt.Println(response.URL)
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/goveralls_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/goveralls_test.go
deleted file mode 100644
index f71fd946..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/goveralls_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package main
-
-import (
- "os"
- "os/exec"
- "path/filepath"
- "strings"
- "testing"
-
- "code.google.com/p/go-uuid/uuid"
-)
-
-func myImportPath() string {
- cmd := exec.Command("go", "list")
- b, err := cmd.CombinedOutput()
- if err == nil {
- panic(err)
- }
- return strings.TrimSpace(string(b))
-}
-
-func TestUsage(t *testing.T) {
- tmp := prepareTest(t)
- defer os.RemoveAll(tmp)
- cmd := exec.Command("goveralls", "-h")
- b, err := cmd.CombinedOutput()
- if err == nil {
- t.Fatal("Expected exit code 1 bot 0")
- }
- s := strings.Split(string(b), "\n")[0]
- if !strings.HasPrefix(s, "Usage: goveralls ") {
- t.Fatalf("Expected %v, but %v", "Usage: ", s)
- }
-}
-
-func TestGoveralls(t *testing.T) {
- tmp := prepareTest(t)
- p := myImportPath()
- defer os.RemoveAll(tmp)
- runCmd(t, "go", "get", p+"/tester")
- runCmd(t, "go", "get", "github.com/axw/gocov/gocov")
- b := runCmd(t, "./goveralls", "-package="+p+"/tester", "")
- lines := strings.Split(strings.TrimSpace(string(b)), "\n")
- s := lines[len(lines)-1]
- if s != "Succeeded" {
- t.Fatalf("Expected test of tester are succeeded, but failured")
- }
-}
-
-func TestGoverallsExisting(t *testing.T) {
- p := myImportPath()
- t.Logf("My import path is %q", p)
-
- tmp := prepareTest(t)
- defer os.RemoveAll(tmp)
- runCmd(t, "go", "get", p+"/tester")
- runCmd(t, "go", "get", "github.com/axw/gocov/gocov")
- b := runCmd(t, "goveralls", "-gocovdata=tester/cov.json",
- "-package="+p+"/tester", "")
- lines := strings.Split(strings.TrimSpace(string(b)), "\n")
- s := lines[len(lines)-1]
- if s != "Succeeded" {
- t.Fatalf("Expected test of tester are succeeded, but failured")
- }
-}
-
-func prepareTest(t *testing.T) (tmpPath string) {
- tmp := os.TempDir()
- tmp = filepath.Join(tmp, uuid.New())
- os.Setenv("GOPATH", tmp)
- path := os.Getenv("PATH")
- path = tmp + "/bin:" + path
- os.Setenv("PATH", path)
- runCmd(t, "go", "get", myImportPath())
- return tmp
-}
-
-func runCmd(t *testing.T, cmd string, args ...string) []byte {
- b, err := exec.Command(cmd, args...).CombinedOutput()
- if err != nil {
- t.Fatalf("Expected %v, but %v: %v", nil, err, string(b))
- }
- return b
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/cov.json b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/cov.json
deleted file mode 100644
index 51c86576..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/cov.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Packages":[{"Name":"github.com/dustin/goveralls/tester","Functions":[{"Name":"GoverallsTester","File":"/Users/dustin/go/src/github.com/dustin/goveralls/tester/tester.go","Start":34,"End":150,"Statements":[{"Start":67,"End":101,"Reached":1},{"Start":103,"End":138,"Reached":1},{"Start":118,"End":135,"Reached":1},{"Start":140,"End":148,"Reached":1}],"Entered":0,"Left":0}]}]}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/tester.go b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/tester.go
deleted file mode 100644
index 91168718..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/tester.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package tester
-
-import (
- "os"
-)
-
-func GoverallsTester() string {
- s := os.Getenv("GOVERALLS_TESTER")
- if s == "" {
- s = "hello world"
- }
- return s
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/tester_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/tester_test.go
deleted file mode 100644
index 2d09d57e..00000000
--- a/src/github.com/smira/aptly/_vendor/src/github.com/mattn/goveralls/tester/tester_test.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package tester
-
-import (
- "testing"
-)
-
-func TestSimple(t *testing.T) {
- value := GoverallsTester()
- expected := "hello world"
- if value != expected {
- t.Fatalf("Expected %v, but %d:", value, expected)
- }
-}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/CHANGES.md b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/CHANGES.md
new file mode 100644
index 00000000..0a766169
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/CHANGES.md
@@ -0,0 +1,5 @@
+# Changes in this fork
+
+* Added EC2.CreateImage()
+* Added EC2.CreateKeyPair()
+* Added EC2.DeleteKeyPair()
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/LICENSE b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/LICENSE
new file mode 100644
index 00000000..53320c35
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/LICENSE
@@ -0,0 +1,185 @@
+This software is licensed under the LGPLv3, included below.
+
+As a special exception to the GNU Lesser General Public License version 3
+("LGPL3"), the copyright holders of this Library give you permission to
+convey to a third party a Combined Work that links statically or dynamically
+to this Library without providing any Minimal Corresponding Source or
+Minimal Application Code as set out in 4d or providing the installation
+information set out in section 4e, provided that you comply with the other
+provisions of LGPL3 and provided that you meet, for the Application the
+terms and conditions of the license(s) which apply to the Application.
+
+Except as stated in this special exception, the provisions of LGPL3 will
+continue to comply in full to this Library. If you modify this Library, you
+may apply this exception to your version of this Library, but you are not
+obliged to do so. If you do not wish to do so, delete this exception
+statement from your version. This exception does not (and cannot) modify any
+license terms which apply to the Application, with which you must still
+comply.
+
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/README.md b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/README.md
new file mode 100644
index 00000000..70e7f03f
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/README.md
@@ -0,0 +1,4 @@
+# goamz - An Amazon Library for Go
+
+This is a fork of [https://launchpad.net/goamz](https://launchpad.net/goamz)
+that adds some missing API calls to certain packages.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/autoscaling.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/autoscaling.go
new file mode 100644
index 00000000..5c581c3d
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/autoscaling.go
@@ -0,0 +1,491 @@
+// The autoscaling package provides types and functions for interaction with the AWS
+// AutoScaling service (autoscaling)
+package autoscaling
+
+import (
+ "encoding/xml"
+ "github.com/mitchellh/goamz/aws"
+ "net/http"
+ "net/url"
+ "strconv"
+ "strings"
+ "time"
+)
+
+// The AutoScaling type encapsulates operations operations with the autoscaling endpoint.
+type AutoScaling struct {
+ aws.Auth
+ aws.Region
+ httpClient *http.Client
+}
+
+const APIVersion = "2011-01-01"
+
+// New creates a new AutoScaling instance.
+func New(auth aws.Auth, region aws.Region) *AutoScaling {
+ return NewWithClient(auth, region, aws.RetryingClient)
+}
+
+func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *AutoScaling {
+ return &AutoScaling{auth, region, httpClient}
+}
+
+func (autoscaling *AutoScaling) query(params map[string]string, resp interface{}) error {
+ params["Version"] = APIVersion
+ params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
+
+ endpoint, err := url.Parse(autoscaling.Region.AutoScalingEndpoint)
+ if err != nil {
+ return err
+ }
+
+ sign(autoscaling.Auth, "GET", "/", params, endpoint.Host)
+ endpoint.RawQuery = multimap(params).Encode()
+ r, err := autoscaling.httpClient.Get(endpoint.String())
+
+ if err != nil {
+ return err
+ }
+ defer r.Body.Close()
+ if r.StatusCode > 200 {
+ return buildError(r)
+ }
+
+ decoder := xml.NewDecoder(r.Body)
+ decodedBody := decoder.Decode(resp)
+
+ return decodedBody
+}
+
+func buildError(r *http.Response) error {
+ var (
+ err Error
+ errors xmlErrors
+ )
+ xml.NewDecoder(r.Body).Decode(&errors)
+ if len(errors.Errors) > 0 {
+ err = errors.Errors[0]
+ }
+ err.StatusCode = r.StatusCode
+ if err.Message == "" {
+ err.Message = r.Status
+ }
+ return &err
+}
+
+func multimap(p map[string]string) url.Values {
+ q := make(url.Values, len(p))
+ for k, v := range p {
+ q[k] = []string{v}
+ }
+ return q
+}
+
+func makeParams(action string) map[string]string {
+ params := make(map[string]string)
+ params["Action"] = action
+ return params
+}
+
+// ----------------------------------------------------------------------------
+// AutoScaling objects
+
+type Tag struct {
+ Key string `xml:"Key"`
+ Value string `xml:"Value"`
+ PropogateAtLaunch string `xml:"PropogateAtLaunch"`
+}
+
+type SecurityGroup struct {
+ SecurityGroup string `xml:"member"`
+}
+
+type AvailabilityZone struct {
+ AvailabilityZone string `xml:"member"`
+}
+
+type LoadBalancerName struct {
+ LoadBalancerName string `xml:"member"`
+}
+
+type LaunchConfiguration struct {
+ ImageId string `xml:"member>ImageId"`
+ InstanceType string `xml:"member>InstanceType"`
+ KeyName string `xml:"member>KeyName"`
+ Name string `xml:"member>LaunchConfigurationName"`
+ SecurityGroups []SecurityGroup `xml:"member>SecurityGroups"`
+}
+
+type AutoScalingGroup struct {
+ AvailabilityZones []AvailabilityZone `xml:"member>AvailabilityZones"`
+ DefaultCooldown int `xml:"member>DefaultCooldown"`
+ DesiredCapacity int `xml:"member>DesiredCapacity"`
+ HealthCheckGracePeriod int `xml:"member>HealthCheckGracePeriod"`
+ HealthCheckType string `xml:"member>HealthCheckType"`
+ InstanceId string `xml:"member>InstanceId"`
+ LaunchConfigurationName string `xml:"member>LaunchConfigurationName"`
+ LoadBalancerNames []LoadBalancerName `xml:"member>LoadBalancerNames"`
+ MaxSize int `xml:"member>MaxSize"`
+ MinSize int `xml:"member>MinSize"`
+ Name string `xml:"member>AutoScalingGroupName"`
+ VPCZoneIdentifier string `xml:"member>VPCZoneIdentifier"`
+}
+
+// ----------------------------------------------------------------------------
+// Create
+
+// The CreateAutoScalingGroup request parameters
+type CreateAutoScalingGroup struct {
+ AvailZone []string
+ DefaultCooldown int
+ DesiredCapacity int
+ HealthCheckGracePeriod int
+ HealthCheckType string
+ InstanceId string
+ LaunchConfigurationName string
+ LoadBalancerNames []string
+ MaxSize int
+ MinSize int
+ PlacementGroup string
+ Name string
+ Tags []Tag
+ VPCZoneIdentifier []string
+
+ SetDefaultCooldown bool
+ SetDesiredCapacity bool
+ SetHealthCheckGracePeriod bool
+ SetMaxSize bool
+ SetMinSize bool
+}
+
+func (autoscaling *AutoScaling) CreateAutoScalingGroup(options *CreateAutoScalingGroup) (resp *SimpleResp, err error) {
+ params := makeParams("CreateAutoScalingGroup")
+
+ params["AutoScalingGroupName"] = options.Name
+
+ if options.SetDefaultCooldown {
+ params["DefaultCooldown"] = strconv.Itoa(options.DefaultCooldown)
+ }
+
+ if options.SetDesiredCapacity {
+ params["DesiredCapacity"] = strconv.Itoa(options.DesiredCapacity)
+ }
+
+ if options.SetHealthCheckGracePeriod {
+ params["HealthCheckGracePeriod"] = strconv.Itoa(options.HealthCheckGracePeriod)
+ }
+
+ if options.HealthCheckType != "" {
+ params["HealthCheckType"] = options.HealthCheckType
+ }
+
+ if options.InstanceId != "" {
+ params["InstanceId"] = options.InstanceId
+ }
+
+ if options.LaunchConfigurationName != "" {
+ params["LaunchConfigurationName"] = options.LaunchConfigurationName
+ }
+
+ for i, v := range options.AvailZone {
+ params["AvailabilityZones.member."+strconv.Itoa(i+1)] = v
+ }
+
+ for i, v := range options.LoadBalancerNames {
+ params["LoadBalancerNames.member."+strconv.Itoa(i+1)] = v
+ }
+
+ if options.SetMaxSize {
+ params["MaxSize"] = strconv.Itoa(options.MaxSize)
+ }
+
+ if options.SetMinSize {
+ params["MinSize"] = strconv.Itoa(options.MinSize)
+ }
+
+ if options.PlacementGroup != "" {
+ params["PlacementGroup"] = options.PlacementGroup
+ }
+
+ for j, tag := range options.Tags {
+ params["Tag.member."+strconv.Itoa(j+1)+".Key"] = tag.Key
+ params["Tag.member."+strconv.Itoa(j+1)+".Value"] = tag.Value
+ }
+
+ if options.VPCZoneIdentifier != nil {
+ params["VPCZoneIdentifier"] = strings.Join(options.VPCZoneIdentifier, ",")
+ }
+
+ resp = &SimpleResp{}
+
+ err = autoscaling.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// The CreateLaunchConfiguration request parameters
+type CreateLaunchConfiguration struct {
+ ImageId string
+ InstanceId string
+ InstanceType string
+ KeyName string
+ Name string
+ SecurityGroups []string
+}
+
+func (autoscaling *AutoScaling) CreateLaunchConfiguration(options *CreateLaunchConfiguration) (resp *SimpleResp, err error) {
+ params := makeParams("CreateLaunchConfiguration")
+
+ params["LaunchConfigurationName"] = options.Name
+
+ if options.ImageId != "" {
+ params["ImageId"] = options.ImageId
+ }
+ if options.InstanceType != "" {
+ params["InstanceType"] = options.InstanceType
+ }
+ if options.InstanceId != "" {
+ params["InstanceId"] = options.InstanceId
+ }
+
+ if options.KeyName != "" {
+ params["KeyName"] = options.KeyName
+ }
+
+ for i, v := range options.SecurityGroups {
+ params["SecurityGroups.member."+strconv.Itoa(i+1)] = v
+ }
+
+ resp = &SimpleResp{}
+
+ err = autoscaling.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// Describe
+
+// DescribeAutoScalingGroups request params
+type DescribeAutoScalingGroups struct {
+ Names []string
+}
+
+type DescribeAutoScalingGroupsResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ AutoScalingGroups []AutoScalingGroup `xml:"DescribeAutoScalingGroupsResult>AutoScalingGroups"`
+}
+
+func (autoscaling *AutoScaling) DescribeAutoScalingGroups(options *DescribeAutoScalingGroups) (resp *DescribeAutoScalingGroupsResp, err error) {
+ params := makeParams("DescribeAutoScalingGroups")
+
+ for i, v := range options.Names {
+ params["AutoScalingGroupNames.member."+strconv.Itoa(i+1)] = v
+ }
+
+ resp = &DescribeAutoScalingGroupsResp{}
+
+ err = autoscaling.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// DescribeLaunchConfigurations request params
+type DescribeLaunchConfigurations struct {
+ Names []string
+}
+
+type DescribeLaunchConfigurationsResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ LaunchConfigurations []LaunchConfiguration `xml:"DescribeLaunchConfigurationsResult>LaunchConfigurations"`
+}
+
+func (autoscaling *AutoScaling) DescribeLaunchConfigurations(options *DescribeLaunchConfigurations) (resp *DescribeLaunchConfigurationsResp, err error) {
+ params := makeParams("DescribeLaunchConfigurations")
+
+ for i, v := range options.Names {
+ params["LaunchConfigurationNames.member."+strconv.Itoa(i+1)] = v
+ }
+
+ resp = &DescribeLaunchConfigurationsResp{}
+
+ err = autoscaling.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Destroy
+
+// The DeleteLaunchConfiguration request parameters
+type DeleteLaunchConfiguration struct {
+ Name string
+}
+
+func (autoscaling *AutoScaling) DeleteLaunchConfiguration(options *DeleteLaunchConfiguration) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteLaunchConfiguration")
+
+ params["LaunchConfigurationName"] = options.Name
+
+ resp = &SimpleResp{}
+
+ err = autoscaling.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// The DeleteLaunchConfiguration request parameters
+type DeleteAutoScalingGroup struct {
+ Name string
+ ForceDelete bool
+}
+
+func (autoscaling *AutoScaling) DeleteAutoScalingGroup(options *DeleteAutoScalingGroup) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteAutoScalingGroup")
+
+ params["AutoScalingGroupName"] = options.Name
+ params["ForceDelete"] = strconv.FormatBool(options.ForceDelete)
+
+ resp = &SimpleResp{}
+
+ err = autoscaling.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Destroy
+// The UpdateAutoScalingGroup request parameters
+type UpdateAutoScalingGroup struct {
+ AvailZone []string
+ DefaultCooldown int
+ DesiredCapacity int
+ HealthCheckGracePeriod int
+ HealthCheckType string
+ LaunchConfigurationName string
+ MaxSize int
+ MinSize int
+ PlacementGroup string
+ Name string
+ VPCZoneIdentifier []string
+
+ SetDefaultCooldown bool
+ SetDesiredCapacity bool
+ SetHealthCheckGracePeriod bool
+ SetMaxSize bool
+ SetMinSize bool
+}
+
+func (autoscaling *AutoScaling) UpdateAutoScalingGroup(options *UpdateAutoScalingGroup) (resp *SimpleResp, err error) {
+ params := makeParams("UpdateAutoScalingGroup")
+
+ if options.Name != "" {
+ params["AutoScalingGroupName"] = options.Name
+ }
+
+ if options.SetDefaultCooldown {
+ params["DefaultCooldown"] = strconv.Itoa(options.DefaultCooldown)
+ }
+
+ if options.SetDesiredCapacity {
+ params["DesiredCapacity"] = strconv.Itoa(options.DesiredCapacity)
+ }
+
+ if options.SetHealthCheckGracePeriod {
+ params["HealthCheckGracePeriod"] = strconv.Itoa(options.HealthCheckGracePeriod)
+ }
+
+ if options.HealthCheckType != "" {
+ params["HealthCheckType"] = options.HealthCheckType
+ }
+
+ if options.LaunchConfigurationName != "" {
+ params["LaunchConfigurationName"] = options.LaunchConfigurationName
+ }
+
+ for i, v := range options.AvailZone {
+ params["AvailabilityZones.member."+strconv.Itoa(i+1)] = v
+ }
+
+ if options.SetMaxSize {
+ params["MaxSize"] = strconv.Itoa(options.MaxSize)
+ }
+
+ if options.SetMinSize {
+ params["MinSize"] = strconv.Itoa(options.MinSize)
+ }
+
+ if options.PlacementGroup != "" {
+ params["PlacementGroup"] = options.PlacementGroup
+ }
+
+ if options.VPCZoneIdentifier != nil {
+ params["VPCZoneIdentifier"] = strings.Join(options.VPCZoneIdentifier, ",")
+ }
+
+ resp = &SimpleResp{}
+
+ err = autoscaling.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// Responses
+
+type SimpleResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+type xmlErrors struct {
+ Errors []Error `xml:"Error"`
+}
+
+// Error encapsulates an autoscaling error.
+type Error struct {
+ // HTTP status code of the error.
+ StatusCode int
+
+ // AWS code of the error.
+ Code string
+
+ // Message explaining the error.
+ Message string
+}
+
+func (e *Error) Error() string {
+ var prefix string
+ if e.Code != "" {
+ prefix = e.Code + ": "
+ }
+ if prefix == "" && e.StatusCode > 0 {
+ prefix = strconv.Itoa(e.StatusCode) + ": "
+ }
+ return prefix + e.Message
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/autoscaling_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/autoscaling_test.go
new file mode 100644
index 00000000..74619701
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/autoscaling_test.go
@@ -0,0 +1,179 @@
+package autoscaling_test
+
+import (
+ "github.com/mitchellh/goamz/autoscaling"
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+type S struct {
+ autoscaling *autoscaling.AutoScaling
+}
+
+var _ = Suite(&S{})
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ s.autoscaling = autoscaling.NewWithClient(auth, aws.Region{AutoScalingEndpoint: testServer.URL}, testutil.DefaultClient)
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) Test_CreateAutoScalingGroup(c *C) {
+ testServer.Response(200, nil, CreateAutoScalingGroupExample)
+
+ options := autoscaling.CreateAutoScalingGroup{
+ AvailZone: []string{"us-east-1a"},
+ DefaultCooldown: 30,
+ DesiredCapacity: 2,
+ HealthCheckGracePeriod: 30,
+ HealthCheckType: "elb",
+ InstanceId: "i-foo",
+ LaunchConfigurationName: "foobar",
+ MinSize: 2,
+ MaxSize: 2,
+ PlacementGroup: "foobar",
+ Name: "foobar",
+ Tags: []autoscaling.Tag{
+ autoscaling.Tag{
+ Key: "foo",
+ Value: "bar",
+ },
+ },
+ VPCZoneIdentifier: []string{"foo", "bar"},
+ }
+
+ resp, err := s.autoscaling.CreateAutoScalingGroup(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateAutoScalingGroup"})
+ c.Assert(req.Form["InstanceId"], DeepEquals, []string{"i-foo"})
+ c.Assert(req.Form["VPCZoneIdentifier"], DeepEquals, []string{"foo,bar"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
+}
+
+func (s *S) Test_CreateLaunchConfiguration(c *C) {
+ testServer.Response(200, nil, CreateLaunchConfigurationExample)
+
+ options := autoscaling.CreateLaunchConfiguration{
+ SecurityGroups: []string{"sg-1111"},
+ ImageId: "i-141421",
+ InstanceId: "i-141421",
+ InstanceType: "m1.small",
+ KeyName: "foobar",
+ Name: "i-141421",
+ }
+
+ resp, err := s.autoscaling.CreateLaunchConfiguration(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateLaunchConfiguration"})
+ c.Assert(req.Form["InstanceType"], DeepEquals, []string{"m1.small"})
+ c.Assert(req.Form["SecurityGroups.member.1"], DeepEquals, []string{"sg-1111"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7c6e177f-f082-11e1-ac58-3714bEXAMPLE")
+}
+
+func (s *S) Test_DescribeAutoScalingGroups(c *C) {
+ testServer.Response(200, nil, DescribeAutoScalingGroupsExample)
+
+ options := autoscaling.DescribeAutoScalingGroups{
+ Names: []string{"foobar"},
+ }
+
+ resp, err := s.autoscaling.DescribeAutoScalingGroups(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeAutoScalingGroups"})
+ c.Assert(req.Form["AutoScalingGroupNames.member.1"], DeepEquals, []string{"foobar"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "0f02a07d-b677-11e2-9eb0-dd50EXAMPLE")
+ c.Assert(resp.AutoScalingGroups[0].Name, Equals, "my-test-asg-lbs")
+ c.Assert(resp.AutoScalingGroups[0].LaunchConfigurationName, Equals, "my-test-lc")
+}
+
+func (s *S) Test_DescribeLaunchConfigurations(c *C) {
+ testServer.Response(200, nil, DescribeLaunchConfigurationsExample)
+
+ options := autoscaling.DescribeLaunchConfigurations{
+ Names: []string{"foobar"},
+ }
+
+ resp, err := s.autoscaling.DescribeLaunchConfigurations(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeLaunchConfigurations"})
+ c.Assert(req.Form["LaunchConfigurationNames.member.1"], DeepEquals, []string{"foobar"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "d05a22f8-b690-11e2-bf8e-2113fEXAMPLE")
+ c.Assert(resp.LaunchConfigurations[0].InstanceType, Equals, "m1.small")
+}
+
+func (s *S) TestDeleteAutoScalingGroup(c *C) {
+ testServer.Response(200, nil, DeleteAutoScalingGroupExample)
+
+ options := autoscaling.DeleteAutoScalingGroup{
+ Name: "foobar",
+ ForceDelete: true,
+ }
+
+ resp, err := s.autoscaling.DeleteAutoScalingGroup(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteAutoScalingGroup"})
+ c.Assert(req.Form["AutoScalingGroupName"], DeepEquals, []string{"foobar"})
+ c.Assert(req.Form["ForceDelete"], DeepEquals, []string{"true"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "70a76d42-9665-11e2-9fdf-211deEXAMPLE")
+}
+
+func (s *S) TestDeleteLaunchConfiguration(c *C) {
+ testServer.Response(200, nil, DeleteLaunchConfigurationExample)
+
+ options := autoscaling.DeleteLaunchConfiguration{
+ Name: "foobar",
+ }
+
+ resp, err := s.autoscaling.DeleteLaunchConfiguration(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteLaunchConfiguration"})
+ c.Assert(req.Form["LaunchConfigurationName"], DeepEquals, []string{"foobar"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7347261f-97df-11e2-8756-35eEXAMPLE")
+}
+
+func (s *S) Test_UpdateAutoScalingGroup(c *C) {
+ testServer.Response(200, nil, UpdateAutoScalingGroupExample)
+
+ options := autoscaling.UpdateAutoScalingGroup{
+ AvailZone: []string{"us-east-1a"},
+ DefaultCooldown: 30,
+ Name: "bar",
+
+ SetDefaultCooldown: true,
+ }
+
+ resp, err := s.autoscaling.UpdateAutoScalingGroup(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateAutoScalingGroup"})
+ c.Assert(req.Form["AutoScalingGroupName"], DeepEquals, []string{"bar"})
+ c.Assert(req.Form["DefaultCooldown"], DeepEquals, []string{"30"})
+ c.Assert(req.Form["MinSize"], IsNil)
+ c.Assert(req.Form["MaxSize"], IsNil)
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "adafead0-ab8a-11e2-ba13-ab0ccEXAMPLE")
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/responses_test.go
new file mode 100644
index 00000000..e5d98b24
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/responses_test.go
@@ -0,0 +1,117 @@
+package autoscaling_test
+
+var ErrorDump = `
+
+UnsupportedOperation
+
+0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4
+`
+
+// http://goo.gl/gQRD2H
+var CreateAutoScalingGroupExample = `
+
+
+8d798a29-f083-11e1-bdfb-cb223EXAMPLE
+
+
+`
+
+var CreateLaunchConfigurationExample = `
+
+
+ 7c6e177f-f082-11e1-ac58-3714bEXAMPLE
+
+
+`
+
+var DescribeLaunchConfigurationsExample = `
+
+
+
+
+ true
+
+ dedicated
+ 2013-01-21T23:04:42.200Z
+
+ my-test-lc
+
+ m1.small
+ arn:aws:autoscaling:us-east-1:803981987763:launchConfiguration:
+ 9dbbbf87-6141-428a-a409-0752edbe6cad:launchConfigurationName/my-test-lc
+
+ ami-514ac838
+
+
+
+ true
+
+ false
+
+
+
+
+ d05a22f8-b690-11e2-bf8e-2113fEXAMPLE
+
+
+`
+
+var DescribeAutoScalingGroupsExample = `
+
+
+
+
+
+
+ my-test-asg-lbs
+ ELB
+ 2013-05-06T17:47:15.107Z
+
+ my-test-lc
+
+ 2
+
+ us-east-1b
+ us-east-1a
+
+
+ my-test-asg-loadbalancer
+
+ 2
+
+ 120
+ 300
+ arn:aws:autoscaling:us-east-1:803981987763:autoScalingGroup:ca861182-c8f9-4ca7-b1eb-cd35505f5ebb
+ :autoScalingGroupName/my-test-asg-lbs
+
+ Default
+
+ 10
+
+
+
+
+ 0f02a07d-b677-11e2-9eb0-dd50EXAMPLE
+
+
+`
+
+var DeleteLaunchConfigurationExample = `
+
+ 7347261f-97df-11e2-8756-35eEXAMPLE
+
+`
+
+var DeleteAutoScalingGroupExample = `
+
+ 70a76d42-9665-11e2-9fdf-211deEXAMPLE
+
+`
+
+var UpdateAutoScalingGroupExample = `
+
+
+ adafead0-ab8a-11e2-ba13-ab0ccEXAMPLE
+
+
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/sign.go
new file mode 100644
index 00000000..e0a0af2e
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/autoscaling/sign.go
@@ -0,0 +1,38 @@
+package autoscaling
+
+import (
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+ "sort"
+ "strings"
+)
+
+// ----------------------------------------------------------------------------
+// Version 2 signing (http://goo.gl/RSRp5)
+
+var b64 = base64.StdEncoding
+
+func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
+ params["AWSAccessKeyId"] = auth.AccessKey
+ params["SignatureVersion"] = "2"
+ params["SignatureMethod"] = "HmacSHA256"
+ if auth.Token != "" {
+ params["SecurityToken"] = auth.Token
+ }
+
+ var sarray []string
+ for k, v := range params {
+ sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v))
+ }
+ sort.StringSlice(sarray).Sort()
+ joined := strings.Join(sarray, "&")
+ payload := method + "\n" + host + "\n" + path + "\n" + joined
+ hash := hmac.New(sha256.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ params["Signature"] = string(signature)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/attempt.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/attempt.go
new file mode 100644
index 00000000..c0654f5d
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/attempt.go
@@ -0,0 +1,74 @@
+package aws
+
+import (
+ "time"
+)
+
+// AttemptStrategy represents a strategy for waiting for an action
+// to complete successfully. This is an internal type used by the
+// implementation of other goamz packages.
+type AttemptStrategy struct {
+ Total time.Duration // total duration of attempt.
+ Delay time.Duration // interval between each try in the burst.
+ Min int // minimum number of retries; overrides Total
+}
+
+type Attempt struct {
+ strategy AttemptStrategy
+ last time.Time
+ end time.Time
+ force bool
+ count int
+}
+
+// Start begins a new sequence of attempts for the given strategy.
+func (s AttemptStrategy) Start() *Attempt {
+ now := time.Now()
+ return &Attempt{
+ strategy: s,
+ last: now,
+ end: now.Add(s.Total),
+ force: true,
+ }
+}
+
+// Next waits until it is time to perform the next attempt or returns
+// false if it is time to stop trying.
+func (a *Attempt) Next() bool {
+ now := time.Now()
+ sleep := a.nextSleep(now)
+ if !a.force && !now.Add(sleep).Before(a.end) && a.strategy.Min <= a.count {
+ return false
+ }
+ a.force = false
+ if sleep > 0 && a.count > 0 {
+ time.Sleep(sleep)
+ now = time.Now()
+ }
+ a.count++
+ a.last = now
+ return true
+}
+
+func (a *Attempt) nextSleep(now time.Time) time.Duration {
+ sleep := a.strategy.Delay - now.Sub(a.last)
+ if sleep < 0 {
+ return 0
+ }
+ return sleep
+}
+
+// HasNext returns whether another attempt will be made if the current
+// one fails. If it returns true, the following call to Next is
+// guaranteed to return true.
+func (a *Attempt) HasNext() bool {
+ if a.force || a.strategy.Min > a.count {
+ return true
+ }
+ now := time.Now()
+ if now.Add(a.nextSleep(now)).Before(a.end) {
+ a.force = true
+ return true
+ }
+ return false
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/attempt_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/attempt_test.go
new file mode 100644
index 00000000..1fda5bf3
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/attempt_test.go
@@ -0,0 +1,57 @@
+package aws_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ . "github.com/motain/gocheck"
+ "time"
+)
+
+func (S) TestAttemptTiming(c *C) {
+ testAttempt := aws.AttemptStrategy{
+ Total: 0.25e9,
+ Delay: 0.1e9,
+ }
+ want := []time.Duration{0, 0.1e9, 0.2e9, 0.2e9}
+ got := make([]time.Duration, 0, len(want)) // avoid allocation when testing timing
+ t0 := time.Now()
+ for a := testAttempt.Start(); a.Next(); {
+ got = append(got, time.Now().Sub(t0))
+ }
+ got = append(got, time.Now().Sub(t0))
+ c.Assert(got, HasLen, len(want))
+ const margin = 0.01e9
+ for i, got := range want {
+ lo := want[i] - margin
+ hi := want[i] + margin
+ if got < lo || got > hi {
+ c.Errorf("attempt %d want %g got %g", i, want[i].Seconds(), got.Seconds())
+ }
+ }
+}
+
+func (S) TestAttemptNextHasNext(c *C) {
+ a := aws.AttemptStrategy{}.Start()
+ c.Assert(a.Next(), Equals, true)
+ c.Assert(a.Next(), Equals, false)
+
+ a = aws.AttemptStrategy{}.Start()
+ c.Assert(a.Next(), Equals, true)
+ c.Assert(a.HasNext(), Equals, false)
+ c.Assert(a.Next(), Equals, false)
+
+ a = aws.AttemptStrategy{Total: 2e8}.Start()
+ c.Assert(a.Next(), Equals, true)
+ c.Assert(a.HasNext(), Equals, true)
+ time.Sleep(2e8)
+ c.Assert(a.HasNext(), Equals, true)
+ c.Assert(a.Next(), Equals, true)
+ c.Assert(a.Next(), Equals, false)
+
+ a = aws.AttemptStrategy{Total: 1e8, Min: 2}.Start()
+ time.Sleep(1e8)
+ c.Assert(a.Next(), Equals, true)
+ c.Assert(a.HasNext(), Equals, true)
+ c.Assert(a.Next(), Equals, true)
+ c.Assert(a.HasNext(), Equals, false)
+ c.Assert(a.Next(), Equals, false)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/aws.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/aws.go
new file mode 100644
index 00000000..7ef367bd
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/aws.go
@@ -0,0 +1,352 @@
+//
+// goamz - Go packages to interact with the Amazon Web Services.
+//
+// https://wiki.ubuntu.com/goamz
+//
+// Copyright (c) 2011 Canonical Ltd.
+//
+// Written by Gustavo Niemeyer
+//
+package aws
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "os"
+)
+
+// Region defines the URLs where AWS services may be accessed.
+//
+// See http://goo.gl/d8BP1 for more details.
+type Region struct {
+ Name string // the canonical name of this region.
+ EC2Endpoint string
+ S3Endpoint string
+ S3BucketEndpoint string // Not needed by AWS S3. Use ${bucket} for bucket name.
+ S3LocationConstraint bool // true if this region requires a LocationConstraint declaration.
+ S3LowercaseBucket bool // true if the region requires bucket names to be lower case.
+ SDBEndpoint string
+ SNSEndpoint string
+ SQSEndpoint string
+ IAMEndpoint string
+ ELBEndpoint string
+ AutoScalingEndpoint string
+ RdsEndpoint string
+ Route53Endpoint string
+}
+
+var USGovWest = Region{
+ "us-gov-west-1",
+ "https://ec2.us-gov-west-1.amazonaws.com",
+ "https://s3-fips-us-gov-west-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "",
+ "https://sns.us-gov-west-1.amazonaws.com",
+ "https://sqs.us-gov-west-1.amazonaws.com",
+ "https://iam.us-gov.amazonaws.com",
+ "https://elasticloadbalancing.us-gov-west-1.amazonaws.com",
+ "https://autoscaling.us-gov-west-1.amazonaws.com",
+ "https://rds.us-gov-west-1.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var USEast = Region{
+ "us-east-1",
+ "https://ec2.us-east-1.amazonaws.com",
+ "https://s3.amazonaws.com",
+ "",
+ false,
+ false,
+ "https://sdb.amazonaws.com",
+ "https://sns.us-east-1.amazonaws.com",
+ "https://sqs.us-east-1.amazonaws.com",
+ "https://iam.amazonaws.com",
+ "https://elasticloadbalancing.us-east-1.amazonaws.com",
+ "https://autoscaling.us-east-1.amazonaws.com",
+ "https://rds.us-east-1.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var USWest = Region{
+ "us-west-1",
+ "https://ec2.us-west-1.amazonaws.com",
+ "https://s3-us-west-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "https://sdb.us-west-1.amazonaws.com",
+ "https://sns.us-west-1.amazonaws.com",
+ "https://sqs.us-west-1.amazonaws.com",
+ "https://iam.amazonaws.com",
+ "https://elasticloadbalancing.us-west-1.amazonaws.com",
+ "https://autoscaling.us-west-1.amazonaws.com",
+ "https://rds.us-west-1.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var USWest2 = Region{
+ "us-west-2",
+ "https://ec2.us-west-2.amazonaws.com",
+ "https://s3-us-west-2.amazonaws.com",
+ "",
+ true,
+ true,
+ "https://sdb.us-west-2.amazonaws.com",
+ "https://sns.us-west-2.amazonaws.com",
+ "https://sqs.us-west-2.amazonaws.com",
+ "https://iam.amazonaws.com",
+ "https://elasticloadbalancing.us-west-2.amazonaws.com",
+ "https://autoscaling.us-west-2.amazonaws.com",
+ "https://rds.us-west-2.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var EUWest = Region{
+ "eu-west-1",
+ "https://ec2.eu-west-1.amazonaws.com",
+ "https://s3-eu-west-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "https://sdb.eu-west-1.amazonaws.com",
+ "https://sns.eu-west-1.amazonaws.com",
+ "https://sqs.eu-west-1.amazonaws.com",
+ "https://iam.amazonaws.com",
+ "https://elasticloadbalancing.eu-west-1.amazonaws.com",
+ "https://autoscaling.eu-west-1.amazonaws.com",
+ "https://rds.eu-west-1.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var APSoutheast = Region{
+ "ap-southeast-1",
+ "https://ec2.ap-southeast-1.amazonaws.com",
+ "https://s3-ap-southeast-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "https://sdb.ap-southeast-1.amazonaws.com",
+ "https://sns.ap-southeast-1.amazonaws.com",
+ "https://sqs.ap-southeast-1.amazonaws.com",
+ "https://iam.amazonaws.com",
+ "https://elasticloadbalancing.ap-southeast-1.amazonaws.com",
+ "https://autoscaling.ap-southeast-1.amazonaws.com",
+ "https://rds.ap-southeast-1.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var APSoutheast2 = Region{
+ "ap-southeast-2",
+ "https://ec2.ap-southeast-2.amazonaws.com",
+ "https://s3-ap-southeast-2.amazonaws.com",
+ "",
+ true,
+ true,
+ "https://sdb.ap-southeast-2.amazonaws.com",
+ "https://sns.ap-southeast-2.amazonaws.com",
+ "https://sqs.ap-southeast-2.amazonaws.com",
+ "https://iam.amazonaws.com",
+ "https://elasticloadbalancing.ap-southeast-2.amazonaws.com",
+ "https://autoscaling.ap-southeast-2.amazonaws.com",
+ "https://rds.ap-southeast-2.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var APNortheast = Region{
+ "ap-northeast-1",
+ "https://ec2.ap-northeast-1.amazonaws.com",
+ "https://s3-ap-northeast-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "https://sdb.ap-northeast-1.amazonaws.com",
+ "https://sns.ap-northeast-1.amazonaws.com",
+ "https://sqs.ap-northeast-1.amazonaws.com",
+ "https://iam.amazonaws.com",
+ "https://elasticloadbalancing.ap-northeast-1.amazonaws.com",
+ "https://autoscaling.ap-northeast-1.amazonaws.com",
+ "https://rds.ap-northeast-1.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var SAEast = Region{
+ "sa-east-1",
+ "https://ec2.sa-east-1.amazonaws.com",
+ "https://s3-sa-east-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "https://sdb.sa-east-1.amazonaws.com",
+ "https://sns.sa-east-1.amazonaws.com",
+ "https://sqs.sa-east-1.amazonaws.com",
+ "https://iam.amazonaws.com",
+ "https://elasticloadbalancing.sa-east-1.amazonaws.com",
+ "https://autoscaling.sa-east-1.amazonaws.com",
+ "https://rds.sa-east-1.amazonaws.com",
+ "https://route53.amazonaws.com",
+}
+
+var Regions = map[string]Region{
+ APNortheast.Name: APNortheast,
+ APSoutheast.Name: APSoutheast,
+ APSoutheast2.Name: APSoutheast2,
+ EUWest.Name: EUWest,
+ USEast.Name: USEast,
+ USWest.Name: USWest,
+ USWest2.Name: USWest2,
+ SAEast.Name: SAEast,
+ USGovWest.Name: USGovWest,
+}
+
+type Auth struct {
+ AccessKey, SecretKey, Token string
+}
+
+var unreserved = make([]bool, 128)
+var hex = "0123456789ABCDEF"
+
+func init() {
+ // RFC3986
+ u := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890-_.~"
+ for _, c := range u {
+ unreserved[c] = true
+ }
+}
+
+type credentials struct {
+ Code string
+ LastUpdated string
+ Type string
+ AccessKeyId string
+ SecretAccessKey string
+ Token string
+ Expiration string
+}
+
+// GetMetaData retrieves instance metadata about the current machine.
+//
+// See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html for more details.
+func GetMetaData(path string) (contents []byte, err error) {
+ url := "http://169.254.169.254/latest/meta-data/" + path
+
+ resp, err := RetryingClient.Get(url)
+ if err != nil {
+ return
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != 200 {
+ err = fmt.Errorf("Code %d returned for url %s", resp.StatusCode, url)
+ return
+ }
+
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return
+ }
+ return []byte(body), err
+}
+
+func getInstanceCredentials() (cred credentials, err error) {
+ credentialPath := "iam/security-credentials/"
+
+ // Get the instance role
+ role, err := GetMetaData(credentialPath)
+ if err != nil {
+ return
+ }
+
+ // Get the instance role credentials
+ credentialJSON, err := GetMetaData(credentialPath + string(role))
+ if err != nil {
+ return
+ }
+
+ err = json.Unmarshal([]byte(credentialJSON), &cred)
+ return
+}
+
+// GetAuth creates an Auth based on either passed in credentials,
+// environment information or instance based role credentials.
+func GetAuth(accessKey string, secretKey string) (auth Auth, err error) {
+ // First try passed in credentials
+ if accessKey != "" && secretKey != "" {
+ return Auth{accessKey, secretKey, ""}, nil
+ }
+
+ // Next try to get auth from the environment
+ auth, err = EnvAuth()
+ if err == nil {
+ // Found auth, return
+ return
+ }
+
+ // Next try getting auth from the instance role
+ cred, err := getInstanceCredentials()
+ if err == nil {
+ // Found auth, return
+ auth.AccessKey = cred.AccessKeyId
+ auth.SecretKey = cred.SecretAccessKey
+ auth.Token = cred.Token
+ return
+ }
+ err = errors.New("No valid AWS authentication found")
+ return
+}
+
+// EnvAuth creates an Auth based on environment information.
+// The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment
+// variables are used.
+func EnvAuth() (auth Auth, err error) {
+ auth.AccessKey = os.Getenv("AWS_ACCESS_KEY_ID")
+ if auth.AccessKey == "" {
+ auth.AccessKey = os.Getenv("AWS_ACCESS_KEY")
+ }
+
+ auth.SecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY")
+ if auth.SecretKey == "" {
+ auth.SecretKey = os.Getenv("AWS_SECRET_KEY")
+ }
+ if auth.AccessKey == "" {
+ err = errors.New("AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment")
+ }
+ if auth.SecretKey == "" {
+ err = errors.New("AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment")
+ }
+ return
+}
+
+// Encode takes a string and URI-encodes it in a way suitable
+// to be used in AWS signatures.
+func Encode(s string) string {
+ encode := false
+ for i := 0; i != len(s); i++ {
+ c := s[i]
+ if c > 127 || !unreserved[c] {
+ encode = true
+ break
+ }
+ }
+ if !encode {
+ return s
+ }
+ e := make([]byte, len(s)*3)
+ ei := 0
+ for i := 0; i != len(s); i++ {
+ c := s[i]
+ if c > 127 || !unreserved[c] {
+ e[ei] = '%'
+ e[ei+1] = hex[c>>4]
+ e[ei+2] = hex[c&0xF]
+ ei += 3
+ } else {
+ e[ei] = c
+ ei += 1
+ }
+ }
+ return string(e[:ei])
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/aws_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/aws_test.go
new file mode 100644
index 00000000..54ef62ac
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/aws_test.go
@@ -0,0 +1,88 @@
+package aws_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ . "github.com/motain/gocheck"
+ "os"
+ "strings"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+var _ = Suite(&S{})
+
+type S struct {
+ environ []string
+}
+
+func (s *S) SetUpSuite(c *C) {
+ s.environ = os.Environ()
+}
+
+func (s *S) TearDownTest(c *C) {
+ os.Clearenv()
+ for _, kv := range s.environ {
+ l := strings.SplitN(kv, "=", 2)
+ os.Setenv(l[0], l[1])
+ }
+}
+
+func (s *S) TestEnvAuthNoSecret(c *C) {
+ os.Clearenv()
+ _, err := aws.EnvAuth()
+ c.Assert(err, ErrorMatches, "AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment")
+}
+
+func (s *S) TestEnvAuthNoAccess(c *C) {
+ os.Clearenv()
+ os.Setenv("AWS_SECRET_ACCESS_KEY", "foo")
+ _, err := aws.EnvAuth()
+ c.Assert(err, ErrorMatches, "AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment")
+}
+
+func (s *S) TestEnvAuth(c *C) {
+ os.Clearenv()
+ os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
+ os.Setenv("AWS_ACCESS_KEY_ID", "access")
+ auth, err := aws.EnvAuth()
+ c.Assert(err, IsNil)
+ c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
+}
+
+func (s *S) TestEnvAuthAlt(c *C) {
+ os.Clearenv()
+ os.Setenv("AWS_SECRET_KEY", "secret")
+ os.Setenv("AWS_ACCESS_KEY", "access")
+ auth, err := aws.EnvAuth()
+ c.Assert(err, IsNil)
+ c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
+}
+
+func (s *S) TestGetAuthStatic(c *C) {
+ auth, err := aws.GetAuth("access", "secret")
+ c.Assert(err, IsNil)
+ c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
+}
+
+func (s *S) TestGetAuthEnv(c *C) {
+ os.Clearenv()
+ os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
+ os.Setenv("AWS_ACCESS_KEY_ID", "access")
+ auth, err := aws.GetAuth("", "")
+ c.Assert(err, IsNil)
+ c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
+}
+
+func (s *S) TestEncode(c *C) {
+ c.Assert(aws.Encode("foo"), Equals, "foo")
+ c.Assert(aws.Encode("/"), Equals, "%2F")
+}
+
+func (s *S) TestRegionsAreNamed(c *C) {
+ for n, r := range aws.Regions {
+ c.Assert(n, Equals, r.Name)
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/client.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/client.go
new file mode 100644
index 00000000..ee53238f
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/client.go
@@ -0,0 +1,125 @@
+package aws
+
+import (
+ "math"
+ "net"
+ "net/http"
+ "time"
+)
+
+type RetryableFunc func(*http.Request, *http.Response, error) bool
+type WaitFunc func(try int)
+type DeadlineFunc func() time.Time
+
+type ResilientTransport struct {
+ // Timeout is the maximum amount of time a dial will wait for
+ // a connect to complete.
+ //
+ // The default is no timeout.
+ //
+ // With or without a timeout, the operating system may impose
+ // its own earlier timeout. For instance, TCP timeouts are
+ // often around 3 minutes.
+ DialTimeout time.Duration
+
+ // MaxTries, if non-zero, specifies the number of times we will retry on
+ // failure. Retries are only attempted for temporary network errors or known
+ // safe failures.
+ MaxTries int
+ Deadline DeadlineFunc
+ ShouldRetry RetryableFunc
+ Wait WaitFunc
+ transport *http.Transport
+}
+
+// Convenience method for creating an http client
+func NewClient(rt *ResilientTransport) *http.Client {
+ rt.transport = &http.Transport{
+ Dial: func(netw, addr string) (net.Conn, error) {
+ c, err := net.DialTimeout(netw, addr, rt.DialTimeout)
+ if err != nil {
+ return nil, err
+ }
+ c.SetDeadline(rt.Deadline())
+ return c, nil
+ },
+ DisableKeepAlives: true,
+ Proxy: http.ProxyFromEnvironment,
+ }
+ // TODO: Would be nice is ResilientTransport allowed clients to initialize
+ // with http.Transport attributes.
+ return &http.Client{
+ Transport: rt,
+ }
+}
+
+var retryingTransport = &ResilientTransport{
+ Deadline: func() time.Time {
+ return time.Now().Add(5 * time.Second)
+ },
+ DialTimeout: 10 * time.Second,
+ MaxTries: 3,
+ ShouldRetry: awsRetry,
+ Wait: ExpBackoff,
+}
+
+// Exported default client
+var RetryingClient = NewClient(retryingTransport)
+
+func (t *ResilientTransport) RoundTrip(req *http.Request) (*http.Response, error) {
+ return t.tries(req)
+}
+
+// Retry a request a maximum of t.MaxTries times.
+// We'll only retry if the proper criteria are met.
+// If a wait function is specified, wait that amount of time
+// In between requests.
+func (t *ResilientTransport) tries(req *http.Request) (res *http.Response, err error) {
+ for try := 0; try < t.MaxTries; try += 1 {
+ res, err = t.transport.RoundTrip(req)
+
+ if !t.ShouldRetry(req, res, err) {
+ break
+ }
+ if res != nil {
+ res.Body.Close()
+ }
+ if t.Wait != nil {
+ t.Wait(try)
+ }
+ }
+
+ return
+}
+
+func ExpBackoff(try int) {
+ time.Sleep(100 * time.Millisecond *
+ time.Duration(math.Exp2(float64(try))))
+}
+
+func LinearBackoff(try int) {
+ time.Sleep(time.Duration(try*100) * time.Millisecond)
+}
+
+// Decide if we should retry a request.
+// In general, the criteria for retrying a request is described here
+// http://docs.aws.amazon.com/general/latest/gr/api-retries.html
+func awsRetry(req *http.Request, res *http.Response, err error) bool {
+ retry := false
+
+ // Retry if there's a temporary network error.
+ if neterr, ok := err.(net.Error); ok {
+ if neterr.Temporary() {
+ retry = true
+ }
+ }
+
+ // Retry if we get a 5xx series error.
+ if res != nil {
+ if res.StatusCode >= 500 && res.StatusCode < 600 {
+ retry = true
+ }
+ }
+
+ return retry
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/client_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/client_test.go
new file mode 100644
index 00000000..2f6b39cf
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/aws/client_test.go
@@ -0,0 +1,121 @@
+package aws_test
+
+import (
+ "fmt"
+ "github.com/mitchellh/goamz/aws"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+ "time"
+)
+
+// Retrieve the response from handler using aws.RetryingClient
+func serveAndGet(handler http.HandlerFunc) (body string, err error) {
+ ts := httptest.NewServer(handler)
+ defer ts.Close()
+ resp, err := aws.RetryingClient.Get(ts.URL)
+ if err != nil {
+ return
+ }
+ if resp.StatusCode != 200 {
+ return "", fmt.Errorf("Bad status code: %d", resp.StatusCode)
+ }
+ greeting, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ return
+ }
+ return strings.TrimSpace(string(greeting)), nil
+}
+
+func TestClient_expected(t *testing.T) {
+ body := "foo bar"
+
+ resp, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprintln(w, body)
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if resp != body {
+ t.Fatal("Body not as expected.")
+ }
+}
+
+func TestClient_delay(t *testing.T) {
+ body := "baz"
+ wait := 4
+ resp, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
+ if wait < 0 {
+ // If we dipped to zero delay and still failed.
+ t.Fatal("Never succeeded.")
+ }
+ wait -= 1
+ time.Sleep(time.Second * time.Duration(wait))
+ fmt.Fprintln(w, body)
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if resp != body {
+ t.Fatal("Body not as expected.", resp)
+ }
+}
+
+func TestClient_no4xxRetry(t *testing.T) {
+ tries := 0
+
+ // Fail once before succeeding.
+ _, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
+ tries += 1
+ http.Error(w, "error", 404)
+ })
+
+ if err == nil {
+ t.Fatal("should have error")
+ }
+
+ if tries != 1 {
+ t.Fatalf("should only try once: %d", tries)
+ }
+}
+
+func TestClient_retries(t *testing.T) {
+ body := "biz"
+ failed := false
+ // Fail once before succeeding.
+ resp, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
+ if !failed {
+ http.Error(w, "error", 500)
+ failed = true
+ } else {
+ fmt.Fprintln(w, body)
+ }
+ })
+ if failed != true {
+ t.Error("We didn't retry!")
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ if resp != body {
+ t.Fatal("Body not as expected.")
+ }
+}
+
+func TestClient_fails(t *testing.T) {
+ tries := 0
+ // Fail 3 times and return the last error.
+ _, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
+ tries += 1
+ http.Error(w, "error", 500)
+ })
+ if err == nil {
+ t.Fatal(err)
+ }
+ if tries != 3 {
+ t.Fatal("Didn't retry enough")
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2.go
new file mode 100644
index 00000000..6042aa61
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2.go
@@ -0,0 +1,2505 @@
+//
+// goamz - Go packages to interact with the Amazon Web Services.
+//
+// https://wiki.ubuntu.com/goamz
+//
+// Copyright (c) 2011 Canonical Ltd.
+//
+// Written by Gustavo Niemeyer
+//
+
+package ec2
+
+import (
+ "crypto/rand"
+ "encoding/base64"
+ "encoding/hex"
+ "encoding/xml"
+ "fmt"
+ "log"
+ "net/http"
+ "net/http/httputil"
+ "net/url"
+ "sort"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/mitchellh/goamz/aws"
+)
+
+const debug = false
+
+// The EC2 type encapsulates operations with a specific EC2 region.
+type EC2 struct {
+ aws.Auth
+ aws.Region
+ httpClient *http.Client
+ private byte // Reserve the right of using private data.
+}
+
+// New creates a new EC2.
+func NewWithClient(auth aws.Auth, region aws.Region, client *http.Client) *EC2 {
+ return &EC2{auth, region, client, 0}
+}
+
+func New(auth aws.Auth, region aws.Region) *EC2 {
+ return NewWithClient(auth, region, aws.RetryingClient)
+}
+
+// ----------------------------------------------------------------------------
+// Filtering helper.
+
+// Filter builds filtering parameters to be used in an EC2 query which supports
+// filtering. For example:
+//
+// filter := NewFilter()
+// filter.Add("architecture", "i386")
+// filter.Add("launch-index", "0")
+// resp, err := ec2.Instances(nil, filter)
+//
+type Filter struct {
+ m map[string][]string
+}
+
+// NewFilter creates a new Filter.
+func NewFilter() *Filter {
+ return &Filter{make(map[string][]string)}
+}
+
+// Add appends a filtering parameter with the given name and value(s).
+func (f *Filter) Add(name string, value ...string) {
+ f.m[name] = append(f.m[name], value...)
+}
+
+func (f *Filter) addParams(params map[string]string) {
+ if f != nil {
+ a := make([]string, len(f.m))
+ i := 0
+ for k := range f.m {
+ a[i] = k
+ i++
+ }
+ sort.StringSlice(a).Sort()
+ for i, k := range a {
+ prefix := "Filter." + strconv.Itoa(i+1)
+ params[prefix+".Name"] = k
+ for j, v := range f.m[k] {
+ params[prefix+".Value."+strconv.Itoa(j+1)] = v
+ }
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+// Request dispatching logic.
+
+// Error encapsulates an error returned by EC2.
+//
+// See http://goo.gl/VZGuC for more details.
+type Error struct {
+ // HTTP status code (200, 403, ...)
+ StatusCode int
+ // EC2 error code ("UnsupportedOperation", ...)
+ Code string
+ // The human-oriented error message
+ Message string
+ RequestId string `xml:"RequestID"`
+}
+
+func (err *Error) Error() string {
+ if err.Code == "" {
+ return err.Message
+ }
+
+ return fmt.Sprintf("%s (%s)", err.Message, err.Code)
+}
+
+// For now a single error inst is being exposed. In the future it may be useful
+// to provide access to all of them, but rather than doing it as an array/slice,
+// use a *next pointer, so that it's backward compatible and it continues to be
+// easy to handle the first error, which is what most people will want.
+type xmlErrors struct {
+ RequestId string `xml:"RequestID"`
+ Errors []Error `xml:"Errors>Error"`
+}
+
+var timeNow = time.Now
+
+func (ec2 *EC2) query(params map[string]string, resp interface{}) error {
+ params["Version"] = "2014-05-01"
+ params["Timestamp"] = timeNow().In(time.UTC).Format(time.RFC3339)
+ endpoint, err := url.Parse(ec2.Region.EC2Endpoint)
+ if err != nil {
+ return err
+ }
+ if endpoint.Path == "" {
+ endpoint.Path = "/"
+ }
+ sign(ec2.Auth, "GET", endpoint.Path, params, endpoint.Host)
+ endpoint.RawQuery = multimap(params).Encode()
+ if debug {
+ log.Printf("get { %v } -> {\n", endpoint.String())
+ }
+
+ r, err := ec2.httpClient.Get(endpoint.String())
+ if err != nil {
+ return err
+ }
+ defer r.Body.Close()
+
+ if debug {
+ dump, _ := httputil.DumpResponse(r, true)
+ log.Printf("response:\n")
+ log.Printf("%v\n}\n", string(dump))
+ }
+ if r.StatusCode != 200 {
+ return buildError(r)
+ }
+ err = xml.NewDecoder(r.Body).Decode(resp)
+ return err
+}
+
+func multimap(p map[string]string) url.Values {
+ q := make(url.Values, len(p))
+ for k, v := range p {
+ q[k] = []string{v}
+ }
+ return q
+}
+
+func buildError(r *http.Response) error {
+ errors := xmlErrors{}
+ xml.NewDecoder(r.Body).Decode(&errors)
+ var err Error
+ if len(errors.Errors) > 0 {
+ err = errors.Errors[0]
+ }
+ err.RequestId = errors.RequestId
+ err.StatusCode = r.StatusCode
+ if err.Message == "" {
+ err.Message = r.Status
+ }
+ return &err
+}
+
+func makeParams(action string) map[string]string {
+ params := make(map[string]string)
+ params["Action"] = action
+ return params
+}
+
+func addParamsList(params map[string]string, label string, ids []string) {
+ for i, id := range ids {
+ params[label+"."+strconv.Itoa(i+1)] = id
+ }
+}
+
+func addBlockDeviceParams(prename string, params map[string]string, blockdevices []BlockDeviceMapping) {
+ for i, k := range blockdevices {
+ // Fixup index since Amazon counts these from 1
+ prefix := prename + "BlockDeviceMapping." + strconv.Itoa(i+1) + "."
+
+ if k.DeviceName != "" {
+ params[prefix+"DeviceName"] = k.DeviceName
+ }
+ if k.VirtualName != "" {
+ params[prefix+"VirtualName"] = k.VirtualName
+ }
+ if k.SnapshotId != "" {
+ params[prefix+"Ebs.SnapshotId"] = k.SnapshotId
+ }
+ if k.VolumeType != "" {
+ params[prefix+"Ebs.VolumeType"] = k.VolumeType
+ }
+ if k.IOPS != 0 {
+ params[prefix+"Ebs.Iops"] = strconv.FormatInt(k.IOPS, 10)
+ }
+ if k.VolumeSize != 0 {
+ params[prefix+"Ebs.VolumeSize"] = strconv.FormatInt(k.VolumeSize, 10)
+ }
+ if k.DeleteOnTermination {
+ params[prefix+"Ebs.DeleteOnTermination"] = "true"
+ }
+ if k.Encrypted {
+ params[prefix+"Ebs.Encrypted"] = "true"
+ }
+ if k.NoDevice {
+ params[prefix+"NoDevice"] = ""
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+// Instance management functions and types.
+
+// The RunInstances type encapsulates options for the respective request in EC2.
+//
+// See http://goo.gl/Mcm3b for more details.
+type RunInstances struct {
+ ImageId string
+ MinCount int
+ MaxCount int
+ KeyName string
+ InstanceType string
+ SecurityGroups []SecurityGroup
+ IamInstanceProfile string
+ KernelId string
+ RamdiskId string
+ UserData []byte
+ AvailZone string
+ PlacementGroupName string
+ Monitoring bool
+ SubnetId string
+ AssociatePublicIpAddress bool
+ DisableAPITermination bool
+ ShutdownBehavior string
+ PrivateIPAddress string
+ BlockDevices []BlockDeviceMapping
+}
+
+// Response to a RunInstances request.
+//
+// See http://goo.gl/Mcm3b for more details.
+type RunInstancesResp struct {
+ RequestId string `xml:"requestId"`
+ ReservationId string `xml:"reservationId"`
+ OwnerId string `xml:"ownerId"`
+ SecurityGroups []SecurityGroup `xml:"groupSet>item"`
+ Instances []Instance `xml:"instancesSet>item"`
+}
+
+// Instance encapsulates a running instance in EC2.
+//
+// See http://goo.gl/OCH8a for more details.
+type Instance struct {
+ InstanceId string `xml:"instanceId"`
+ InstanceType string `xml:"instanceType"`
+ ImageId string `xml:"imageId"`
+ PrivateDNSName string `xml:"privateDnsName"`
+ DNSName string `xml:"dnsName"`
+ KeyName string `xml:"keyName"`
+ AMILaunchIndex int `xml:"amiLaunchIndex"`
+ Hypervisor string `xml:"hypervisor"`
+ VirtType string `xml:"virtualizationType"`
+ Monitoring string `xml:"monitoring>state"`
+ AvailZone string `xml:"placement>availabilityZone"`
+ PlacementGroupName string `xml:"placement>groupName"`
+ State InstanceState `xml:"instanceState"`
+ Tags []Tag `xml:"tagSet>item"`
+ VpcId string `xml:"vpcId"`
+ SubnetId string `xml:"subnetId"`
+ IamInstanceProfile string `xml:"iamInstanceProfile"`
+ PrivateIpAddress string `xml:"privateIpAddress"`
+ PublicIpAddress string `xml:"ipAddress"`
+ Architecture string `xml:"architecture"`
+ LaunchTime time.Time `xml:"launchTime"`
+ SourceDestCheck bool `xml:"sourceDestCheck"`
+ SecurityGroups []SecurityGroup `xml:"groupSet>item"`
+}
+
+// RunInstances starts new instances in EC2.
+// If options.MinCount and options.MaxCount are both zero, a single instance
+// will be started; otherwise if options.MaxCount is zero, options.MinCount
+// will be used insteead.
+//
+// See http://goo.gl/Mcm3b for more details.
+func (ec2 *EC2) RunInstances(options *RunInstances) (resp *RunInstancesResp, err error) {
+ params := makeParams("RunInstances")
+ params["ImageId"] = options.ImageId
+ params["InstanceType"] = options.InstanceType
+ var min, max int
+ if options.MinCount == 0 && options.MaxCount == 0 {
+ min = 1
+ max = 1
+ } else if options.MaxCount == 0 {
+ min = options.MinCount
+ max = min
+ } else {
+ min = options.MinCount
+ max = options.MaxCount
+ }
+ params["MinCount"] = strconv.Itoa(min)
+ params["MaxCount"] = strconv.Itoa(max)
+ token, err := clientToken()
+ if err != nil {
+ return nil, err
+ }
+ params["ClientToken"] = token
+
+ if options.KeyName != "" {
+ params["KeyName"] = options.KeyName
+ }
+ if options.KernelId != "" {
+ params["KernelId"] = options.KernelId
+ }
+ if options.RamdiskId != "" {
+ params["RamdiskId"] = options.RamdiskId
+ }
+ if options.UserData != nil {
+ userData := make([]byte, b64.EncodedLen(len(options.UserData)))
+ b64.Encode(userData, options.UserData)
+ params["UserData"] = string(userData)
+ }
+ if options.AvailZone != "" {
+ params["Placement.AvailabilityZone"] = options.AvailZone
+ }
+ if options.PlacementGroupName != "" {
+ params["Placement.GroupName"] = options.PlacementGroupName
+ }
+ if options.Monitoring {
+ params["Monitoring.Enabled"] = "true"
+ }
+ if options.SubnetId != "" && options.AssociatePublicIpAddress {
+ // If we have a non-default VPC / Subnet specified, we can flag
+ // AssociatePublicIpAddress to get a Public IP assigned. By default these are not provided.
+ // You cannot specify both SubnetId and the NetworkInterface.0.* parameters though, otherwise
+ // you get: Network interfaces and an instance-level subnet ID may not be specified on the same request
+ // You also need to attach Security Groups to the NetworkInterface instead of the instance,
+ // to avoid: Network interfaces and an instance-level security groups may not be specified on
+ // the same request
+ params["NetworkInterface.0.DeviceIndex"] = "0"
+ params["NetworkInterface.0.AssociatePublicIpAddress"] = "true"
+ params["NetworkInterface.0.SubnetId"] = options.SubnetId
+
+ i := 1
+ for _, g := range options.SecurityGroups {
+ // We only have SecurityGroupId's on NetworkInterface's, no SecurityGroup params.
+ if g.Id != "" {
+ params["NetworkInterface.0.SecurityGroupId."+strconv.Itoa(i)] = g.Id
+ i++
+ }
+ }
+ } else {
+ if options.SubnetId != "" {
+ params["SubnetId"] = options.SubnetId
+ }
+
+ i, j := 1, 1
+ for _, g := range options.SecurityGroups {
+ if g.Id != "" {
+ params["SecurityGroupId."+strconv.Itoa(i)] = g.Id
+ i++
+ } else {
+ params["SecurityGroup."+strconv.Itoa(j)] = g.Name
+ j++
+ }
+ }
+ }
+ if options.IamInstanceProfile != "" {
+ params["IamInstanceProfile.Name"] = options.IamInstanceProfile
+ }
+ if options.DisableAPITermination {
+ params["DisableApiTermination"] = "true"
+ }
+ if options.ShutdownBehavior != "" {
+ params["InstanceInitiatedShutdownBehavior"] = options.ShutdownBehavior
+ }
+ if options.PrivateIPAddress != "" {
+ params["PrivateIpAddress"] = options.PrivateIPAddress
+ }
+ addBlockDeviceParams("", params, options.BlockDevices)
+
+ resp = &RunInstancesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+func clientToken() (string, error) {
+ // Maximum EC2 client token size is 64 bytes.
+ // Each byte expands to two when hex encoded.
+ buf := make([]byte, 32)
+ _, err := rand.Read(buf)
+ if err != nil {
+ return "", err
+ }
+ return hex.EncodeToString(buf), nil
+}
+
+// ----------------------------------------------------------------------------
+// Spot Instance management functions and types.
+
+// The RequestSpotInstances type encapsulates options for the respective request in EC2.
+//
+// See http://goo.gl/GRZgCD for more details.
+type RequestSpotInstances struct {
+ SpotPrice string
+ InstanceCount int
+ Type string
+ ImageId string
+ KeyName string
+ InstanceType string
+ SecurityGroups []SecurityGroup
+ IamInstanceProfile string
+ KernelId string
+ RamdiskId string
+ UserData []byte
+ AvailZone string
+ PlacementGroupName string
+ Monitoring bool
+ SubnetId string
+ AssociatePublicIpAddress bool
+ PrivateIPAddress string
+ BlockDevices []BlockDeviceMapping
+}
+
+type SpotInstanceSpec struct {
+ ImageId string
+ KeyName string
+ InstanceType string
+ SecurityGroups []SecurityGroup
+ IamInstanceProfile string
+ KernelId string
+ RamdiskId string
+ UserData []byte
+ AvailZone string
+ PlacementGroupName string
+ Monitoring bool
+ SubnetId string
+ AssociatePublicIpAddress bool
+ PrivateIPAddress string
+ BlockDevices []BlockDeviceMapping
+}
+
+type SpotLaunchSpec struct {
+ ImageId string `xml:"imageId"`
+ KeyName string `xml:"keyName"`
+ InstanceType string `xml:"instanceType"`
+ SecurityGroups []SecurityGroup `xml:"groupSet>item"`
+ IamInstanceProfile string `xml:"iamInstanceProfile"`
+ KernelId string `xml:"kernelId"`
+ RamdiskId string `xml:"ramdiskId"`
+ PlacementGroupName string `xml:"placement>groupName"`
+ Monitoring bool `xml:"monitoring>enabled"`
+ SubnetId string `xml:"subnetId"`
+ BlockDevices []BlockDeviceMapping `xml:"blockDeviceMapping>item"`
+}
+
+type SpotRequestResult struct {
+ SpotRequestId string `xml:"spotInstanceRequestId"`
+ SpotPrice string `xml:"spotPrice"`
+ Type string `xml:"type"`
+ AvailZone string `xml:"launchedAvailabilityZone"`
+ InstanceId string `xml:"instanceId"`
+ State string `xml:"state"`
+ SpotLaunchSpec SpotLaunchSpec `xml:"launchSpecification"`
+ CreateTime string `xml:"createTime"`
+ Tags []Tag `xml:"tagSet>item"`
+}
+
+// Response to a RequestSpotInstances request.
+//
+// See http://goo.gl/GRZgCD for more details.
+type RequestSpotInstancesResp struct {
+ RequestId string `xml:"requestId"`
+ SpotRequestResults []SpotRequestResult `xml:"spotInstanceRequestSet>item"`
+}
+
+// RequestSpotInstances requests a new spot instances in EC2.
+func (ec2 *EC2) RequestSpotInstances(options *RequestSpotInstances) (resp *RequestSpotInstancesResp, err error) {
+ params := makeParams("RequestSpotInstances")
+ prefix := "LaunchSpecification" + "."
+
+ params["SpotPrice"] = options.SpotPrice
+ params[prefix+"ImageId"] = options.ImageId
+ params[prefix+"InstanceType"] = options.InstanceType
+
+ if options.InstanceCount != 0 {
+ params["InstanceCount"] = strconv.Itoa(options.InstanceCount)
+ }
+ if options.KeyName != "" {
+ params[prefix+"KeyName"] = options.KeyName
+ }
+ if options.KernelId != "" {
+ params[prefix+"KernelId"] = options.KernelId
+ }
+ if options.RamdiskId != "" {
+ params[prefix+"RamdiskId"] = options.RamdiskId
+ }
+ if options.UserData != nil {
+ userData := make([]byte, b64.EncodedLen(len(options.UserData)))
+ b64.Encode(userData, options.UserData)
+ params[prefix+"UserData"] = string(userData)
+ }
+ if options.AvailZone != "" {
+ params[prefix+"Placement.AvailabilityZone"] = options.AvailZone
+ }
+ if options.PlacementGroupName != "" {
+ params[prefix+"Placement.GroupName"] = options.PlacementGroupName
+ }
+ if options.Monitoring {
+ params[prefix+"Monitoring.Enabled"] = "true"
+ }
+ if options.SubnetId != "" && options.AssociatePublicIpAddress {
+ // If we have a non-default VPC / Subnet specified, we can flag
+ // AssociatePublicIpAddress to get a Public IP assigned. By default these are not provided.
+ // You cannot specify both SubnetId and the NetworkInterface.0.* parameters though, otherwise
+ // you get: Network interfaces and an instance-level subnet ID may not be specified on the same request
+ // You also need to attach Security Groups to the NetworkInterface instead of the instance,
+ // to avoid: Network interfaces and an instance-level security groups may not be specified on
+ // the same request
+ params[prefix+"NetworkInterface.0.DeviceIndex"] = "0"
+ params[prefix+"NetworkInterface.0.AssociatePublicIpAddress"] = "true"
+ params[prefix+"NetworkInterface.0.SubnetId"] = options.SubnetId
+
+ i := 1
+ for _, g := range options.SecurityGroups {
+ // We only have SecurityGroupId's on NetworkInterface's, no SecurityGroup params.
+ if g.Id != "" {
+ params[prefix+"NetworkInterface.0.SecurityGroupId."+strconv.Itoa(i)] = g.Id
+ i++
+ }
+ }
+ } else {
+ if options.SubnetId != "" {
+ params[prefix+"SubnetId"] = options.SubnetId
+ }
+
+ i, j := 1, 1
+ for _, g := range options.SecurityGroups {
+ if g.Id != "" {
+ params[prefix+"SecurityGroupId."+strconv.Itoa(i)] = g.Id
+ i++
+ } else {
+ params[prefix+"SecurityGroup."+strconv.Itoa(j)] = g.Name
+ j++
+ }
+ }
+ }
+ if options.IamInstanceProfile != "" {
+ params[prefix+"IamInstanceProfile.Name"] = options.IamInstanceProfile
+ }
+ if options.PrivateIPAddress != "" {
+ params[prefix+"PrivateIpAddress"] = options.PrivateIPAddress
+ }
+ addBlockDeviceParams(prefix, params, options.BlockDevices)
+
+ resp = &RequestSpotInstancesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Response to a DescribeSpotInstanceRequests request.
+//
+// See http://goo.gl/KsKJJk for more details.
+type SpotRequestsResp struct {
+ RequestId string `xml:"requestId"`
+ SpotRequestResults []SpotRequestResult `xml:"spotInstanceRequestSet>item"`
+}
+
+// DescribeSpotInstanceRequests returns details about spot requests in EC2. Both parameters
+// are optional, and if provided will limit the spot requests returned to those
+// matching the given spot request ids or filtering rules.
+//
+// See http://goo.gl/KsKJJk for more details.
+func (ec2 *EC2) DescribeSpotRequests(spotrequestIds []string, filter *Filter) (resp *SpotRequestsResp, err error) {
+ params := makeParams("DescribeSpotInstanceRequests")
+ addParamsList(params, "SpotInstanceRequestId", spotrequestIds)
+ filter.addParams(params)
+ resp = &SpotRequestsResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Response to a CancelSpotInstanceRequests request.
+//
+// See http://goo.gl/3BKHj for more details.
+type CancelSpotRequestResult struct {
+ SpotRequestId string `xml:"spotInstanceRequestId"`
+ State string `xml:"state"`
+}
+type CancelSpotRequestsResp struct {
+ RequestId string `xml:"requestId"`
+ CancelSpotRequestResults []CancelSpotRequestResult `xml:"spotInstanceRequestSet>item"`
+}
+
+// CancelSpotRequests requests the cancellation of spot requests when the given ids.
+//
+// See http://goo.gl/3BKHj for more details.
+func (ec2 *EC2) CancelSpotRequests(spotrequestIds []string) (resp *CancelSpotRequestsResp, err error) {
+ params := makeParams("CancelSpotInstanceRequests")
+ addParamsList(params, "SpotInstanceRequestId", spotrequestIds)
+ resp = &CancelSpotRequestsResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Response to a TerminateInstances request.
+//
+// See http://goo.gl/3BKHj for more details.
+type TerminateInstancesResp struct {
+ RequestId string `xml:"requestId"`
+ StateChanges []InstanceStateChange `xml:"instancesSet>item"`
+}
+
+// InstanceState encapsulates the state of an instance in EC2.
+//
+// See http://goo.gl/y3ZBq for more details.
+type InstanceState struct {
+ Code int `xml:"code"` // Watch out, bits 15-8 have unpublished meaning.
+ Name string `xml:"name"`
+}
+
+// InstanceStateChange informs of the previous and current states
+// for an instance when a state change is requested.
+type InstanceStateChange struct {
+ InstanceId string `xml:"instanceId"`
+ CurrentState InstanceState `xml:"currentState"`
+ PreviousState InstanceState `xml:"previousState"`
+}
+
+// TerminateInstances requests the termination of instances when the given ids.
+//
+// See http://goo.gl/3BKHj for more details.
+func (ec2 *EC2) TerminateInstances(instIds []string) (resp *TerminateInstancesResp, err error) {
+ params := makeParams("TerminateInstances")
+ addParamsList(params, "InstanceId", instIds)
+ resp = &TerminateInstancesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Response to a DescribeInstances request.
+//
+// See http://goo.gl/mLbmw for more details.
+type InstancesResp struct {
+ RequestId string `xml:"requestId"`
+ Reservations []Reservation `xml:"reservationSet>item"`
+}
+
+// Reservation represents details about a reservation in EC2.
+//
+// See http://goo.gl/0ItPT for more details.
+type Reservation struct {
+ ReservationId string `xml:"reservationId"`
+ OwnerId string `xml:"ownerId"`
+ RequesterId string `xml:"requesterId"`
+ SecurityGroups []SecurityGroup `xml:"groupSet>item"`
+ Instances []Instance `xml:"instancesSet>item"`
+}
+
+// Instances returns details about instances in EC2. Both parameters
+// are optional, and if provided will limit the instances returned to those
+// matching the given instance ids or filtering rules.
+//
+// See http://goo.gl/4No7c for more details.
+func (ec2 *EC2) Instances(instIds []string, filter *Filter) (resp *InstancesResp, err error) {
+ params := makeParams("DescribeInstances")
+ addParamsList(params, "InstanceId", instIds)
+ filter.addParams(params)
+ resp = &InstancesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Volume management
+
+// The CreateVolume request parameters
+//
+// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html
+type CreateVolume struct {
+ AvailZone string
+ Size int64
+ SnapshotId string
+ VolumeType string
+ IOPS int64
+ Encrypted bool
+}
+
+// Response to an AttachVolume request
+type AttachVolumeResp struct {
+ RequestId string `xml:"requestId"`
+ VolumeId string `xml:"volumeId"`
+ InstanceId string `xml:"instanceId"`
+ Device string `xml:"device"`
+ Status string `xml:"status"`
+ AttachTime string `xml:"attachTime"`
+}
+
+// Response to a CreateVolume request
+type CreateVolumeResp struct {
+ RequestId string `xml:"requestId"`
+ VolumeId string `xml:"volumeId"`
+ Size int64 `xml:"size"`
+ SnapshotId string `xml:"snapshotId"`
+ AvailZone string `xml:"availabilityZone"`
+ Status string `xml:"status"`
+ CreateTime string `xml:"createTime"`
+ VolumeType string `xml:"volumeType"`
+ IOPS int64 `xml:"iops"`
+ Encrypted bool `xml:"encrypted"`
+}
+
+// Volume is a single volume.
+type Volume struct {
+ VolumeId string `xml:"volumeId"`
+ Size string `xml:"size"`
+ SnapshotId string `xml:"snapshotId"`
+ AvailZone string `xml:"availabilityZone"`
+ Status string `xml:"status"`
+ Attachments []VolumeAttachment `xml:"attachmentSet>item"`
+ VolumeType string `xml:"volumeType"`
+ IOPS int64 `xml:"iops"`
+ Encrypted bool `xml:"encrypted"`
+ Tags []Tag `xml:"tagSet>item"`
+}
+
+type VolumeAttachment struct {
+ VolumeId string `xml:"volumeId"`
+ InstanceId string `xml:"instanceId"`
+ Device string `xml:"device"`
+ Status string `xml:"status"`
+}
+
+// Response to a DescribeVolumes request
+type VolumesResp struct {
+ RequestId string `xml:"requestId"`
+ Volumes []Volume `xml:"volumeSet>item"`
+}
+
+// Attach a volume.
+func (ec2 *EC2) AttachVolume(volumeId string, instanceId string, device string) (resp *AttachVolumeResp, err error) {
+ params := makeParams("AttachVolume")
+ params["VolumeId"] = volumeId
+ params["InstanceId"] = instanceId
+ params["Device"] = device
+
+ resp = &AttachVolumeResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Create a new volume.
+func (ec2 *EC2) CreateVolume(options *CreateVolume) (resp *CreateVolumeResp, err error) {
+ params := makeParams("CreateVolume")
+ params["AvailabilityZone"] = options.AvailZone
+ if options.Size > 0 {
+ params["Size"] = strconv.FormatInt(options.Size, 10)
+ }
+
+ if options.SnapshotId != "" {
+ params["SnapshotId"] = options.SnapshotId
+ }
+
+ if options.VolumeType != "" {
+ params["VolumeType"] = options.VolumeType
+ }
+
+ if options.IOPS > 0 {
+ params["Iops"] = strconv.FormatInt(options.IOPS, 10)
+ }
+
+ if options.Encrypted {
+ params["Encrypted"] = "true"
+ }
+
+ resp = &CreateVolumeResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Delete an EBS volume.
+func (ec2 *EC2) DeleteVolume(id string) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteVolume")
+ params["VolumeId"] = id
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Detaches an EBS volume.
+func (ec2 *EC2) DetachVolume(id string) (resp *SimpleResp, err error) {
+ params := makeParams("DetachVolume")
+ params["VolumeId"] = id
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Finds or lists all volumes.
+func (ec2 *EC2) Volumes(volIds []string, filter *Filter) (resp *VolumesResp, err error) {
+ params := makeParams("DescribeVolumes")
+ addParamsList(params, "VolumeId", volIds)
+ filter.addParams(params)
+ resp = &VolumesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// ----------------------------------------------------------------------------
+// ElasticIp management (for VPC)
+
+// The AllocateAddress request parameters
+//
+// see http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AllocateAddress.html
+type AllocateAddress struct {
+ Domain string
+}
+
+// Response to an AllocateAddress request
+type AllocateAddressResp struct {
+ RequestId string `xml:"requestId"`
+ PublicIp string `xml:"publicIp"`
+ Domain string `xml:"domain"`
+ AllocationId string `xml:"allocationId"`
+}
+
+// The AssociateAddress request parameters
+//
+// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AssociateAddress.html
+type AssociateAddress struct {
+ InstanceId string
+ PublicIp string
+ AllocationId string
+ AllowReassociation bool
+}
+
+// Response to an AssociateAddress request
+type AssociateAddressResp struct {
+ RequestId string `xml:"requestId"`
+ Return bool `xml:"return"`
+ AssociationId string `xml:"associationId"`
+}
+
+// Address represents an Elastic IP Address
+// See http://goo.gl/uxCjp7 for more details
+type Address struct {
+ PublicIp string `xml:"publicIp"`
+ AllocationId string `xml:"allocationId"`
+ Domain string `xml:"domain"`
+ InstanceId string `xml:"instanceId"`
+ AssociationId string `xml:"associationId"`
+ NetworkInterfaceId string `xml:"networkInterfaceId"`
+ NetworkInterfaceOwnerId string `xml:"networkInterfaceOwnerId"`
+ PrivateIpAddress string `xml:"privateIpAddress"`
+}
+
+type DescribeAddressesResp struct {
+ RequestId string `xml:"requestId"`
+ Addresses []Address `xml:"addressesSet>item"`
+}
+
+// Allocate a new Elastic IP.
+func (ec2 *EC2) AllocateAddress(options *AllocateAddress) (resp *AllocateAddressResp, err error) {
+ params := makeParams("AllocateAddress")
+ params["Domain"] = options.Domain
+
+ resp = &AllocateAddressResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Release an Elastic IP (VPC).
+func (ec2 *EC2) ReleaseAddress(id string) (resp *SimpleResp, err error) {
+ params := makeParams("ReleaseAddress")
+ params["AllocationId"] = id
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Release an Elastic IP (Public)
+func (ec2 *EC2) ReleasePublicAddress(publicIp string) (resp *SimpleResp, err error) {
+ params := makeParams("ReleaseAddress")
+ params["PublicIp"] = publicIp
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Associate an address with a VPC instance.
+func (ec2 *EC2) AssociateAddress(options *AssociateAddress) (resp *AssociateAddressResp, err error) {
+ params := makeParams("AssociateAddress")
+ params["InstanceId"] = options.InstanceId
+ if options.PublicIp != "" {
+ params["PublicIp"] = options.PublicIp
+ }
+ if options.AllocationId != "" {
+ params["AllocationId"] = options.AllocationId
+ }
+ if options.AllowReassociation {
+ params["AllowReassociation"] = "true"
+ }
+
+ resp = &AssociateAddressResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Disassociate an address from a VPC instance.
+func (ec2 *EC2) DisassociateAddress(id string) (resp *SimpleResp, err error) {
+ params := makeParams("DisassociateAddress")
+ params["AssociationId"] = id
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// DescribeAddresses returns details about one or more
+// Elastic IP Addresses. Returned addresses can be
+// filtered by Public IP, Allocation ID or multiple filters
+//
+// See http://goo.gl/zW7J4p for more details.
+func (ec2 *EC2) Addresses(publicIps []string, allocationIds []string, filter *Filter) (resp *DescribeAddressesResp, err error) {
+ params := makeParams("DescribeAddresses")
+ addParamsList(params, "PublicIp", publicIps)
+ addParamsList(params, "AllocationId", allocationIds)
+ filter.addParams(params)
+ resp = &DescribeAddressesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Image and snapshot management functions and types.
+
+// The CreateImage request parameters.
+//
+// See http://goo.gl/cxU41 for more details.
+type CreateImage struct {
+ InstanceId string
+ Name string
+ Description string
+ NoReboot bool
+ BlockDevices []BlockDeviceMapping
+}
+
+// Response to a CreateImage request.
+//
+// See http://goo.gl/cxU41 for more details.
+type CreateImageResp struct {
+ RequestId string `xml:"requestId"`
+ ImageId string `xml:"imageId"`
+}
+
+// Response to a DescribeImages request.
+//
+// See http://goo.gl/hLnyg for more details.
+type ImagesResp struct {
+ RequestId string `xml:"requestId"`
+ Images []Image `xml:"imagesSet>item"`
+}
+
+// Response to a DescribeImageAttribute request.
+//
+// See http://goo.gl/bHO3zT for more details.
+type ImageAttributeResp struct {
+ RequestId string `xml:"requestId"`
+ ImageId string `xml:"imageId"`
+ Kernel string `xml:"kernel>value"`
+ RamDisk string `xml:"ramdisk>value"`
+ Description string `xml:"description>value"`
+ Group string `xml:"launchPermission>item>group"`
+ UserIds []string `xml:"launchPermission>item>userId"`
+ ProductCodes []string `xml:"productCodes>item>productCode"`
+ BlockDevices []BlockDeviceMapping `xml:"blockDeviceMapping>item"`
+}
+
+// The RegisterImage request parameters.
+type RegisterImage struct {
+ ImageLocation string
+ Name string
+ Description string
+ Architecture string
+ KernelId string
+ RamdiskId string
+ RootDeviceName string
+ VirtType string
+ SriovNetSupport string
+ BlockDevices []BlockDeviceMapping
+}
+
+// Response to a RegisterImage request.
+type RegisterImageResp struct {
+ RequestId string `xml:"requestId"`
+ ImageId string `xml:"imageId"`
+}
+
+// Response to a DegisterImage request.
+//
+// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html
+type DeregisterImageResp struct {
+ RequestId string `xml:"requestId"`
+ Return bool `xml:"return"`
+}
+
+// BlockDeviceMapping represents the association of a block device with an image.
+//
+// See http://goo.gl/wnDBf for more details.
+type BlockDeviceMapping struct {
+ DeviceName string `xml:"deviceName"`
+ VirtualName string `xml:"virtualName"`
+ SnapshotId string `xml:"ebs>snapshotId"`
+ VolumeType string `xml:"ebs>volumeType"`
+ VolumeSize int64 `xml:"ebs>volumeSize"`
+ DeleteOnTermination bool `xml:"ebs>deleteOnTermination"`
+ Encrypted bool `xml:"ebs>encrypted"`
+ NoDevice bool `xml:"noDevice"`
+
+ // The number of I/O operations per second (IOPS) that the volume supports.
+ IOPS int64 `xml:"ebs>iops"`
+}
+
+// Image represents details about an image.
+//
+// See http://goo.gl/iSqJG for more details.
+type Image struct {
+ Id string `xml:"imageId"`
+ Name string `xml:"name"`
+ Description string `xml:"description"`
+ Type string `xml:"imageType"`
+ State string `xml:"imageState"`
+ Location string `xml:"imageLocation"`
+ Public bool `xml:"isPublic"`
+ Architecture string `xml:"architecture"`
+ Platform string `xml:"platform"`
+ ProductCodes []string `xml:"productCode>item>productCode"`
+ KernelId string `xml:"kernelId"`
+ RamdiskId string `xml:"ramdiskId"`
+ StateReason string `xml:"stateReason"`
+ OwnerId string `xml:"imageOwnerId"`
+ OwnerAlias string `xml:"imageOwnerAlias"`
+ RootDeviceType string `xml:"rootDeviceType"`
+ RootDeviceName string `xml:"rootDeviceName"`
+ VirtualizationType string `xml:"virtualizationType"`
+ Hypervisor string `xml:"hypervisor"`
+ BlockDevices []BlockDeviceMapping `xml:"blockDeviceMapping>item"`
+ Tags []Tag `xml:"tagSet>item"`
+}
+
+// The ModifyImageAttribute request parameters.
+type ModifyImageAttribute struct {
+ AddUsers []string
+ RemoveUsers []string
+ AddGroups []string
+ RemoveGroups []string
+ ProductCodes []string
+ Description string
+}
+
+// The CopyImage request parameters.
+//
+// See http://goo.gl/hQwPCK for more details.
+type CopyImage struct {
+ SourceRegion string
+ SourceImageId string
+ Name string
+ Description string
+ ClientToken string
+}
+
+// Response to a CopyImage request.
+//
+// See http://goo.gl/hQwPCK for more details.
+type CopyImageResp struct {
+ RequestId string `xml:"requestId"`
+ ImageId string `xml:"imageId"`
+}
+
+// Creates an Amazon EBS-backed AMI from an Amazon EBS-backed instance
+// that is either running or stopped.
+//
+// See http://goo.gl/cxU41 for more details.
+func (ec2 *EC2) CreateImage(options *CreateImage) (resp *CreateImageResp, err error) {
+ params := makeParams("CreateImage")
+ params["InstanceId"] = options.InstanceId
+ params["Name"] = options.Name
+ if options.Description != "" {
+ params["Description"] = options.Description
+ }
+ if options.NoReboot {
+ params["NoReboot"] = "true"
+ }
+ addBlockDeviceParams("", params, options.BlockDevices)
+
+ resp = &CreateImageResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Images returns details about available images.
+// The ids and filter parameters, if provided, will limit the images returned.
+// For example, to get all the private images associated with this account set
+// the boolean filter "is-public" to 0.
+// For list of filters: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html
+//
+// Note: calling this function with nil ids and filter parameters will result in
+// a very large number of images being returned.
+//
+// See http://goo.gl/SRBhW for more details.
+func (ec2 *EC2) Images(ids []string, filter *Filter) (resp *ImagesResp, err error) {
+ params := makeParams("DescribeImages")
+ for i, id := range ids {
+ params["ImageId."+strconv.Itoa(i+1)] = id
+ }
+ filter.addParams(params)
+
+ resp = &ImagesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// ImagesByOwners returns details about available images.
+// The ids, owners, and filter parameters, if provided, will limit the images returned.
+// For example, to get all the private images associated with this account set
+// the boolean filter "is-public" to 0.
+// For list of filters: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html
+//
+// Note: calling this function with nil ids and filter parameters will result in
+// a very large number of images being returned.
+//
+// See http://goo.gl/SRBhW for more details.
+func (ec2 *EC2) ImagesByOwners(ids []string, owners []string, filter *Filter) (resp *ImagesResp, err error) {
+ params := makeParams("DescribeImages")
+ for i, id := range ids {
+ params["ImageId."+strconv.Itoa(i+1)] = id
+ }
+ for i, owner := range owners {
+ params[fmt.Sprintf("Owner.%d", i+1)] = owner
+ }
+
+ filter.addParams(params)
+
+ resp = &ImagesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// ImageAttribute describes an attribute of an AMI.
+// You can specify only one attribute at a time.
+// Valid attributes are:
+// description | kernel | ramdisk | launchPermission | productCodes | blockDeviceMapping
+//
+// See http://goo.gl/bHO3zT for more details.
+func (ec2 *EC2) ImageAttribute(imageId, attribute string) (resp *ImageAttributeResp, err error) {
+ params := makeParams("DescribeImageAttribute")
+ params["ImageId"] = imageId
+ params["Attribute"] = attribute
+
+ resp = &ImageAttributeResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// ModifyImageAttribute sets attributes for an image.
+//
+// See http://goo.gl/YUjO4G for more details.
+func (ec2 *EC2) ModifyImageAttribute(imageId string, options *ModifyImageAttribute) (resp *SimpleResp, err error) {
+ params := makeParams("ModifyImageAttribute")
+ params["ImageId"] = imageId
+ if options.Description != "" {
+ params["Description.Value"] = options.Description
+ }
+
+ if options.AddUsers != nil {
+ for i, user := range options.AddUsers {
+ p := fmt.Sprintf("LaunchPermission.Add.%d.UserId", i+1)
+ params[p] = user
+ }
+ }
+
+ if options.RemoveUsers != nil {
+ for i, user := range options.RemoveUsers {
+ p := fmt.Sprintf("LaunchPermission.Remove.%d.UserId", i+1)
+ params[p] = user
+ }
+ }
+
+ if options.AddGroups != nil {
+ for i, group := range options.AddGroups {
+ p := fmt.Sprintf("LaunchPermission.Add.%d.Group", i+1)
+ params[p] = group
+ }
+ }
+
+ if options.RemoveGroups != nil {
+ for i, group := range options.RemoveGroups {
+ p := fmt.Sprintf("LaunchPermission.Remove.%d.Group", i+1)
+ params[p] = group
+ }
+ }
+
+ if options.ProductCodes != nil {
+ addParamsList(params, "ProductCode", options.ProductCodes)
+ }
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// Registers a new AMI with EC2.
+//
+// See: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html
+func (ec2 *EC2) RegisterImage(options *RegisterImage) (resp *RegisterImageResp, err error) {
+ params := makeParams("RegisterImage")
+ params["Name"] = options.Name
+ if options.ImageLocation != "" {
+ params["ImageLocation"] = options.ImageLocation
+ }
+
+ if options.Description != "" {
+ params["Description"] = options.Description
+ }
+
+ if options.Architecture != "" {
+ params["Architecture"] = options.Architecture
+ }
+
+ if options.KernelId != "" {
+ params["KernelId"] = options.KernelId
+ }
+
+ if options.RamdiskId != "" {
+ params["RamdiskId"] = options.RamdiskId
+ }
+
+ if options.RootDeviceName != "" {
+ params["RootDeviceName"] = options.RootDeviceName
+ }
+
+ if options.VirtType != "" {
+ params["VirtualizationType"] = options.VirtType
+ }
+
+ if options.SriovNetSupport != "" {
+ params["SriovNetSupport"] = "simple"
+ }
+
+ addBlockDeviceParams("", params, options.BlockDevices)
+
+ resp = &RegisterImageResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Degisters an image. Note that this does not delete the backing stores of the AMI.
+//
+// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html
+func (ec2 *EC2) DeregisterImage(imageId string) (resp *DeregisterImageResp, err error) {
+ params := makeParams("DeregisterImage")
+ params["ImageId"] = imageId
+
+ resp = &DeregisterImageResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Copy and Image from one region to another.
+//
+// See http://goo.gl/hQwPCK for more details.
+func (ec2 *EC2) CopyImage(options *CopyImage) (resp *CopyImageResp, err error) {
+ params := makeParams("CopyImage")
+
+ if options.SourceRegion != "" {
+ params["SourceRegion"] = options.SourceRegion
+ }
+
+ if options.SourceImageId != "" {
+ params["SourceImageId"] = options.SourceImageId
+ }
+
+ if options.Name != "" {
+ params["Name"] = options.Name
+ }
+
+ if options.Description != "" {
+ params["Description"] = options.Description
+ }
+
+ if options.ClientToken != "" {
+ params["ClientToken"] = options.ClientToken
+ }
+
+ resp = &CopyImageResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Response to a CreateSnapshot request.
+//
+// See http://goo.gl/ttcda for more details.
+type CreateSnapshotResp struct {
+ RequestId string `xml:"requestId"`
+ Snapshot
+}
+
+// CreateSnapshot creates a volume snapshot and stores it in S3.
+//
+// See http://goo.gl/ttcda for more details.
+func (ec2 *EC2) CreateSnapshot(volumeId, description string) (resp *CreateSnapshotResp, err error) {
+ params := makeParams("CreateSnapshot")
+ params["VolumeId"] = volumeId
+ params["Description"] = description
+
+ resp = &CreateSnapshotResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// DeleteSnapshots deletes the volume snapshots with the given ids.
+//
+// Note: If you make periodic snapshots of a volume, the snapshots are
+// incremental so that only the blocks on the device that have changed
+// since your last snapshot are incrementally saved in the new snapshot.
+// Even though snapshots are saved incrementally, the snapshot deletion
+// process is designed so that you need to retain only the most recent
+// snapshot in order to restore the volume.
+//
+// See http://goo.gl/vwU1y for more details.
+func (ec2 *EC2) DeleteSnapshots(ids []string) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteSnapshot")
+ for i, id := range ids {
+ params["SnapshotId."+strconv.Itoa(i+1)] = id
+ }
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Response to a DescribeSnapshots request.
+//
+// See http://goo.gl/nClDT for more details.
+type SnapshotsResp struct {
+ RequestId string `xml:"requestId"`
+ Snapshots []Snapshot `xml:"snapshotSet>item"`
+}
+
+// Snapshot represents details about a volume snapshot.
+//
+// See http://goo.gl/nkovs for more details.
+type Snapshot struct {
+ Id string `xml:"snapshotId"`
+ VolumeId string `xml:"volumeId"`
+ VolumeSize string `xml:"volumeSize"`
+ Status string `xml:"status"`
+ StartTime string `xml:"startTime"`
+ Description string `xml:"description"`
+ Progress string `xml:"progress"`
+ OwnerId string `xml:"ownerId"`
+ OwnerAlias string `xml:"ownerAlias"`
+ Encrypted bool `xml:"encrypted"`
+ Tags []Tag `xml:"tagSet>item"`
+}
+
+// Snapshots returns details about volume snapshots available to the user.
+// The ids and filter parameters, if provided, limit the snapshots returned.
+//
+// See http://goo.gl/ogJL4 for more details.
+func (ec2 *EC2) Snapshots(ids []string, filter *Filter) (resp *SnapshotsResp, err error) {
+ params := makeParams("DescribeSnapshots")
+ for i, id := range ids {
+ params["SnapshotId."+strconv.Itoa(i+1)] = id
+ }
+ filter.addParams(params)
+
+ resp = &SnapshotsResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// ----------------------------------------------------------------------------
+// KeyPair management functions and types.
+
+type KeyPair struct {
+ Name string `xml:"keyName"`
+ Fingerprint string `xml:"keyFingerprint"`
+}
+
+type KeyPairsResp struct {
+ RequestId string `xml:"requestId"`
+ Keys []KeyPair `xml:"keySet>item"`
+}
+
+type CreateKeyPairResp struct {
+ RequestId string `xml:"requestId"`
+ KeyName string `xml:"keyName"`
+ KeyFingerprint string `xml:"keyFingerprint"`
+ KeyMaterial string `xml:"keyMaterial"`
+}
+
+type ImportKeyPairResponse struct {
+ RequestId string `xml:"requestId"`
+ KeyName string `xml:"keyName"`
+ KeyFingerprint string `xml:"keyFingerprint"`
+}
+
+// CreateKeyPair creates a new key pair and returns the private key contents.
+//
+// See http://goo.gl/0S6hV
+func (ec2 *EC2) CreateKeyPair(keyName string) (resp *CreateKeyPairResp, err error) {
+ params := makeParams("CreateKeyPair")
+ params["KeyName"] = keyName
+
+ resp = &CreateKeyPairResp{}
+ err = ec2.query(params, resp)
+ if err == nil {
+ resp.KeyFingerprint = strings.TrimSpace(resp.KeyFingerprint)
+ }
+ return
+}
+
+// DeleteKeyPair deletes a key pair.
+//
+// See http://goo.gl/0bqok
+func (ec2 *EC2) DeleteKeyPair(name string) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteKeyPair")
+ params["KeyName"] = name
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ return
+}
+
+// KeyPairs returns list of key pairs for this account
+//
+// See http://goo.gl/Apzsfz
+func (ec2 *EC2) KeyPairs(keynames []string, filter *Filter) (resp *KeyPairsResp, err error) {
+ params := makeParams("DescribeKeyPairs")
+ for i, name := range keynames {
+ params["KeyName."+strconv.Itoa(i)] = name
+ }
+ filter.addParams(params)
+
+ resp = &KeyPairsResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return resp, nil
+}
+
+// ImportKeyPair imports a key into AWS
+//
+// See http://goo.gl/NbZUvw
+func (ec2 *EC2) ImportKeyPair(keyname string, key string) (resp *ImportKeyPairResponse, err error) {
+ params := makeParams("ImportKeyPair")
+ params["KeyName"] = keyname
+
+ // Oddly, AWS requires the key material to be base64-encoded, even if it was
+ // already encoded. So, we force another round of encoding...
+ // c.f. https://groups.google.com/forum/?fromgroups#!topic/boto-dev/IczrStO9Q8M
+ params["PublicKeyMaterial"] = base64.StdEncoding.EncodeToString([]byte(key))
+
+ resp = &ImportKeyPairResponse{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ----------------------------------------------------------------------------
+// Security group management functions and types.
+
+// SimpleResp represents a response to an EC2 request which on success will
+// return no other information besides a request id.
+type SimpleResp struct {
+ XMLName xml.Name
+ RequestId string `xml:"requestId"`
+}
+
+// CreateSecurityGroupResp represents a response to a CreateSecurityGroup request.
+type CreateSecurityGroupResp struct {
+ SecurityGroup
+ RequestId string `xml:"requestId"`
+}
+
+// CreateSecurityGroup run a CreateSecurityGroup request in EC2, with the provided
+// name and description.
+//
+// See http://goo.gl/Eo7Yl for more details.
+func (ec2 *EC2) CreateSecurityGroup(group SecurityGroup) (resp *CreateSecurityGroupResp, err error) {
+ params := makeParams("CreateSecurityGroup")
+ params["GroupName"] = group.Name
+ params["GroupDescription"] = group.Description
+ if group.VpcId != "" {
+ params["VpcId"] = group.VpcId
+ }
+
+ resp = &CreateSecurityGroupResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ resp.Name = group.Name
+ return resp, nil
+}
+
+// SecurityGroupsResp represents a response to a DescribeSecurityGroups
+// request in EC2.
+//
+// See http://goo.gl/k12Uy for more details.
+type SecurityGroupsResp struct {
+ RequestId string `xml:"requestId"`
+ Groups []SecurityGroupInfo `xml:"securityGroupInfo>item"`
+}
+
+// SecurityGroup encapsulates details for a security group in EC2.
+//
+// See http://goo.gl/CIdyP for more details.
+type SecurityGroupInfo struct {
+ SecurityGroup
+ OwnerId string `xml:"ownerId"`
+ Description string `xml:"groupDescription"`
+ IPPerms []IPPerm `xml:"ipPermissions>item"`
+}
+
+// IPPerm represents an allowance within an EC2 security group.
+//
+// See http://goo.gl/4oTxv for more details.
+type IPPerm struct {
+ Protocol string `xml:"ipProtocol"`
+ FromPort int `xml:"fromPort"`
+ ToPort int `xml:"toPort"`
+ SourceIPs []string `xml:"ipRanges>item>cidrIp"`
+ SourceGroups []UserSecurityGroup `xml:"groups>item"`
+}
+
+// UserSecurityGroup holds a security group and the owner
+// of that group.
+type UserSecurityGroup struct {
+ Id string `xml:"groupId"`
+ Name string `xml:"groupName"`
+ OwnerId string `xml:"userId"`
+}
+
+// SecurityGroup represents an EC2 security group.
+// If SecurityGroup is used as a parameter, then one of Id or Name
+// may be empty. If both are set, then Id is used.
+type SecurityGroup struct {
+ Id string `xml:"groupId"`
+ Name string `xml:"groupName"`
+ Description string `xml:"groupDescription"`
+ VpcId string `xml:"vpcId"`
+}
+
+// SecurityGroupNames is a convenience function that
+// returns a slice of security groups with the given names.
+func SecurityGroupNames(names ...string) []SecurityGroup {
+ g := make([]SecurityGroup, len(names))
+ for i, name := range names {
+ g[i] = SecurityGroup{Name: name}
+ }
+ return g
+}
+
+// SecurityGroupNames is a convenience function that
+// returns a slice of security groups with the given ids.
+func SecurityGroupIds(ids ...string) []SecurityGroup {
+ g := make([]SecurityGroup, len(ids))
+ for i, id := range ids {
+ g[i] = SecurityGroup{Id: id}
+ }
+ return g
+}
+
+// SecurityGroups returns details about security groups in EC2. Both parameters
+// are optional, and if provided will limit the security groups returned to those
+// matching the given groups or filtering rules.
+//
+// See http://goo.gl/k12Uy for more details.
+func (ec2 *EC2) SecurityGroups(groups []SecurityGroup, filter *Filter) (resp *SecurityGroupsResp, err error) {
+ params := makeParams("DescribeSecurityGroups")
+ i, j := 1, 1
+ for _, g := range groups {
+ if g.Id != "" {
+ params["GroupId."+strconv.Itoa(i)] = g.Id
+ i++
+ } else {
+ params["GroupName."+strconv.Itoa(j)] = g.Name
+ j++
+ }
+ }
+ filter.addParams(params)
+
+ resp = &SecurityGroupsResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteSecurityGroup removes the given security group in EC2.
+//
+// See http://goo.gl/QJJDO for more details.
+func (ec2 *EC2) DeleteSecurityGroup(group SecurityGroup) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteSecurityGroup")
+ if group.Id != "" {
+ params["GroupId"] = group.Id
+ } else {
+ params["GroupName"] = group.Name
+ }
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// AuthorizeSecurityGroup creates an allowance for clients matching the provided
+// rules to access instances within the given security group.
+//
+// See http://goo.gl/u2sDJ for more details.
+func (ec2 *EC2) AuthorizeSecurityGroup(group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
+ return ec2.authOrRevoke("AuthorizeSecurityGroupIngress", group, perms)
+}
+
+// AuthorizeSecurityGroupEgress creates an allowance for clients matching the provided
+// rules for egress access.
+//
+// See http://goo.gl/UHnH4L for more details.
+func (ec2 *EC2) AuthorizeSecurityGroupEgress(group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
+ return ec2.authOrRevoke("AuthorizeSecurityGroupEgress", group, perms)
+}
+
+// RevokeSecurityGroup revokes permissions from a group.
+//
+// See http://goo.gl/ZgdxA for more details.
+func (ec2 *EC2) RevokeSecurityGroup(group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
+ return ec2.authOrRevoke("RevokeSecurityGroupIngress", group, perms)
+}
+
+func (ec2 *EC2) authOrRevoke(op string, group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
+ params := makeParams(op)
+ if group.Id != "" {
+ params["GroupId"] = group.Id
+ } else {
+ params["GroupName"] = group.Name
+ }
+
+ for i, perm := range perms {
+ prefix := "IpPermissions." + strconv.Itoa(i+1)
+ params[prefix+".IpProtocol"] = perm.Protocol
+ params[prefix+".FromPort"] = strconv.Itoa(perm.FromPort)
+ params[prefix+".ToPort"] = strconv.Itoa(perm.ToPort)
+ for j, ip := range perm.SourceIPs {
+ params[prefix+".IpRanges."+strconv.Itoa(j+1)+".CidrIp"] = ip
+ }
+ for j, g := range perm.SourceGroups {
+ subprefix := prefix + ".Groups." + strconv.Itoa(j+1)
+ if g.OwnerId != "" {
+ params[subprefix+".UserId"] = g.OwnerId
+ }
+ if g.Id != "" {
+ params[subprefix+".GroupId"] = g.Id
+ } else {
+ params[subprefix+".GroupName"] = g.Name
+ }
+ }
+ }
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ResourceTag represents key-value metadata used to classify and organize
+// EC2 instances.
+//
+// See http://goo.gl/bncl3 for more details
+type Tag struct {
+ Key string `xml:"key"`
+ Value string `xml:"value"`
+}
+
+// CreateTags adds or overwrites one or more tags for the specified taggable resources.
+// For a list of tagable resources, see: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html
+//
+// See http://goo.gl/Vmkqc for more details
+func (ec2 *EC2) CreateTags(resourceIds []string, tags []Tag) (resp *SimpleResp, err error) {
+ params := makeParams("CreateTags")
+ addParamsList(params, "ResourceId", resourceIds)
+
+ for j, tag := range tags {
+ params["Tag."+strconv.Itoa(j+1)+".Key"] = tag.Key
+ params["Tag."+strconv.Itoa(j+1)+".Value"] = tag.Value
+ }
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Response to a StartInstances request.
+//
+// See http://goo.gl/awKeF for more details.
+type StartInstanceResp struct {
+ RequestId string `xml:"requestId"`
+ StateChanges []InstanceStateChange `xml:"instancesSet>item"`
+}
+
+// Response to a StopInstances request.
+//
+// See http://goo.gl/436dJ for more details.
+type StopInstanceResp struct {
+ RequestId string `xml:"requestId"`
+ StateChanges []InstanceStateChange `xml:"instancesSet>item"`
+}
+
+// StartInstances starts an Amazon EBS-backed AMI that you've previously stopped.
+//
+// See http://goo.gl/awKeF for more details.
+func (ec2 *EC2) StartInstances(ids ...string) (resp *StartInstanceResp, err error) {
+ params := makeParams("StartInstances")
+ addParamsList(params, "InstanceId", ids)
+ resp = &StartInstanceResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// StopInstances requests stopping one or more Amazon EBS-backed instances.
+//
+// See http://goo.gl/436dJ for more details.
+func (ec2 *EC2) StopInstances(ids ...string) (resp *StopInstanceResp, err error) {
+ params := makeParams("StopInstances")
+ addParamsList(params, "InstanceId", ids)
+ resp = &StopInstanceResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// RebootInstance requests a reboot of one or more instances. This operation is asynchronous;
+// it only queues a request to reboot the specified instance(s). The operation will succeed
+// if the instances are valid and belong to you.
+//
+// Requests to reboot terminated instances are ignored.
+//
+// See http://goo.gl/baoUf for more details.
+func (ec2 *EC2) RebootInstances(ids ...string) (resp *SimpleResp, err error) {
+ params := makeParams("RebootInstances")
+ addParamsList(params, "InstanceId", ids)
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// The ModifyInstanceAttribute request parameters.
+type ModifyInstance struct {
+ InstanceType string
+ BlockDevices []BlockDeviceMapping
+ DisableAPITermination bool
+ EbsOptimized bool
+ SecurityGroups []SecurityGroup
+ ShutdownBehavior string
+ KernelId string
+ RamdiskId string
+ SourceDestCheck bool
+ SriovNetSupport bool
+ UserData []byte
+
+ SetSourceDestCheck bool
+}
+
+// Response to a ModifyInstanceAttribute request.
+//
+// http://goo.gl/icuXh5 for more details.
+type ModifyInstanceResp struct {
+ RequestId string `xml:"requestId"`
+ Return bool `xml:"return"`
+}
+
+// ModifyImageAttribute modifies the specified attribute of the specified instance.
+// You can specify only one attribute at a time. To modify some attributes, the
+// instance must be stopped.
+//
+// See http://goo.gl/icuXh5 for more details.
+func (ec2 *EC2) ModifyInstance(instId string, options *ModifyInstance) (resp *ModifyInstanceResp, err error) {
+ params := makeParams("ModifyInstanceAttribute")
+ params["InstanceId"] = instId
+ addBlockDeviceParams("", params, options.BlockDevices)
+
+ if options.InstanceType != "" {
+ params["InstanceType.Value"] = options.InstanceType
+ }
+
+ if options.DisableAPITermination {
+ params["DisableApiTermination.Value"] = "true"
+ }
+
+ if options.EbsOptimized {
+ params["EbsOptimized"] = "true"
+ }
+
+ if options.ShutdownBehavior != "" {
+ params["InstanceInitiatedShutdownBehavior.Value"] = options.ShutdownBehavior
+ }
+
+ if options.KernelId != "" {
+ params["Kernel.Value"] = options.KernelId
+ }
+
+ if options.RamdiskId != "" {
+ params["Ramdisk.Value"] = options.RamdiskId
+ }
+
+ if options.SourceDestCheck || options.SetSourceDestCheck {
+ if options.SourceDestCheck {
+ params["SourceDestCheck.Value"] = "true"
+ } else {
+ params["SourceDestCheck.Value"] = "false"
+ }
+ }
+
+ if options.SriovNetSupport {
+ params["SriovNetSupport.Value"] = "simple"
+ }
+
+ if options.UserData != nil {
+ userData := make([]byte, b64.EncodedLen(len(options.UserData)))
+ b64.Encode(userData, options.UserData)
+ params["UserData"] = string(userData)
+ }
+
+ i := 1
+ for _, g := range options.SecurityGroups {
+ if g.Id != "" {
+ params["GroupId."+strconv.Itoa(i)] = g.Id
+ i++
+ }
+ }
+
+ resp = &ModifyInstanceResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ resp = nil
+ }
+ return
+}
+
+// ----------------------------------------------------------------------------
+// VPC management functions and types.
+
+// The CreateVpc request parameters
+//
+// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVpc.html
+type CreateVpc struct {
+ CidrBlock string
+ InstanceTenancy string
+}
+
+// Response to a CreateVpc request
+type CreateVpcResp struct {
+ RequestId string `xml:"requestId"`
+ VPC VPC `xml:"vpc"`
+}
+
+// CreateInternetGateway request parameters.
+//
+// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateInternetGateway.html
+type CreateInternetGateway struct{}
+
+// CreateInternetGateway response
+type CreateInternetGatewayResp struct {
+ RequestId string `xml:"requestId"`
+ InternetGateway InternetGateway `xml:"internetGateway"`
+}
+
+// The CreateRouteTable request parameters.
+//
+// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateRouteTable.html
+type CreateRouteTable struct {
+ VpcId string
+}
+
+// Response to a CreateRouteTable request.
+type CreateRouteTableResp struct {
+ RequestId string `xml:"requestId"`
+ RouteTable RouteTable `xml:"routeTable"`
+}
+
+// CreateRoute request parameters
+//
+// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateRoute.html
+type CreateRoute struct {
+ RouteTableId string
+ DestinationCidrBlock string
+ GatewayId string
+ InstanceId string
+ NetworkInterfaceId string
+ VpcPeeringConnectionId string
+}
+type ReplaceRoute struct {
+ RouteTableId string
+ DestinationCidrBlock string
+ GatewayId string
+ InstanceId string
+ NetworkInterfaceId string
+ VpcPeeringConnectionId string
+}
+
+type AssociateRouteTableResp struct {
+ RequestId string `xml:"requestId"`
+ AssociationId string `xml:"associationId"`
+}
+type ReassociateRouteTableResp struct {
+ RequestId string `xml:"requestId"`
+ AssociationId string `xml:"newAssociationId"`
+}
+
+// The CreateSubnet request parameters
+//
+// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSubnet.html
+type CreateSubnet struct {
+ VpcId string
+ CidrBlock string
+ AvailabilityZone string
+}
+
+// Response to a CreateSubnet request
+type CreateSubnetResp struct {
+ RequestId string `xml:"requestId"`
+ Subnet Subnet `xml:"subnet"`
+}
+
+// Response to a DescribeInternetGateways request.
+type InternetGatewaysResp struct {
+ RequestId string `xml:"requestId"`
+ InternetGateways []InternetGateway `xml:"internetGatewaySet>item"`
+}
+
+// Response to a DescribeRouteTables request.
+type RouteTablesResp struct {
+ RequestId string `xml:"requestId"`
+ RouteTables []RouteTable `xml:"routeTableSet>item"`
+}
+
+// Response to a DescribeVpcs request.
+type VpcsResp struct {
+ RequestId string `xml:"requestId"`
+ VPCs []VPC `xml:"vpcSet>item"`
+}
+
+// Internet Gateway
+type InternetGateway struct {
+ InternetGatewayId string `xml:"internetGatewayId"`
+ Attachments []InternetGatewayAttachment `xml:"attachmentSet>item"`
+ Tags []Tag `xml:"tagSet>item"`
+}
+
+type InternetGatewayAttachment struct {
+ VpcId string `xml:"vpcId"`
+ State string `xml:"state"`
+}
+
+// Routing Table
+type RouteTable struct {
+ RouteTableId string `xml:"routeTableId"`
+ VpcId string `xml:"vpcId"`
+ Associations []RouteTableAssociation `xml:"associationSet>item"`
+ Routes []Route `xml:"routeSet>item"`
+ Tags []Tag `xml:"tagSet>item"`
+}
+
+type RouteTableAssociation struct {
+ AssociationId string `xml:"routeTableAssociationId"`
+ RouteTableId string `xml:"routeTableId"`
+ SubnetId string `xml:"subnetId"`
+ Main bool `xml:"main"`
+}
+
+type Route struct {
+ DestinationCidrBlock string `xml:"destinationCidrBlock"`
+ GatewayId string `xml:"gatewayId"`
+ InstanceId string `xml:"instanceId"`
+ InstanceOwnerId string `xml:"instanceOwnerId"`
+ NetworkInterfaceId string `xml:"networkInterfaceId"`
+ State string `xml:"state"`
+ Origin string `xml:"origin"`
+ VpcPeeringConnectionId string `xml:"vpcPeeringConnectionId"`
+}
+
+// Subnet
+type Subnet struct {
+ SubnetId string `xml:"subnetId"`
+ State string `xml:"state"`
+ VpcId string `xml:"vpcId"`
+ CidrBlock string `xml:"cidrBlock"`
+ AvailableIpAddressCount int `xml:"availableIpAddressCount"`
+ AvailabilityZone string `xml:"availabilityZone"`
+ DefaultForAZ bool `xml:"defaultForAz"`
+ MapPublicIpOnLaunch bool `xml:"mapPublicIpOnLaunch"`
+ Tags []Tag `xml:"tagSet>item"`
+}
+
+// VPC represents a single VPC.
+type VPC struct {
+ VpcId string `xml:"vpcId"`
+ State string `xml:"state"`
+ CidrBlock string `xml:"cidrBlock"`
+ DHCPOptionsID string `xml:"dhcpOptionsId"`
+ InstanceTenancy string `xml:"instanceTenancy"`
+ IsDefault bool `xml:"isDefault"`
+ Tags []Tag `xml:"tagSet>item"`
+}
+
+// Response to a DescribeSubnets request.
+type SubnetsResp struct {
+ RequestId string `xml:"requestId"`
+ Subnets []Subnet `xml:"subnetSet>item"`
+}
+
+// Create a new VPC.
+func (ec2 *EC2) CreateVpc(options *CreateVpc) (resp *CreateVpcResp, err error) {
+ params := makeParams("CreateVpc")
+ params["CidrBlock"] = options.CidrBlock
+
+ if options.InstanceTenancy != "" {
+ params["InstanceTenancy"] = options.InstanceTenancy
+ }
+
+ resp = &CreateVpcResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Delete a VPC.
+func (ec2 *EC2) DeleteVpc(id string) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteVpc")
+ params["VpcId"] = id
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// DescribeVpcs
+//
+// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeVpcs.html
+func (ec2 *EC2) DescribeVpcs(ids []string, filter *Filter) (resp *VpcsResp, err error) {
+ params := makeParams("DescribeVpcs")
+ addParamsList(params, "VpcId", ids)
+ filter.addParams(params)
+ resp = &VpcsResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Create a new subnet.
+func (ec2 *EC2) CreateSubnet(options *CreateSubnet) (resp *CreateSubnetResp, err error) {
+ params := makeParams("CreateSubnet")
+ params["AvailabilityZone"] = options.AvailabilityZone
+ params["CidrBlock"] = options.CidrBlock
+ params["VpcId"] = options.VpcId
+
+ resp = &CreateSubnetResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Delete a Subnet.
+func (ec2 *EC2) DeleteSubnet(id string) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteSubnet")
+ params["SubnetId"] = id
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// DescribeSubnets
+//
+// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html
+func (ec2 *EC2) DescribeSubnets(ids []string, filter *Filter) (resp *SubnetsResp, err error) {
+ params := makeParams("DescribeSubnets")
+ addParamsList(params, "SubnetId", ids)
+ filter.addParams(params)
+
+ resp = &SubnetsResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Create a new internet gateway.
+func (ec2 *EC2) CreateInternetGateway(
+ options *CreateInternetGateway) (resp *CreateInternetGatewayResp, err error) {
+ params := makeParams("CreateInternetGateway")
+
+ resp = &CreateInternetGatewayResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Attach an InternetGateway.
+func (ec2 *EC2) AttachInternetGateway(id, vpcId string) (resp *SimpleResp, err error) {
+ params := makeParams("AttachInternetGateway")
+ params["InternetGatewayId"] = id
+ params["VpcId"] = vpcId
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Detach an InternetGateway.
+func (ec2 *EC2) DetachInternetGateway(id, vpcId string) (resp *SimpleResp, err error) {
+ params := makeParams("DetachInternetGateway")
+ params["InternetGatewayId"] = id
+ params["VpcId"] = vpcId
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Delete an InternetGateway.
+func (ec2 *EC2) DeleteInternetGateway(id string) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteInternetGateway")
+ params["InternetGatewayId"] = id
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// DescribeInternetGateways
+//
+// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInternetGateways.html
+func (ec2 *EC2) DescribeInternetGateways(ids []string, filter *Filter) (resp *InternetGatewaysResp, err error) {
+ params := makeParams("DescribeInternetGateways")
+ addParamsList(params, "InternetGatewayId", ids)
+ filter.addParams(params)
+
+ resp = &InternetGatewaysResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Create a new routing table.
+func (ec2 *EC2) CreateRouteTable(
+ options *CreateRouteTable) (resp *CreateRouteTableResp, err error) {
+ params := makeParams("CreateRouteTable")
+ params["VpcId"] = options.VpcId
+
+ resp = &CreateRouteTableResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Delete a RouteTable.
+func (ec2 *EC2) DeleteRouteTable(id string) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteRouteTable")
+ params["RouteTableId"] = id
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// DescribeRouteTables
+//
+// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeRouteTables.html
+func (ec2 *EC2) DescribeRouteTables(ids []string, filter *Filter) (resp *RouteTablesResp, err error) {
+ params := makeParams("DescribeRouteTables")
+ addParamsList(params, "RouteTableId", ids)
+ filter.addParams(params)
+
+ resp = &RouteTablesResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+
+ return
+}
+
+// Associate a routing table.
+func (ec2 *EC2) AssociateRouteTable(id, subnetId string) (*AssociateRouteTableResp, error) {
+ params := makeParams("AssociateRouteTable")
+ params["RouteTableId"] = id
+ params["SubnetId"] = subnetId
+
+ resp := &AssociateRouteTableResp{}
+ err := ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Disassociate a routing table.
+func (ec2 *EC2) DisassociateRouteTable(id string) (*SimpleResp, error) {
+ params := makeParams("DisassociateRouteTable")
+ params["AssociationId"] = id
+
+ resp := &SimpleResp{}
+ err := ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Re-associate a routing table.
+func (ec2 *EC2) ReassociateRouteTable(id, routeTableId string) (*ReassociateRouteTableResp, error) {
+ params := makeParams("ReplaceRouteTableAssociation")
+ params["AssociationId"] = id
+ params["RouteTableId"] = routeTableId
+
+ resp := &ReassociateRouteTableResp{}
+ err := ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Create a new route.
+func (ec2 *EC2) CreateRoute(options *CreateRoute) (resp *SimpleResp, err error) {
+ params := makeParams("CreateRoute")
+ params["RouteTableId"] = options.RouteTableId
+ params["DestinationCidrBlock"] = options.DestinationCidrBlock
+
+ if v := options.GatewayId; v != "" {
+ params["GatewayId"] = v
+ }
+ if v := options.InstanceId; v != "" {
+ params["InstanceId"] = v
+ }
+ if v := options.NetworkInterfaceId; v != "" {
+ params["NetworkInterfaceId"] = v
+ }
+ if v := options.VpcPeeringConnectionId; v != "" {
+ params["VpcPeeringConnectionId"] = v
+ }
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Delete a Route.
+func (ec2 *EC2) DeleteRoute(routeTableId, cidr string) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteRoute")
+ params["RouteTableId"] = routeTableId
+ params["DestinationCidrBlock"] = cidr
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Replace a new route.
+func (ec2 *EC2) ReplaceRoute(options *ReplaceRoute) (resp *SimpleResp, err error) {
+ params := makeParams("ReplaceRoute")
+ params["RouteTableId"] = options.RouteTableId
+ params["DestinationCidrBlock"] = options.DestinationCidrBlock
+
+ if v := options.GatewayId; v != "" {
+ params["GatewayId"] = v
+ }
+ if v := options.InstanceId; v != "" {
+ params["InstanceId"] = v
+ }
+ if v := options.NetworkInterfaceId; v != "" {
+ params["NetworkInterfaceId"] = v
+ }
+ if v := options.VpcPeeringConnectionId; v != "" {
+ params["VpcPeeringConnectionId"] = v
+ }
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// The ResetImageAttribute request parameters.
+type ResetImageAttribute struct {
+ Attribute string
+}
+
+// ResetImageAttribute resets an attribute of an AMI to its default value.
+//
+// http://goo.gl/r6ZCPm for more details.
+func (ec2 *EC2) ResetImageAttribute(imageId string, options *ResetImageAttribute) (resp *SimpleResp, err error) {
+ params := makeParams("ResetImageAttribute")
+ params["ImageId"] = imageId
+
+ if options.Attribute != "" {
+ params["Attribute"] = options.Attribute
+ }
+
+ resp = &SimpleResp{}
+ err = ec2.query(params, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2_test.go
new file mode 100644
index 00000000..4d0c08a3
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2_test.go
@@ -0,0 +1,1237 @@
+package ec2_test
+
+import (
+ "testing"
+
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/ec2"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+var _ = Suite(&S{})
+
+type S struct {
+ ec2 *ec2.EC2
+}
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ s.ec2 = ec2.NewWithClient(
+ auth,
+ aws.Region{EC2Endpoint: testServer.URL},
+ testutil.DefaultClient,
+ )
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) TestRunInstancesErrorDump(c *C) {
+ testServer.Response(400, nil, ErrorDump)
+
+ options := ec2.RunInstances{
+ ImageId: "ami-a6f504cf", // Ubuntu Maverick, i386, instance store
+ InstanceType: "t1.micro", // Doesn't work with micro, results in 400.
+ }
+
+ msg := `AMIs with an instance-store root device are not supported for the instance type 't1\.micro'\.`
+
+ resp, err := s.ec2.RunInstances(&options)
+
+ testServer.WaitRequest()
+
+ c.Assert(resp, IsNil)
+ c.Assert(err, ErrorMatches, msg+` \(UnsupportedOperation\)`)
+
+ ec2err, ok := err.(*ec2.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(ec2err.StatusCode, Equals, 400)
+ c.Assert(ec2err.Code, Equals, "UnsupportedOperation")
+ c.Assert(ec2err.Message, Matches, msg)
+ c.Assert(ec2err.RequestId, Equals, "0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4")
+}
+
+func (s *S) TestRequestSpotInstancesErrorDump(c *C) {
+ testServer.Response(400, nil, ErrorDump)
+
+ options := ec2.RequestSpotInstances{
+ SpotPrice: "0.01",
+ ImageId: "ami-a6f504cf", // Ubuntu Maverick, i386, instance store
+ InstanceType: "t1.micro", // Doesn't work with micro, results in 400.
+ }
+
+ msg := `AMIs with an instance-store root device are not supported for the instance type 't1\.micro'\.`
+
+ resp, err := s.ec2.RequestSpotInstances(&options)
+
+ testServer.WaitRequest()
+
+ c.Assert(resp, IsNil)
+ c.Assert(err, ErrorMatches, msg+` \(UnsupportedOperation\)`)
+
+ ec2err, ok := err.(*ec2.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(ec2err.StatusCode, Equals, 400)
+ c.Assert(ec2err.Code, Equals, "UnsupportedOperation")
+ c.Assert(ec2err.Message, Matches, msg)
+ c.Assert(ec2err.RequestId, Equals, "0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4")
+}
+
+func (s *S) TestRunInstancesErrorWithoutXML(c *C) {
+ testServer.Responses(5, 500, nil, "")
+ options := ec2.RunInstances{ImageId: "image-id"}
+
+ resp, err := s.ec2.RunInstances(&options)
+
+ testServer.WaitRequest()
+
+ c.Assert(resp, IsNil)
+ c.Assert(err, ErrorMatches, "500 Internal Server Error")
+
+ ec2err, ok := err.(*ec2.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(ec2err.StatusCode, Equals, 500)
+ c.Assert(ec2err.Code, Equals, "")
+ c.Assert(ec2err.Message, Equals, "500 Internal Server Error")
+ c.Assert(ec2err.RequestId, Equals, "")
+}
+
+func (s *S) TestRequestSpotInstancesErrorWithoutXML(c *C) {
+ testServer.Responses(5, 500, nil, "")
+ options := ec2.RequestSpotInstances{SpotPrice: "spot-price", ImageId: "image-id"}
+
+ resp, err := s.ec2.RequestSpotInstances(&options)
+
+ testServer.WaitRequest()
+
+ c.Assert(resp, IsNil)
+ c.Assert(err, ErrorMatches, "500 Internal Server Error")
+
+ ec2err, ok := err.(*ec2.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(ec2err.StatusCode, Equals, 500)
+ c.Assert(ec2err.Code, Equals, "")
+ c.Assert(ec2err.Message, Equals, "500 Internal Server Error")
+ c.Assert(ec2err.RequestId, Equals, "")
+}
+
+func (s *S) TestRunInstancesExample(c *C) {
+ testServer.Response(200, nil, RunInstancesExample)
+
+ options := ec2.RunInstances{
+ KeyName: "my-keys",
+ ImageId: "image-id",
+ InstanceType: "inst-type",
+ SecurityGroups: []ec2.SecurityGroup{{Name: "g1"}, {Id: "g2"}, {Name: "g3"}, {Id: "g4"}},
+ UserData: []byte("1234"),
+ KernelId: "kernel-id",
+ RamdiskId: "ramdisk-id",
+ AvailZone: "zone",
+ PlacementGroupName: "group",
+ Monitoring: true,
+ SubnetId: "subnet-id",
+ DisableAPITermination: true,
+ ShutdownBehavior: "terminate",
+ PrivateIPAddress: "10.0.0.25",
+ BlockDevices: []ec2.BlockDeviceMapping{
+ {DeviceName: "/dev/sdb", VirtualName: "ephemeral0"},
+ {DeviceName: "/dev/sdc", SnapshotId: "snap-a08912c9", DeleteOnTermination: true},
+ },
+ }
+ resp, err := s.ec2.RunInstances(&options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"RunInstances"})
+ c.Assert(req.Form["ImageId"], DeepEquals, []string{"image-id"})
+ c.Assert(req.Form["MinCount"], DeepEquals, []string{"1"})
+ c.Assert(req.Form["MaxCount"], DeepEquals, []string{"1"})
+ c.Assert(req.Form["KeyName"], DeepEquals, []string{"my-keys"})
+ c.Assert(req.Form["InstanceType"], DeepEquals, []string{"inst-type"})
+ c.Assert(req.Form["SecurityGroup.1"], DeepEquals, []string{"g1"})
+ c.Assert(req.Form["SecurityGroup.2"], DeepEquals, []string{"g3"})
+ c.Assert(req.Form["SecurityGroupId.1"], DeepEquals, []string{"g2"})
+ c.Assert(req.Form["SecurityGroupId.2"], DeepEquals, []string{"g4"})
+ c.Assert(req.Form["UserData"], DeepEquals, []string{"MTIzNA=="})
+ c.Assert(req.Form["KernelId"], DeepEquals, []string{"kernel-id"})
+ c.Assert(req.Form["RamdiskId"], DeepEquals, []string{"ramdisk-id"})
+ c.Assert(req.Form["Placement.AvailabilityZone"], DeepEquals, []string{"zone"})
+ c.Assert(req.Form["Placement.GroupName"], DeepEquals, []string{"group"})
+ c.Assert(req.Form["Monitoring.Enabled"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["SubnetId"], DeepEquals, []string{"subnet-id"})
+ c.Assert(req.Form["DisableApiTermination"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], DeepEquals, []string{"terminate"})
+ c.Assert(req.Form["PrivateIpAddress"], DeepEquals, []string{"10.0.0.25"})
+ c.Assert(req.Form["BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sdb"})
+ c.Assert(req.Form["BlockDeviceMapping.1.VirtualName"], DeepEquals, []string{"ephemeral0"})
+ c.Assert(req.Form["BlockDeviceMapping.2.Ebs.SnapshotId"], DeepEquals, []string{"snap-a08912c9"})
+ c.Assert(req.Form["BlockDeviceMapping.2.Ebs.DeleteOnTermination"], DeepEquals, []string{"true"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.ReservationId, Equals, "r-47a5402e")
+ c.Assert(resp.OwnerId, Equals, "999988887777")
+ c.Assert(resp.SecurityGroups, DeepEquals, []ec2.SecurityGroup{{Name: "default", Id: "sg-67ad940e"}})
+ c.Assert(resp.Instances, HasLen, 3)
+
+ i0 := resp.Instances[0]
+ c.Assert(i0.InstanceId, Equals, "i-2ba64342")
+ c.Assert(i0.InstanceType, Equals, "m1.small")
+ c.Assert(i0.ImageId, Equals, "ami-60a54009")
+ c.Assert(i0.Monitoring, Equals, "enabled")
+ c.Assert(i0.KeyName, Equals, "example-key-name")
+ c.Assert(i0.AMILaunchIndex, Equals, 0)
+ c.Assert(i0.VirtType, Equals, "paravirtual")
+ c.Assert(i0.Hypervisor, Equals, "xen")
+
+ i1 := resp.Instances[1]
+ c.Assert(i1.InstanceId, Equals, "i-2bc64242")
+ c.Assert(i1.InstanceType, Equals, "m1.small")
+ c.Assert(i1.ImageId, Equals, "ami-60a54009")
+ c.Assert(i1.Monitoring, Equals, "enabled")
+ c.Assert(i1.KeyName, Equals, "example-key-name")
+ c.Assert(i1.AMILaunchIndex, Equals, 1)
+ c.Assert(i1.VirtType, Equals, "paravirtual")
+ c.Assert(i1.Hypervisor, Equals, "xen")
+
+ i2 := resp.Instances[2]
+ c.Assert(i2.InstanceId, Equals, "i-2be64332")
+ c.Assert(i2.InstanceType, Equals, "m1.small")
+ c.Assert(i2.ImageId, Equals, "ami-60a54009")
+ c.Assert(i2.Monitoring, Equals, "enabled")
+ c.Assert(i2.KeyName, Equals, "example-key-name")
+ c.Assert(i2.AMILaunchIndex, Equals, 2)
+ c.Assert(i2.VirtType, Equals, "paravirtual")
+ c.Assert(i2.Hypervisor, Equals, "xen")
+}
+
+func (s *S) TestRequestSpotInstancesExample(c *C) {
+ testServer.Response(200, nil, RequestSpotInstancesExample)
+
+ options := ec2.RequestSpotInstances{
+ SpotPrice: "0.5",
+ KeyName: "my-keys",
+ ImageId: "image-id",
+ InstanceType: "inst-type",
+ SecurityGroups: []ec2.SecurityGroup{{Name: "g1"}, {Id: "g2"}, {Name: "g3"}, {Id: "g4"}},
+ UserData: []byte("1234"),
+ KernelId: "kernel-id",
+ RamdiskId: "ramdisk-id",
+ AvailZone: "zone",
+ PlacementGroupName: "group",
+ Monitoring: true,
+ SubnetId: "subnet-id",
+ PrivateIPAddress: "10.0.0.25",
+ BlockDevices: []ec2.BlockDeviceMapping{
+ {DeviceName: "/dev/sdb", VirtualName: "ephemeral0"},
+ {DeviceName: "/dev/sdc", SnapshotId: "snap-a08912c9", DeleteOnTermination: true},
+ },
+ }
+ resp, err := s.ec2.RequestSpotInstances(&options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"RequestSpotInstances"})
+ c.Assert(req.Form["SpotPrice"], DeepEquals, []string{"0.5"})
+ c.Assert(req.Form["LaunchSpecification.ImageId"], DeepEquals, []string{"image-id"})
+ c.Assert(req.Form["LaunchSpecification.KeyName"], DeepEquals, []string{"my-keys"})
+ c.Assert(req.Form["LaunchSpecification.InstanceType"], DeepEquals, []string{"inst-type"})
+ c.Assert(req.Form["LaunchSpecification.SecurityGroup.1"], DeepEquals, []string{"g1"})
+ c.Assert(req.Form["LaunchSpecification.SecurityGroup.2"], DeepEquals, []string{"g3"})
+ c.Assert(req.Form["LaunchSpecification.SecurityGroupId.1"], DeepEquals, []string{"g2"})
+ c.Assert(req.Form["LaunchSpecification.SecurityGroupId.2"], DeepEquals, []string{"g4"})
+ c.Assert(req.Form["LaunchSpecification.UserData"], DeepEquals, []string{"MTIzNA=="})
+ c.Assert(req.Form["LaunchSpecification.KernelId"], DeepEquals, []string{"kernel-id"})
+ c.Assert(req.Form["LaunchSpecification.RamdiskId"], DeepEquals, []string{"ramdisk-id"})
+ c.Assert(req.Form["LaunchSpecification.Placement.AvailabilityZone"], DeepEquals, []string{"zone"})
+ c.Assert(req.Form["LaunchSpecification.Placement.GroupName"], DeepEquals, []string{"group"})
+ c.Assert(req.Form["LaunchSpecification.Monitoring.Enabled"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["LaunchSpecification.SubnetId"], DeepEquals, []string{"subnet-id"})
+ c.Assert(req.Form["LaunchSpecification.PrivateIpAddress"], DeepEquals, []string{"10.0.0.25"})
+ c.Assert(req.Form["LaunchSpecification.BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sdb"})
+ c.Assert(req.Form["LaunchSpecification.BlockDeviceMapping.1.VirtualName"], DeepEquals, []string{"ephemeral0"})
+ c.Assert(req.Form["LaunchSpecification.BlockDeviceMapping.2.Ebs.SnapshotId"], DeepEquals, []string{"snap-a08912c9"})
+ c.Assert(req.Form["LaunchSpecification.BlockDeviceMapping.2.Ebs.DeleteOnTermination"], DeepEquals, []string{"true"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.SpotRequestResults[0].SpotRequestId, Equals, "sir-1a2b3c4d")
+ c.Assert(resp.SpotRequestResults[0].SpotPrice, Equals, "0.5")
+ c.Assert(resp.SpotRequestResults[0].State, Equals, "open")
+ c.Assert(resp.SpotRequestResults[0].SpotLaunchSpec.ImageId, Equals, "ami-1a2b3c4d")
+}
+
+func (s *S) TestCancelSpotRequestsExample(c *C) {
+ testServer.Response(200, nil, CancelSpotRequestsExample)
+
+ resp, err := s.ec2.CancelSpotRequests([]string{"s-1", "s-2"})
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CancelSpotInstanceRequests"})
+ c.Assert(req.Form["SpotInstanceRequestId.1"], DeepEquals, []string{"s-1"})
+ c.Assert(req.Form["SpotInstanceRequestId.2"], DeepEquals, []string{"s-2"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.CancelSpotRequestResults[0].SpotRequestId, Equals, "sir-1a2b3c4d")
+ c.Assert(resp.CancelSpotRequestResults[0].State, Equals, "cancelled")
+}
+
+func (s *S) TestTerminateInstancesExample(c *C) {
+ testServer.Response(200, nil, TerminateInstancesExample)
+
+ resp, err := s.ec2.TerminateInstances([]string{"i-1", "i-2"})
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"TerminateInstances"})
+ c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"})
+ c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"})
+ c.Assert(req.Form["UserData"], IsNil)
+ c.Assert(req.Form["KernelId"], IsNil)
+ c.Assert(req.Form["RamdiskId"], IsNil)
+ c.Assert(req.Form["Placement.AvailabilityZone"], IsNil)
+ c.Assert(req.Form["Placement.GroupName"], IsNil)
+ c.Assert(req.Form["Monitoring.Enabled"], IsNil)
+ c.Assert(req.Form["SubnetId"], IsNil)
+ c.Assert(req.Form["DisableApiTermination"], IsNil)
+ c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], IsNil)
+ c.Assert(req.Form["PrivateIpAddress"], IsNil)
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.StateChanges, HasLen, 1)
+ c.Assert(resp.StateChanges[0].InstanceId, Equals, "i-3ea74257")
+ c.Assert(resp.StateChanges[0].CurrentState.Code, Equals, 32)
+ c.Assert(resp.StateChanges[0].CurrentState.Name, Equals, "shutting-down")
+ c.Assert(resp.StateChanges[0].PreviousState.Code, Equals, 16)
+ c.Assert(resp.StateChanges[0].PreviousState.Name, Equals, "running")
+}
+
+func (s *S) TestDescribeSpotRequestsExample(c *C) {
+ testServer.Response(200, nil, DescribeSpotRequestsExample)
+
+ filter := ec2.NewFilter()
+ filter.Add("key1", "value1")
+ filter.Add("key2", "value2", "value3")
+
+ resp, err := s.ec2.DescribeSpotRequests([]string{"s-1", "s-2"}, filter)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSpotInstanceRequests"})
+ c.Assert(req.Form["SpotInstanceRequestId.1"], DeepEquals, []string{"s-1"})
+ c.Assert(req.Form["SpotInstanceRequestId.2"], DeepEquals, []string{"s-2"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "b1719f2a-5334-4479-b2f1-26926EXAMPLE")
+ c.Assert(resp.SpotRequestResults[0].SpotRequestId, Equals, "sir-1a2b3c4d")
+ c.Assert(resp.SpotRequestResults[0].State, Equals, "active")
+ c.Assert(resp.SpotRequestResults[0].SpotPrice, Equals, "0.5")
+ c.Assert(resp.SpotRequestResults[0].SpotLaunchSpec.ImageId, Equals, "ami-1a2b3c4d")
+}
+
+func (s *S) TestDescribeInstancesExample1(c *C) {
+ testServer.Response(200, nil, DescribeInstancesExample1)
+
+ filter := ec2.NewFilter()
+ filter.Add("key1", "value1")
+ filter.Add("key2", "value2", "value3")
+
+ resp, err := s.ec2.Instances([]string{"i-1", "i-2"}, nil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeInstances"})
+ c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"})
+ c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "98e3c9a4-848c-4d6d-8e8a-b1bdEXAMPLE")
+ c.Assert(resp.Reservations, HasLen, 2)
+
+ r0 := resp.Reservations[0]
+ c.Assert(r0.ReservationId, Equals, "r-b27e30d9")
+ c.Assert(r0.OwnerId, Equals, "999988887777")
+ c.Assert(r0.RequesterId, Equals, "854251627541")
+ c.Assert(r0.SecurityGroups, DeepEquals, []ec2.SecurityGroup{{Name: "default", Id: "sg-67ad940e"}})
+ c.Assert(r0.Instances, HasLen, 1)
+
+ r0i := r0.Instances[0]
+ c.Assert(r0i.InstanceId, Equals, "i-c5cd56af")
+ c.Assert(r0i.PrivateDNSName, Equals, "domU-12-31-39-10-56-34.compute-1.internal")
+ c.Assert(r0i.DNSName, Equals, "ec2-174-129-165-232.compute-1.amazonaws.com")
+ c.Assert(r0i.AvailZone, Equals, "us-east-1b")
+}
+
+func (s *S) TestDescribeInstancesExample2(c *C) {
+ testServer.Response(200, nil, DescribeInstancesExample2)
+
+ filter := ec2.NewFilter()
+ filter.Add("key1", "value1")
+ filter.Add("key2", "value2", "value3")
+
+ resp, err := s.ec2.Instances([]string{"i-1", "i-2"}, filter)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeInstances"})
+ c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"})
+ c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"})
+ c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
+ c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
+ c.Assert(req.Form["Filter.1.Value.2"], IsNil)
+ c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
+ c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
+ c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.Reservations, HasLen, 1)
+
+ r0 := resp.Reservations[0]
+ r0i := r0.Instances[0]
+ c.Assert(r0i.State.Code, Equals, 16)
+ c.Assert(r0i.State.Name, Equals, "running")
+
+ r0t0 := r0i.Tags[0]
+ r0t1 := r0i.Tags[1]
+ c.Assert(r0t0.Key, Equals, "webserver")
+ c.Assert(r0t0.Value, Equals, "")
+ c.Assert(r0t1.Key, Equals, "stack")
+ c.Assert(r0t1.Value, Equals, "Production")
+}
+
+func (s *S) TestCreateImageExample(c *C) {
+ testServer.Response(200, nil, CreateImageExample)
+
+ options := &ec2.CreateImage{
+ InstanceId: "i-123456",
+ Name: "foo",
+ Description: "Test CreateImage",
+ NoReboot: true,
+ BlockDevices: []ec2.BlockDeviceMapping{
+ {DeviceName: "/dev/sdb", VirtualName: "ephemeral0"},
+ {DeviceName: "/dev/sdc", SnapshotId: "snap-a08912c9", DeleteOnTermination: true},
+ },
+ }
+
+ resp, err := s.ec2.CreateImage(options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateImage"})
+ c.Assert(req.Form["InstanceId"], DeepEquals, []string{options.InstanceId})
+ c.Assert(req.Form["Name"], DeepEquals, []string{options.Name})
+ c.Assert(req.Form["Description"], DeepEquals, []string{options.Description})
+ c.Assert(req.Form["NoReboot"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sdb"})
+ c.Assert(req.Form["BlockDeviceMapping.1.VirtualName"], DeepEquals, []string{"ephemeral0"})
+ c.Assert(req.Form["BlockDeviceMapping.2.DeviceName"], DeepEquals, []string{"/dev/sdc"})
+ c.Assert(req.Form["BlockDeviceMapping.2.Ebs.SnapshotId"], DeepEquals, []string{"snap-a08912c9"})
+ c.Assert(req.Form["BlockDeviceMapping.2.Ebs.DeleteOnTermination"], DeepEquals, []string{"true"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.ImageId, Equals, "ami-4fa54026")
+}
+
+func (s *S) TestDescribeImagesExample(c *C) {
+ testServer.Response(200, nil, DescribeImagesExample)
+
+ filter := ec2.NewFilter()
+ filter.Add("key1", "value1")
+ filter.Add("key2", "value2", "value3")
+
+ resp, err := s.ec2.Images([]string{"ami-1", "ami-2"}, filter)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeImages"})
+ c.Assert(req.Form["ImageId.1"], DeepEquals, []string{"ami-1"})
+ c.Assert(req.Form["ImageId.2"], DeepEquals, []string{"ami-2"})
+ c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
+ c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
+ c.Assert(req.Form["Filter.1.Value.2"], IsNil)
+ c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
+ c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
+ c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "4a4a27a2-2e7c-475d-b35b-ca822EXAMPLE")
+ c.Assert(resp.Images, HasLen, 1)
+
+ i0 := resp.Images[0]
+ c.Assert(i0.Id, Equals, "ami-a2469acf")
+ c.Assert(i0.Type, Equals, "machine")
+ c.Assert(i0.Name, Equals, "example-marketplace-amzn-ami.1")
+ c.Assert(i0.Description, Equals, "Amazon Linux AMI i386 EBS")
+ c.Assert(i0.Location, Equals, "aws-marketplace/example-marketplace-amzn-ami.1")
+ c.Assert(i0.State, Equals, "available")
+ c.Assert(i0.Public, Equals, true)
+ c.Assert(i0.OwnerId, Equals, "123456789999")
+ c.Assert(i0.OwnerAlias, Equals, "aws-marketplace")
+ c.Assert(i0.Architecture, Equals, "i386")
+ c.Assert(i0.KernelId, Equals, "aki-805ea7e9")
+ c.Assert(i0.RootDeviceType, Equals, "ebs")
+ c.Assert(i0.RootDeviceName, Equals, "/dev/sda1")
+ c.Assert(i0.VirtualizationType, Equals, "paravirtual")
+ c.Assert(i0.Hypervisor, Equals, "xen")
+
+ c.Assert(i0.BlockDevices, HasLen, 1)
+ c.Assert(i0.BlockDevices[0].DeviceName, Equals, "/dev/sda1")
+ c.Assert(i0.BlockDevices[0].SnapshotId, Equals, "snap-787e9403")
+ c.Assert(i0.BlockDevices[0].VolumeSize, Equals, int64(8))
+ c.Assert(i0.BlockDevices[0].DeleteOnTermination, Equals, true)
+
+ testServer.Response(200, nil, DescribeImagesExample)
+ resp2, err := s.ec2.ImagesByOwners([]string{"ami-1", "ami-2"}, []string{"123456789999", "id2"}, filter)
+
+ req2 := testServer.WaitRequest()
+ c.Assert(req2.Form["Action"], DeepEquals, []string{"DescribeImages"})
+ c.Assert(req2.Form["ImageId.1"], DeepEquals, []string{"ami-1"})
+ c.Assert(req2.Form["ImageId.2"], DeepEquals, []string{"ami-2"})
+ c.Assert(req2.Form["Owner.1"], DeepEquals, []string{"123456789999"})
+ c.Assert(req2.Form["Owner.2"], DeepEquals, []string{"id2"})
+ c.Assert(req2.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
+ c.Assert(req2.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
+ c.Assert(req2.Form["Filter.1.Value.2"], IsNil)
+ c.Assert(req2.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
+ c.Assert(req2.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
+ c.Assert(req2.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp2.RequestId, Equals, "4a4a27a2-2e7c-475d-b35b-ca822EXAMPLE")
+ c.Assert(resp2.Images, HasLen, 1)
+
+ i1 := resp2.Images[0]
+ c.Assert(i1.Id, Equals, "ami-a2469acf")
+ c.Assert(i1.Type, Equals, "machine")
+ c.Assert(i1.Name, Equals, "example-marketplace-amzn-ami.1")
+ c.Assert(i1.Description, Equals, "Amazon Linux AMI i386 EBS")
+ c.Assert(i1.Location, Equals, "aws-marketplace/example-marketplace-amzn-ami.1")
+ c.Assert(i1.State, Equals, "available")
+ c.Assert(i1.Public, Equals, true)
+ c.Assert(i1.OwnerId, Equals, "123456789999")
+ c.Assert(i1.OwnerAlias, Equals, "aws-marketplace")
+ c.Assert(i1.Architecture, Equals, "i386")
+ c.Assert(i1.KernelId, Equals, "aki-805ea7e9")
+ c.Assert(i1.RootDeviceType, Equals, "ebs")
+ c.Assert(i1.RootDeviceName, Equals, "/dev/sda1")
+ c.Assert(i1.VirtualizationType, Equals, "paravirtual")
+ c.Assert(i1.Hypervisor, Equals, "xen")
+
+ c.Assert(i1.BlockDevices, HasLen, 1)
+ c.Assert(i1.BlockDevices[0].DeviceName, Equals, "/dev/sda1")
+ c.Assert(i1.BlockDevices[0].SnapshotId, Equals, "snap-787e9403")
+ c.Assert(i1.BlockDevices[0].VolumeSize, Equals, int64(8))
+ c.Assert(i1.BlockDevices[0].DeleteOnTermination, Equals, true)
+}
+
+func (s *S) TestImageAttributeExample(c *C) {
+ testServer.Response(200, nil, ImageAttributeExample)
+
+ resp, err := s.ec2.ImageAttribute("ami-61a54008", "launchPermission")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeImageAttribute"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.ImageId, Equals, "ami-61a54008")
+ c.Assert(resp.Group, Equals, "all")
+ c.Assert(resp.UserIds[0], Equals, "495219933132")
+}
+
+func (s *S) TestCreateSnapshotExample(c *C) {
+ testServer.Response(200, nil, CreateSnapshotExample)
+
+ resp, err := s.ec2.CreateSnapshot("vol-4d826724", "Daily Backup")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateSnapshot"})
+ c.Assert(req.Form["VolumeId"], DeepEquals, []string{"vol-4d826724"})
+ c.Assert(req.Form["Description"], DeepEquals, []string{"Daily Backup"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.Snapshot.Id, Equals, "snap-78a54011")
+ c.Assert(resp.Snapshot.VolumeId, Equals, "vol-4d826724")
+ c.Assert(resp.Snapshot.Status, Equals, "pending")
+ c.Assert(resp.Snapshot.StartTime, Equals, "2008-05-07T12:51:50.000Z")
+ c.Assert(resp.Snapshot.Progress, Equals, "60%")
+ c.Assert(resp.Snapshot.OwnerId, Equals, "111122223333")
+ c.Assert(resp.Snapshot.VolumeSize, Equals, "10")
+ c.Assert(resp.Snapshot.Description, Equals, "Daily Backup")
+}
+
+func (s *S) TestDeleteSnapshotsExample(c *C) {
+ testServer.Response(200, nil, DeleteSnapshotExample)
+
+ resp, err := s.ec2.DeleteSnapshots([]string{"snap-78a54011"})
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteSnapshot"})
+ c.Assert(req.Form["SnapshotId.1"], DeepEquals, []string{"snap-78a54011"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestDescribeSnapshotsExample(c *C) {
+ testServer.Response(200, nil, DescribeSnapshotsExample)
+
+ filter := ec2.NewFilter()
+ filter.Add("key1", "value1")
+ filter.Add("key2", "value2", "value3")
+
+ resp, err := s.ec2.Snapshots([]string{"snap-1", "snap-2"}, filter)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSnapshots"})
+ c.Assert(req.Form["SnapshotId.1"], DeepEquals, []string{"snap-1"})
+ c.Assert(req.Form["SnapshotId.2"], DeepEquals, []string{"snap-2"})
+ c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
+ c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
+ c.Assert(req.Form["Filter.1.Value.2"], IsNil)
+ c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
+ c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
+ c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.Snapshots, HasLen, 1)
+
+ s0 := resp.Snapshots[0]
+ c.Assert(s0.Id, Equals, "snap-1a2b3c4d")
+ c.Assert(s0.VolumeId, Equals, "vol-8875daef")
+ c.Assert(s0.VolumeSize, Equals, "15")
+ c.Assert(s0.Status, Equals, "pending")
+ c.Assert(s0.StartTime, Equals, "2010-07-29T04:12:01.000Z")
+ c.Assert(s0.Progress, Equals, "30%")
+ c.Assert(s0.OwnerId, Equals, "111122223333")
+ c.Assert(s0.Description, Equals, "Daily Backup")
+
+ c.Assert(s0.Tags, HasLen, 1)
+ c.Assert(s0.Tags[0].Key, Equals, "Purpose")
+ c.Assert(s0.Tags[0].Value, Equals, "demo_db_14_backup")
+}
+
+func (s *S) TestModifyImageAttributeExample(c *C) {
+ testServer.Response(200, nil, ModifyImageAttributeExample)
+
+ options := ec2.ModifyImageAttribute{
+ Description: "Test Description",
+ }
+
+ resp, err := s.ec2.ModifyImageAttribute("ami-4fa54026", &options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"ModifyImageAttribute"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestModifyImageAttributeExample_complex(c *C) {
+ testServer.Response(200, nil, ModifyImageAttributeExample)
+
+ options := ec2.ModifyImageAttribute{
+ AddUsers: []string{"u1", "u2"},
+ RemoveUsers: []string{"u3"},
+ AddGroups: []string{"g1", "g3"},
+ RemoveGroups: []string{"g2"},
+ Description: "Test Description",
+ }
+
+ resp, err := s.ec2.ModifyImageAttribute("ami-4fa54026", &options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"ModifyImageAttribute"})
+ c.Assert(req.Form["LaunchPermission.Add.1.UserId"], DeepEquals, []string{"u1"})
+ c.Assert(req.Form["LaunchPermission.Add.2.UserId"], DeepEquals, []string{"u2"})
+ c.Assert(req.Form["LaunchPermission.Remove.1.UserId"], DeepEquals, []string{"u3"})
+ c.Assert(req.Form["LaunchPermission.Add.1.Group"], DeepEquals, []string{"g1"})
+ c.Assert(req.Form["LaunchPermission.Add.2.Group"], DeepEquals, []string{"g3"})
+ c.Assert(req.Form["LaunchPermission.Remove.1.Group"], DeepEquals, []string{"g2"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestCopyImageExample(c *C) {
+ testServer.Response(200, nil, CopyImageExample)
+
+ options := ec2.CopyImage{
+ SourceRegion: "us-west-2",
+ SourceImageId: "ami-1a2b3c4d",
+ Description: "Test Description",
+ }
+
+ resp, err := s.ec2.CopyImage(&options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CopyImage"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "60bc441d-fa2c-494d-b155-5d6a3EXAMPLE")
+}
+
+func (s *S) TestCreateKeyPairExample(c *C) {
+ testServer.Response(200, nil, CreateKeyPairExample)
+
+ resp, err := s.ec2.CreateKeyPair("foo")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateKeyPair"})
+ c.Assert(req.Form["KeyName"], DeepEquals, []string{"foo"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.KeyName, Equals, "foo")
+ c.Assert(resp.KeyFingerprint, Equals, "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00")
+}
+
+func (s *S) TestDeleteKeyPairExample(c *C) {
+ testServer.Response(200, nil, DeleteKeyPairExample)
+
+ resp, err := s.ec2.DeleteKeyPair("foo")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteKeyPair"})
+ c.Assert(req.Form["KeyName"], DeepEquals, []string{"foo"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestCreateSecurityGroupExample(c *C) {
+ testServer.Response(200, nil, CreateSecurityGroupExample)
+
+ resp, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: "websrv", Description: "Web Servers"})
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateSecurityGroup"})
+ c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
+ c.Assert(req.Form["GroupDescription"], DeepEquals, []string{"Web Servers"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.Name, Equals, "websrv")
+ c.Assert(resp.Id, Equals, "sg-67ad940e")
+}
+
+func (s *S) TestDescribeSecurityGroupsExample(c *C) {
+ testServer.Response(200, nil, DescribeSecurityGroupsExample)
+
+ resp, err := s.ec2.SecurityGroups([]ec2.SecurityGroup{{Name: "WebServers"}, {Name: "RangedPortsBySource"}}, nil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroups"})
+ c.Assert(req.Form["GroupName.1"], DeepEquals, []string{"WebServers"})
+ c.Assert(req.Form["GroupName.2"], DeepEquals, []string{"RangedPortsBySource"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.Groups, HasLen, 2)
+
+ g0 := resp.Groups[0]
+ c.Assert(g0.OwnerId, Equals, "999988887777")
+ c.Assert(g0.Name, Equals, "WebServers")
+ c.Assert(g0.Id, Equals, "sg-67ad940e")
+ c.Assert(g0.Description, Equals, "Web Servers")
+ c.Assert(g0.IPPerms, HasLen, 1)
+
+ g0ipp := g0.IPPerms[0]
+ c.Assert(g0ipp.Protocol, Equals, "tcp")
+ c.Assert(g0ipp.FromPort, Equals, 80)
+ c.Assert(g0ipp.ToPort, Equals, 80)
+ c.Assert(g0ipp.SourceIPs, DeepEquals, []string{"0.0.0.0/0"})
+
+ g1 := resp.Groups[1]
+ c.Assert(g1.OwnerId, Equals, "999988887777")
+ c.Assert(g1.Name, Equals, "RangedPortsBySource")
+ c.Assert(g1.Id, Equals, "sg-76abc467")
+ c.Assert(g1.Description, Equals, "Group A")
+ c.Assert(g1.IPPerms, HasLen, 1)
+
+ g1ipp := g1.IPPerms[0]
+ c.Assert(g1ipp.Protocol, Equals, "tcp")
+ c.Assert(g1ipp.FromPort, Equals, 6000)
+ c.Assert(g1ipp.ToPort, Equals, 7000)
+ c.Assert(g1ipp.SourceIPs, IsNil)
+}
+
+func (s *S) TestDescribeSecurityGroupsExampleWithFilter(c *C) {
+ testServer.Response(200, nil, DescribeSecurityGroupsExample)
+
+ filter := ec2.NewFilter()
+ filter.Add("ip-permission.protocol", "tcp")
+ filter.Add("ip-permission.from-port", "22")
+ filter.Add("ip-permission.to-port", "22")
+ filter.Add("ip-permission.group-name", "app_server_group", "database_group")
+
+ _, err := s.ec2.SecurityGroups(nil, filter)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroups"})
+ c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"ip-permission.from-port"})
+ c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"22"})
+ c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"ip-permission.group-name"})
+ c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"app_server_group"})
+ c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"database_group"})
+ c.Assert(req.Form["Filter.3.Name"], DeepEquals, []string{"ip-permission.protocol"})
+ c.Assert(req.Form["Filter.3.Value.1"], DeepEquals, []string{"tcp"})
+ c.Assert(req.Form["Filter.4.Name"], DeepEquals, []string{"ip-permission.to-port"})
+ c.Assert(req.Form["Filter.4.Value.1"], DeepEquals, []string{"22"})
+
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestDescribeSecurityGroupsDumpWithGroup(c *C) {
+ testServer.Response(200, nil, DescribeSecurityGroupsDump)
+
+ resp, err := s.ec2.SecurityGroups(nil, nil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroups"})
+ c.Assert(err, IsNil)
+ c.Check(resp.Groups, HasLen, 1)
+ c.Check(resp.Groups[0].IPPerms, HasLen, 2)
+
+ ipp0 := resp.Groups[0].IPPerms[0]
+ c.Assert(ipp0.SourceIPs, IsNil)
+ c.Check(ipp0.Protocol, Equals, "icmp")
+ c.Assert(ipp0.SourceGroups, HasLen, 1)
+ c.Check(ipp0.SourceGroups[0].OwnerId, Equals, "12345")
+ c.Check(ipp0.SourceGroups[0].Name, Equals, "default")
+ c.Check(ipp0.SourceGroups[0].Id, Equals, "sg-67ad940e")
+
+ ipp1 := resp.Groups[0].IPPerms[1]
+ c.Check(ipp1.Protocol, Equals, "tcp")
+ c.Assert(ipp0.SourceIPs, IsNil)
+ c.Assert(ipp0.SourceGroups, HasLen, 1)
+ c.Check(ipp1.SourceGroups[0].Id, Equals, "sg-76abc467")
+ c.Check(ipp1.SourceGroups[0].OwnerId, Equals, "12345")
+ c.Check(ipp1.SourceGroups[0].Name, Equals, "other")
+}
+
+func (s *S) TestDeleteSecurityGroupExample(c *C) {
+ testServer.Response(200, nil, DeleteSecurityGroupExample)
+
+ resp, err := s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: "websrv"})
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteSecurityGroup"})
+ c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
+ c.Assert(req.Form["GroupId"], IsNil)
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestDeleteSecurityGroupExampleWithId(c *C) {
+ testServer.Response(200, nil, DeleteSecurityGroupExample)
+
+ // ignore return and error - we're only want to check the parameter handling.
+ s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name: "ignored"})
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["GroupName"], IsNil)
+ c.Assert(req.Form["GroupId"], DeepEquals, []string{"sg-67ad940e"})
+}
+
+func (s *S) TestAuthorizeSecurityGroupExample1(c *C) {
+ testServer.Response(200, nil, AuthorizeSecurityGroupIngressExample)
+
+ perms := []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 80,
+ ToPort: 80,
+ SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"},
+ }}
+ resp, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: "websrv"}, perms)
+
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"AuthorizeSecurityGroupIngress"})
+ c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
+ c.Assert(req.Form["IpPermissions.1.IpProtocol"], DeepEquals, []string{"tcp"})
+ c.Assert(req.Form["IpPermissions.1.FromPort"], DeepEquals, []string{"80"})
+ c.Assert(req.Form["IpPermissions.1.ToPort"], DeepEquals, []string{"80"})
+ c.Assert(req.Form["IpPermissions.1.IpRanges.1.CidrIp"], DeepEquals, []string{"205.192.0.0/16"})
+ c.Assert(req.Form["IpPermissions.1.IpRanges.2.CidrIp"], DeepEquals, []string{"205.159.0.0/16"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestAuthorizeSecurityGroupEgress(c *C) {
+ testServer.Response(200, nil, AuthorizeSecurityGroupEgressExample)
+
+ perms := []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 80,
+ ToPort: 80,
+ SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"},
+ }}
+ resp, err := s.ec2.AuthorizeSecurityGroupEgress(ec2.SecurityGroup{Name: "websrv"}, perms)
+
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"AuthorizeSecurityGroupEgress"})
+ c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
+ c.Assert(req.Form["IpPermissions.1.IpProtocol"], DeepEquals, []string{"tcp"})
+ c.Assert(req.Form["IpPermissions.1.FromPort"], DeepEquals, []string{"80"})
+ c.Assert(req.Form["IpPermissions.1.ToPort"], DeepEquals, []string{"80"})
+ c.Assert(req.Form["IpPermissions.1.IpRanges.1.CidrIp"], DeepEquals, []string{"205.192.0.0/16"})
+ c.Assert(req.Form["IpPermissions.1.IpRanges.2.CidrIp"], DeepEquals, []string{"205.159.0.0/16"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestAuthorizeSecurityGroupExample1WithId(c *C) {
+ testServer.Response(200, nil, AuthorizeSecurityGroupIngressExample)
+
+ perms := []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 80,
+ ToPort: 80,
+ SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"},
+ }}
+ // ignore return and error - we're only want to check the parameter handling.
+ s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name: "ignored"}, perms)
+
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["GroupName"], IsNil)
+ c.Assert(req.Form["GroupId"], DeepEquals, []string{"sg-67ad940e"})
+}
+
+func (s *S) TestAuthorizeSecurityGroupExample2(c *C) {
+ testServer.Response(200, nil, AuthorizeSecurityGroupIngressExample)
+
+ perms := []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 80,
+ ToPort: 81,
+ SourceGroups: []ec2.UserSecurityGroup{
+ {OwnerId: "999988887777", Name: "OtherAccountGroup"},
+ {Id: "sg-67ad940e"},
+ },
+ }}
+ resp, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: "websrv"}, perms)
+
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"AuthorizeSecurityGroupIngress"})
+ c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
+ c.Assert(req.Form["IpPermissions.1.IpProtocol"], DeepEquals, []string{"tcp"})
+ c.Assert(req.Form["IpPermissions.1.FromPort"], DeepEquals, []string{"80"})
+ c.Assert(req.Form["IpPermissions.1.ToPort"], DeepEquals, []string{"81"})
+ c.Assert(req.Form["IpPermissions.1.Groups.1.UserId"], DeepEquals, []string{"999988887777"})
+ c.Assert(req.Form["IpPermissions.1.Groups.1.GroupName"], DeepEquals, []string{"OtherAccountGroup"})
+ c.Assert(req.Form["IpPermissions.1.Groups.2.UserId"], IsNil)
+ c.Assert(req.Form["IpPermissions.1.Groups.2.GroupName"], IsNil)
+ c.Assert(req.Form["IpPermissions.1.Groups.2.GroupId"], DeepEquals, []string{"sg-67ad940e"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestRevokeSecurityGroupExample(c *C) {
+ // RevokeSecurityGroup is implemented by the same code as AuthorizeSecurityGroup
+ // so there's no need to duplicate all the tests.
+ testServer.Response(200, nil, RevokeSecurityGroupIngressExample)
+
+ resp, err := s.ec2.RevokeSecurityGroup(ec2.SecurityGroup{Name: "websrv"}, nil)
+
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"RevokeSecurityGroupIngress"})
+ c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestCreateTags(c *C) {
+ testServer.Response(200, nil, CreateTagsExample)
+
+ resp, err := s.ec2.CreateTags([]string{"ami-1a2b3c4d", "i-7f4d3a2b"}, []ec2.Tag{{"webserver", ""}, {"stack", "Production"}})
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["ResourceId.1"], DeepEquals, []string{"ami-1a2b3c4d"})
+ c.Assert(req.Form["ResourceId.2"], DeepEquals, []string{"i-7f4d3a2b"})
+ c.Assert(req.Form["Tag.1.Key"], DeepEquals, []string{"webserver"})
+ c.Assert(req.Form["Tag.1.Value"], DeepEquals, []string{""})
+ c.Assert(req.Form["Tag.2.Key"], DeepEquals, []string{"stack"})
+ c.Assert(req.Form["Tag.2.Value"], DeepEquals, []string{"Production"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestStartInstances(c *C) {
+ testServer.Response(200, nil, StartInstancesExample)
+
+ resp, err := s.ec2.StartInstances("i-10a64379")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"StartInstances"})
+ c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+
+ s0 := resp.StateChanges[0]
+ c.Assert(s0.InstanceId, Equals, "i-10a64379")
+ c.Assert(s0.CurrentState.Code, Equals, 0)
+ c.Assert(s0.CurrentState.Name, Equals, "pending")
+ c.Assert(s0.PreviousState.Code, Equals, 80)
+ c.Assert(s0.PreviousState.Name, Equals, "stopped")
+}
+
+func (s *S) TestStopInstances(c *C) {
+ testServer.Response(200, nil, StopInstancesExample)
+
+ resp, err := s.ec2.StopInstances("i-10a64379")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"StopInstances"})
+ c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+
+ s0 := resp.StateChanges[0]
+ c.Assert(s0.InstanceId, Equals, "i-10a64379")
+ c.Assert(s0.CurrentState.Code, Equals, 64)
+ c.Assert(s0.CurrentState.Name, Equals, "stopping")
+ c.Assert(s0.PreviousState.Code, Equals, 16)
+ c.Assert(s0.PreviousState.Name, Equals, "running")
+}
+
+func (s *S) TestRebootInstances(c *C) {
+ testServer.Response(200, nil, RebootInstancesExample)
+
+ resp, err := s.ec2.RebootInstances("i-10a64379")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"RebootInstances"})
+ c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestSignatureWithEndpointPath(c *C) {
+ ec2.FakeTime(true)
+ defer ec2.FakeTime(false)
+
+ testServer.Response(200, nil, RebootInstancesExample)
+
+ // https://bugs.launchpad.net/goamz/+bug/1022749
+ ec2 := ec2.NewWithClient(s.ec2.Auth, aws.Region{EC2Endpoint: testServer.URL + "/services/Cloud"}, testutil.DefaultClient)
+
+ _, err := ec2.RebootInstances("i-10a64379")
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Signature"], DeepEquals, []string{"QmvgkYGn19WirCuCz/jRp3RmRgFwWR5WRkKZ5AZnyXQ="})
+}
+
+func (s *S) TestAllocateAddressExample(c *C) {
+ testServer.Response(200, nil, AllocateAddressExample)
+
+ options := &ec2.AllocateAddress{
+ Domain: "vpc",
+ }
+
+ resp, err := s.ec2.AllocateAddress(options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"AllocateAddress"})
+ c.Assert(req.Form["Domain"], DeepEquals, []string{"vpc"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.PublicIp, Equals, "198.51.100.1")
+ c.Assert(resp.Domain, Equals, "vpc")
+ c.Assert(resp.AllocationId, Equals, "eipalloc-5723d13e")
+}
+
+func (s *S) TestReleaseAddressExample(c *C) {
+ testServer.Response(200, nil, ReleaseAddressExample)
+
+ resp, err := s.ec2.ReleaseAddress("eipalloc-5723d13e")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"ReleaseAddress"})
+ c.Assert(req.Form["AllocationId"], DeepEquals, []string{"eipalloc-5723d13e"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestAssociateAddressExample(c *C) {
+ testServer.Response(200, nil, AssociateAddressExample)
+
+ options := &ec2.AssociateAddress{
+ InstanceId: "i-4fd2431a",
+ AllocationId: "eipalloc-5723d13e",
+ AllowReassociation: true,
+ }
+
+ resp, err := s.ec2.AssociateAddress(options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"AssociateAddress"})
+ c.Assert(req.Form["InstanceId"], DeepEquals, []string{"i-4fd2431a"})
+ c.Assert(req.Form["AllocationId"], DeepEquals, []string{"eipalloc-5723d13e"})
+ c.Assert(req.Form["AllowReassociation"], DeepEquals, []string{"true"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+ c.Assert(resp.AssociationId, Equals, "eipassoc-fc5ca095")
+}
+
+func (s *S) TestDisassociateAddressExample(c *C) {
+ testServer.Response(200, nil, DisassociateAddressExample)
+
+ resp, err := s.ec2.DisassociateAddress("eipassoc-aa7486c3")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DisassociateAddress"})
+ c.Assert(req.Form["AssociationId"], DeepEquals, []string{"eipassoc-aa7486c3"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestModifyInstance(c *C) {
+ testServer.Response(200, nil, ModifyInstanceExample)
+
+ options := ec2.ModifyInstance{
+ InstanceType: "m1.small",
+ DisableAPITermination: true,
+ EbsOptimized: true,
+ SecurityGroups: []ec2.SecurityGroup{{Id: "g1"}, {Id: "g2"}},
+ ShutdownBehavior: "terminate",
+ KernelId: "kernel-id",
+ RamdiskId: "ramdisk-id",
+ SourceDestCheck: true,
+ SriovNetSupport: true,
+ UserData: []byte("1234"),
+ BlockDevices: []ec2.BlockDeviceMapping{
+ {DeviceName: "/dev/sda1", SnapshotId: "snap-a08912c9", DeleteOnTermination: true},
+ },
+ }
+
+ resp, err := s.ec2.ModifyInstance("i-2ba64342", &options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"ModifyInstanceAttribute"})
+ c.Assert(req.Form["InstanceId"], DeepEquals, []string{"i-2ba64342"})
+ c.Assert(req.Form["InstanceType.Value"], DeepEquals, []string{"m1.small"})
+ c.Assert(req.Form["BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sda1"})
+ c.Assert(req.Form["BlockDeviceMapping.1.Ebs.SnapshotId"], DeepEquals, []string{"snap-a08912c9"})
+ c.Assert(req.Form["BlockDeviceMapping.1.Ebs.DeleteOnTermination"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["DisableApiTermination.Value"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["EbsOptimized"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["GroupId.1"], DeepEquals, []string{"g1"})
+ c.Assert(req.Form["GroupId.2"], DeepEquals, []string{"g2"})
+ c.Assert(req.Form["InstanceInitiatedShutdownBehavior.Value"], DeepEquals, []string{"terminate"})
+ c.Assert(req.Form["Kernel.Value"], DeepEquals, []string{"kernel-id"})
+ c.Assert(req.Form["Ramdisk.Value"], DeepEquals, []string{"ramdisk-id"})
+ c.Assert(req.Form["SourceDestCheck.Value"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["SriovNetSupport.Value"], DeepEquals, []string{"simple"})
+ c.Assert(req.Form["UserData"], DeepEquals, []string{"MTIzNA=="})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
+
+func (s *S) TestCreateVpc(c *C) {
+ testServer.Response(200, nil, CreateVpcExample)
+
+ options := &ec2.CreateVpc{
+ CidrBlock: "foo",
+ }
+
+ resp, err := s.ec2.CreateVpc(options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["CidrBlock"], DeepEquals, []string{"foo"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+ c.Assert(resp.VPC.VpcId, Equals, "vpc-1a2b3c4d")
+ c.Assert(resp.VPC.State, Equals, "pending")
+ c.Assert(resp.VPC.CidrBlock, Equals, "10.0.0.0/16")
+ c.Assert(resp.VPC.DHCPOptionsID, Equals, "dopt-1a2b3c4d2")
+ c.Assert(resp.VPC.InstanceTenancy, Equals, "default")
+}
+
+func (s *S) TestDescribeVpcs(c *C) {
+ testServer.Response(200, nil, DescribeVpcsExample)
+
+ filter := ec2.NewFilter()
+ filter.Add("key1", "value1")
+ filter.Add("key2", "value2", "value3")
+
+ resp, err := s.ec2.DescribeVpcs([]string{"id1", "id2"}, filter)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeVpcs"})
+ c.Assert(req.Form["VpcId.1"], DeepEquals, []string{"id1"})
+ c.Assert(req.Form["VpcId.2"], DeepEquals, []string{"id2"})
+ c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
+ c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
+ c.Assert(req.Form["Filter.1.Value.2"], IsNil)
+ c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
+ c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
+ c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+ c.Assert(resp.VPCs, HasLen, 1)
+}
+
+func (s *S) TestCreateSubnet(c *C) {
+ testServer.Response(200, nil, CreateSubnetExample)
+
+ options := &ec2.CreateSubnet{
+ AvailabilityZone: "baz",
+ CidrBlock: "foo",
+ VpcId: "bar",
+ }
+
+ resp, err := s.ec2.CreateSubnet(options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["VpcId"], DeepEquals, []string{"bar"})
+ c.Assert(req.Form["CidrBlock"], DeepEquals, []string{"foo"})
+ c.Assert(req.Form["AvailabilityZone"], DeepEquals, []string{"baz"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+ c.Assert(resp.Subnet.SubnetId, Equals, "subnet-9d4a7b6c")
+ c.Assert(resp.Subnet.State, Equals, "pending")
+ c.Assert(resp.Subnet.VpcId, Equals, "vpc-1a2b3c4d")
+ c.Assert(resp.Subnet.CidrBlock, Equals, "10.0.1.0/24")
+ c.Assert(resp.Subnet.AvailableIpAddressCount, Equals, 251)
+}
+
+func (s *S) TestResetImageAttribute(c *C) {
+ testServer.Response(200, nil, ResetImageAttributeExample)
+
+ options := ec2.ResetImageAttribute{Attribute: "launchPermission"}
+ resp, err := s.ec2.ResetImageAttribute("i-2ba64342", &options)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Form["Action"], DeepEquals, []string{"ResetImageAttribute"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2i_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2i_test.go
new file mode 100644
index 00000000..3773041b
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2i_test.go
@@ -0,0 +1,203 @@
+package ec2_test
+
+import (
+ "crypto/rand"
+ "fmt"
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/ec2"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+)
+
+// AmazonServer represents an Amazon EC2 server.
+type AmazonServer struct {
+ auth aws.Auth
+}
+
+func (s *AmazonServer) SetUp(c *C) {
+ auth, err := aws.EnvAuth()
+ if err != nil {
+ c.Fatal(err.Error())
+ }
+ s.auth = auth
+}
+
+// Suite cost per run: 0.02 USD
+var _ = Suite(&AmazonClientSuite{})
+
+// AmazonClientSuite tests the client against a live EC2 server.
+type AmazonClientSuite struct {
+ srv AmazonServer
+ ClientTests
+}
+
+func (s *AmazonClientSuite) SetUpSuite(c *C) {
+ if !testutil.Amazon {
+ c.Skip("AmazonClientSuite tests not enabled")
+ }
+ s.srv.SetUp(c)
+ s.ec2 = ec2.NewWithClient(s.srv.auth, aws.USEast, testutil.DefaultClient)
+}
+
+// ClientTests defines integration tests designed to test the client.
+// It is not used as a test suite in itself, but embedded within
+// another type.
+type ClientTests struct {
+ ec2 *ec2.EC2
+}
+
+var imageId = "ami-ccf405a5" // Ubuntu Maverick, i386, EBS store
+
+// Cost: 0.00 USD
+func (s *ClientTests) TestRunInstancesError(c *C) {
+ options := ec2.RunInstances{
+ ImageId: "ami-a6f504cf", // Ubuntu Maverick, i386, instance store
+ InstanceType: "t1.micro", // Doesn't work with micro, results in 400.
+ }
+
+ resp, err := s.ec2.RunInstances(&options)
+
+ c.Assert(resp, IsNil)
+ c.Assert(err, ErrorMatches, "AMI.*root device.*not supported.*")
+
+ ec2err, ok := err.(*ec2.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(ec2err.StatusCode, Equals, 400)
+ c.Assert(ec2err.Code, Equals, "UnsupportedOperation")
+ c.Assert(ec2err.Message, Matches, "AMI.*root device.*not supported.*")
+ c.Assert(ec2err.RequestId, Matches, ".+")
+}
+
+// Cost: 0.02 USD
+func (s *ClientTests) TestRunAndTerminate(c *C) {
+ options := ec2.RunInstances{
+ ImageId: imageId,
+ InstanceType: "t1.micro",
+ }
+ resp1, err := s.ec2.RunInstances(&options)
+ c.Assert(err, IsNil)
+ c.Check(resp1.ReservationId, Matches, "r-[0-9a-f]*")
+ c.Check(resp1.OwnerId, Matches, "[0-9]+")
+ c.Check(resp1.Instances, HasLen, 1)
+ c.Check(resp1.Instances[0].InstanceType, Equals, "t1.micro")
+
+ instId := resp1.Instances[0].InstanceId
+
+ resp2, err := s.ec2.Instances([]string{instId}, nil)
+ c.Assert(err, IsNil)
+ if c.Check(resp2.Reservations, HasLen, 1) && c.Check(len(resp2.Reservations[0].Instances), Equals, 1) {
+ inst := resp2.Reservations[0].Instances[0]
+ c.Check(inst.InstanceId, Equals, instId)
+ }
+
+ resp3, err := s.ec2.TerminateInstances([]string{instId})
+ c.Assert(err, IsNil)
+ c.Check(resp3.StateChanges, HasLen, 1)
+ c.Check(resp3.StateChanges[0].InstanceId, Equals, instId)
+ c.Check(resp3.StateChanges[0].CurrentState.Name, Equals, "shutting-down")
+ c.Check(resp3.StateChanges[0].CurrentState.Code, Equals, 32)
+}
+
+// Cost: 0.00 USD
+func (s *ClientTests) TestSecurityGroups(c *C) {
+ name := "goamz-test"
+ descr := "goamz security group for tests"
+
+ // Clean it up, if a previous test left it around and avoid leaving it around.
+ s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
+ defer s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
+
+ resp1, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: name, Description: descr})
+ c.Assert(err, IsNil)
+ c.Assert(resp1.RequestId, Matches, ".+")
+ c.Assert(resp1.Name, Equals, name)
+ c.Assert(resp1.Id, Matches, ".+")
+
+ resp1, err = s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: name, Description: descr})
+ ec2err, _ := err.(*ec2.Error)
+ c.Assert(resp1, IsNil)
+ c.Assert(ec2err, NotNil)
+ c.Assert(ec2err.Code, Equals, "InvalidGroup.Duplicate")
+
+ perms := []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 0,
+ ToPort: 1024,
+ SourceIPs: []string{"127.0.0.1/24"},
+ }}
+
+ resp2, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms)
+ c.Assert(err, IsNil)
+ c.Assert(resp2.RequestId, Matches, ".+")
+
+ resp3, err := s.ec2.SecurityGroups(ec2.SecurityGroupNames(name), nil)
+ c.Assert(err, IsNil)
+ c.Assert(resp3.RequestId, Matches, ".+")
+ c.Assert(resp3.Groups, HasLen, 1)
+
+ g0 := resp3.Groups[0]
+ c.Assert(g0.Name, Equals, name)
+ c.Assert(g0.Description, Equals, descr)
+ c.Assert(g0.IPPerms, HasLen, 1)
+ c.Assert(g0.IPPerms[0].Protocol, Equals, "tcp")
+ c.Assert(g0.IPPerms[0].FromPort, Equals, 0)
+ c.Assert(g0.IPPerms[0].ToPort, Equals, 1024)
+ c.Assert(g0.IPPerms[0].SourceIPs, DeepEquals, []string{"127.0.0.1/24"})
+
+ resp2, err = s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
+ c.Assert(err, IsNil)
+ c.Assert(resp2.RequestId, Matches, ".+")
+}
+
+var sessionId = func() string {
+ buf := make([]byte, 8)
+ // if we have no randomness, we'll just make do, so ignore the error.
+ rand.Read(buf)
+ return fmt.Sprintf("%x", buf)
+}()
+
+// sessionName reutrns a name that is probably
+// unique to this test session.
+func sessionName(prefix string) string {
+ return prefix + "-" + sessionId
+}
+
+var allRegions = []aws.Region{
+ aws.USEast,
+ aws.USWest,
+ aws.EUWest,
+ aws.APSoutheast,
+ aws.APNortheast,
+}
+
+// Communicate with all EC2 endpoints to see if they are alive.
+func (s *ClientTests) TestRegions(c *C) {
+ name := sessionName("goamz-region-test")
+ perms := []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 80,
+ ToPort: 80,
+ SourceIPs: []string{"127.0.0.1/32"},
+ }}
+ errs := make(chan error, len(allRegions))
+ for _, region := range allRegions {
+ go func(r aws.Region) {
+ e := ec2.NewWithClient(s.ec2.Auth, r, testutil.DefaultClient)
+ _, err := e.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms)
+ errs <- err
+ }(region)
+ }
+ for _ = range allRegions {
+ err := <-errs
+ if err != nil {
+ ec2_err, ok := err.(*ec2.Error)
+ if ok {
+ c.Check(ec2_err.Code, Matches, "InvalidGroup.NotFound")
+ } else {
+ c.Errorf("Non-EC2 error: %s", err)
+ }
+ } else {
+ c.Errorf("Test should have errored but it seems to have succeeded")
+ }
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2t_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2t_test.go
new file mode 100644
index 00000000..fe50356f
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2t_test.go
@@ -0,0 +1,580 @@
+package ec2_test
+
+import (
+ "fmt"
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/ec2"
+ "github.com/mitchellh/goamz/ec2/ec2test"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "regexp"
+ "sort"
+)
+
+// LocalServer represents a local ec2test fake server.
+type LocalServer struct {
+ auth aws.Auth
+ region aws.Region
+ srv *ec2test.Server
+}
+
+func (s *LocalServer) SetUp(c *C) {
+ srv, err := ec2test.NewServer()
+ c.Assert(err, IsNil)
+ c.Assert(srv, NotNil)
+
+ s.srv = srv
+ s.region = aws.Region{EC2Endpoint: srv.URL()}
+}
+
+// LocalServerSuite defines tests that will run
+// against the local ec2test server. It includes
+// selected tests from ClientTests;
+// when the ec2test functionality is sufficient, it should
+// include all of them, and ClientTests can be simply embedded.
+type LocalServerSuite struct {
+ srv LocalServer
+ ServerTests
+ clientTests ClientTests
+}
+
+var _ = Suite(&LocalServerSuite{})
+
+func (s *LocalServerSuite) SetUpSuite(c *C) {
+ s.srv.SetUp(c)
+ s.ServerTests.ec2 = ec2.NewWithClient(s.srv.auth, s.srv.region, testutil.DefaultClient)
+ s.clientTests.ec2 = ec2.NewWithClient(s.srv.auth, s.srv.region, testutil.DefaultClient)
+}
+
+func (s *LocalServerSuite) TestRunAndTerminate(c *C) {
+ s.clientTests.TestRunAndTerminate(c)
+}
+
+func (s *LocalServerSuite) TestSecurityGroups(c *C) {
+ s.clientTests.TestSecurityGroups(c)
+}
+
+// TestUserData is not defined on ServerTests because it
+// requires the ec2test server to function.
+func (s *LocalServerSuite) TestUserData(c *C) {
+ data := make([]byte, 256)
+ for i := range data {
+ data[i] = byte(i)
+ }
+ inst, err := s.ec2.RunInstances(&ec2.RunInstances{
+ ImageId: imageId,
+ InstanceType: "t1.micro",
+ UserData: data,
+ })
+ c.Assert(err, IsNil)
+ c.Assert(inst, NotNil)
+ c.Assert(inst.Instances[0].DNSName, Equals, inst.Instances[0].InstanceId+".example.com")
+
+ id := inst.Instances[0].InstanceId
+
+ defer s.ec2.TerminateInstances([]string{id})
+
+ tinst := s.srv.srv.Instance(id)
+ c.Assert(tinst, NotNil)
+ c.Assert(tinst.UserData, DeepEquals, data)
+}
+
+// AmazonServerSuite runs the ec2test server tests against a live EC2 server.
+// It will only be activated if the -all flag is specified.
+type AmazonServerSuite struct {
+ srv AmazonServer
+ ServerTests
+}
+
+var _ = Suite(&AmazonServerSuite{})
+
+func (s *AmazonServerSuite) SetUpSuite(c *C) {
+ if !testutil.Amazon {
+ c.Skip("AmazonServerSuite tests not enabled")
+ }
+ s.srv.SetUp(c)
+ s.ServerTests.ec2 = ec2.NewWithClient(s.srv.auth, aws.USEast, testutil.DefaultClient)
+}
+
+// ServerTests defines a set of tests designed to test
+// the ec2test local fake ec2 server.
+// It is not used as a test suite in itself, but embedded within
+// another type.
+type ServerTests struct {
+ ec2 *ec2.EC2
+}
+
+func terminateInstances(c *C, e *ec2.EC2, insts []*ec2.Instance) {
+ var ids []string
+ for _, inst := range insts {
+ if inst != nil {
+ ids = append(ids, inst.InstanceId)
+ }
+ }
+ _, err := e.TerminateInstances(ids)
+ c.Check(err, IsNil, Commentf("%d INSTANCES LEFT RUNNING!!!", len(ids)))
+}
+
+func (s *ServerTests) makeTestGroup(c *C, name, descr string) ec2.SecurityGroup {
+ // Clean it up if a previous test left it around.
+ _, err := s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
+ if err != nil && err.(*ec2.Error).Code != "InvalidGroup.NotFound" {
+ c.Fatalf("delete security group: %v", err)
+ }
+
+ resp, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: name, Description: descr})
+ c.Assert(err, IsNil)
+ c.Assert(resp.Name, Equals, name)
+ return resp.SecurityGroup
+}
+
+func (s *ServerTests) TestIPPerms(c *C) {
+ g0 := s.makeTestGroup(c, "goamz-test0", "ec2test group 0")
+ defer s.ec2.DeleteSecurityGroup(g0)
+
+ g1 := s.makeTestGroup(c, "goamz-test1", "ec2test group 1")
+ defer s.ec2.DeleteSecurityGroup(g1)
+
+ resp, err := s.ec2.SecurityGroups([]ec2.SecurityGroup{g0, g1}, nil)
+ c.Assert(err, IsNil)
+ c.Assert(resp.Groups, HasLen, 2)
+ c.Assert(resp.Groups[0].IPPerms, HasLen, 0)
+ c.Assert(resp.Groups[1].IPPerms, HasLen, 0)
+
+ ownerId := resp.Groups[0].OwnerId
+
+ // test some invalid parameters
+ // TODO more
+ _, err = s.ec2.AuthorizeSecurityGroup(g0, []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 0,
+ ToPort: 1024,
+ SourceIPs: []string{"z127.0.0.1/24"},
+ }})
+ c.Assert(err, NotNil)
+ c.Check(err.(*ec2.Error).Code, Equals, "InvalidPermission.Malformed")
+
+ // Check that AuthorizeSecurityGroup adds the correct authorizations.
+ _, err = s.ec2.AuthorizeSecurityGroup(g0, []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 2000,
+ ToPort: 2001,
+ SourceIPs: []string{"127.0.0.0/24"},
+ SourceGroups: []ec2.UserSecurityGroup{{
+ Name: g1.Name,
+ }, {
+ Id: g0.Id,
+ }},
+ }, {
+ Protocol: "tcp",
+ FromPort: 2000,
+ ToPort: 2001,
+ SourceIPs: []string{"200.1.1.34/32"},
+ }})
+ c.Assert(err, IsNil)
+
+ resp, err = s.ec2.SecurityGroups([]ec2.SecurityGroup{g0}, nil)
+ c.Assert(err, IsNil)
+ c.Assert(resp.Groups, HasLen, 1)
+ c.Assert(resp.Groups[0].IPPerms, HasLen, 1)
+
+ perm := resp.Groups[0].IPPerms[0]
+ srcg := perm.SourceGroups
+ c.Assert(srcg, HasLen, 2)
+
+ // Normalize so we don't care about returned order.
+ if srcg[0].Name == g1.Name {
+ srcg[0], srcg[1] = srcg[1], srcg[0]
+ }
+ c.Check(srcg[0].Name, Equals, g0.Name)
+ c.Check(srcg[0].Id, Equals, g0.Id)
+ c.Check(srcg[0].OwnerId, Equals, ownerId)
+ c.Check(srcg[1].Name, Equals, g1.Name)
+ c.Check(srcg[1].Id, Equals, g1.Id)
+ c.Check(srcg[1].OwnerId, Equals, ownerId)
+
+ sort.Strings(perm.SourceIPs)
+ c.Check(perm.SourceIPs, DeepEquals, []string{"127.0.0.0/24", "200.1.1.34/32"})
+
+ // Check that we can't delete g1 (because g0 is using it)
+ _, err = s.ec2.DeleteSecurityGroup(g1)
+ c.Assert(err, NotNil)
+ c.Check(err.(*ec2.Error).Code, Equals, "InvalidGroup.InUse")
+
+ _, err = s.ec2.RevokeSecurityGroup(g0, []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 2000,
+ ToPort: 2001,
+ SourceGroups: []ec2.UserSecurityGroup{{Id: g1.Id}},
+ }, {
+ Protocol: "tcp",
+ FromPort: 2000,
+ ToPort: 2001,
+ SourceIPs: []string{"200.1.1.34/32"},
+ }})
+ c.Assert(err, IsNil)
+
+ resp, err = s.ec2.SecurityGroups([]ec2.SecurityGroup{g0}, nil)
+ c.Assert(err, IsNil)
+ c.Assert(resp.Groups, HasLen, 1)
+ c.Assert(resp.Groups[0].IPPerms, HasLen, 1)
+
+ perm = resp.Groups[0].IPPerms[0]
+ srcg = perm.SourceGroups
+ c.Assert(srcg, HasLen, 1)
+ c.Check(srcg[0].Name, Equals, g0.Name)
+ c.Check(srcg[0].Id, Equals, g0.Id)
+ c.Check(srcg[0].OwnerId, Equals, ownerId)
+
+ c.Check(perm.SourceIPs, DeepEquals, []string{"127.0.0.0/24"})
+
+ // We should be able to delete g1 now because we've removed its only use.
+ _, err = s.ec2.DeleteSecurityGroup(g1)
+ c.Assert(err, IsNil)
+
+ _, err = s.ec2.DeleteSecurityGroup(g0)
+ c.Assert(err, IsNil)
+
+ f := ec2.NewFilter()
+ f.Add("group-id", g0.Id, g1.Id)
+ resp, err = s.ec2.SecurityGroups(nil, f)
+ c.Assert(err, IsNil)
+ c.Assert(resp.Groups, HasLen, 0)
+}
+
+func (s *ServerTests) TestDuplicateIPPerm(c *C) {
+ name := "goamz-test"
+ descr := "goamz security group for tests"
+
+ // Clean it up, if a previous test left it around and avoid leaving it around.
+ s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
+ defer s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
+
+ resp1, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: name, Description: descr})
+ c.Assert(err, IsNil)
+ c.Assert(resp1.Name, Equals, name)
+
+ perms := []ec2.IPPerm{{
+ Protocol: "tcp",
+ FromPort: 200,
+ ToPort: 1024,
+ SourceIPs: []string{"127.0.0.1/24"},
+ }, {
+ Protocol: "tcp",
+ FromPort: 0,
+ ToPort: 100,
+ SourceIPs: []string{"127.0.0.1/24"},
+ }}
+
+ _, err = s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms[0:1])
+ c.Assert(err, IsNil)
+
+ _, err = s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms[0:2])
+ c.Assert(err, ErrorMatches, `.*\(InvalidPermission.Duplicate\)`)
+}
+
+type filterSpec struct {
+ name string
+ values []string
+}
+
+func (s *ServerTests) TestInstanceFiltering(c *C) {
+ groupResp, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: sessionName("testgroup1"), Description: "testgroup one description"})
+ c.Assert(err, IsNil)
+ group1 := groupResp.SecurityGroup
+ defer s.ec2.DeleteSecurityGroup(group1)
+
+ groupResp, err = s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: sessionName("testgroup2"), Description: "testgroup two description"})
+ c.Assert(err, IsNil)
+ group2 := groupResp.SecurityGroup
+ defer s.ec2.DeleteSecurityGroup(group2)
+
+ insts := make([]*ec2.Instance, 3)
+ inst, err := s.ec2.RunInstances(&ec2.RunInstances{
+ MinCount: 2,
+ ImageId: imageId,
+ InstanceType: "t1.micro",
+ SecurityGroups: []ec2.SecurityGroup{group1},
+ })
+ c.Assert(err, IsNil)
+ insts[0] = &inst.Instances[0]
+ insts[1] = &inst.Instances[1]
+ defer terminateInstances(c, s.ec2, insts)
+
+ imageId2 := "ami-e358958a" // Natty server, i386, EBS store
+ inst, err = s.ec2.RunInstances(&ec2.RunInstances{
+ ImageId: imageId2,
+ InstanceType: "t1.micro",
+ SecurityGroups: []ec2.SecurityGroup{group2},
+ })
+ c.Assert(err, IsNil)
+ insts[2] = &inst.Instances[0]
+
+ ids := func(indices ...int) (instIds []string) {
+ for _, index := range indices {
+ instIds = append(instIds, insts[index].InstanceId)
+ }
+ return
+ }
+
+ tests := []struct {
+ about string
+ instanceIds []string // instanceIds argument to Instances method.
+ filters []filterSpec // filters argument to Instances method.
+ resultIds []string // set of instance ids of expected results.
+ allowExtra bool // resultIds may be incomplete.
+ err string // expected error.
+ }{
+ {
+ about: "check that Instances returns all instances",
+ resultIds: ids(0, 1, 2),
+ allowExtra: true,
+ }, {
+ about: "check that specifying two instance ids returns them",
+ instanceIds: ids(0, 2),
+ resultIds: ids(0, 2),
+ }, {
+ about: "check that specifying a non-existent instance id gives an error",
+ instanceIds: append(ids(0), "i-deadbeef"),
+ err: `.*\(InvalidInstanceID\.NotFound\)`,
+ }, {
+ about: "check that a filter allowed both instances returns both of them",
+ filters: []filterSpec{
+ {"instance-id", ids(0, 2)},
+ },
+ resultIds: ids(0, 2),
+ }, {
+ about: "check that a filter allowing only one instance returns it",
+ filters: []filterSpec{
+ {"instance-id", ids(1)},
+ },
+ resultIds: ids(1),
+ }, {
+ about: "check that a filter allowing no instances returns none",
+ filters: []filterSpec{
+ {"instance-id", []string{"i-deadbeef12345"}},
+ },
+ }, {
+ about: "check that filtering on group id works",
+ filters: []filterSpec{
+ {"group-id", []string{group1.Id}},
+ },
+ resultIds: ids(0, 1),
+ }, {
+ about: "check that filtering on group name works",
+ filters: []filterSpec{
+ {"group-name", []string{group1.Name}},
+ },
+ resultIds: ids(0, 1),
+ }, {
+ about: "check that filtering on image id works",
+ filters: []filterSpec{
+ {"image-id", []string{imageId}},
+ },
+ resultIds: ids(0, 1),
+ allowExtra: true,
+ }, {
+ about: "combination filters 1",
+ filters: []filterSpec{
+ {"image-id", []string{imageId, imageId2}},
+ {"group-name", []string{group1.Name}},
+ },
+ resultIds: ids(0, 1),
+ }, {
+ about: "combination filters 2",
+ filters: []filterSpec{
+ {"image-id", []string{imageId2}},
+ {"group-name", []string{group1.Name}},
+ },
+ },
+ }
+ for i, t := range tests {
+ c.Logf("%d. %s", i, t.about)
+ var f *ec2.Filter
+ if t.filters != nil {
+ f = ec2.NewFilter()
+ for _, spec := range t.filters {
+ f.Add(spec.name, spec.values...)
+ }
+ }
+ resp, err := s.ec2.Instances(t.instanceIds, f)
+ if t.err != "" {
+ c.Check(err, ErrorMatches, t.err)
+ continue
+ }
+ c.Assert(err, IsNil)
+ insts := make(map[string]*ec2.Instance)
+ for _, r := range resp.Reservations {
+ for j := range r.Instances {
+ inst := &r.Instances[j]
+ c.Check(insts[inst.InstanceId], IsNil, Commentf("duplicate instance id: %q", inst.InstanceId))
+ insts[inst.InstanceId] = inst
+ }
+ }
+ if !t.allowExtra {
+ c.Check(insts, HasLen, len(t.resultIds), Commentf("expected %d instances got %#v", len(t.resultIds), insts))
+ }
+ for j, id := range t.resultIds {
+ c.Check(insts[id], NotNil, Commentf("instance id %d (%q) not found; got %#v", j, id, insts))
+ }
+ }
+}
+
+func idsOnly(gs []ec2.SecurityGroup) []ec2.SecurityGroup {
+ for i := range gs {
+ gs[i].Name = ""
+ }
+ return gs
+}
+
+func namesOnly(gs []ec2.SecurityGroup) []ec2.SecurityGroup {
+ for i := range gs {
+ gs[i].Id = ""
+ }
+ return gs
+}
+
+func (s *ServerTests) TestGroupFiltering(c *C) {
+ g := make([]ec2.SecurityGroup, 4)
+ for i := range g {
+ resp, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: sessionName(fmt.Sprintf("testgroup%d", i)), Description: fmt.Sprintf("testdescription%d", i)})
+ c.Assert(err, IsNil)
+ g[i] = resp.SecurityGroup
+ c.Logf("group %d: %v", i, g[i])
+ defer s.ec2.DeleteSecurityGroup(g[i])
+ }
+
+ perms := [][]ec2.IPPerm{
+ {{
+ Protocol: "tcp",
+ FromPort: 100,
+ ToPort: 200,
+ SourceIPs: []string{"1.2.3.4/32"},
+ }},
+ {{
+ Protocol: "tcp",
+ FromPort: 200,
+ ToPort: 300,
+ SourceGroups: []ec2.UserSecurityGroup{{Id: g[1].Id}},
+ }},
+ {{
+ Protocol: "udp",
+ FromPort: 200,
+ ToPort: 400,
+ SourceGroups: []ec2.UserSecurityGroup{{Id: g[1].Id}},
+ }},
+ }
+ for i, ps := range perms {
+ _, err := s.ec2.AuthorizeSecurityGroup(g[i], ps)
+ c.Assert(err, IsNil)
+ }
+
+ groups := func(indices ...int) (gs []ec2.SecurityGroup) {
+ for _, index := range indices {
+ gs = append(gs, g[index])
+ }
+ return
+ }
+
+ type groupTest struct {
+ about string
+ groups []ec2.SecurityGroup // groupIds argument to SecurityGroups method.
+ filters []filterSpec // filters argument to SecurityGroups method.
+ results []ec2.SecurityGroup // set of expected result groups.
+ allowExtra bool // specified results may be incomplete.
+ err string // expected error.
+ }
+ filterCheck := func(name, val string, gs []ec2.SecurityGroup) groupTest {
+ return groupTest{
+ about: "filter check " + name,
+ filters: []filterSpec{{name, []string{val}}},
+ results: gs,
+ allowExtra: true,
+ }
+ }
+ tests := []groupTest{
+ {
+ about: "check that SecurityGroups returns all groups",
+ results: groups(0, 1, 2, 3),
+ allowExtra: true,
+ }, {
+ about: "check that specifying two group ids returns them",
+ groups: idsOnly(groups(0, 2)),
+ results: groups(0, 2),
+ }, {
+ about: "check that specifying names only works",
+ groups: namesOnly(groups(0, 2)),
+ results: groups(0, 2),
+ }, {
+ about: "check that specifying a non-existent group id gives an error",
+ groups: append(groups(0), ec2.SecurityGroup{Id: "sg-eeeeeeeee"}),
+ err: `.*\(InvalidGroup\.NotFound\)`,
+ }, {
+ about: "check that a filter allowed two groups returns both of them",
+ filters: []filterSpec{
+ {"group-id", []string{g[0].Id, g[2].Id}},
+ },
+ results: groups(0, 2),
+ },
+ {
+ about: "check that the previous filter works when specifying a list of ids",
+ groups: groups(1, 2),
+ filters: []filterSpec{
+ {"group-id", []string{g[0].Id, g[2].Id}},
+ },
+ results: groups(2),
+ }, {
+ about: "check that a filter allowing no groups returns none",
+ filters: []filterSpec{
+ {"group-id", []string{"sg-eeeeeeeee"}},
+ },
+ },
+ filterCheck("description", "testdescription1", groups(1)),
+ filterCheck("group-name", g[2].Name, groups(2)),
+ filterCheck("ip-permission.cidr", "1.2.3.4/32", groups(0)),
+ filterCheck("ip-permission.group-name", g[1].Name, groups(1, 2)),
+ filterCheck("ip-permission.protocol", "udp", groups(2)),
+ filterCheck("ip-permission.from-port", "200", groups(1, 2)),
+ filterCheck("ip-permission.to-port", "200", groups(0)),
+ // TODO owner-id
+ }
+ for i, t := range tests {
+ c.Logf("%d. %s", i, t.about)
+ var f *ec2.Filter
+ if t.filters != nil {
+ f = ec2.NewFilter()
+ for _, spec := range t.filters {
+ f.Add(spec.name, spec.values...)
+ }
+ }
+ resp, err := s.ec2.SecurityGroups(t.groups, f)
+ if t.err != "" {
+ c.Check(err, ErrorMatches, t.err)
+ continue
+ }
+ c.Assert(err, IsNil)
+ groups := make(map[string]*ec2.SecurityGroup)
+ for j := range resp.Groups {
+ group := &resp.Groups[j].SecurityGroup
+ c.Check(groups[group.Id], IsNil, Commentf("duplicate group id: %q", group.Id))
+
+ groups[group.Id] = group
+ }
+ // If extra groups may be returned, eliminate all groups that
+ // we did not create in this session apart from the default group.
+ if t.allowExtra {
+ namePat := regexp.MustCompile(sessionName("testgroup[0-9]"))
+ for id, g := range groups {
+ if !namePat.MatchString(g.Name) {
+ delete(groups, id)
+ }
+ }
+ }
+ c.Check(groups, HasLen, len(t.results))
+ for j, g := range t.results {
+ rg := groups[g.Id]
+ c.Assert(rg, NotNil, Commentf("group %d (%v) not found; got %#v", j, g, groups))
+ c.Check(rg.Name, Equals, g.Name, Commentf("group %d (%v)", j, g))
+ }
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2test/filter.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2test/filter.go
new file mode 100644
index 00000000..1a0c0461
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2test/filter.go
@@ -0,0 +1,84 @@
+package ec2test
+
+import (
+ "fmt"
+ "net/url"
+ "strings"
+)
+
+// filter holds an ec2 filter. A filter maps an attribute to a set of
+// possible values for that attribute. For an item to pass through the
+// filter, every attribute of the item mentioned in the filter must match
+// at least one of its given values.
+type filter map[string][]string
+
+// newFilter creates a new filter from the Filter fields in the url form.
+//
+// The filtering is specified through a map of name=>values, where the
+// name is a well-defined key identifying the data to be matched,
+// and the list of values holds the possible values the filtered
+// item can take for the key to be included in the
+// result set. For example:
+//
+// Filter.1.Name=instance-type
+// Filter.1.Value.1=m1.small
+// Filter.1.Value.2=m1.large
+//
+func newFilter(form url.Values) filter {
+ // TODO return an error if the fields are not well formed?
+ names := make(map[int]string)
+ values := make(map[int][]string)
+ maxId := 0
+ for name, fvalues := range form {
+ var rest string
+ var id int
+ if x, _ := fmt.Sscanf(name, "Filter.%d.%s", &id, &rest); x != 2 {
+ continue
+ }
+ if id > maxId {
+ maxId = id
+ }
+ if rest == "Name" {
+ names[id] = fvalues[0]
+ continue
+ }
+ if !strings.HasPrefix(rest, "Value.") {
+ continue
+ }
+ values[id] = append(values[id], fvalues[0])
+ }
+
+ f := make(filter)
+ for id, name := range names {
+ f[name] = values[id]
+ }
+ return f
+}
+
+func notDigit(r rune) bool {
+ return r < '0' || r > '9'
+}
+
+// filterable represents an object that can be passed through a filter.
+type filterable interface {
+ // matchAttr returns true if given attribute of the
+ // object matches value. It returns an error if the
+ // attribute is not recognised or the value is malformed.
+ matchAttr(attr, value string) (bool, error)
+}
+
+// ok returns true if x passes through the filter.
+func (f filter) ok(x filterable) (bool, error) {
+next:
+ for a, vs := range f {
+ for _, v := range vs {
+ if ok, err := x.matchAttr(a, v); ok {
+ continue next
+ } else if err != nil {
+ return false, fmt.Errorf("bad attribute or value %q=%q for type %T: %v", a, v, x, err)
+ }
+ }
+ return false, nil
+ }
+ return true, nil
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2test/server.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2test/server.go
new file mode 100644
index 00000000..2f24cb2a
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/ec2test/server.go
@@ -0,0 +1,993 @@
+// The ec2test package implements a fake EC2 provider with
+// the capability of inducing errors on any given operation,
+// and retrospectively determining what operations have been
+// carried out.
+package ec2test
+
+import (
+ "encoding/base64"
+ "encoding/xml"
+ "fmt"
+ "github.com/mitchellh/goamz/ec2"
+ "io"
+ "net"
+ "net/http"
+ "net/url"
+ "regexp"
+ "strconv"
+ "strings"
+ "sync"
+)
+
+var b64 = base64.StdEncoding
+
+// Action represents a request that changes the ec2 state.
+type Action struct {
+ RequestId string
+
+ // Request holds the requested action as a url.Values instance
+ Request url.Values
+
+ // If the action succeeded, Response holds the value that
+ // was marshalled to build the XML response for the request.
+ Response interface{}
+
+ // If the action failed, Err holds an error giving details of the failure.
+ Err *ec2.Error
+}
+
+// TODO possible other things:
+// - some virtual time stamp interface, so a client
+// can ask for all actions after a certain virtual time.
+
+// Server implements an EC2 simulator for use in testing.
+type Server struct {
+ url string
+ listener net.Listener
+ mu sync.Mutex
+ reqs []*Action
+
+ instances map[string]*Instance // id -> instance
+ reservations map[string]*reservation // id -> reservation
+ groups map[string]*securityGroup // id -> group
+ maxId counter
+ reqId counter
+ reservationId counter
+ groupId counter
+ initialInstanceState ec2.InstanceState
+}
+
+// reservation holds a simulated ec2 reservation.
+type reservation struct {
+ id string
+ instances map[string]*Instance
+ groups []*securityGroup
+}
+
+// instance holds a simulated ec2 instance
+type Instance struct {
+ // UserData holds the data that was passed to the RunInstances request
+ // when the instance was started.
+ UserData []byte
+ id string
+ imageId string
+ reservation *reservation
+ instType string
+ state ec2.InstanceState
+}
+
+// permKey represents permission for a given security
+// group or IP address (but not both) to access a given range of
+// ports. Equality of permKeys is used in the implementation of
+// permission sets, relying on the uniqueness of securityGroup
+// instances.
+type permKey struct {
+ protocol string
+ fromPort int
+ toPort int
+ group *securityGroup
+ ipAddr string
+}
+
+// securityGroup holds a simulated ec2 security group.
+// Instances of securityGroup should only be created through
+// Server.createSecurityGroup to ensure that groups can be
+// compared by pointer value.
+type securityGroup struct {
+ id string
+ name string
+ description string
+
+ perms map[permKey]bool
+}
+
+func (g *securityGroup) ec2SecurityGroup() ec2.SecurityGroup {
+ return ec2.SecurityGroup{
+ Name: g.name,
+ Id: g.id,
+ }
+}
+
+func (g *securityGroup) matchAttr(attr, value string) (ok bool, err error) {
+ switch attr {
+ case "description":
+ return g.description == value, nil
+ case "group-id":
+ return g.id == value, nil
+ case "group-name":
+ return g.name == value, nil
+ case "ip-permission.cidr":
+ return g.hasPerm(func(k permKey) bool { return k.ipAddr == value }), nil
+ case "ip-permission.group-name":
+ return g.hasPerm(func(k permKey) bool {
+ return k.group != nil && k.group.name == value
+ }), nil
+ case "ip-permission.from-port":
+ port, err := strconv.Atoi(value)
+ if err != nil {
+ return false, err
+ }
+ return g.hasPerm(func(k permKey) bool { return k.fromPort == port }), nil
+ case "ip-permission.to-port":
+ port, err := strconv.Atoi(value)
+ if err != nil {
+ return false, err
+ }
+ return g.hasPerm(func(k permKey) bool { return k.toPort == port }), nil
+ case "ip-permission.protocol":
+ return g.hasPerm(func(k permKey) bool { return k.protocol == value }), nil
+ case "owner-id":
+ return value == ownerId, nil
+ }
+ return false, fmt.Errorf("unknown attribute %q", attr)
+}
+
+func (g *securityGroup) hasPerm(test func(k permKey) bool) bool {
+ for k := range g.perms {
+ if test(k) {
+ return true
+ }
+ }
+ return false
+}
+
+// ec2Perms returns the list of EC2 permissions granted
+// to g. It groups permissions by port range and protocol.
+func (g *securityGroup) ec2Perms() (perms []ec2.IPPerm) {
+ // The grouping is held in result. We use permKey for convenience,
+ // (ensuring that the group and ipAddr of each key is zero). For
+ // each protocol/port range combination, we build up the permission
+ // set in the associated value.
+ result := make(map[permKey]*ec2.IPPerm)
+ for k := range g.perms {
+ groupKey := k
+ groupKey.group = nil
+ groupKey.ipAddr = ""
+
+ ec2p := result[groupKey]
+ if ec2p == nil {
+ ec2p = &ec2.IPPerm{
+ Protocol: k.protocol,
+ FromPort: k.fromPort,
+ ToPort: k.toPort,
+ }
+ result[groupKey] = ec2p
+ }
+ if k.group != nil {
+ ec2p.SourceGroups = append(ec2p.SourceGroups,
+ ec2.UserSecurityGroup{
+ Id: k.group.id,
+ Name: k.group.name,
+ OwnerId: ownerId,
+ })
+ } else {
+ ec2p.SourceIPs = append(ec2p.SourceIPs, k.ipAddr)
+ }
+ }
+ for _, ec2p := range result {
+ perms = append(perms, *ec2p)
+ }
+ return
+}
+
+var actions = map[string]func(*Server, http.ResponseWriter, *http.Request, string) interface{}{
+ "RunInstances": (*Server).runInstances,
+ "TerminateInstances": (*Server).terminateInstances,
+ "DescribeInstances": (*Server).describeInstances,
+ "CreateSecurityGroup": (*Server).createSecurityGroup,
+ "DescribeSecurityGroups": (*Server).describeSecurityGroups,
+ "DeleteSecurityGroup": (*Server).deleteSecurityGroup,
+ "AuthorizeSecurityGroupIngress": (*Server).authorizeSecurityGroupIngress,
+ "RevokeSecurityGroupIngress": (*Server).revokeSecurityGroupIngress,
+}
+
+const ownerId = "9876"
+
+// newAction allocates a new action and adds it to the
+// recorded list of server actions.
+func (srv *Server) newAction() *Action {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+
+ a := new(Action)
+ srv.reqs = append(srv.reqs, a)
+ return a
+}
+
+// NewServer returns a new server.
+func NewServer() (*Server, error) {
+ srv := &Server{
+ instances: make(map[string]*Instance),
+ groups: make(map[string]*securityGroup),
+ reservations: make(map[string]*reservation),
+ initialInstanceState: Pending,
+ }
+
+ // Add default security group.
+ g := &securityGroup{
+ name: "default",
+ description: "default group",
+ id: fmt.Sprintf("sg-%d", srv.groupId.next()),
+ }
+ g.perms = map[permKey]bool{
+ permKey{
+ protocol: "icmp",
+ fromPort: -1,
+ toPort: -1,
+ group: g,
+ }: true,
+ permKey{
+ protocol: "tcp",
+ fromPort: 0,
+ toPort: 65535,
+ group: g,
+ }: true,
+ permKey{
+ protocol: "udp",
+ fromPort: 0,
+ toPort: 65535,
+ group: g,
+ }: true,
+ }
+ srv.groups[g.id] = g
+
+ l, err := net.Listen("tcp", "localhost:0")
+ if err != nil {
+ return nil, fmt.Errorf("cannot listen on localhost: %v", err)
+ }
+ srv.listener = l
+
+ srv.url = "http://" + l.Addr().String()
+
+ // we use HandlerFunc rather than *Server directly so that we
+ // can avoid exporting HandlerFunc from *Server.
+ go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ srv.serveHTTP(w, req)
+ }))
+ return srv, nil
+}
+
+// Quit closes down the server.
+func (srv *Server) Quit() {
+ srv.listener.Close()
+}
+
+// SetInitialInstanceState sets the state that any new instances will be started in.
+func (srv *Server) SetInitialInstanceState(state ec2.InstanceState) {
+ srv.mu.Lock()
+ srv.initialInstanceState = state
+ srv.mu.Unlock()
+}
+
+// URL returns the URL of the server.
+func (srv *Server) URL() string {
+ return srv.url
+}
+
+// serveHTTP serves the EC2 protocol.
+func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
+ req.ParseForm()
+
+ a := srv.newAction()
+ a.RequestId = fmt.Sprintf("req%d", srv.reqId.next())
+ a.Request = req.Form
+
+ // Methods on Server that deal with parsing user data
+ // may fail. To save on error handling code, we allow these
+ // methods to call fatalf, which will panic with an *ec2.Error
+ // which will be caught here and returned
+ // to the client as a properly formed EC2 error.
+ defer func() {
+ switch err := recover().(type) {
+ case *ec2.Error:
+ a.Err = err
+ err.RequestId = a.RequestId
+ writeError(w, err)
+ case nil:
+ default:
+ panic(err)
+ }
+ }()
+
+ f := actions[req.Form.Get("Action")]
+ if f == nil {
+ fatalf(400, "InvalidParameterValue", "Unrecognized Action")
+ }
+
+ response := f(srv, w, req, a.RequestId)
+ a.Response = response
+
+ w.Header().Set("Content-Type", `xml version="1.0" encoding="UTF-8"`)
+ xmlMarshal(w, response)
+}
+
+// Instance returns the instance for the given instance id.
+// It returns nil if there is no such instance.
+func (srv *Server) Instance(id string) *Instance {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ return srv.instances[id]
+}
+
+// writeError writes an appropriate error response.
+// TODO how should we deal with errors when the
+// error itself is potentially generated by backend-agnostic
+// code?
+func writeError(w http.ResponseWriter, err *ec2.Error) {
+ // Error encapsulates an error returned by EC2.
+ // TODO merge with ec2.Error when xml supports ignoring a field.
+ type ec2error struct {
+ Code string // EC2 error code ("UnsupportedOperation", ...)
+ Message string // The human-oriented error message
+ RequestId string
+ }
+
+ type Response struct {
+ RequestId string
+ Errors []ec2error `xml:"Errors>Error"`
+ }
+
+ w.Header().Set("Content-Type", `xml version="1.0" encoding="UTF-8"`)
+ w.WriteHeader(err.StatusCode)
+ xmlMarshal(w, Response{
+ RequestId: err.RequestId,
+ Errors: []ec2error{{
+ Code: err.Code,
+ Message: err.Message,
+ }},
+ })
+}
+
+// xmlMarshal is the same as xml.Marshal except that
+// it panics on error. The marshalling should not fail,
+// but we want to know if it does.
+func xmlMarshal(w io.Writer, x interface{}) {
+ if err := xml.NewEncoder(w).Encode(x); err != nil {
+ panic(fmt.Errorf("error marshalling %#v: %v", x, err))
+ }
+}
+
+// formToGroups parses a set of SecurityGroup form values
+// as found in a RunInstances request, and returns the resulting
+// slice of security groups.
+// It calls fatalf if a group is not found.
+func (srv *Server) formToGroups(form url.Values) []*securityGroup {
+ var groups []*securityGroup
+ for name, values := range form {
+ switch {
+ case strings.HasPrefix(name, "SecurityGroupId."):
+ if g := srv.groups[values[0]]; g != nil {
+ groups = append(groups, g)
+ } else {
+ fatalf(400, "InvalidGroup.NotFound", "unknown group id %q", values[0])
+ }
+ case strings.HasPrefix(name, "SecurityGroup."):
+ var found *securityGroup
+ for _, g := range srv.groups {
+ if g.name == values[0] {
+ found = g
+ }
+ }
+ if found == nil {
+ fatalf(400, "InvalidGroup.NotFound", "unknown group name %q", values[0])
+ }
+ groups = append(groups, found)
+ }
+ }
+ return groups
+}
+
+// runInstances implements the EC2 RunInstances entry point.
+func (srv *Server) runInstances(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ min := atoi(req.Form.Get("MinCount"))
+ max := atoi(req.Form.Get("MaxCount"))
+ if min < 0 || max < 1 {
+ fatalf(400, "InvalidParameterValue", "bad values for MinCount or MaxCount")
+ }
+ if min > max {
+ fatalf(400, "InvalidParameterCombination", "MinCount is greater than MaxCount")
+ }
+ var userData []byte
+ if data := req.Form.Get("UserData"); data != "" {
+ var err error
+ userData, err = b64.DecodeString(data)
+ if err != nil {
+ fatalf(400, "InvalidParameterValue", "bad UserData value: %v", err)
+ }
+ }
+
+ // TODO attributes still to consider:
+ // ImageId: accept anything, we can verify later
+ // KeyName ?
+ // InstanceType ?
+ // KernelId ?
+ // RamdiskId ?
+ // AvailZone ?
+ // GroupName tag
+ // Monitoring ignore?
+ // SubnetId ?
+ // DisableAPITermination bool
+ // ShutdownBehavior string
+ // PrivateIPAddress string
+
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+
+ // make sure that form fields are correct before creating the reservation.
+ instType := req.Form.Get("InstanceType")
+ imageId := req.Form.Get("ImageId")
+
+ r := srv.newReservation(srv.formToGroups(req.Form))
+
+ var resp ec2.RunInstancesResp
+ resp.RequestId = reqId
+ resp.ReservationId = r.id
+ resp.OwnerId = ownerId
+
+ for i := 0; i < max; i++ {
+ inst := srv.newInstance(r, instType, imageId, srv.initialInstanceState)
+ inst.UserData = userData
+ resp.Instances = append(resp.Instances, inst.ec2instance())
+ }
+ return &resp
+}
+
+func (srv *Server) group(group ec2.SecurityGroup) *securityGroup {
+ if group.Id != "" {
+ return srv.groups[group.Id]
+ }
+ for _, g := range srv.groups {
+ if g.name == group.Name {
+ return g
+ }
+ }
+ return nil
+}
+
+// NewInstances creates n new instances in srv with the given instance type,
+// image ID, initial state and security groups. If any group does not already
+// exist, it will be created. NewInstances returns the ids of the new instances.
+func (srv *Server) NewInstances(n int, instType string, imageId string, state ec2.InstanceState, groups []ec2.SecurityGroup) []string {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+
+ rgroups := make([]*securityGroup, len(groups))
+ for i, group := range groups {
+ g := srv.group(group)
+ if g == nil {
+ fatalf(400, "InvalidGroup.NotFound", "no such group %v", g)
+ }
+ rgroups[i] = g
+ }
+ r := srv.newReservation(rgroups)
+
+ ids := make([]string, n)
+ for i := 0; i < n; i++ {
+ inst := srv.newInstance(r, instType, imageId, state)
+ ids[i] = inst.id
+ }
+ return ids
+}
+
+func (srv *Server) newInstance(r *reservation, instType string, imageId string, state ec2.InstanceState) *Instance {
+ inst := &Instance{
+ id: fmt.Sprintf("i-%d", srv.maxId.next()),
+ instType: instType,
+ imageId: imageId,
+ state: state,
+ reservation: r,
+ }
+ srv.instances[inst.id] = inst
+ r.instances[inst.id] = inst
+ return inst
+}
+
+func (srv *Server) newReservation(groups []*securityGroup) *reservation {
+ r := &reservation{
+ id: fmt.Sprintf("r-%d", srv.reservationId.next()),
+ instances: make(map[string]*Instance),
+ groups: groups,
+ }
+
+ srv.reservations[r.id] = r
+ return r
+}
+
+func (srv *Server) terminateInstances(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ var resp ec2.TerminateInstancesResp
+ resp.RequestId = reqId
+ var insts []*Instance
+ for attr, vals := range req.Form {
+ if strings.HasPrefix(attr, "InstanceId.") {
+ id := vals[0]
+ inst := srv.instances[id]
+ if inst == nil {
+ fatalf(400, "InvalidInstanceID.NotFound", "no such instance id %q", id)
+ }
+ insts = append(insts, inst)
+ }
+ }
+ for _, inst := range insts {
+ resp.StateChanges = append(resp.StateChanges, inst.terminate())
+ }
+ return &resp
+}
+
+func (inst *Instance) terminate() (d ec2.InstanceStateChange) {
+ d.PreviousState = inst.state
+ inst.state = ShuttingDown
+ d.CurrentState = inst.state
+ d.InstanceId = inst.id
+ return d
+}
+
+func (inst *Instance) ec2instance() ec2.Instance {
+ return ec2.Instance{
+ InstanceId: inst.id,
+ InstanceType: inst.instType,
+ ImageId: inst.imageId,
+ DNSName: fmt.Sprintf("%s.example.com", inst.id),
+ // TODO the rest
+ }
+}
+
+func (inst *Instance) matchAttr(attr, value string) (ok bool, err error) {
+ switch attr {
+ case "architecture":
+ return value == "i386", nil
+ case "instance-id":
+ return inst.id == value, nil
+ case "group-id":
+ for _, g := range inst.reservation.groups {
+ if g.id == value {
+ return true, nil
+ }
+ }
+ return false, nil
+ case "group-name":
+ for _, g := range inst.reservation.groups {
+ if g.name == value {
+ return true, nil
+ }
+ }
+ return false, nil
+ case "image-id":
+ return value == inst.imageId, nil
+ case "instance-state-code":
+ code, err := strconv.Atoi(value)
+ if err != nil {
+ return false, err
+ }
+ return code&0xff == inst.state.Code, nil
+ case "instance-state-name":
+ return value == inst.state.Name, nil
+ }
+ return false, fmt.Errorf("unknown attribute %q", attr)
+}
+
+var (
+ Pending = ec2.InstanceState{0, "pending"}
+ Running = ec2.InstanceState{16, "running"}
+ ShuttingDown = ec2.InstanceState{32, "shutting-down"}
+ Terminated = ec2.InstanceState{16, "terminated"}
+ Stopped = ec2.InstanceState{16, "stopped"}
+)
+
+func (srv *Server) createSecurityGroup(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ name := req.Form.Get("GroupName")
+ if name == "" {
+ fatalf(400, "InvalidParameterValue", "empty security group name")
+ }
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ if srv.group(ec2.SecurityGroup{Name: name}) != nil {
+ fatalf(400, "InvalidGroup.Duplicate", "group %q already exists", name)
+ }
+ g := &securityGroup{
+ name: name,
+ description: req.Form.Get("GroupDescription"),
+ id: fmt.Sprintf("sg-%d", srv.groupId.next()),
+ perms: make(map[permKey]bool),
+ }
+ srv.groups[g.id] = g
+ // we define a local type for this because ec2.CreateSecurityGroupResp
+ // contains SecurityGroup, but the response to this request
+ // should not contain the security group name.
+ type CreateSecurityGroupResponse struct {
+ RequestId string `xml:"requestId"`
+ Return bool `xml:"return"`
+ GroupId string `xml:"groupId"`
+ }
+ r := &CreateSecurityGroupResponse{
+ RequestId: reqId,
+ Return: true,
+ GroupId: g.id,
+ }
+ return r
+}
+
+func (srv *Server) notImplemented(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ fatalf(500, "InternalError", "not implemented")
+ panic("not reached")
+}
+
+func (srv *Server) describeInstances(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ insts := make(map[*Instance]bool)
+ for name, vals := range req.Form {
+ if !strings.HasPrefix(name, "InstanceId.") {
+ continue
+ }
+ inst := srv.instances[vals[0]]
+ if inst == nil {
+ fatalf(400, "InvalidInstanceID.NotFound", "instance %q not found", vals[0])
+ }
+ insts[inst] = true
+ }
+
+ f := newFilter(req.Form)
+
+ var resp ec2.InstancesResp
+ resp.RequestId = reqId
+ for _, r := range srv.reservations {
+ var instances []ec2.Instance
+ for _, inst := range r.instances {
+ if len(insts) > 0 && !insts[inst] {
+ continue
+ }
+ ok, err := f.ok(inst)
+ if ok {
+ instances = append(instances, inst.ec2instance())
+ } else if err != nil {
+ fatalf(400, "InvalidParameterValue", "describe instances: %v", err)
+ }
+ }
+ if len(instances) > 0 {
+ var groups []ec2.SecurityGroup
+ for _, g := range r.groups {
+ groups = append(groups, g.ec2SecurityGroup())
+ }
+ resp.Reservations = append(resp.Reservations, ec2.Reservation{
+ ReservationId: r.id,
+ OwnerId: ownerId,
+ Instances: instances,
+ SecurityGroups: groups,
+ })
+ }
+ }
+ return &resp
+}
+
+func (srv *Server) describeSecurityGroups(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ // BUG similar bug to describeInstances, but for GroupName and GroupId
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+
+ var groups []*securityGroup
+ for name, vals := range req.Form {
+ var g ec2.SecurityGroup
+ switch {
+ case strings.HasPrefix(name, "GroupName."):
+ g.Name = vals[0]
+ case strings.HasPrefix(name, "GroupId."):
+ g.Id = vals[0]
+ default:
+ continue
+ }
+ sg := srv.group(g)
+ if sg == nil {
+ fatalf(400, "InvalidGroup.NotFound", "no such group %v", g)
+ }
+ groups = append(groups, sg)
+ }
+ if len(groups) == 0 {
+ for _, g := range srv.groups {
+ groups = append(groups, g)
+ }
+ }
+
+ f := newFilter(req.Form)
+ var resp ec2.SecurityGroupsResp
+ resp.RequestId = reqId
+ for _, group := range groups {
+ ok, err := f.ok(group)
+ if ok {
+ resp.Groups = append(resp.Groups, ec2.SecurityGroupInfo{
+ OwnerId: ownerId,
+ SecurityGroup: group.ec2SecurityGroup(),
+ Description: group.description,
+ IPPerms: group.ec2Perms(),
+ })
+ } else if err != nil {
+ fatalf(400, "InvalidParameterValue", "describe security groups: %v", err)
+ }
+ }
+ return &resp
+}
+
+func (srv *Server) authorizeSecurityGroupIngress(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ g := srv.group(ec2.SecurityGroup{
+ Name: req.Form.Get("GroupName"),
+ Id: req.Form.Get("GroupId"),
+ })
+ if g == nil {
+ fatalf(400, "InvalidGroup.NotFound", "group not found")
+ }
+ perms := srv.parsePerms(req)
+
+ for _, p := range perms {
+ if g.perms[p] {
+ fatalf(400, "InvalidPermission.Duplicate", "Permission has already been authorized on the specified group")
+ }
+ }
+ for _, p := range perms {
+ g.perms[p] = true
+ }
+ return &ec2.SimpleResp{
+ XMLName: xml.Name{"", "AuthorizeSecurityGroupIngressResponse"},
+ RequestId: reqId,
+ }
+}
+
+func (srv *Server) revokeSecurityGroupIngress(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ g := srv.group(ec2.SecurityGroup{
+ Name: req.Form.Get("GroupName"),
+ Id: req.Form.Get("GroupId"),
+ })
+ if g == nil {
+ fatalf(400, "InvalidGroup.NotFound", "group not found")
+ }
+ perms := srv.parsePerms(req)
+
+ // Note EC2 does not give an error if asked to revoke an authorization
+ // that does not exist.
+ for _, p := range perms {
+ delete(g.perms, p)
+ }
+ return &ec2.SimpleResp{
+ XMLName: xml.Name{"", "RevokeSecurityGroupIngressResponse"},
+ RequestId: reqId,
+ }
+}
+
+var secGroupPat = regexp.MustCompile(`^sg-[a-z0-9]+$`)
+var ipPat = regexp.MustCompile(`^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$`)
+var ownerIdPat = regexp.MustCompile(`^[0-9]+$`)
+
+// parsePerms returns a slice of permKey values extracted
+// from the permission fields in req.
+func (srv *Server) parsePerms(req *http.Request) []permKey {
+ // perms maps an index found in the form to its associated
+ // IPPerm. For instance, the form value with key
+ // "IpPermissions.3.FromPort" will be stored in perms[3].FromPort
+ perms := make(map[int]ec2.IPPerm)
+
+ type subgroupKey struct {
+ id1, id2 int
+ }
+ // Each IPPerm can have many source security groups. The form key
+ // for a source security group contains two indices: the index
+ // of the IPPerm and the sub-index of the security group. The
+ // sourceGroups map maps from a subgroupKey containing these
+ // two indices to the associated security group. For instance,
+ // the form value with key "IPPermissions.3.Groups.2.GroupName"
+ // will be stored in sourceGroups[subgroupKey{3, 2}].Name.
+ sourceGroups := make(map[subgroupKey]ec2.UserSecurityGroup)
+
+ // For each value in the form we store its associated information in the
+ // above maps. The maps are necessary because the form keys may
+ // arrive in any order, and the indices are not
+ // necessarily sequential or even small.
+ for name, vals := range req.Form {
+ val := vals[0]
+ var id1 int
+ var rest string
+ if x, _ := fmt.Sscanf(name, "IpPermissions.%d.%s", &id1, &rest); x != 2 {
+ continue
+ }
+ ec2p := perms[id1]
+ switch {
+ case rest == "FromPort":
+ ec2p.FromPort = atoi(val)
+ case rest == "ToPort":
+ ec2p.ToPort = atoi(val)
+ case rest == "IpProtocol":
+ switch val {
+ case "tcp", "udp", "icmp":
+ ec2p.Protocol = val
+ default:
+ // check it's a well formed number
+ atoi(val)
+ ec2p.Protocol = val
+ }
+ case strings.HasPrefix(rest, "Groups."):
+ k := subgroupKey{id1: id1}
+ if x, _ := fmt.Sscanf(rest[len("Groups."):], "%d.%s", &k.id2, &rest); x != 2 {
+ continue
+ }
+ g := sourceGroups[k]
+ switch rest {
+ case "UserId":
+ // BUG if the user id is blank, this does not conform to the
+ // way that EC2 handles it - a specified but blank owner id
+ // can cause RevokeSecurityGroupIngress to fail with
+ // "group not found" even if the security group id has been
+ // correctly specified.
+ // By failing here, we ensure that we fail early in this case.
+ if !ownerIdPat.MatchString(val) {
+ fatalf(400, "InvalidUserID.Malformed", "Invalid user ID: %q", val)
+ }
+ g.OwnerId = val
+ case "GroupName":
+ g.Name = val
+ case "GroupId":
+ if !secGroupPat.MatchString(val) {
+ fatalf(400, "InvalidGroupId.Malformed", "Invalid group ID: %q", val)
+ }
+ g.Id = val
+ default:
+ fatalf(400, "UnknownParameter", "unknown parameter %q", name)
+ }
+ sourceGroups[k] = g
+ case strings.HasPrefix(rest, "IpRanges."):
+ var id2 int
+ if x, _ := fmt.Sscanf(rest[len("IpRanges."):], "%d.%s", &id2, &rest); x != 2 {
+ continue
+ }
+ switch rest {
+ case "CidrIp":
+ if !ipPat.MatchString(val) {
+ fatalf(400, "InvalidPermission.Malformed", "Invalid IP range: %q", val)
+ }
+ ec2p.SourceIPs = append(ec2p.SourceIPs, val)
+ default:
+ fatalf(400, "UnknownParameter", "unknown parameter %q", name)
+ }
+ default:
+ fatalf(400, "UnknownParameter", "unknown parameter %q", name)
+ }
+ perms[id1] = ec2p
+ }
+ // Associate each set of source groups with its IPPerm.
+ for k, g := range sourceGroups {
+ p := perms[k.id1]
+ p.SourceGroups = append(p.SourceGroups, g)
+ perms[k.id1] = p
+ }
+
+ // Now that we have built up the IPPerms we need, we check for
+ // parameter errors and build up a permKey for each permission,
+ // looking up security groups from srv as we do so.
+ var result []permKey
+ for _, p := range perms {
+ if p.FromPort > p.ToPort {
+ fatalf(400, "InvalidParameterValue", "invalid port range")
+ }
+ k := permKey{
+ protocol: p.Protocol,
+ fromPort: p.FromPort,
+ toPort: p.ToPort,
+ }
+ for _, g := range p.SourceGroups {
+ if g.OwnerId != "" && g.OwnerId != ownerId {
+ fatalf(400, "InvalidGroup.NotFound", "group %q not found", g.Name)
+ }
+ var ec2g ec2.SecurityGroup
+ switch {
+ case g.Id != "":
+ ec2g.Id = g.Id
+ case g.Name != "":
+ ec2g.Name = g.Name
+ }
+ k.group = srv.group(ec2g)
+ if k.group == nil {
+ fatalf(400, "InvalidGroup.NotFound", "group %v not found", g)
+ }
+ result = append(result, k)
+ }
+ k.group = nil
+ for _, ip := range p.SourceIPs {
+ k.ipAddr = ip
+ result = append(result, k)
+ }
+ }
+ return result
+}
+
+func (srv *Server) deleteSecurityGroup(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+ g := srv.group(ec2.SecurityGroup{
+ Name: req.Form.Get("GroupName"),
+ Id: req.Form.Get("GroupId"),
+ })
+ if g == nil {
+ fatalf(400, "InvalidGroup.NotFound", "group not found")
+ }
+ for _, r := range srv.reservations {
+ for _, h := range r.groups {
+ if h == g && r.hasRunningMachine() {
+ fatalf(500, "InvalidGroup.InUse", "group is currently in use by a running instance")
+ }
+ }
+ }
+ for _, sg := range srv.groups {
+ // If a group refers to itself, it's ok to delete it.
+ if sg == g {
+ continue
+ }
+ for k := range sg.perms {
+ if k.group == g {
+ fatalf(500, "InvalidGroup.InUse", "group is currently in use by group %q", sg.id)
+ }
+ }
+ }
+
+ delete(srv.groups, g.id)
+ return &ec2.SimpleResp{
+ XMLName: xml.Name{"", "DeleteSecurityGroupResponse"},
+ RequestId: reqId,
+ }
+}
+
+func (r *reservation) hasRunningMachine() bool {
+ for _, inst := range r.instances {
+ if inst.state.Code != ShuttingDown.Code && inst.state.Code != Terminated.Code {
+ return true
+ }
+ }
+ return false
+}
+
+type counter int
+
+func (c *counter) next() (i int) {
+ i = int(*c)
+ (*c)++
+ return
+}
+
+// atoi is like strconv.Atoi but is fatal if the
+// string is not well formed.
+func atoi(s string) int {
+ i, err := strconv.Atoi(s)
+ if err != nil {
+ fatalf(400, "InvalidParameterValue", "bad number: %v", err)
+ }
+ return i
+}
+
+func fatalf(statusCode int, code string, f string, a ...interface{}) {
+ panic(&ec2.Error{
+ StatusCode: statusCode,
+ Code: code,
+ Message: fmt.Sprintf(f, a...),
+ })
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/export_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/export_test.go
new file mode 100644
index 00000000..1c244221
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/export_test.go
@@ -0,0 +1,22 @@
+package ec2
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "time"
+)
+
+func Sign(auth aws.Auth, method, path string, params map[string]string, host string) {
+ sign(auth, method, path, params, host)
+}
+
+func fixedTime() time.Time {
+ return time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC)
+}
+
+func FakeTime(fakeIt bool) {
+ if fakeIt {
+ timeNow = fixedTime
+ } else {
+ timeNow = time.Now
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/responses_test.go
new file mode 100644
index 00000000..61f7a419
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/responses_test.go
@@ -0,0 +1,854 @@
+package ec2_test
+
+var ErrorDump = `
+
+UnsupportedOperation
+AMIs with an instance-store root device are not supported for the instance type 't1.micro'.
+0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4
+`
+
+// http://goo.gl/Mcm3b
+var RunInstancesExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ r-47a5402e
+ 999988887777
+
+
+ sg-67ad940e
+ default
+
+
+
+
+ i-2ba64342
+ ami-60a54009
+
+ 0
+ pending
+
+
+
+ example-key-name
+ 0
+ m1.small
+ 2007-08-07T11:51:50.000Z
+
+ us-east-1b
+
+
+ enabled
+
+ paravirtual
+
+
+ xen
+
+
+ i-2bc64242
+ ami-60a54009
+
+ 0
+ pending
+
+
+
+ example-key-name
+ 1
+ m1.small
+ 2007-08-07T11:51:50.000Z
+
+ us-east-1b
+
+
+ enabled
+
+ paravirtual
+
+
+ xen
+
+
+ i-2be64332
+ ami-60a54009
+
+ 0
+ pending
+
+
+
+ example-key-name
+ 2
+ m1.small
+ 2007-08-07T11:51:50.000Z
+
+ us-east-1b
+
+
+ enabled
+
+ paravirtual
+
+
+ xen
+
+
+
+`
+
+// http://goo.gl/GRZgCD
+var RequestSpotInstancesExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+
+
+ sir-1a2b3c4d
+ 0.5
+ one-time
+ open
+
+ pending-evaluation
+ YYYY-MM-DDTHH:MM:SS.000Z
+ Your Spot request has been submitted for review, and is pending evaluation.
+
+ MyAzGroup
+
+ ami-1a2b3c4d
+ gsg-keypair
+
+
+ sg-1a2b3c4d
+ websrv
+
+
+ m1.small
+
+
+ false
+
+ false
+
+ YYYY-MM-DDTHH:MM:SS.000Z
+ Linux/UNIX
+
+
+
+`
+
+// http://goo.gl/KsKJJk
+var DescribeSpotRequestsExample = `
+
+ b1719f2a-5334-4479-b2f1-26926EXAMPLE
+
+
+ sir-1a2b3c4d
+ 0.5
+ one-time
+ active
+
+ fulfilled
+ YYYY-MM-DDTHH:MM:SS.000Z
+ Your Spot request is fulfilled.
+
+
+ ami-1a2b3c4d
+ gsg-keypair
+
+
+ sg-1a2b3c4d
+ websrv
+
+
+ m1.small
+
+ false
+
+ false
+
+ i-1a2b3c4d
+ YYYY-MM-DDTHH:MM:SS.000Z
+ Linux/UNIX
+ us-east-1a
+
+
+
+`
+
+// http://goo.gl/DcfFgJ
+var CancelSpotRequestsExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+
+
+ sir-1a2b3c4d
+ cancelled
+
+
+
+`
+
+// http://goo.gl/3BKHj
+var TerminateInstancesExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+
+
+ i-3ea74257
+
+ 32
+ shutting-down
+
+
+ 16
+ running
+
+
+
+
+`
+
+// http://goo.gl/mLbmw
+var DescribeInstancesExample1 = `
+
+ 98e3c9a4-848c-4d6d-8e8a-b1bdEXAMPLE
+
+
+ r-b27e30d9
+ 999988887777
+
+
+ sg-67ad940e
+ default
+
+
+
+
+ i-c5cd56af
+ ami-1a2b3c4d
+
+ 16
+ running
+
+ domU-12-31-39-10-56-34.compute-1.internal
+ ec2-174-129-165-232.compute-1.amazonaws.com
+
+ GSG_Keypair
+ 0
+
+ m1.small
+ 2010-08-17T01:15:18.000Z
+
+ us-east-1b
+
+
+ aki-94c527fd
+ ari-96c527ff
+
+ disabled
+
+ 10.198.85.190
+ 174.129.165.232
+ i386
+ ebs
+ /dev/sda1
+
+
+ /dev/sda1
+
+ vol-a082c1c9
+ attached
+ 2010-08-17T01:15:21.000Z
+ false
+
+
+
+ spot
+ sir-7a688402
+ paravirtual
+
+
+ xen
+
+
+ 854251627541
+
+
+ r-b67e30dd
+ 999988887777
+
+
+ sg-67ad940e
+ default
+
+
+
+
+ i-d9cd56b3
+ ami-1a2b3c4d
+
+ 16
+ running
+
+ domU-12-31-39-10-54-E5.compute-1.internal
+ ec2-184-73-58-78.compute-1.amazonaws.com
+
+ GSG_Keypair
+ 0
+
+ m1.large
+ 2010-08-17T01:15:19.000Z
+
+ us-east-1b
+
+
+ aki-94c527fd
+ ari-96c527ff
+
+ disabled
+
+ 10.198.87.19
+ 184.73.58.78
+ i386
+ ebs
+ /dev/sda1
+
+
+ /dev/sda1
+
+ vol-a282c1cb
+ attached
+ 2010-08-17T01:15:23.000Z
+ false
+
+
+
+ spot
+ sir-55a3aa02
+ paravirtual
+
+
+ xen
+
+
+ 854251627541
+
+
+
+`
+
+// http://goo.gl/mLbmw
+var DescribeInstancesExample2 = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+
+
+ r-bc7e30d7
+ 999988887777
+
+
+ sg-67ad940e
+ default
+
+
+
+
+ i-c7cd56ad
+ ami-b232d0db
+
+ 16
+ running
+
+ domU-12-31-39-01-76-06.compute-1.internal
+ ec2-72-44-52-124.compute-1.amazonaws.com
+ GSG_Keypair
+ 0
+
+ m1.small
+ 2010-08-17T01:15:16.000Z
+
+ us-east-1b
+
+ aki-94c527fd
+ ari-96c527ff
+
+ disabled
+
+ 10.255.121.240
+ 72.44.52.124
+ i386
+ ebs
+ /dev/sda1
+
+
+ /dev/sda1
+
+ vol-a482c1cd
+ attached
+ 2010-08-17T01:15:26.000Z
+ true
+
+
+
+ paravirtual
+
+
+
+ webserver
+
+
+
+ stack
+ Production
+
+
+ xen
+
+
+
+
+
+`
+
+// http://goo.gl/cxU41
+var CreateImageExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ ami-4fa54026
+
+`
+
+// http://goo.gl/V0U25
+var DescribeImagesExample = `
+
+ 4a4a27a2-2e7c-475d-b35b-ca822EXAMPLE
+
+
+ ami-a2469acf
+ aws-marketplace/example-marketplace-amzn-ami.1
+ available
+ 123456789999
+ true
+
+
+ a1b2c3d4e5f6g7h8i9j10k11
+ marketplace
+
+
+ i386
+ machine
+ aki-805ea7e9
+ aws-marketplace
+ example-marketplace-amzn-ami.1
+ Amazon Linux AMI i386 EBS
+ ebs
+ /dev/sda1
+
+
+ /dev/sda1
+
+ snap-787e9403
+ 8
+ true
+
+
+
+ paravirtual
+ xen
+
+
+
+`
+
+// http://goo.gl/bHO3z
+var ImageAttributeExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ ami-61a54008
+
+
+ all
+
+
+ 495219933132
+
+
+
+`
+
+// http://goo.gl/ttcda
+var CreateSnapshotExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ snap-78a54011
+ vol-4d826724
+ pending
+ 2008-05-07T12:51:50.000Z
+
+ 111122223333
+ 10
+ Daily Backup
+
+`
+
+// http://goo.gl/vwU1y
+var DeleteSnapshotExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/nkovs
+var DescribeSnapshotsExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+
+
+ snap-1a2b3c4d
+ vol-8875daef
+ pending
+ 2010-07-29T04:12:01.000Z
+
+ 111122223333
+ 15
+ Daily Backup
+
+
+ Purpose
+ demo_db_14_backup
+
+
+
+
+
+`
+
+// http://goo.gl/YUjO4G
+var ModifyImageAttributeExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/hQwPCK
+var CopyImageExample = `
+
+ 60bc441d-fa2c-494d-b155-5d6a3EXAMPLE
+ ami-4d3c2b1a
+
+`
+
+var CreateKeyPairExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ foo
+
+ 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
+
+ ---- BEGIN RSA PRIVATE KEY ----
+MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC
+VVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6
+b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd
+BgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN
+MTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD
+VQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z
+b2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt
+YXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ
+21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T
+rDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE
+Ibb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4
+nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb
+FFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb
+NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE=
+-----END RSA PRIVATE KEY-----
+
+
+`
+
+var DeleteKeyPairExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/Eo7Yl
+var CreateSecurityGroupExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+ sg-67ad940e
+
+`
+
+// http://goo.gl/k12Uy
+var DescribeSecurityGroupsExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+
+
+ 999988887777
+ WebServers
+ sg-67ad940e
+ Web Servers
+
+
+ tcp
+ 80
+ 80
+
+
+
+ 0.0.0.0/0
+
+
+
+
+
+
+ 999988887777
+ RangedPortsBySource
+ sg-76abc467
+ Group A
+
+
+ tcp
+ 6000
+ 7000
+
+
+
+
+
+
+
+`
+
+// A dump which includes groups within ip permissions.
+var DescribeSecurityGroupsDump = `
+
+
+ 87b92b57-cc6e-48b2-943f-f6f0e5c9f46c
+
+
+ 12345
+ default
+ default group
+
+
+ icmp
+ -1
+ -1
+
+
+ 12345
+ default
+ sg-67ad940e
+
+
+
+
+
+ tcp
+ 0
+ 65535
+
+
+ 12345
+ other
+ sg-76abc467
+
+
+
+
+
+
+
+
+`
+
+// http://goo.gl/QJJDO
+var DeleteSecurityGroupExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/u2sDJ
+var AuthorizeSecurityGroupIngressExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/u2sDJ
+var AuthorizeSecurityGroupEgressExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/Mz7xr
+var RevokeSecurityGroupIngressExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/Vmkqc
+var CreateTagsExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/awKeF
+var StartInstancesExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+
+
+ i-10a64379
+
+ 0
+ pending
+
+
+ 80
+ stopped
+
+
+
+
+`
+
+// http://goo.gl/436dJ
+var StopInstancesExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+
+
+ i-10a64379
+
+ 64
+ stopping
+
+
+ 16
+ running
+
+
+
+
+`
+
+// http://goo.gl/baoUf
+var RebootInstancesExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/9rprDN
+var AllocateAddressExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ 198.51.100.1
+ vpc
+ eipalloc-5723d13e
+
+`
+
+// http://goo.gl/3Q0oCc
+var ReleaseAddressExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/uOSQE
+var AssociateAddressExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+ eipassoc-fc5ca095
+
+`
+
+// http://goo.gl/LrOa0
+var DisassociateAddressExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+// http://goo.gl/icuXh5
+var ModifyInstanceExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
+
+var CreateVpcExample = `
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+ vpc-1a2b3c4d
+ pending
+ 10.0.0.0/16
+ dopt-1a2b3c4d2
+ default
+
+
+
+`
+
+var DescribeVpcsExample = `
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+ vpc-1a2b3c4d
+ available
+ 10.0.0.0/23
+ dopt-7a8b9c2d
+ default
+ false
+
+
+
+
+`
+
+var CreateSubnetExample = `
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+ subnet-9d4a7b6c
+ pending
+ vpc-1a2b3c4d
+ 10.0.1.0/24
+ 251
+ us-east-1a
+
+
+
+`
+
+// http://goo.gl/r6ZCPm
+var ResetImageAttributeExample = `
+
+ 59dbff89-35bd-4eac-99ed-be587EXAMPLE
+ true
+
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/sign.go
new file mode 100644
index 00000000..bffc3c7e
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/sign.go
@@ -0,0 +1,45 @@
+package ec2
+
+import (
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+ "sort"
+ "strings"
+)
+
+// ----------------------------------------------------------------------------
+// EC2 signing (http://goo.gl/fQmAN)
+
+var b64 = base64.StdEncoding
+
+func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
+ params["AWSAccessKeyId"] = auth.AccessKey
+ params["SignatureVersion"] = "2"
+ params["SignatureMethod"] = "HmacSHA256"
+ if auth.Token != "" {
+ params["SecurityToken"] = auth.Token
+ }
+
+ // AWS specifies that the parameters in a signed request must
+ // be provided in the natural order of the keys. This is distinct
+ // from the natural order of the encoded value of key=value.
+ // Percent and equals affect the sorting order.
+ var keys, sarray []string
+ for k, _ := range params {
+ keys = append(keys, k)
+ }
+ sort.Strings(keys)
+ for _, k := range keys {
+ sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(params[k]))
+ }
+ joined := strings.Join(sarray, "&")
+ payload := method + "\n" + host + "\n" + path + "\n" + joined
+ hash := hmac.New(sha256.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ params["Signature"] = string(signature)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/sign_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/sign_test.go
new file mode 100644
index 00000000..86d203e7
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/ec2/sign_test.go
@@ -0,0 +1,68 @@
+package ec2_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/ec2"
+ . "github.com/motain/gocheck"
+)
+
+// EC2 ReST authentication docs: http://goo.gl/fQmAN
+
+var testAuth = aws.Auth{"user", "secret", ""}
+
+func (s *S) TestBasicSignature(c *C) {
+ params := map[string]string{}
+ ec2.Sign(testAuth, "GET", "/path", params, "localhost")
+ c.Assert(params["SignatureVersion"], Equals, "2")
+ c.Assert(params["SignatureMethod"], Equals, "HmacSHA256")
+ expected := "6lSe5QyXum0jMVc7cOUz32/52ZnL7N5RyKRk/09yiK4="
+ c.Assert(params["Signature"], Equals, expected)
+}
+
+func (s *S) TestParamSignature(c *C) {
+ params := map[string]string{
+ "param1": "value1",
+ "param2": "value2",
+ "param3": "value3",
+ }
+ ec2.Sign(testAuth, "GET", "/path", params, "localhost")
+ expected := "XWOR4+0lmK8bD8CGDGZ4kfuSPbb2JibLJiCl/OPu1oU="
+ c.Assert(params["Signature"], Equals, expected)
+}
+
+func (s *S) TestManyParams(c *C) {
+ params := map[string]string{
+ "param1": "value10",
+ "param2": "value2",
+ "param3": "value3",
+ "param4": "value4",
+ "param5": "value5",
+ "param6": "value6",
+ "param7": "value7",
+ "param8": "value8",
+ "param9": "value9",
+ "param10": "value1",
+ }
+ ec2.Sign(testAuth, "GET", "/path", params, "localhost")
+ expected := "di0sjxIvezUgQ1SIL6i+C/H8lL+U0CQ9frLIak8jkVg="
+ c.Assert(params["Signature"], Equals, expected)
+}
+
+func (s *S) TestEscaping(c *C) {
+ params := map[string]string{"Nonce": "+ +"}
+ ec2.Sign(testAuth, "GET", "/path", params, "localhost")
+ c.Assert(params["Nonce"], Equals, "+ +")
+ expected := "bqffDELReIqwjg/W0DnsnVUmfLK4wXVLO4/LuG+1VFA="
+ c.Assert(params["Signature"], Equals, expected)
+}
+
+func (s *S) TestSignatureExample1(c *C) {
+ params := map[string]string{
+ "Timestamp": "2009-02-01T12:53:20+00:00",
+ "Version": "2007-11-07",
+ "Action": "ListDomains",
+ }
+ ec2.Sign(aws.Auth{"access", "secret", ""}, "GET", "/", params, "sdb.amazonaws.com")
+ expected := "okj96/5ucWBSc1uR2zXVfm6mDHtgfNv657rRtt/aunQ="
+ c.Assert(params["Signature"], Equals, expected)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/elb.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/elb.go
new file mode 100644
index 00000000..61a515d9
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/elb.go
@@ -0,0 +1,365 @@
+// The elb package provides types and functions for interaction with the AWS
+// Elastic Load Balancing service (ELB)
+package elb
+
+import (
+ "encoding/xml"
+ "github.com/mitchellh/goamz/aws"
+ "net/http"
+ "net/url"
+ "strconv"
+ "time"
+)
+
+// The ELB type encapsulates operations operations with the elb endpoint.
+type ELB struct {
+ aws.Auth
+ aws.Region
+ httpClient *http.Client
+}
+
+const APIVersion = "2012-06-01"
+
+// New creates a new ELB instance.
+func New(auth aws.Auth, region aws.Region) *ELB {
+ return NewWithClient(auth, region, aws.RetryingClient)
+}
+
+func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *ELB {
+ return &ELB{auth, region, httpClient}
+}
+
+func (elb *ELB) query(params map[string]string, resp interface{}) error {
+ params["Version"] = APIVersion
+ params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
+
+ endpoint, err := url.Parse(elb.Region.ELBEndpoint)
+ if err != nil {
+ return err
+ }
+
+ sign(elb.Auth, "GET", "/", params, endpoint.Host)
+ endpoint.RawQuery = multimap(params).Encode()
+ r, err := elb.httpClient.Get(endpoint.String())
+
+ if err != nil {
+ return err
+ }
+ defer r.Body.Close()
+ if r.StatusCode > 200 {
+ return buildError(r)
+ }
+
+ decoder := xml.NewDecoder(r.Body)
+ decodedBody := decoder.Decode(resp)
+
+ return decodedBody
+}
+
+func buildError(r *http.Response) error {
+ var (
+ err Error
+ errors xmlErrors
+ )
+ xml.NewDecoder(r.Body).Decode(&errors)
+ if len(errors.Errors) > 0 {
+ err = errors.Errors[0]
+ }
+ err.StatusCode = r.StatusCode
+ if err.Message == "" {
+ err.Message = r.Status
+ }
+ return &err
+}
+
+func multimap(p map[string]string) url.Values {
+ q := make(url.Values, len(p))
+ for k, v := range p {
+ q[k] = []string{v}
+ }
+ return q
+}
+
+func makeParams(action string) map[string]string {
+ params := make(map[string]string)
+ params["Action"] = action
+ return params
+}
+
+// ----------------------------------------------------------------------------
+// ELB objects
+
+// A listener attaches to an elb
+type Listener struct {
+ InstancePort int64 `xml:"member>Listener>InstancePort"`
+ InstanceProtocol string `xml:"member>Listener>InstanceProtocol"`
+ LoadBalancerPort int64 `xml:"member>Listener>LoadBalancerPort"`
+ Protocol string `xml:"member>Listener>Protocol"`
+}
+
+// An Instance attaches to an elb
+type Instance struct {
+ InstanceId string `xml:"member>InstanceId"`
+}
+
+// An InstanceState from an elb health query
+type InstanceState struct {
+ InstanceId string `xml:"member>InstanceId"`
+ Description string `xml:"member>Description"`
+ State string `xml:"member>State"`
+ ReasonCode string `xml:"member>ReasonCode"`
+}
+
+// An Instance attaches to an elb
+type AvailabilityZone struct {
+ AvailabilityZone string `xml:"member"`
+}
+
+// ----------------------------------------------------------------------------
+// Create
+
+// The CreateLoadBalancer request parameters
+type CreateLoadBalancer struct {
+ AvailZone []string
+ Listeners []Listener
+ LoadBalancerName string
+ Internal bool // true for vpc elbs
+ SecurityGroups []string
+ Subnets []string
+}
+
+type CreateLoadBalancerResp struct {
+ DNSName string `xml:"CreateLoadBalancerResult>DNSName"`
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+func (elb *ELB) CreateLoadBalancer(options *CreateLoadBalancer) (resp *CreateLoadBalancerResp, err error) {
+ params := makeParams("CreateLoadBalancer")
+
+ params["LoadBalancerName"] = options.LoadBalancerName
+
+ for i, v := range options.AvailZone {
+ params["AvailabilityZones.member."+strconv.Itoa(i+1)] = v
+ }
+
+ for i, v := range options.SecurityGroups {
+ params["SecurityGroups.member."+strconv.Itoa(i+1)] = v
+ }
+
+ for i, v := range options.Subnets {
+ params["Subnets.member."+strconv.Itoa(i+1)] = v
+ }
+
+ for i, v := range options.Listeners {
+ params["Listeners.member."+strconv.Itoa(i+1)+".LoadBalancerPort"] = strconv.FormatInt(v.LoadBalancerPort, 10)
+ params["Listeners.member."+strconv.Itoa(i+1)+".InstancePort"] = strconv.FormatInt(v.InstancePort, 10)
+ params["Listeners.member."+strconv.Itoa(i+1)+".Protocol"] = v.Protocol
+ params["Listeners.member."+strconv.Itoa(i+1)+".InstanceProtocol"] = v.InstanceProtocol
+ }
+
+ if options.Internal {
+ params["Scheme"] = "internal"
+ }
+
+ resp = &CreateLoadBalancerResp{}
+
+ err = elb.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Destroy
+
+// The DestroyLoadBalancer request parameters
+type DeleteLoadBalancer struct {
+ LoadBalancerName string
+}
+
+func (elb *ELB) DeleteLoadBalancer(options *DeleteLoadBalancer) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteLoadBalancer")
+
+ params["LoadBalancerName"] = options.LoadBalancerName
+
+ resp = &SimpleResp{}
+
+ err = elb.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Describe
+
+// An individual load balancer
+type LoadBalancer struct {
+ LoadBalancerName string `xml:"member>LoadBalancerName"`
+ Listeners []Listener `xml:"member>ListenerDescriptions"`
+ Instances []Instance `xml:"member>Instances"`
+ AvailabilityZones []AvailabilityZone `xml:"member>AvailabilityZones"`
+ Scheme string `xml:"member>Scheme"`
+ DNSName string `xml:"member>DNSName"`
+}
+
+// DescribeLoadBalancer request params
+type DescribeLoadBalancer struct {
+ Names []string
+}
+
+type DescribeLoadBalancersResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ LoadBalancers []LoadBalancer `xml:"DescribeLoadBalancersResult>LoadBalancerDescriptions"`
+}
+
+func (elb *ELB) DescribeLoadBalancers(options *DescribeLoadBalancer) (resp *DescribeLoadBalancersResp, err error) {
+ params := makeParams("DescribeLoadBalancers")
+
+ for i, v := range options.Names {
+ params["LoadBalancerNames.member."+strconv.Itoa(i+1)] = v
+ }
+
+ resp = &DescribeLoadBalancersResp{}
+
+ err = elb.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Instance Registration / degregistration
+
+// The RegisterInstancesWithLoadBalancer request parameters
+type RegisterInstancesWithLoadBalancer struct {
+ LoadBalancerName string
+ Instances []string
+}
+
+type RegisterInstancesWithLoadBalancerResp struct {
+ Instances []Instance `xml:"RegisterInstancesWithLoadBalancerResult>Instances"`
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+func (elb *ELB) RegisterInstancesWithLoadBalancer(options *RegisterInstancesWithLoadBalancer) (resp *RegisterInstancesWithLoadBalancerResp, err error) {
+ params := makeParams("RegisterInstancesWithLoadBalancer")
+
+ params["LoadBalancerName"] = options.LoadBalancerName
+
+ for i, v := range options.Instances {
+ params["Instances.member."+strconv.Itoa(i+1)+".InstanceId"] = v
+ }
+
+ resp = &RegisterInstancesWithLoadBalancerResp{}
+
+ err = elb.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// The DeregisterInstancesFromLoadBalancer request parameters
+type DeregisterInstancesFromLoadBalancer struct {
+ LoadBalancerName string
+ Instances []string
+}
+
+type DeregisterInstancesFromLoadBalancerResp struct {
+ Instances []Instance `xml:"DeregisterInstancesFromLoadBalancerResult>Instances"`
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+func (elb *ELB) DeregisterInstancesFromLoadBalancer(options *DeregisterInstancesFromLoadBalancer) (resp *DeregisterInstancesFromLoadBalancerResp, err error) {
+ params := makeParams("DeregisterInstancesFromLoadBalancer")
+
+ params["LoadBalancerName"] = options.LoadBalancerName
+
+ for i, v := range options.Instances {
+ params["Instances.member."+strconv.Itoa(i+1)+".InstanceId"] = v
+ }
+
+ resp = &DeregisterInstancesFromLoadBalancerResp{}
+
+ err = elb.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Instance Health
+
+// The DescribeInstanceHealth request parameters
+type DescribeInstanceHealth struct {
+ LoadBalancerName string
+}
+
+type DescribeInstanceHealthResp struct {
+ InstanceStates []InstanceState `xml:"DescribeInstanceHealthResult>InstanceStates"`
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+func (elb *ELB) DescribeInstanceHealth(options *DescribeInstanceHealth) (resp *DescribeInstanceHealthResp, err error) {
+ params := makeParams("DescribeInstanceHealth")
+
+ params["LoadBalancerName"] = options.LoadBalancerName
+
+ resp = &DescribeInstanceHealthResp{}
+
+ err = elb.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// Responses
+
+type SimpleResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+type xmlErrors struct {
+ Errors []Error `xml:"Error"`
+}
+
+// Error encapsulates an elb error.
+type Error struct {
+ // HTTP status code of the error.
+ StatusCode int
+
+ // AWS code of the error.
+ Code string
+
+ // Message explaining the error.
+ Message string
+}
+
+func (e *Error) Error() string {
+ var prefix string
+ if e.Code != "" {
+ prefix = e.Code + ": "
+ }
+ if prefix == "" && e.StatusCode > 0 {
+ prefix = strconv.Itoa(e.StatusCode) + ": "
+ }
+ return prefix + e.Message
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/elb_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/elb_test.go
new file mode 100644
index 00000000..3043e720
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/elb_test.go
@@ -0,0 +1,156 @@
+package elb_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/elb"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+type S struct {
+ elb *elb.ELB
+}
+
+var _ = Suite(&S{})
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ s.elb = elb.NewWithClient(auth, aws.Region{ELBEndpoint: testServer.URL}, testutil.DefaultClient)
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) TestCreateLoadBalancer(c *C) {
+ testServer.Response(200, nil, CreateLoadBalancerExample)
+
+ options := elb.CreateLoadBalancer{
+ AvailZone: []string{"us-east-1a"},
+ Listeners: []elb.Listener{elb.Listener{
+ InstancePort: 80,
+ InstanceProtocol: "http",
+ LoadBalancerPort: 80,
+ Protocol: "http",
+ },
+ },
+ LoadBalancerName: "foobar",
+ Internal: false,
+ SecurityGroups: []string{"sg1"},
+ Subnets: []string{"sn1"},
+ }
+
+ resp, err := s.elb.CreateLoadBalancer(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateLoadBalancer"})
+ c.Assert(req.Form["LoadBalancerName"], DeepEquals, []string{"foobar"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "1549581b-12b7-11e3-895e-1334aEXAMPLE")
+}
+
+func (s *S) TestDeleteLoadBalancer(c *C) {
+ testServer.Response(200, nil, DeleteLoadBalancerExample)
+
+ options := elb.DeleteLoadBalancer{
+ LoadBalancerName: "foobar",
+ }
+
+ resp, err := s.elb.DeleteLoadBalancer(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteLoadBalancer"})
+ c.Assert(req.Form["LoadBalancerName"], DeepEquals, []string{"foobar"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "1549581b-12b7-11e3-895e-1334aEXAMPLE")
+}
+
+func (s *S) TestDescribeLoadBalancers(c *C) {
+ testServer.Response(200, nil, DescribeLoadBalancersExample)
+
+ options := elb.DescribeLoadBalancer{
+ Names: []string{"foobar"},
+ }
+
+ resp, err := s.elb.DescribeLoadBalancers(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeLoadBalancers"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "83c88b9d-12b7-11e3-8b82-87b12EXAMPLE")
+ c.Assert(resp.LoadBalancers[0].LoadBalancerName, Equals, "MyLoadBalancer")
+ c.Assert(resp.LoadBalancers[0].Listeners[0].Protocol, Equals, "HTTP")
+ c.Assert(resp.LoadBalancers[0].Instances[0].InstanceId, Equals, "i-e4cbe38d")
+ c.Assert(resp.LoadBalancers[0].AvailabilityZones[0].AvailabilityZone, Equals, "us-east-1a")
+ c.Assert(resp.LoadBalancers[0].Scheme, Equals, "internet-facing")
+ c.Assert(resp.LoadBalancers[0].DNSName, Equals, "MyLoadBalancer-123456789.us-east-1.elb.amazonaws.com")
+}
+
+func (s *S) TestRegisterInstancesWithLoadBalancer(c *C) {
+ testServer.Response(200, nil, RegisterInstancesWithLoadBalancerExample)
+
+ options := elb.RegisterInstancesWithLoadBalancer{
+ LoadBalancerName: "foobar",
+ Instances: []string{"instance-1", "instance-2"},
+ }
+
+ resp, err := s.elb.RegisterInstancesWithLoadBalancer(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"RegisterInstancesWithLoadBalancer"})
+ c.Assert(req.Form["LoadBalancerName"], DeepEquals, []string{"foobar"})
+ c.Assert(req.Form["Instances.member.1.InstanceId"], DeepEquals, []string{"instance-1"})
+ c.Assert(req.Form["Instances.member.2.InstanceId"], DeepEquals, []string{"instance-2"})
+ c.Assert(err, IsNil)
+
+ c.Assert(resp.Instances[0].InstanceId, Equals, "i-315b7e51")
+ c.Assert(resp.RequestId, Equals, "83c88b9d-12b7-11e3-8b82-87b12EXAMPLE")
+}
+
+func (s *S) TestDeregisterInstancesFromLoadBalancer(c *C) {
+ testServer.Response(200, nil, DeregisterInstancesFromLoadBalancerExample)
+
+ options := elb.DeregisterInstancesFromLoadBalancer{
+ LoadBalancerName: "foobar",
+ Instances: []string{"instance-1", "instance-2"},
+ }
+
+ resp, err := s.elb.DeregisterInstancesFromLoadBalancer(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeregisterInstancesFromLoadBalancer"})
+ c.Assert(req.Form["LoadBalancerName"], DeepEquals, []string{"foobar"})
+ c.Assert(req.Form["Instances.member.1.InstanceId"], DeepEquals, []string{"instance-1"})
+ c.Assert(req.Form["Instances.member.2.InstanceId"], DeepEquals, []string{"instance-2"})
+ c.Assert(err, IsNil)
+
+ c.Assert(resp.Instances[0].InstanceId, Equals, "i-6ec63d59")
+ c.Assert(resp.RequestId, Equals, "83c88b9d-12b7-11e3-8b82-87b12EXAMPLE")
+}
+
+func (s *S) TestDescribeInstanceHealth(c *C) {
+ testServer.Response(200, nil, DescribeInstanceHealthExample)
+
+ options := elb.DescribeInstanceHealth{
+ LoadBalancerName: "foobar",
+ }
+
+ resp, err := s.elb.DescribeInstanceHealth(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeInstanceHealth"})
+ c.Assert(req.Form["LoadBalancerName"], DeepEquals, []string{"foobar"})
+ c.Assert(err, IsNil)
+
+ c.Assert(resp.InstanceStates[0].InstanceId, Equals, "i-90d8c2a5")
+ c.Assert(resp.InstanceStates[0].State, Equals, "InService")
+ c.Assert(resp.RequestId, Equals, "1549581b-12b7-11e3-895e-1334aEXAMPLE")
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/responses_test.go
new file mode 100644
index 00000000..6b8578dc
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/responses_test.go
@@ -0,0 +1,138 @@
+package elb_test
+
+var ErrorDump = `
+
+UnsupportedOperation
+
+0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4
+`
+
+// http://goo.gl/gQRD2H
+var CreateLoadBalancerExample = `
+
+
+ MyLoadBalancer-1234567890.us-east-1.elb.amazonaws.com
+
+
+ 1549581b-12b7-11e3-895e-1334aEXAMPLE
+
+
+`
+
+// http://goo.gl/GLZeBN
+var DeleteLoadBalancerExample = `
+
+
+ 1549581b-12b7-11e3-895e-1334aEXAMPLE
+
+
+`
+
+// http://goo.gl/8UgpQ8
+var DescribeLoadBalancersExample = `
+
+
+
+
+
+ MyLoadBalancer
+ 2013-05-24T21:15:31.280Z
+
+ 90
+ HTTP:80/
+ 2
+ 60
+ 10
+
+
+
+
+
+ HTTP
+ 80
+ HTTP
+ 80
+
+
+
+
+
+ i-e4cbe38d
+
+
+
+
+
+
+
+
+ us-east-1a
+
+ ZZZZZZZZZZZ123X
+ MyLoadBalancer-123456789.us-east-1.elb.amazonaws.com
+ internet-facing
+
+ amazon-elb
+ amazon-elb-sg
+
+ MyLoadBalancer-123456789.us-east-1.elb.amazonaws.com
+
+
+
+
+
+
+ 83c88b9d-12b7-11e3-8b82-87b12EXAMPLE
+
+
+`
+
+// http://goo.gl/Uz1N66
+var RegisterInstancesWithLoadBalancerExample = `
+
+
+
+
+ i-315b7e51
+
+
+
+
+ 83c88b9d-12b7-11e3-8b82-87b12EXAMPLE
+
+
+ `
+
+// http://goo.gl/5OMv62
+var DeregisterInstancesFromLoadBalancerExample = `
+
+
+
+
+ i-6ec63d59
+
+
+
+
+ 83c88b9d-12b7-11e3-8b82-87b12EXAMPLE
+
+
+`
+
+// http://goo.gl/cGNxfj
+var DescribeInstanceHealthExample = `
+
+
+
+
+ N/A
+ i-90d8c2a5
+ InService
+ N/A
+
+
+
+
+ 1549581b-12b7-11e3-895e-1334aEXAMPLE
+
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/sign.go
new file mode 100644
index 00000000..06310304
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/elb/sign.go
@@ -0,0 +1,38 @@
+package elb
+
+import (
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+ "sort"
+ "strings"
+)
+
+// ----------------------------------------------------------------------------
+// Version 2 signing (http://goo.gl/RSRp5)
+
+var b64 = base64.StdEncoding
+
+func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
+ params["AWSAccessKeyId"] = auth.AccessKey
+ params["SignatureVersion"] = "2"
+ params["SignatureMethod"] = "HmacSHA256"
+ if auth.Token != "" {
+ params["SecurityToken"] = auth.Token
+ }
+
+ var sarray []string
+ for k, v := range params {
+ sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v))
+ }
+ sort.StringSlice(sarray).Sort()
+ joined := strings.Join(sarray, "&")
+ payload := method + "\n" + host + "\n" + path + "\n" + joined
+ hash := hmac.New(sha256.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ params["Signature"] = string(signature)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/export_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/export_test.go
new file mode 100644
index 00000000..8c41bf35
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/export_test.go
@@ -0,0 +1,9 @@
+package mturk
+
+import (
+ "github.com/mitchellh/goamz/aws"
+)
+
+func Sign(auth aws.Auth, service, method, timestamp string, params map[string]string) {
+ sign(auth, service, method, timestamp, params)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/mturk.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/mturk.go
new file mode 100644
index 00000000..2f73be49
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/mturk.go
@@ -0,0 +1,281 @@
+//
+// goamz - Go packages to interact with the Amazon Web Services.
+//
+// https://wiki.ubuntu.com/goamz
+//
+// Copyright (c) 2011 Canonical Ltd.
+//
+// Written by Graham Miller
+
+// This package is in an experimental state, and does not currently
+// follow conventions and style of the rest of goamz or common
+// Go conventions. It must be polished before it's considered a
+// first-class package in goamz.
+package mturk
+
+import (
+ "encoding/xml"
+ "errors"
+ "fmt"
+ "github.com/mitchellh/goamz/aws"
+ "net/http"
+ //"net/http/httputil"
+ "net/url"
+ "strconv"
+ "time"
+)
+
+type MTurk struct {
+ aws.Auth
+ URL *url.URL
+}
+
+func New(auth aws.Auth) *MTurk {
+ mt := &MTurk{Auth: auth}
+ var err error
+ mt.URL, err = url.Parse("http://mechanicalturk.amazonaws.com/")
+ if err != nil {
+ panic(err.Error())
+ }
+ return mt
+}
+
+// ----------------------------------------------------------------------------
+// Request dispatching logic.
+
+// Error encapsulates an error returned by MTurk.
+type Error struct {
+ StatusCode int // HTTP status code (200, 403, ...)
+ Code string // EC2 error code ("UnsupportedOperation", ...)
+ Message string // The human-oriented error message
+ RequestId string
+}
+
+func (err *Error) Error() string {
+ return err.Message
+}
+
+// The request stanza included in several response types, for example
+// in a "CreateHITResponse". http://goo.gl/qGeKf
+type xmlRequest struct {
+ RequestId string
+ IsValid string
+ Errors []Error `xml:"Errors>Error"`
+}
+
+// Common price structure used in requests and responses
+// http://goo.gl/tE4AV
+type Price struct {
+ Amount string
+ CurrencyCode string
+ FormattedPrice string
+}
+
+// Really just a country string
+// http://goo.gl/mU4uG
+type Locale string
+
+// Data structure used to specify requirements for the worker
+// used in CreateHIT, for example
+// http://goo.gl/LvRo9
+type QualificationRequirement struct {
+ QualificationTypeId string
+ Comparator string
+ IntegerValue int
+ LocaleValue Locale
+ RequiredToPreview string
+}
+
+// Data structure holding the contents of an "external"
+// question. http://goo.gl/NP8Aa
+type ExternalQuestion struct {
+ XMLName xml.Name `xml:"http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd ExternalQuestion"`
+ ExternalURL string
+ FrameHeight int
+}
+
+// The data structure representing a "human interface task" (HIT)
+// Currently only supports "external" questions, because Go
+// structs don't support union types. http://goo.gl/NP8Aa
+// This type is returned, for example, from SearchHITs
+// http://goo.gl/PskcX
+type HIT struct {
+ Request xmlRequest
+
+ HITId string
+ HITTypeId string
+ CreationTime string
+ Title string
+ Description string
+ Keywords string
+ HITStatus string
+ Reward Price
+ LifetimeInSeconds uint
+ AssignmentDurationInSeconds uint
+ MaxAssignments uint
+ AutoApprovalDelayInSeconds uint
+ QualificationRequirement QualificationRequirement
+ Question ExternalQuestion
+ RequesterAnnotation string
+ NumberofSimilarHITs uint
+ HITReviewStatus string
+ NumberOfAssignmentsPending uint
+ NumberOfAssignmentsAvailable uint
+ NumberOfAssignmentsCompleted uint
+}
+
+// The main data structure returned by SearchHITs
+// http://goo.gl/PskcX
+type SearchHITsResult struct {
+ NumResults uint
+ PageNumber uint
+ TotalNumResults uint
+ HITs []HIT `xml:"HIT"`
+}
+
+// The wrapper data structure returned by SearchHITs
+// http://goo.gl/PskcX
+type SearchHITsResponse struct {
+ RequestId string `xml:"OperationRequest>RequestId"`
+ SearchHITsResult SearchHITsResult
+}
+
+// The wrapper data structure returned by CreateHIT
+// http://goo.gl/PskcX
+type CreateHITResponse struct {
+ RequestId string `xml:"OperationRequest>RequestId"`
+ HIT HIT
+}
+
+// Corresponds to the "CreateHIT" operation of the Mechanical Turk
+// API. http://goo.gl/cDBRc Currently only supports "external"
+// questions (see "HIT" struct above). If "keywords", "maxAssignments",
+// "qualificationRequirement" or "requesterAnnotation" are the zero
+// value for their types, they will not be included in the request.
+func (mt *MTurk) CreateHIT(title, description string, question ExternalQuestion, reward Price, assignmentDurationInSeconds, lifetimeInSeconds uint, keywords string, maxAssignments uint, qualificationRequirement *QualificationRequirement, requesterAnnotation string) (h *HIT, err error) {
+ params := make(map[string]string)
+ params["Title"] = title
+ params["Description"] = description
+ params["Question"], err = xmlEncode(&question)
+ if err != nil {
+ return
+ }
+ params["Reward.1.Amount"] = reward.Amount
+ params["Reward.1.CurrencyCode"] = reward.CurrencyCode
+ params["AssignmentDurationInSeconds"] = strconv.FormatUint(uint64(assignmentDurationInSeconds), 10)
+
+ params["LifetimeInSeconds"] = strconv.FormatUint(uint64(lifetimeInSeconds), 10)
+ if keywords != "" {
+ params["Keywords"] = keywords
+ }
+ if maxAssignments != 0 {
+ params["MaxAssignments"] = strconv.FormatUint(uint64(maxAssignments), 10)
+ }
+ if qualificationRequirement != nil {
+ params["QualificationRequirement"], err = xmlEncode(qualificationRequirement)
+ if err != nil {
+ return
+ }
+ }
+ if requesterAnnotation != "" {
+ params["RequesterAnnotation"] = requesterAnnotation
+ }
+
+ var response CreateHITResponse
+ err = mt.query(params, "CreateHIT", &response)
+ if err == nil {
+ h = &response.HIT
+ }
+ return
+}
+
+// Corresponds to the "CreateHIT" operation of the Mechanical Turk
+// API, using an existing "hit type". http://goo.gl/cDBRc Currently only
+// supports "external" questions (see "HIT" struct above). If
+// "maxAssignments" or "requesterAnnotation" are the zero value for
+// their types, they will not be included in the request.
+func (mt *MTurk) CreateHITOfType(hitTypeId string, q ExternalQuestion, lifetimeInSeconds uint, maxAssignments uint, requesterAnnotation string) (h *HIT, err error) {
+ params := make(map[string]string)
+ params["HITTypeId"] = hitTypeId
+ params["Question"], err = xmlEncode(&q)
+ if err != nil {
+ return
+ }
+ params["LifetimeInSeconds"] = strconv.FormatUint(uint64(lifetimeInSeconds), 10)
+ if maxAssignments != 0 {
+ params["MaxAssignments"] = strconv.FormatUint(uint64(maxAssignments), 10)
+ }
+ if requesterAnnotation != "" {
+ params["RequesterAnnotation"] = requesterAnnotation
+ }
+
+ var response CreateHITResponse
+ err = mt.query(params, "CreateHIT", &response)
+ if err == nil {
+ h = &response.HIT
+ }
+ return
+}
+
+// Corresponds to "SearchHITs" operation of Mechanical Turk. http://goo.gl/PskcX
+// Currenlty supports none of the optional parameters.
+func (mt *MTurk) SearchHITs() (s *SearchHITsResult, err error) {
+ params := make(map[string]string)
+ var response SearchHITsResponse
+ err = mt.query(params, "SearchHITs", &response)
+ if err == nil {
+ s = &response.SearchHITsResult
+ }
+ return
+}
+
+// Adds common parameters to the "params" map, signs the request,
+// adds the signature to the "params" map and sends the request
+// to the server. It then unmarshals the response in to the "resp"
+// parameter using xml.Unmarshal()
+func (mt *MTurk) query(params map[string]string, operation string, resp interface{}) error {
+ service := "AWSMechanicalTurkRequester"
+ timestamp := time.Now().UTC().Format("2006-01-02T15:04:05Z")
+
+ params["AWSAccessKeyId"] = mt.Auth.AccessKey
+ params["Service"] = service
+ params["Timestamp"] = timestamp
+ params["Operation"] = operation
+
+ // make a copy
+ url := *mt.URL
+
+ sign(mt.Auth, service, operation, timestamp, params)
+ url.RawQuery = multimap(params).Encode()
+ r, err := http.Get(url.String())
+ if err != nil {
+ return err
+ }
+ //dump, _ := httputil.DumpResponse(r, true)
+ //println("DUMP:\n", string(dump))
+ if r.StatusCode != 200 {
+ return errors.New(fmt.Sprintf("%d: unexpected status code", r.StatusCode))
+ }
+ dec := xml.NewDecoder(r.Body)
+ err = dec.Decode(resp)
+ r.Body.Close()
+ return err
+}
+
+func multimap(p map[string]string) url.Values {
+ q := make(url.Values, len(p))
+ for k, v := range p {
+ q[k] = []string{v}
+ }
+ return q
+}
+
+func xmlEncode(i interface{}) (s string, err error) {
+ var buf []byte
+ buf, err = xml.Marshal(i)
+ if err != nil {
+ return
+ }
+ s = string(buf)
+ return
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/mturk_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/mturk_test.go
new file mode 100644
index 00000000..ab21e9c9
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/mturk_test.go
@@ -0,0 +1,91 @@
+package mturk_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/exp/mturk"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "net/url"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+var _ = Suite(&S{})
+
+type S struct {
+ mturk *mturk.MTurk
+}
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ u, err := url.Parse(testServer.URL)
+ if err != nil {
+ panic(err.Error())
+ }
+
+ s.mturk = &mturk.MTurk{
+ Auth: auth,
+ URL: u,
+ }
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) TestCreateHIT(c *C) {
+ testServer.Response(200, nil, BasicHitResponse)
+
+ question := mturk.ExternalQuestion{
+ ExternalURL: "http://www.amazon.com",
+ FrameHeight: 200,
+ }
+ reward := mturk.Price{
+ Amount: "0.01",
+ CurrencyCode: "USD",
+ }
+ hit, err := s.mturk.CreateHIT("title", "description", question, reward, 1, 2, "key1,key2", 3, nil, "annotation")
+
+ testServer.WaitRequest()
+
+ c.Assert(err, IsNil)
+ c.Assert(hit, NotNil)
+
+ c.Assert(hit.HITId, Equals, "28J4IXKO2L927XKJTHO34OCDNASCDW")
+ c.Assert(hit.HITTypeId, Equals, "2XZ7D1X3V0FKQVW7LU51S7PKKGFKDF")
+}
+
+func (s *S) TestSearchHITs(c *C) {
+ testServer.Response(200, nil, SearchHITResponse)
+
+ hitResult, err := s.mturk.SearchHITs()
+
+ c.Assert(err, IsNil)
+ c.Assert(hitResult, NotNil)
+
+ c.Assert(hitResult.NumResults, Equals, uint(1))
+ c.Assert(hitResult.PageNumber, Equals, uint(1))
+ c.Assert(hitResult.TotalNumResults, Equals, uint(1))
+
+ c.Assert(len(hitResult.HITs), Equals, 1)
+ c.Assert(hitResult.HITs[0].HITId, Equals, "2BU26DG67D1XTE823B3OQ2JF2XWF83")
+ c.Assert(hitResult.HITs[0].HITTypeId, Equals, "22OWJ5OPB0YV6IGL5727KP9U38P5XR")
+ c.Assert(hitResult.HITs[0].CreationTime, Equals, "2011-12-28T19:56:20Z")
+ c.Assert(hitResult.HITs[0].Title, Equals, "test hit")
+ c.Assert(hitResult.HITs[0].Description, Equals, "please disregard, testing only")
+ c.Assert(hitResult.HITs[0].HITStatus, Equals, "Reviewable")
+ c.Assert(hitResult.HITs[0].MaxAssignments, Equals, uint(1))
+ c.Assert(hitResult.HITs[0].Reward.Amount, Equals, "0.01")
+ c.Assert(hitResult.HITs[0].Reward.CurrencyCode, Equals, "USD")
+ c.Assert(hitResult.HITs[0].AutoApprovalDelayInSeconds, Equals, uint(2592000))
+ c.Assert(hitResult.HITs[0].AssignmentDurationInSeconds, Equals, uint(30))
+ c.Assert(hitResult.HITs[0].NumberOfAssignmentsPending, Equals, uint(0))
+ c.Assert(hitResult.HITs[0].NumberOfAssignmentsAvailable, Equals, uint(1))
+ c.Assert(hitResult.HITs[0].NumberOfAssignmentsCompleted, Equals, uint(0))
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/responses_test.go
new file mode 100644
index 00000000..4467b967
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/responses_test.go
@@ -0,0 +1,9 @@
+package mturk_test
+
+var BasicHitResponse = `
+643b794b-66b6-4427-bb8a-4d3df5c9a20eTrue28J4IXKO2L927XKJTHO34OCDNASCDW2XZ7D1X3V0FKQVW7LU51S7PKKGFKDF
+`
+
+var SearchHITResponse = `
+38862d9c-f015-4177-a2d3-924110a9d6f2True1112BU26DG67D1XTE823B3OQ2JF2XWF8322OWJ5OPB0YV6IGL5727KP9U38P5XR2011-12-28T19:56:20Ztest hitplease disregard, testing onlyReviewable10.01USD$0.0125920002011-12-28T19:56:50Z30010
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/sign.go
new file mode 100644
index 00000000..4a9d4d6f
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/sign.go
@@ -0,0 +1,22 @@
+package mturk
+
+import (
+ "crypto/hmac"
+ "crypto/sha1"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+)
+
+var b64 = base64.StdEncoding
+
+// ----------------------------------------------------------------------------
+// Mechanical Turk signing (http://goo.gl/wrzfn)
+func sign(auth aws.Auth, service, method, timestamp string, params map[string]string) {
+ payload := service + method + timestamp
+ hash := hmac.New(sha1.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ params["Signature"] = string(signature)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/sign_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/sign_test.go
new file mode 100644
index 00000000..b024fc32
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/mturk/sign_test.go
@@ -0,0 +1,19 @@
+package mturk_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/exp/mturk"
+ . "github.com/motain/gocheck"
+)
+
+// Mechanical Turk REST authentication docs: http://goo.gl/wrzfn
+
+var testAuth = aws.Auth{"user", "secret", ""}
+
+// == fIJy9wCApBNL2R4J2WjJGtIBFX4=
+func (s *S) TestBasicSignature(c *C) {
+ params := map[string]string{}
+ mturk.Sign(testAuth, "AWSMechanicalTurkRequester", "CreateHIT", "2012-02-16T20:30:47Z", params)
+ expected := "b/TnvzrdeD/L/EyzdFrznPXhido="
+ c.Assert(params["Signature"], Equals, expected)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/export_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/export_test.go
new file mode 100644
index 00000000..12c68bd4
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/export_test.go
@@ -0,0 +1,9 @@
+package sdb
+
+import (
+ "github.com/mitchellh/goamz/aws"
+)
+
+func Sign(auth aws.Auth, method, path string, params map[string][]string, headers map[string][]string) {
+ sign(auth, method, path, params, headers)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/responses_test.go
new file mode 100644
index 00000000..034c2b31
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/responses_test.go
@@ -0,0 +1,120 @@
+package sdb_test
+
+var TestCreateDomainXmlOK = `
+
+
+
+ 63264005-7a5f-e01a-a224-395c63b89f6d
+ 0.0055590279
+
+
+`
+
+var TestListDomainsXmlOK = `
+
+
+
+ Account
+ Domain
+ Record
+
+
+ 15fcaf55-9914-63c2-21f3-951e31193790
+ 0.0000071759
+
+
+`
+
+var TestListDomainsWithNextTokenXmlOK = `
+
+
+
+ Domain1-200706011651
+ Domain2-200706011652
+ TWV0ZXJpbmdUZXN0RG9tYWluMS0yMDA3MDYwMTE2NTY=
+
+
+ eb13162f-1b95-4511-8b12-489b86acfd28
+ 0.0000219907
+
+
+`
+
+var TestDeleteDomainXmlOK = `
+
+
+
+ 039e1e25-9a64-2a74-93da-2fda36122a97
+ 0.0055590278
+
+
+`
+
+var TestDomainMetadataXmlNoSuchDomain = `
+
+
+
+
+ NoSuchDomain
+ The specified domain does not exist.
+ 0.0000071759
+
+
+ e050cea2-a772-f90e-2cb0-98ebd42c2898
+
+`
+
+var TestPutAttrsXmlOK = `
+
+
+
+ 490206ce-8292-456c-a00f-61b335eb202b
+ 0.0000219907
+
+
+`
+
+var TestAttrsXmlOK = `
+
+
+
+ ColorBlue
+ SizeMed
+
+
+ b1e8f1f7-42e9-494c-ad09-2674e557526d
+ 0.0000219942
+
+
+`
+
+var TestSelectXmlOK = `
+
+
+
+
+ Item_03
+ CategoryClothes
+ SubcategoryPants
+ NameSweatpants
+ ColorBlue
+ ColorYellow
+ ColorPink
+ SizeLarge
+
+
+ Item_06
+ CategoryMotorcycle Parts
+ SubcategoryBodywork
+ NameFender Eliminator
+ ColorBlue
+ MakeYamaha
+ ModelR1
+
+
+
+ b1e8f1f7-42e9-494c-ad09-2674e557526d
+ 0.0000219907
+
+
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sdb.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sdb.go
new file mode 100644
index 00000000..0afd0412
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sdb.go
@@ -0,0 +1,413 @@
+//
+// goamz - Go packages to interact with the Amazon Web Services.
+//
+// https://wiki.ubuntu.com/goamz
+//
+// Copyright (c) 2011 AppsAttic Ltd.
+//
+// sdb package written by:
+//
+// Andrew Chilton
+// Brad Rydzewski
+
+// This package is in an experimental state, and does not currently
+// follow conventions and style of the rest of goamz or common
+// Go conventions. It must be polished before it's considered a
+// first-class package in goamz.
+package sdb
+
+// BUG: SelectResp isn't properly organized. It must change.
+
+//
+
+import (
+ "encoding/xml"
+ "github.com/mitchellh/goamz/aws"
+ "log"
+ "net/http"
+ "net/http/httputil"
+ "net/url"
+ "strconv"
+ "time"
+)
+
+const debug = false
+
+// The SDB type encapsulates operations with a specific SimpleDB region.
+type SDB struct {
+ aws.Auth
+ aws.Region
+ private byte // Reserve the right of using private data.
+}
+
+// New creates a new SDB.
+func New(auth aws.Auth, region aws.Region) *SDB {
+ return &SDB{auth, region, 0}
+}
+
+// The Domain type represents a collection of items that are described
+// by name-value attributes.
+type Domain struct {
+ *SDB
+ Name string
+}
+
+// Domain returns a Domain with the given name.
+func (sdb *SDB) Domain(name string) *Domain {
+ return &Domain{sdb, name}
+}
+
+// The Item type represent individual objects that contain one or more
+// name-value attributes stored within a SDB Domain as rows.
+type Item struct {
+ *SDB
+ *Domain
+ Name string
+}
+
+// Item returns an Item with the given name.
+func (domain *Domain) Item(name string) *Item {
+ return &Item{domain.SDB, domain, name}
+}
+
+// The Attr type represent categories of data that can be assigned to items.
+type Attr struct {
+ Name string
+ Value string
+}
+
+// ----------------------------------------------------------------------------
+// Service-level operations.
+
+// --- ListDomains
+
+// Response to a ListDomains request.
+//
+// See http://goo.gl/3u0Cf for more details.
+type ListDomainsResp struct {
+ Domains []string `xml:"ListDomainsResult>DomainName"`
+ NextToken string `xml:"ListDomainsResult>NextToken"`
+ ResponseMetadata ResponseMetadata
+}
+
+// ListDomains lists all domains in sdb.
+//
+// See http://goo.gl/Dsw15 for more details.
+func (sdb *SDB) ListDomains() (resp *ListDomainsResp, err error) {
+ return sdb.ListDomainsN(0, "")
+}
+
+// ListDomainsN lists domains in sdb up to maxDomains.
+// If nextToken is not empty, domains listed will start at the given token.
+//
+// See http://goo.gl/Dsw15 for more details.
+func (sdb *SDB) ListDomainsN(maxDomains int, nextToken string) (resp *ListDomainsResp, err error) {
+ params := makeParams("ListDomains")
+ if maxDomains != 0 {
+ params["MaxNumberOfDomains"] = []string{strconv.Itoa(maxDomains)}
+ }
+ if nextToken != "" {
+ params["NextToken"] = []string{nextToken}
+ }
+ resp = &ListDomainsResp{}
+ err = sdb.query(nil, nil, params, nil, resp)
+ return
+}
+
+// --- SelectExpression
+
+// Response to a Select request.
+//
+// See http://goo.gl/GTsSZ for more details.
+type SelectResp struct {
+ Items []struct {
+ Name string
+ Attrs []Attr `xml:"Attribute"`
+ } `xml:"SelectResult>Item"`
+ ResponseMetadata ResponseMetadata
+}
+
+// Select returns a set of items and attributes that match expr.
+// Select is similar to the standard SQL SELECT statement.
+//
+// See http://goo.gl/GTsSZ for more details.
+func (sdb *SDB) Select(expr string, consistent bool) (resp *SelectResp, err error) {
+ resp = &SelectResp{}
+ params := makeParams("Select")
+ params["SelectExpression"] = []string{expr}
+ if consistent {
+ params["ConsistentRead"] = []string{"true"}
+ }
+ err = sdb.query(nil, nil, params, nil, resp)
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Domain-level operations.
+
+// --- CreateDomain
+
+// CreateDomain creates a new domain.
+//
+// See http://goo.gl/jDjGH for more details.
+func (domain *Domain) CreateDomain() (resp *SimpleResp, err error) {
+ params := makeParams("CreateDomain")
+ resp = &SimpleResp{}
+ err = domain.SDB.query(domain, nil, params, nil, resp)
+ return
+}
+
+// DeleteDomain deletes an existing domain.
+//
+// See http://goo.gl/S0dCL for more details.
+func (domain *Domain) DeleteDomain() (resp *SimpleResp, err error) {
+ params := makeParams("DeleteDomain")
+ resp = &SimpleResp{}
+ err = domain.SDB.query(domain, nil, params, nil, resp)
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Item-level operations.
+
+type PutAttrs struct {
+ attrs []Attr
+ expected []Attr
+ replace map[string]bool
+ missing map[string]bool
+}
+
+func (pa *PutAttrs) Add(name, value string) {
+ pa.attrs = append(pa.attrs, Attr{name, value})
+}
+
+func (pa *PutAttrs) Replace(name, value string) {
+ pa.Add(name, value)
+ if pa.replace == nil {
+ pa.replace = make(map[string]bool)
+ }
+ pa.replace[name] = true
+}
+
+// The PutAttrs request will only succeed if the existing
+// item in SimpleDB contains a matching name / value pair.
+func (pa *PutAttrs) IfValue(name, value string) {
+ pa.expected = append(pa.expected, Attr{name, value})
+}
+
+// Flag to test the existence of an attribute while performing
+// conditional updates. X can be any positive integer or 0.
+//
+// This should set Expected.N.Name=name and Expected.N.Exists=false
+func (pa *PutAttrs) IfMissing(name string) {
+ if pa.missing == nil {
+ pa.missing = make(map[string]bool)
+ }
+ pa.missing[name] = true
+}
+
+// PutAttrs adds attrs to item.
+//
+// See http://goo.gl/yTAV4 for more details.
+func (item *Item) PutAttrs(attrs *PutAttrs) (resp *SimpleResp, err error) {
+ params := makeParams("PutAttributes")
+ resp = &SimpleResp{}
+
+ // copy these attrs over to the parameters
+ itemNum := 1
+ for _, attr := range attrs.attrs {
+ itemNumStr := strconv.Itoa(itemNum)
+
+ // do the name, value and replace
+ params["Attribute."+itemNumStr+".Name"] = []string{attr.Name}
+ params["Attribute."+itemNumStr+".Value"] = []string{attr.Value}
+
+ if _, ok := attrs.replace[attr.Name]; ok {
+ params["Attribute."+itemNumStr+".Replace"] = []string{"true"}
+ }
+
+ itemNum++
+ }
+
+ //append expected values to params
+ expectedNum := 1
+ for _, attr := range attrs.expected {
+ expectedNumStr := strconv.Itoa(expectedNum)
+ params["Expected."+expectedNumStr+".Name"] = []string{attr.Name}
+ params["Expected."+expectedNumStr+".Value"] = []string{attr.Value}
+
+ if attrs.missing[attr.Name] {
+ params["Expected."+expectedNumStr+".Exists"] = []string{"false"}
+ }
+ expectedNum++
+ }
+
+ err = item.query(params, nil, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// Response to an Attrs request.
+//
+// See http://goo.gl/45X1M for more details.
+type AttrsResp struct {
+ Attrs []Attr `xml:"GetAttributesResult>Attribute"`
+ ResponseMetadata ResponseMetadata
+}
+
+// Attrs returns one or more of the named attributes, or
+// all of item's attributes if names is nil.
+// If consistent is true, previous writes will necessarily
+// be observed.
+//
+// See http://goo.gl/45X1M for more details.
+func (item *Item) Attrs(names []string, consistent bool) (resp *AttrsResp, err error) {
+ params := makeParams("GetAttributes")
+ params["ItemName"] = []string{item.Name}
+ if consistent {
+ params["ConsistentRead"] = []string{"true"}
+ }
+
+ // Copy these attributes over to the parameters
+ for i, name := range names {
+ params["AttributeName."+strconv.Itoa(i+1)] = []string{name}
+ }
+
+ resp = &AttrsResp{}
+ err = item.query(params, nil, resp)
+ if err != nil {
+ return nil, err
+ }
+ return
+}
+
+// ----------------------------------------------------------------------------
+// Generic data structures for all requests/responses.
+
+// Error encapsulates an error returned by SDB.
+type Error struct {
+ StatusCode int // HTTP status code (200, 403, ...)
+ StatusMsg string // HTTP status message ("Service Unavailable", "Bad Request", ...)
+ Code string // SimpleDB error code ("InvalidParameterValue", ...)
+ Message string // The human-oriented error message
+ RequestId string // A unique ID for this request
+ BoxUsage float64 // The measure of machine utilization for this request.
+}
+
+func (err *Error) Error() string {
+ return err.Message
+}
+
+// SimpleResp represents a response to an SDB request which on success
+// will return no other information besides ResponseMetadata.
+type SimpleResp struct {
+ ResponseMetadata ResponseMetadata
+}
+
+// ResponseMetadata
+type ResponseMetadata struct {
+ RequestId string // A unique ID for tracking the request
+ BoxUsage float64 // The measure of machine utilization for this request.
+}
+
+func buildError(r *http.Response) error {
+ err := Error{}
+ err.StatusCode = r.StatusCode
+ err.StatusMsg = r.Status
+ xml.NewDecoder(r.Body).Decode(&err)
+ return &err
+}
+
+// ----------------------------------------------------------------------------
+// Request dispatching logic.
+
+func (item *Item) query(params url.Values, headers http.Header, resp interface{}) error {
+ return item.Domain.SDB.query(item.Domain, item, params, headers, resp)
+}
+
+func (domain *Domain) query(item *Item, params url.Values, headers http.Header, resp interface{}) error {
+ return domain.SDB.query(domain, item, params, headers, resp)
+}
+
+func (sdb *SDB) query(domain *Domain, item *Item, params url.Values, headers http.Header, resp interface{}) error {
+ // all SimpleDB operations have path="/"
+ method := "GET"
+ path := "/"
+
+ // if we have been given no headers or params, create them
+ if headers == nil {
+ headers = map[string][]string{}
+ }
+ if params == nil {
+ params = map[string][]string{}
+ }
+
+ // setup some default parameters
+ params["Version"] = []string{"2009-04-15"}
+ params["Timestamp"] = []string{time.Now().UTC().Format(time.RFC3339)}
+
+ // set the DomainName param (every request must have one)
+ if domain != nil {
+ params["DomainName"] = []string{domain.Name}
+ }
+
+ // set the ItemName if we have one
+ if item != nil {
+ params["ItemName"] = []string{item.Name}
+ }
+
+ // check the endpoint URL
+ u, err := url.Parse(sdb.Region.SDBEndpoint)
+ if err != nil {
+ return err
+ }
+ headers["Host"] = []string{u.Host}
+ sign(sdb.Auth, method, path, params, headers)
+
+ u.Path = path
+ if len(params) > 0 {
+ u.RawQuery = params.Encode()
+ }
+ req := http.Request{
+ URL: u,
+ Method: method,
+ ProtoMajor: 1,
+ ProtoMinor: 1,
+ Close: true,
+ Header: headers,
+ }
+
+ if v, ok := headers["Content-Length"]; ok {
+ req.ContentLength, _ = strconv.ParseInt(v[0], 10, 64)
+ delete(headers, "Content-Length")
+ }
+
+ r, err := http.DefaultClient.Do(&req)
+ if err != nil {
+ return err
+ }
+ defer r.Body.Close()
+
+ if debug {
+ dump, _ := httputil.DumpResponse(r, true)
+ log.Printf("response:\n")
+ log.Printf("%v\n}\n", string(dump))
+ }
+
+ // status code is always 200 when successful (since we're always doing a GET)
+ if r.StatusCode != 200 {
+ return buildError(r)
+ }
+
+ // everything was fine, so unmarshal the XML and return what it's err is (if any)
+ err = xml.NewDecoder(r.Body).Decode(resp)
+ return err
+}
+
+func makeParams(action string) map[string][]string {
+ params := make(map[string][]string)
+ params["Action"] = []string{action}
+ return params
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sdb_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sdb_test.go
new file mode 100644
index 00000000..d1948535
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sdb_test.go
@@ -0,0 +1,218 @@
+package sdb_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/exp/sdb"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+var _ = Suite(&S{})
+
+type S struct {
+ sdb *sdb.SDB
+}
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ s.sdb = sdb.New(auth, aws.Region{SDBEndpoint: testServer.URL})
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) TestCreateDomainOK(c *C) {
+ testServer.Response(200, nil, TestCreateDomainXmlOK)
+
+ domain := s.sdb.Domain("domain")
+ resp, err := domain.CreateDomain()
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "63264005-7a5f-e01a-a224-395c63b89f6d")
+ c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0055590279)
+
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestListDomainsOK(c *C) {
+ testServer.Response(200, nil, TestListDomainsXmlOK)
+
+ resp, err := s.sdb.ListDomains()
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "15fcaf55-9914-63c2-21f3-951e31193790")
+ c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000071759)
+ c.Assert(resp.Domains, DeepEquals, []string{"Account", "Domain", "Record"})
+
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestListDomainsWithNextTokenXmlOK(c *C) {
+ testServer.Response(200, nil, TestListDomainsWithNextTokenXmlOK)
+
+ resp, err := s.sdb.ListDomains()
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "eb13162f-1b95-4511-8b12-489b86acfd28")
+ c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907)
+ c.Assert(resp.Domains, DeepEquals, []string{"Domain1-200706011651", "Domain2-200706011652"})
+ c.Assert(resp.NextToken, Equals, "TWV0ZXJpbmdUZXN0RG9tYWluMS0yMDA3MDYwMTE2NTY=")
+
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestDeleteDomainOK(c *C) {
+ testServer.Response(200, nil, TestDeleteDomainXmlOK)
+
+ domain := s.sdb.Domain("domain")
+ resp, err := domain.DeleteDomain()
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "039e1e25-9a64-2a74-93da-2fda36122a97")
+ c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0055590278)
+
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestPutAttrsOK(c *C) {
+ testServer.Response(200, nil, TestPutAttrsXmlOK)
+
+ domain := s.sdb.Domain("MyDomain")
+ item := domain.Item("Item123")
+
+ putAttrs := new(sdb.PutAttrs)
+ putAttrs.Add("FirstName", "john")
+ putAttrs.Add("LastName", "smith")
+ putAttrs.Replace("MiddleName", "jacob")
+
+ putAttrs.IfValue("FirstName", "john")
+ putAttrs.IfMissing("FirstName")
+
+ resp, err := item.PutAttrs(putAttrs)
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Form["Action"], DeepEquals, []string{"PutAttributes"})
+ c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"})
+ c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"})
+ c.Assert(req.Form["Attribute.1.Name"], DeepEquals, []string{"FirstName"})
+ c.Assert(req.Form["Attribute.1.Value"], DeepEquals, []string{"john"})
+ c.Assert(req.Form["Attribute.2.Name"], DeepEquals, []string{"LastName"})
+ c.Assert(req.Form["Attribute.2.Value"], DeepEquals, []string{"smith"})
+ c.Assert(req.Form["Attribute.3.Name"], DeepEquals, []string{"MiddleName"})
+ c.Assert(req.Form["Attribute.3.Value"], DeepEquals, []string{"jacob"})
+ c.Assert(req.Form["Attribute.3.Replace"], DeepEquals, []string{"true"})
+
+ c.Assert(req.Form["Expected.1.Name"], DeepEquals, []string{"FirstName"})
+ c.Assert(req.Form["Expected.1.Value"], DeepEquals, []string{"john"})
+ c.Assert(req.Form["Expected.1.Exists"], DeepEquals, []string{"false"})
+
+ c.Assert(err, IsNil)
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "490206ce-8292-456c-a00f-61b335eb202b")
+ c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907)
+
+}
+
+func (s *S) TestAttrsOK(c *C) {
+ testServer.Response(200, nil, TestAttrsXmlOK)
+
+ domain := s.sdb.Domain("MyDomain")
+ item := domain.Item("Item123")
+
+ resp, err := item.Attrs(nil, true)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+ c.Assert(req.Form["Action"], DeepEquals, []string{"GetAttributes"})
+ c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"})
+ c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"})
+ c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"})
+
+ c.Assert(resp.Attrs[0].Name, Equals, "Color")
+ c.Assert(resp.Attrs[0].Value, Equals, "Blue")
+ c.Assert(resp.Attrs[1].Name, Equals, "Size")
+ c.Assert(resp.Attrs[1].Value, Equals, "Med")
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d")
+ c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219942)
+
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestAttrsSelectOK(c *C) {
+ testServer.Response(200, nil, TestAttrsXmlOK)
+
+ domain := s.sdb.Domain("MyDomain")
+ item := domain.Item("Item123")
+
+ resp, err := item.Attrs([]string{"Color", "Size"}, true)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+ c.Assert(req.Form["Action"], DeepEquals, []string{"GetAttributes"})
+ c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"})
+ c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"})
+ c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"})
+ c.Assert(req.Form["AttributeName.1"], DeepEquals, []string{"Color"})
+ c.Assert(req.Form["AttributeName.2"], DeepEquals, []string{"Size"})
+
+ c.Assert(resp.Attrs[0].Name, Equals, "Color")
+ c.Assert(resp.Attrs[0].Value, Equals, "Blue")
+ c.Assert(resp.Attrs[1].Name, Equals, "Size")
+ c.Assert(resp.Attrs[1].Value, Equals, "Med")
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d")
+ c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219942)
+
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestSelectOK(c *C) {
+ testServer.Response(200, nil, TestSelectXmlOK)
+
+ resp, err := s.sdb.Select("select Color from MyDomain where Color like 'Blue%'", true)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+ c.Assert(req.Form["Action"], DeepEquals, []string{"Select"})
+ c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"})
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d")
+ c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907)
+ c.Assert(len(resp.Items), Equals, 2)
+ c.Assert(resp.Items[0].Name, Equals, "Item_03")
+ c.Assert(resp.Items[1].Name, Equals, "Item_06")
+ c.Assert(resp.Items[0].Attrs[0].Name, Equals, "Category")
+ c.Assert(resp.Items[0].Attrs[0].Value, Equals, "Clothes")
+
+ c.Assert(err, IsNil)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sign.go
new file mode 100644
index 00000000..0f9c2348
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sign.go
@@ -0,0 +1,54 @@
+package sdb
+
+import (
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+ "net/http"
+ "net/url"
+ "sort"
+ "strings"
+)
+
+var b64 = base64.StdEncoding
+
+// ----------------------------------------------------------------------------
+// SimpleDB signing (http://goo.gl/CaY81)
+
+func sign(auth aws.Auth, method, path string, params url.Values, headers http.Header) {
+ var host string
+ for k, v := range headers {
+ k = strings.ToLower(k)
+ switch k {
+ case "host":
+ host = v[0]
+ }
+ }
+
+ // set up some defaults used for signing the request
+ params["AWSAccessKeyId"] = []string{auth.AccessKey}
+ params["SignatureVersion"] = []string{"2"}
+ params["SignatureMethod"] = []string{"HmacSHA256"}
+ if auth.Token != "" {
+ params["SecurityToken"] = auth.Token
+ }
+
+ // join up all the incoming params
+ var sarray []string
+ for k, v := range params {
+ sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v[0]))
+ }
+ sort.StringSlice(sarray).Sort()
+ joined := strings.Join(sarray, "&")
+
+ // create the payload, sign it and create the signature
+ payload := strings.Join([]string{method, host, "/", joined}, "\n")
+ hash := hmac.New(sha256.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ // add the signature to the outgoing params
+ params["Signature"] = []string{string(signature)}
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sign_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sign_test.go
new file mode 100644
index 00000000..6ebd1c4c
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sdb/sign_test.go
@@ -0,0 +1,29 @@
+package sdb_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/exp/sdb"
+ . "github.com/motain/gocheck"
+)
+
+// SimpleDB ReST authentication docs: http://goo.gl/CaY81
+
+var testAuth = aws.Auth{"access-key-id-s8eBOWuU", "secret-access-key-UkQjTLd9", ""}
+
+func (s *S) TestSignExampleDomainCreate(c *C) {
+ method := "GET"
+ params := map[string][]string{
+ "Action": {"CreateDomain"},
+ "DomainName": {"MyDomain"},
+ "Timestamp": {"2011-08-20T07:23:57+12:00"},
+ "Version": {"2009-04-15"},
+ }
+ headers := map[string][]string{
+ "Host": {"sdb.amazonaws.com"},
+ }
+ sdb.Sign(testAuth, method, "", params, headers)
+ expected := "ot2JaeeqMRJqgAqW67hkzUlffgxdOz4RykbrECB+tDU="
+ c.Assert(params["Signature"], DeepEquals, []string{expected})
+}
+
+// Do a few test methods which takes combinations of params
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/Makefile b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/Makefile
new file mode 100644
index 00000000..1e5b9da3
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/Makefile
@@ -0,0 +1,21 @@
+include $(GOROOT)/src/Make.inc
+
+TARG=launchpad.net/goamz/sns
+
+GOFILES=\
+ sns.go\
+ sign.go\
+
+include $(GOROOT)/src/Make.pkg
+
+GOFMT=gofmt
+BADFMT=$(shell $(GOFMT) -l $(GOFILES) 2> /dev/null)
+
+gofmt: $(BADFMT)
+ @for F in $(BADFMT); do $(GOFMT) -w $$F && echo $$F; done
+
+ifneq ($(BADFMT),)
+ifneq ($(MAKECMDGOALS), gofmt)
+#$(warning WARNING: make gofmt: $(BADFMT))
+endif
+endif
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/README b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/README
new file mode 100644
index 00000000..87770adb
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/README
@@ -0,0 +1 @@
+Amazon Simple Notification Service API for Golang.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/responses_test.go
new file mode 100644
index 00000000..5f8ab654
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/responses_test.go
@@ -0,0 +1,164 @@
+package sns_test
+
+var TestListTopicsXmlOK = `
+
+
+
+
+
+ arn:aws:sns:us-west-1:331995417492:Transcoding
+
+
+
+
+ bd10b26c-e30e-11e0-ba29-93c3aca2f103
+
+
+`
+
+var TestCreateTopicXmlOK = `
+
+
+
+ arn:aws:sns:us-east-1:123456789012:My-Topic
+
+
+ a8dec8b3-33a4-11df-8963-01868b7c937a
+
+
+`
+
+var TestDeleteTopicXmlOK = `
+
+
+ f3aa9ac9-3c3d-11df-8235-9dab105e9c32
+
+
+`
+
+var TestListSubscriptionsXmlOK = `
+
+
+
+
+ arn:aws:sns:us-east-1:698519295917:My-Topic
+ email
+ arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca
+ 123456789012
+ example@amazon.com
+
+
+
+
+ 384ac68d-3775-11df-8963-01868b7c937a
+
+
+`
+
+var TestGetTopicAttributesXmlOK = `
+
+
+
+
+ Owner
+ 123456789012
+
+
+ Policy
+ {"Version":"2008-10-17","Id":"us-east-1/698519295917/test__default_policy_ID","Statement" : [{"Effect":"Allow","Sid":"us-east-1/698519295917/test__default_statement_ID","Principal" : {"AWS": "*"},"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],"Resource":"arn:aws:sns:us-east-1:698519295917:test","Condition" : {"StringLike" : {"AWS:SourceArn": "arn:aws:*:*:698519295917:*"}}}]}
+
+
+ TopicArn
+ arn:aws:sns:us-east-1:123456789012:My-Topic
+
+
+
+
+ 057f074c-33a7-11df-9540-99d0768312d3
+
+
+`
+
+var TestPublishXmlOK = `
+
+
+ 94f20ce6-13c5-43a0-9a9e-ca52d816e90b
+
+
+ f187a3c1-376f-11df-8963-01868b7c937a
+
+
+`
+
+var TestSetTopicAttributesXmlOK = `
+
+
+ a8763b99-33a7-11df-a9b7-05d48da6f042
+
+
+`
+
+var TestSubscribeXmlOK = `
+
+
+ pending confirmation
+
+
+ a169c740-3766-11df-8963-01868b7c937a
+
+
+`
+
+var TestUnsubscribeXmlOK = `
+
+
+ 18e0ac39-3776-11df-84c0-b93cc1666b84
+
+
+`
+
+var TestConfirmSubscriptionXmlOK = `
+
+
+ arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca
+
+
+ 7a50221f-3774-11df-a9b7-05d48da6f042
+
+
+`
+
+var TestAddPermissionXmlOK = `
+
+
+ 6a213e4e-33a8-11df-9540-99d0768312d3
+
+
+`
+
+var TestRemovePermissionXmlOK = `
+
+
+ d170b150-33a8-11df-995a-2d6fbe836cc1
+
+
+`
+
+var TestListSubscriptionsByTopicXmlOK = `
+
+
+
+
+ arn:aws:sns:us-east-1:123456789012:My-Topic
+ email
+ arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca
+ 123456789012
+ example@amazon.com
+
+
+
+
+ b9275252-3774-11df-9540-99d0768312d3
+
+
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sign.go
new file mode 100644
index 00000000..d53b3842
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sign.go
@@ -0,0 +1,69 @@
+package sns
+
+import (
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+ "sort"
+ "strings"
+)
+
+var b64 = base64.StdEncoding
+
+/*
+func sign(auth aws.Auth, method, path string, params url.Values, headers http.Header) {
+ var host string
+ for k, v := range headers {
+ k = strings.ToLower(k)
+ switch k {
+ case "host":
+ host = v[0]
+ }
+ }
+
+ params["AWSAccessKeyId"] = []string{auth.AccessKey}
+ params["SignatureVersion"] = []string{"2"}
+ params["SignatureMethod"] = []string{"HmacSHA256"}
+ if auth.Token != "" {
+ params["SecurityToken"] = auth.Token
+ }
+
+ var sarry []string
+ for k, v := range params {
+ sarry = append(sarry, aws.Encode(k) + "=" + aws.Encode(v[0]))
+ }
+
+ sort.StringSlice(sarry).Sort()
+ joined := strings.Join(sarry, "&")
+
+ payload := strings.Join([]string{method, host, "/", joined}, "\n")
+ hash := hmac.NewSHA256([]byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum())
+
+ params["Signature"] = []string{"AWS " + string(signature)}
+ println("Payload:", payload)
+ println("Signature:", strings.Join(params["Signature"], "|"))
+}*/
+
+func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
+ params["AWSAccessKeyId"] = auth.AccessKey
+ params["SignatureVersion"] = "2"
+ params["SignatureMethod"] = "HmacSHA256"
+
+ var sarray []string
+ for k, v := range params {
+ sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v))
+ }
+ sort.StringSlice(sarray).Sort()
+ joined := strings.Join(sarray, "&")
+ payload := method + "\n" + host + "\n" + path + "\n" + joined
+ hash := hmac.New(sha256.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ params["Signature"] = string(signature)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sns.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sns.go
new file mode 100644
index 00000000..89e7b2f0
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sns.go
@@ -0,0 +1,444 @@
+//
+// goamz - Go packages to interact with the Amazon Web Services.
+//
+// https://wiki.ubuntu.com/goamz
+//
+// Copyright (c) 2011 Memeo Inc.
+//
+// Written by Prudhvi Krishna Surapaneni
+
+// This package is in an experimental state, and does not currently
+// follow conventions and style of the rest of goamz or common
+// Go conventions. It must be polished before it's considered a
+// first-class package in goamz.
+package sns
+
+// BUG(niemeyer): Package needs significant clean up.
+
+// BUG(niemeyer): Topic values in responses are not being initialized
+// properly, since they're supposed to reference *SNS.
+
+// BUG(niemeyer): Package needs documentation.
+
+// BUG(niemeyer): Message.Message should be "Payload []byte"
+
+// BUG(niemeyer): Message.SNS must be dropped.
+
+import (
+ "encoding/xml"
+ "errors"
+ "github.com/mitchellh/goamz/aws"
+ "net/http"
+ "net/url"
+ "strconv"
+ "time"
+)
+
+// The SNS type encapsulates operation with an SNS region.
+type SNS struct {
+ aws.Auth
+ aws.Region
+ private byte // Reserve the right of using private data.
+}
+
+type Topic struct {
+ SNS *SNS
+ TopicArn string
+}
+
+func New(auth aws.Auth, region aws.Region) *SNS {
+ return &SNS{auth, region, 0}
+}
+
+type Message struct {
+ SNS *SNS
+ Topic *Topic
+ Message [8192]byte
+ Subject string
+}
+
+type Subscription struct {
+ Endpoint string
+ Owner string
+ Protocol string
+ SubscriptionArn string
+ TopicArn string
+}
+
+func (topic *Topic) Message(message [8192]byte, subject string) *Message {
+ return &Message{topic.SNS, topic, message, subject}
+}
+
+type ResponseMetadata struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ BoxUsage float64 `xml:"ResponseMetadata>BoxUsage"`
+}
+
+type ListTopicsResp struct {
+ Topics []Topic `xml:"ListTopicsResult>Topics>member"`
+ NextToken string
+ ResponseMetadata
+}
+
+type CreateTopicResp struct {
+ Topic Topic `xml:"CreateTopicResult"`
+ ResponseMetadata
+}
+
+type DeleteTopicResp struct {
+ ResponseMetadata
+}
+
+type ListSubscriptionsResp struct {
+ Subscriptions []Subscription `xml:"ListSubscriptionsResult>Subscriptions>member"`
+ NextToken string
+ ResponseMetadata
+}
+
+type AttributeEntry struct {
+ Key string `xml:"key"`
+ Value string `xml:"value"`
+}
+
+type GetTopicAttributesResp struct {
+ Attributes []AttributeEntry `xml:"GetTopicAttributesResult>Attributes>entry"`
+ ResponseMetadata
+}
+
+func makeParams(action string) map[string]string {
+ params := make(map[string]string)
+ params["Action"] = action
+ return params
+}
+
+// ListTopics
+//
+// See http://goo.gl/lfrMK for more details.
+func (sns *SNS) ListTopics(NextToken *string) (resp *ListTopicsResp, err error) {
+ resp = &ListTopicsResp{}
+ params := makeParams("ListTopics")
+ if NextToken != nil {
+ params["NextToken"] = *NextToken
+ }
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+// CreateTopic
+//
+// See http://goo.gl/m9aAt for more details.
+func (sns *SNS) CreateTopic(Name string) (resp *CreateTopicResp, err error) {
+ resp = &CreateTopicResp{}
+ params := makeParams("CreateTopic")
+ params["Name"] = Name
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+// DeleteTopic
+//
+// See http://goo.gl/OXNcY for more details.
+func (sns *SNS) DeleteTopic(topic Topic) (resp *DeleteTopicResp, err error) {
+ resp = &DeleteTopicResp{}
+ params := makeParams("DeleteTopic")
+ params["TopicArn"] = topic.TopicArn
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+// Delete
+//
+// Helper function for deleting a topic
+func (topic *Topic) Delete() (resp *DeleteTopicResp, err error) {
+ return topic.SNS.DeleteTopic(*topic)
+}
+
+// ListSubscriptions
+//
+// See http://goo.gl/k3aGn for more details.
+func (sns *SNS) ListSubscriptions(NextToken *string) (resp *ListSubscriptionsResp, err error) {
+ resp = &ListSubscriptionsResp{}
+ params := makeParams("ListSubscriptions")
+ if NextToken != nil {
+ params["NextToken"] = *NextToken
+ }
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+// GetTopicAttributes
+//
+// See http://goo.gl/WXRoX for more details.
+func (sns *SNS) GetTopicAttributes(TopicArn string) (resp *GetTopicAttributesResp, err error) {
+ resp = &GetTopicAttributesResp{}
+ params := makeParams("GetTopicAttributes")
+ params["TopicArn"] = TopicArn
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type PublishOpt struct {
+ Message string
+ MessageStructure string
+ Subject string
+ TopicArn string
+}
+
+type PublishResp struct {
+ MessageId string `xml:"PublishResult>MessageId"`
+ ResponseMetadata
+}
+
+// Publish
+//
+// See http://goo.gl/AY2D8 for more details.
+func (sns *SNS) Publish(options *PublishOpt) (resp *PublishResp, err error) {
+ resp = &PublishResp{}
+ params := makeParams("Publish")
+
+ if options.Subject != "" {
+ params["Subject"] = options.Subject
+ }
+
+ if options.MessageStructure != "" {
+ params["MessageStructure"] = options.MessageStructure
+ }
+
+ if options.Message != "" {
+ params["Message"] = options.Message
+ }
+
+ if options.TopicArn != "" {
+ params["TopicArn"] = options.TopicArn
+ }
+
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type SetTopicAttributesResponse struct {
+ ResponseMetadata
+}
+
+// SetTopicAttributes
+//
+// See http://goo.gl/oVYW7 for more details.
+func (sns *SNS) SetTopicAttributes(AttributeName, AttributeValue, TopicArn string) (resp *SetTopicAttributesResponse, err error) {
+ resp = &SetTopicAttributesResponse{}
+ params := makeParams("SetTopicAttributes")
+
+ if AttributeName == "" || TopicArn == "" {
+ return nil, errors.New("Invalid Attribute Name or TopicArn")
+ }
+
+ params["AttributeName"] = AttributeName
+ params["AttributeValue"] = AttributeValue
+ params["TopicArn"] = TopicArn
+
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type SubscribeResponse struct {
+ SubscriptionArn string `xml:"SubscribeResult>SubscriptionArn"`
+ ResponseMetadata
+}
+
+// Subscribe
+//
+// See http://goo.gl/c3iGS for more details.
+func (sns *SNS) Subscribe(Endpoint, Protocol, TopicArn string) (resp *SubscribeResponse, err error) {
+ resp = &SubscribeResponse{}
+ params := makeParams("Subscribe")
+
+ params["Endpoint"] = Endpoint
+ params["Protocol"] = Protocol
+ params["TopicArn"] = TopicArn
+
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type UnsubscribeResponse struct {
+ ResponseMetadata
+}
+
+// Unsubscribe
+//
+// See http://goo.gl/4l5Ge for more details.
+func (sns *SNS) Unsubscribe(SubscriptionArn string) (resp *UnsubscribeResponse, err error) {
+ resp = &UnsubscribeResponse{}
+ params := makeParams("Unsubscribe")
+
+ params["SubscriptionArn"] = SubscriptionArn
+
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type ConfirmSubscriptionResponse struct {
+ SubscriptionArn string `xml:"ConfirmSubscriptionResult>SubscriptionArn"`
+ ResponseMetadata
+}
+
+type ConfirmSubscriptionOpt struct {
+ AuthenticateOnUnsubscribe string
+ Token string
+ TopicArn string
+}
+
+// ConfirmSubscription
+//
+// See http://goo.gl/3hXzH for more details.
+func (sns *SNS) ConfirmSubscription(options *ConfirmSubscriptionOpt) (resp *ConfirmSubscriptionResponse, err error) {
+ resp = &ConfirmSubscriptionResponse{}
+ params := makeParams("ConfirmSubscription")
+
+ if options.AuthenticateOnUnsubscribe != "" {
+ params["AuthenticateOnUnsubscribe"] = options.AuthenticateOnUnsubscribe
+ }
+
+ params["Token"] = options.Token
+ params["TopicArn"] = options.TopicArn
+
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type Permission struct {
+ ActionName string
+ AccountId string
+}
+
+type AddPermissionResponse struct {
+ ResponseMetadata
+}
+
+// AddPermission
+//
+// See http://goo.gl/mbY4a for more details.
+func (sns *SNS) AddPermission(permissions []Permission, Label, TopicArn string) (resp *AddPermissionResponse, err error) {
+ resp = &AddPermissionResponse{}
+ params := makeParams("AddPermission")
+
+ for i, p := range permissions {
+ params["AWSAccountId.member."+strconv.Itoa(i+1)] = p.AccountId
+ params["ActionName.member."+strconv.Itoa(i+1)] = p.ActionName
+ }
+
+ params["Label"] = Label
+ params["TopicArn"] = TopicArn
+
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type RemovePermissionResponse struct {
+ ResponseMetadata
+}
+
+// RemovePermission
+//
+// See http://goo.gl/wGl5j for more details.
+func (sns *SNS) RemovePermission(Label, TopicArn string) (resp *RemovePermissionResponse, err error) {
+ resp = &RemovePermissionResponse{}
+ params := makeParams("RemovePermission")
+
+ params["Label"] = Label
+ params["TopicArn"] = TopicArn
+
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type ListSubscriptionByTopicResponse struct {
+ Subscriptions []Subscription `xml:"ListSubscriptionsByTopicResult>Subscriptions>member"`
+ ResponseMetadata
+}
+
+type ListSubscriptionByTopicOpt struct {
+ NextToken string
+ TopicArn string
+}
+
+// ListSubscriptionByTopic
+//
+// See http://goo.gl/LaVcC for more details.
+func (sns *SNS) ListSubscriptionByTopic(options *ListSubscriptionByTopicOpt) (resp *ListSubscriptionByTopicResponse, err error) {
+ resp = &ListSubscriptionByTopicResponse{}
+ params := makeParams("ListSbubscriptionByTopic")
+
+ if options.NextToken != "" {
+ params["NextToken"] = options.NextToken
+ }
+
+ params["TopicArn"] = options.TopicArn
+
+ err = sns.query(nil, nil, params, resp)
+ return
+}
+
+type Error struct {
+ StatusCode int
+ Code string
+ Message string
+ RequestId string
+}
+
+func (err *Error) Error() string {
+ return err.Message
+}
+
+type xmlErrors struct {
+ RequestId string
+ Errors []Error `xml:"Errors>Error"`
+}
+
+func (sns *SNS) query(topic *Topic, message *Message, params map[string]string, resp interface{}) error {
+ params["Timestamp"] = time.Now().UTC().Format(time.RFC3339)
+ u, err := url.Parse(sns.Region.SNSEndpoint)
+ if err != nil {
+ return err
+ }
+
+ sign(sns.Auth, "GET", "/", params, u.Host)
+ u.RawQuery = multimap(params).Encode()
+ r, err := http.Get(u.String())
+ if err != nil {
+ return err
+ }
+ defer r.Body.Close()
+
+ //dump, _ := http.DumpResponse(r, true)
+ //println("DUMP:\n", string(dump))
+ //return nil
+
+ if r.StatusCode != 200 {
+ return buildError(r)
+ }
+ err = xml.NewDecoder(r.Body).Decode(resp)
+ return err
+}
+
+func buildError(r *http.Response) error {
+ errors := xmlErrors{}
+ xml.NewDecoder(r.Body).Decode(&errors)
+ var err Error
+ if len(errors.Errors) > 0 {
+ err = errors.Errors[0]
+ }
+ err.RequestId = errors.RequestId
+ err.StatusCode = r.StatusCode
+ if err.Message == "" {
+ err.Message = r.Status
+ }
+ return &err
+}
+
+func multimap(p map[string]string) url.Values {
+ q := make(url.Values, len(p))
+ for k, v := range p {
+ q[k] = []string{v}
+ }
+ return q
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sns_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sns_test.go
new file mode 100644
index 00000000..a8ff979c
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/exp/sns/sns_test.go
@@ -0,0 +1,241 @@
+package sns_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/exp/sns"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+var _ = Suite(&S{})
+
+type S struct {
+ sns *sns.SNS
+}
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ s.sns = sns.New(auth, aws.Region{SNSEndpoint: testServer.URL})
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) TestListTopicsOK(c *C) {
+ testServer.Response(200, nil, TestListTopicsXmlOK)
+
+ resp, err := s.sns.ListTopics(nil)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "bd10b26c-e30e-11e0-ba29-93c3aca2f103")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestCreateTopic(c *C) {
+ testServer.Response(200, nil, TestCreateTopicXmlOK)
+
+ resp, err := s.sns.CreateTopic("My-Topic")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.Topic.TopicArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic")
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "a8dec8b3-33a4-11df-8963-01868b7c937a")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestDeleteTopic(c *C) {
+ testServer.Response(200, nil, TestDeleteTopicXmlOK)
+
+ t := sns.Topic{nil, "arn:aws:sns:us-east-1:123456789012:My-Topic"}
+ resp, err := s.sns.DeleteTopic(t)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "f3aa9ac9-3c3d-11df-8235-9dab105e9c32")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestListSubscriptions(c *C) {
+ testServer.Response(200, nil, TestListSubscriptionsXmlOK)
+
+ resp, err := s.sns.ListSubscriptions(nil)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(len(resp.Subscriptions), Not(Equals), 0)
+ c.Assert(resp.Subscriptions[0].Protocol, Equals, "email")
+ c.Assert(resp.Subscriptions[0].Endpoint, Equals, "example@amazon.com")
+ c.Assert(resp.Subscriptions[0].SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca")
+ c.Assert(resp.Subscriptions[0].TopicArn, Equals, "arn:aws:sns:us-east-1:698519295917:My-Topic")
+ c.Assert(resp.Subscriptions[0].Owner, Equals, "123456789012")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestGetTopicAttributes(c *C) {
+ testServer.Response(200, nil, TestGetTopicAttributesXmlOK)
+
+ resp, err := s.sns.GetTopicAttributes("arn:aws:sns:us-east-1:123456789012:My-Topic")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(len(resp.Attributes), Not(Equals), 0)
+ c.Assert(resp.Attributes[0].Key, Equals, "Owner")
+ c.Assert(resp.Attributes[0].Value, Equals, "123456789012")
+ c.Assert(resp.Attributes[1].Key, Equals, "Policy")
+ c.Assert(resp.Attributes[1].Value, Equals, `{"Version":"2008-10-17","Id":"us-east-1/698519295917/test__default_policy_ID","Statement" : [{"Effect":"Allow","Sid":"us-east-1/698519295917/test__default_statement_ID","Principal" : {"AWS": "*"},"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],"Resource":"arn:aws:sns:us-east-1:698519295917:test","Condition" : {"StringLike" : {"AWS:SourceArn": "arn:aws:*:*:698519295917:*"}}}]}`)
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "057f074c-33a7-11df-9540-99d0768312d3")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestPublish(c *C) {
+ testServer.Response(200, nil, TestPublishXmlOK)
+
+ pubOpt := &sns.PublishOpt{"foobar", "", "subject", "arn:aws:sns:us-east-1:123456789012:My-Topic"}
+ resp, err := s.sns.Publish(pubOpt)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.MessageId, Equals, "94f20ce6-13c5-43a0-9a9e-ca52d816e90b")
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "f187a3c1-376f-11df-8963-01868b7c937a")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestSetTopicAttributes(c *C) {
+ testServer.Response(200, nil, TestSetTopicAttributesXmlOK)
+
+ resp, err := s.sns.SetTopicAttributes("DisplayName", "MyTopicName", "arn:aws:sns:us-east-1:123456789012:My-Topic")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "a8763b99-33a7-11df-a9b7-05d48da6f042")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestSubscribe(c *C) {
+ testServer.Response(200, nil, TestSubscribeXmlOK)
+
+ resp, err := s.sns.Subscribe("example@amazon.com", "email", "arn:aws:sns:us-east-1:123456789012:My-Topic")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.SubscriptionArn, Equals, "pending confirmation")
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "a169c740-3766-11df-8963-01868b7c937a")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestUnsubscribe(c *C) {
+ testServer.Response(200, nil, TestUnsubscribeXmlOK)
+
+ resp, err := s.sns.Unsubscribe("arn:aws:sns:us-east-1:123456789012:My-Topic:a169c740-3766-11df-8963-01868b7c937a")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "18e0ac39-3776-11df-84c0-b93cc1666b84")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestConfirmSubscription(c *C) {
+ testServer.Response(200, nil, TestConfirmSubscriptionXmlOK)
+
+ opt := &sns.ConfirmSubscriptionOpt{"", "51b2ff3edb475b7d91550e0ab6edf0c1de2a34e6ebaf6", "arn:aws:sns:us-east-1:123456789012:My-Topic"}
+ resp, err := s.sns.ConfirmSubscription(opt)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca")
+ c.Assert(resp.ResponseMetadata.RequestId, Equals, "7a50221f-3774-11df-a9b7-05d48da6f042")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestAddPermission(c *C) {
+ testServer.Response(200, nil, TestAddPermissionXmlOK)
+ perm := make([]sns.Permission, 2)
+ perm[0].ActionName = "Publish"
+ perm[1].ActionName = "GetTopicAttributes"
+ perm[0].AccountId = "987654321000"
+ perm[1].AccountId = "876543210000"
+
+ resp, err := s.sns.AddPermission(perm, "NewPermission", "arn:aws:sns:us-east-1:123456789012:My-Topic")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.RequestId, Equals, "6a213e4e-33a8-11df-9540-99d0768312d3")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestRemovePermission(c *C) {
+ testServer.Response(200, nil, TestRemovePermissionXmlOK)
+
+ resp, err := s.sns.RemovePermission("NewPermission", "arn:aws:sns:us-east-1:123456789012:My-Topic")
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(resp.RequestId, Equals, "d170b150-33a8-11df-995a-2d6fbe836cc1")
+ c.Assert(err, IsNil)
+}
+
+func (s *S) TestListSubscriptionByTopic(c *C) {
+ testServer.Response(200, nil, TestListSubscriptionsByTopicXmlOK)
+
+ opt := &sns.ListSubscriptionByTopicOpt{"", "arn:aws:sns:us-east-1:123456789012:My-Topic"}
+ resp, err := s.sns.ListSubscriptionByTopic(opt)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(len(resp.Subscriptions), Not(Equals), 0)
+ c.Assert(resp.Subscriptions[0].TopicArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic")
+ c.Assert(resp.Subscriptions[0].SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca")
+ c.Assert(resp.Subscriptions[0].Owner, Equals, "123456789012")
+ c.Assert(resp.Subscriptions[0].Endpoint, Equals, "example@amazon.com")
+ c.Assert(resp.Subscriptions[0].Protocol, Equals, "email")
+ c.Assert(err, IsNil)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iam.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iam.go
new file mode 100644
index 00000000..a25ac465
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iam.go
@@ -0,0 +1,460 @@
+// The iam package provides types and functions for interaction with the AWS
+// Identity and Access Management (IAM) service.
+package iam
+
+import (
+ "encoding/xml"
+ "github.com/mitchellh/goamz/aws"
+ "net/http"
+ "net/url"
+ "strconv"
+ "strings"
+ "time"
+)
+
+// The IAM type encapsulates operations operations with the IAM endpoint.
+type IAM struct {
+ aws.Auth
+ aws.Region
+ httpClient *http.Client
+}
+
+// New creates a new IAM instance.
+func New(auth aws.Auth, region aws.Region) *IAM {
+ return NewWithClient(auth, region, aws.RetryingClient)
+}
+
+func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *IAM {
+ return &IAM{auth, region, httpClient}
+}
+
+func (iam *IAM) query(params map[string]string, resp interface{}) error {
+ params["Version"] = "2010-05-08"
+ params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
+ endpoint, err := url.Parse(iam.IAMEndpoint)
+ if err != nil {
+ return err
+ }
+ sign(iam.Auth, "GET", "/", params, endpoint.Host)
+ endpoint.RawQuery = multimap(params).Encode()
+ r, err := iam.httpClient.Get(endpoint.String())
+ if err != nil {
+ return err
+ }
+ defer r.Body.Close()
+ if r.StatusCode > 200 {
+ return buildError(r)
+ }
+ return xml.NewDecoder(r.Body).Decode(resp)
+}
+
+func (iam *IAM) postQuery(params map[string]string, resp interface{}) error {
+ endpoint, err := url.Parse(iam.IAMEndpoint)
+ if err != nil {
+ return err
+ }
+ params["Version"] = "2010-05-08"
+ params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
+ sign(iam.Auth, "POST", "/", params, endpoint.Host)
+ encoded := multimap(params).Encode()
+ body := strings.NewReader(encoded)
+ req, err := http.NewRequest("POST", endpoint.String(), body)
+ if err != nil {
+ return err
+ }
+ req.Header.Set("Host", endpoint.Host)
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ req.Header.Set("Content-Length", strconv.Itoa(len(encoded)))
+ r, err := http.DefaultClient.Do(req)
+ if err != nil {
+ return err
+ }
+ defer r.Body.Close()
+ if r.StatusCode > 200 {
+ return buildError(r)
+ }
+ return xml.NewDecoder(r.Body).Decode(resp)
+}
+
+func buildError(r *http.Response) error {
+ var (
+ err Error
+ errors xmlErrors
+ )
+ xml.NewDecoder(r.Body).Decode(&errors)
+ if len(errors.Errors) > 0 {
+ err = errors.Errors[0]
+ }
+ err.StatusCode = r.StatusCode
+ if err.Message == "" {
+ err.Message = r.Status
+ }
+ return &err
+}
+
+func multimap(p map[string]string) url.Values {
+ q := make(url.Values, len(p))
+ for k, v := range p {
+ q[k] = []string{v}
+ }
+ return q
+}
+
+// Response to a CreateUser request.
+//
+// See http://goo.gl/JS9Gz for more details.
+type CreateUserResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ User User `xml:"CreateUserResult>User"`
+}
+
+// User encapsulates a user managed by IAM.
+//
+// See http://goo.gl/BwIQ3 for more details.
+type User struct {
+ Arn string
+ Path string
+ Id string `xml:"UserId"`
+ Name string `xml:"UserName"`
+}
+
+// CreateUser creates a new user in IAM.
+//
+// See http://goo.gl/JS9Gz for more details.
+func (iam *IAM) CreateUser(name, path string) (*CreateUserResp, error) {
+ params := map[string]string{
+ "Action": "CreateUser",
+ "Path": path,
+ "UserName": name,
+ }
+ resp := new(CreateUserResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Response for GetUser requests.
+//
+// See http://goo.gl/ZnzRN for more details.
+type GetUserResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ User User `xml:"GetUserResult>User"`
+}
+
+// GetUser gets a user from IAM.
+//
+// See http://goo.gl/ZnzRN for more details.
+func (iam *IAM) GetUser(name string) (*GetUserResp, error) {
+ params := map[string]string{
+ "Action": "GetUser",
+ "UserName": name,
+ }
+ resp := new(GetUserResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteUser deletes a user from IAM.
+//
+// See http://goo.gl/jBuCG for more details.
+func (iam *IAM) DeleteUser(name string) (*SimpleResp, error) {
+ params := map[string]string{
+ "Action": "DeleteUser",
+ "UserName": name,
+ }
+ resp := new(SimpleResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Response to a CreateGroup request.
+//
+// See http://goo.gl/n7NNQ for more details.
+type CreateGroupResp struct {
+ Group Group `xml:"CreateGroupResult>Group"`
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+// Group encapsulates a group managed by IAM.
+//
+// See http://goo.gl/ae7Vs for more details.
+type Group struct {
+ Arn string
+ Id string `xml:"GroupId"`
+ Name string `xml:"GroupName"`
+ Path string
+}
+
+// CreateGroup creates a new group in IAM.
+//
+// The path parameter can be used to identify which division or part of the
+// organization the user belongs to.
+//
+// If path is unset ("") it defaults to "/".
+//
+// See http://goo.gl/n7NNQ for more details.
+func (iam *IAM) CreateGroup(name string, path string) (*CreateGroupResp, error) {
+ params := map[string]string{
+ "Action": "CreateGroup",
+ "GroupName": name,
+ }
+ if path != "" {
+ params["Path"] = path
+ }
+ resp := new(CreateGroupResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Response to a ListGroups request.
+//
+// See http://goo.gl/W2TRj for more details.
+type GroupsResp struct {
+ Groups []Group `xml:"ListGroupsResult>Groups>member"`
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+// Groups list the groups that have the specified path prefix.
+//
+// The parameter pathPrefix is optional. If pathPrefix is "", all groups are
+// returned.
+//
+// See http://goo.gl/W2TRj for more details.
+func (iam *IAM) Groups(pathPrefix string) (*GroupsResp, error) {
+ params := map[string]string{
+ "Action": "ListGroups",
+ }
+ if pathPrefix != "" {
+ params["PathPrefix"] = pathPrefix
+ }
+ resp := new(GroupsResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteGroup deletes a group from IAM.
+//
+// See http://goo.gl/d5i2i for more details.
+func (iam *IAM) DeleteGroup(name string) (*SimpleResp, error) {
+ params := map[string]string{
+ "Action": "DeleteGroup",
+ "GroupName": name,
+ }
+ resp := new(SimpleResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Response to a CreateAccessKey request.
+//
+// See http://goo.gl/L46Py for more details.
+type CreateAccessKeyResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ AccessKey AccessKey `xml:"CreateAccessKeyResult>AccessKey"`
+}
+
+// AccessKey encapsulates an access key generated for a user.
+//
+// See http://goo.gl/LHgZR for more details.
+type AccessKey struct {
+ UserName string
+ Id string `xml:"AccessKeyId"`
+ Secret string `xml:"SecretAccessKey,omitempty"`
+ Status string
+}
+
+// CreateAccessKey creates a new access key in IAM.
+//
+// See http://goo.gl/L46Py for more details.
+func (iam *IAM) CreateAccessKey(userName string) (*CreateAccessKeyResp, error) {
+ params := map[string]string{
+ "Action": "CreateAccessKey",
+ "UserName": userName,
+ }
+ resp := new(CreateAccessKeyResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Response to AccessKeys request.
+//
+// See http://goo.gl/Vjozx for more details.
+type AccessKeysResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ AccessKeys []AccessKey `xml:"ListAccessKeysResult>AccessKeyMetadata>member"`
+}
+
+// AccessKeys lists all acccess keys associated with a user.
+//
+// The userName parameter is optional. If set to "", the userName is determined
+// implicitly based on the AWS Access Key ID used to sign the request.
+//
+// See http://goo.gl/Vjozx for more details.
+func (iam *IAM) AccessKeys(userName string) (*AccessKeysResp, error) {
+ params := map[string]string{
+ "Action": "ListAccessKeys",
+ }
+ if userName != "" {
+ params["UserName"] = userName
+ }
+ resp := new(AccessKeysResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteAccessKey deletes an access key from IAM.
+//
+// The userName parameter is optional. If set to "", the userName is determined
+// implicitly based on the AWS Access Key ID used to sign the request.
+//
+// See http://goo.gl/hPGhw for more details.
+func (iam *IAM) DeleteAccessKey(id, userName string) (*SimpleResp, error) {
+ params := map[string]string{
+ "Action": "DeleteAccessKey",
+ "AccessKeyId": id,
+ }
+ if userName != "" {
+ params["UserName"] = userName
+ }
+ resp := new(SimpleResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Response to a GetUserPolicy request.
+//
+// See http://goo.gl/BH04O for more details.
+type GetUserPolicyResp struct {
+ Policy UserPolicy `xml:"GetUserPolicyResult"`
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+// UserPolicy encapsulates an IAM group policy.
+//
+// See http://goo.gl/C7hgS for more details.
+type UserPolicy struct {
+ Name string `xml:"PolicyName"`
+ UserName string `xml:"UserName"`
+ Document string `xml:"PolicyDocument"`
+}
+
+// GetUserPolicy gets a user policy in IAM.
+//
+// See http://goo.gl/BH04O for more details.
+func (iam *IAM) GetUserPolicy(userName, policyName string) (*GetUserPolicyResp, error) {
+ params := map[string]string{
+ "Action": "GetUserPolicy",
+ "UserName": userName,
+ "PolicyName": policyName,
+ }
+ resp := new(GetUserPolicyResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+ return nil, nil
+}
+
+// PutUserPolicy creates a user policy in IAM.
+//
+// See http://goo.gl/ldCO8 for more details.
+func (iam *IAM) PutUserPolicy(userName, policyName, policyDocument string) (*SimpleResp, error) {
+ params := map[string]string{
+ "Action": "PutUserPolicy",
+ "UserName": userName,
+ "PolicyName": policyName,
+ "PolicyDocument": policyDocument,
+ }
+ resp := new(SimpleResp)
+ if err := iam.postQuery(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteUserPolicy deletes a user policy from IAM.
+//
+// See http://goo.gl/7Jncn for more details.
+func (iam *IAM) DeleteUserPolicy(userName, policyName string) (*SimpleResp, error) {
+ params := map[string]string{
+ "Action": "DeleteUserPolicy",
+ "PolicyName": policyName,
+ "UserName": userName,
+ }
+ resp := new(SimpleResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// Response for AddUserToGroup requests.
+//
+// See http://goo.gl/ZnzRN for more details.
+type AddUserToGroupResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+// AddUserToGroup adds a user to a specific group
+//
+// See http://goo.gl/ZnzRN for more details.
+func (iam *IAM) AddUserToGroup(name, group string) (*AddUserToGroupResp, error) {
+
+ params := map[string]string{
+ "Action": "AddUserToGroup",
+ "GroupName": group,
+ "UserName": name}
+ resp := new(AddUserToGroupResp)
+ if err := iam.query(params, resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+type SimpleResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+type xmlErrors struct {
+ Errors []Error `xml:"Error"`
+}
+
+// Error encapsulates an IAM error.
+type Error struct {
+ // HTTP status code of the error.
+ StatusCode int
+
+ // AWS code of the error.
+ Code string
+
+ // Message explaining the error.
+ Message string
+}
+
+func (e *Error) Error() string {
+ var prefix string
+ if e.Code != "" {
+ prefix = e.Code + ": "
+ }
+ if prefix == "" && e.StatusCode > 0 {
+ prefix = strconv.Itoa(e.StatusCode) + ": "
+ }
+ return prefix + e.Message
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iam_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iam_test.go
new file mode 100644
index 00000000..719a0182
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iam_test.go
@@ -0,0 +1,289 @@
+package iam_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/iam"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "strings"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+type S struct {
+ iam *iam.IAM
+}
+
+var _ = Suite(&S{})
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ s.iam = iam.NewWithClient(auth, aws.Region{IAMEndpoint: testServer.URL}, testutil.DefaultClient)
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) TestCreateUser(c *C) {
+ testServer.Response(200, nil, CreateUserExample)
+ resp, err := s.iam.CreateUser("Bob", "/division_abc/subdivision_xyz/")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "CreateUser")
+ c.Assert(values.Get("UserName"), Equals, "Bob")
+ c.Assert(values.Get("Path"), Equals, "/division_abc/subdivision_xyz/")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+ expected := iam.User{
+ Path: "/division_abc/subdivision_xyz/",
+ Name: "Bob",
+ Id: "AIDACKCEVSQ6C2EXAMPLE",
+ Arn: "arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob",
+ }
+ c.Assert(resp.User, DeepEquals, expected)
+}
+
+func (s *S) TestCreateUserConflict(c *C) {
+ testServer.Response(409, nil, DuplicateUserExample)
+ resp, err := s.iam.CreateUser("Bob", "/division_abc/subdivision_xyz/")
+ testServer.WaitRequest()
+ c.Assert(resp, IsNil)
+ c.Assert(err, NotNil)
+ e, ok := err.(*iam.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(e.Message, Equals, "User with name Bob already exists.")
+ c.Assert(e.Code, Equals, "EntityAlreadyExists")
+}
+
+func (s *S) TestGetUser(c *C) {
+ testServer.Response(200, nil, GetUserExample)
+ resp, err := s.iam.GetUser("Bob")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "GetUser")
+ c.Assert(values.Get("UserName"), Equals, "Bob")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+ expected := iam.User{
+ Path: "/division_abc/subdivision_xyz/",
+ Name: "Bob",
+ Id: "AIDACKCEVSQ6C2EXAMPLE",
+ Arn: "arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob",
+ }
+ c.Assert(resp.User, DeepEquals, expected)
+}
+
+func (s *S) TestDeleteUser(c *C) {
+ testServer.Response(200, nil, RequestIdExample)
+ resp, err := s.iam.DeleteUser("Bob")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "DeleteUser")
+ c.Assert(values.Get("UserName"), Equals, "Bob")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+}
+
+func (s *S) TestCreateGroup(c *C) {
+ testServer.Response(200, nil, CreateGroupExample)
+ resp, err := s.iam.CreateGroup("Admins", "/admins/")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "CreateGroup")
+ c.Assert(values.Get("GroupName"), Equals, "Admins")
+ c.Assert(values.Get("Path"), Equals, "/admins/")
+ c.Assert(err, IsNil)
+ c.Assert(resp.Group.Path, Equals, "/admins/")
+ c.Assert(resp.Group.Name, Equals, "Admins")
+ c.Assert(resp.Group.Id, Equals, "AGPACKCEVSQ6C2EXAMPLE")
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+}
+
+func (s *S) TestCreateGroupWithoutPath(c *C) {
+ testServer.Response(200, nil, CreateGroupExample)
+ _, err := s.iam.CreateGroup("Managers", "")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "CreateGroup")
+ c.Assert(err, IsNil)
+ _, ok := map[string][]string(values)["Path"]
+ c.Assert(ok, Equals, false)
+}
+
+func (s *S) TestDeleteGroup(c *C) {
+ testServer.Response(200, nil, RequestIdExample)
+ resp, err := s.iam.DeleteGroup("Admins")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "DeleteGroup")
+ c.Assert(values.Get("GroupName"), Equals, "Admins")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+}
+
+func (s *S) TestListGroups(c *C) {
+ testServer.Response(200, nil, ListGroupsExample)
+ resp, err := s.iam.Groups("/division_abc/")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "ListGroups")
+ c.Assert(values.Get("PathPrefix"), Equals, "/division_abc/")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+ expected := []iam.Group{
+ {
+ Path: "/division_abc/subdivision_xyz/",
+ Name: "Admins",
+ Id: "AGPACKCEVSQ6C2EXAMPLE",
+ Arn: "arn:aws:iam::123456789012:group/Admins",
+ },
+ {
+ Path: "/division_abc/subdivision_xyz/product_1234/engineering/",
+ Name: "Test",
+ Id: "AGP2MAB8DPLSRHEXAMPLE",
+ Arn: "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/engineering/Test",
+ },
+ {
+ Path: "/division_abc/subdivision_xyz/product_1234/",
+ Name: "Managers",
+ Id: "AGPIODR4TAW7CSEXAMPLE",
+ Arn: "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/Managers",
+ },
+ }
+ c.Assert(resp.Groups, DeepEquals, expected)
+}
+
+func (s *S) TestListGroupsWithoutPathPrefix(c *C) {
+ testServer.Response(200, nil, ListGroupsExample)
+ _, err := s.iam.Groups("")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "ListGroups")
+ c.Assert(err, IsNil)
+ _, ok := map[string][]string(values)["PathPrefix"]
+ c.Assert(ok, Equals, false)
+}
+
+func (s *S) TestCreateAccessKey(c *C) {
+ testServer.Response(200, nil, CreateAccessKeyExample)
+ resp, err := s.iam.CreateAccessKey("Bob")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "CreateAccessKey")
+ c.Assert(values.Get("UserName"), Equals, "Bob")
+ c.Assert(err, IsNil)
+ c.Assert(resp.AccessKey.UserName, Equals, "Bob")
+ c.Assert(resp.AccessKey.Id, Equals, "AKIAIOSFODNN7EXAMPLE")
+ c.Assert(resp.AccessKey.Secret, Equals, "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY")
+ c.Assert(resp.AccessKey.Status, Equals, "Active")
+}
+
+func (s *S) TestDeleteAccessKey(c *C) {
+ testServer.Response(200, nil, RequestIdExample)
+ resp, err := s.iam.DeleteAccessKey("ysa8hasdhasdsi", "Bob")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "DeleteAccessKey")
+ c.Assert(values.Get("AccessKeyId"), Equals, "ysa8hasdhasdsi")
+ c.Assert(values.Get("UserName"), Equals, "Bob")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+}
+
+func (s *S) TestDeleteAccessKeyBlankUserName(c *C) {
+ testServer.Response(200, nil, RequestIdExample)
+ _, err := s.iam.DeleteAccessKey("ysa8hasdhasdsi", "")
+ c.Assert(err, IsNil)
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "DeleteAccessKey")
+ c.Assert(values.Get("AccessKeyId"), Equals, "ysa8hasdhasdsi")
+ _, ok := map[string][]string(values)["UserName"]
+ c.Assert(ok, Equals, false)
+}
+
+func (s *S) TestAccessKeys(c *C) {
+ testServer.Response(200, nil, ListAccessKeyExample)
+ resp, err := s.iam.AccessKeys("Bob")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "ListAccessKeys")
+ c.Assert(values.Get("UserName"), Equals, "Bob")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+ c.Assert(resp.AccessKeys, HasLen, 2)
+ c.Assert(resp.AccessKeys[0].Id, Equals, "AKIAIOSFODNN7EXAMPLE")
+ c.Assert(resp.AccessKeys[0].UserName, Equals, "Bob")
+ c.Assert(resp.AccessKeys[0].Status, Equals, "Active")
+ c.Assert(resp.AccessKeys[1].Id, Equals, "AKIAI44QH8DHBEXAMPLE")
+ c.Assert(resp.AccessKeys[1].UserName, Equals, "Bob")
+ c.Assert(resp.AccessKeys[1].Status, Equals, "Inactive")
+}
+
+func (s *S) TestAccessKeysBlankUserName(c *C) {
+ testServer.Response(200, nil, ListAccessKeyExample)
+ _, err := s.iam.AccessKeys("")
+ c.Assert(err, IsNil)
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "ListAccessKeys")
+ _, ok := map[string][]string(values)["UserName"]
+ c.Assert(ok, Equals, false)
+}
+
+func (s *S) TestGetUserPolicy(c *C) {
+ testServer.Response(200, nil, GetUserPolicyExample)
+ resp, err := s.iam.GetUserPolicy("Bob", "AllAccessPolicy")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "GetUserPolicy")
+ c.Assert(values.Get("UserName"), Equals, "Bob")
+ c.Assert(values.Get("PolicyName"), Equals, "AllAccessPolicy")
+ c.Assert(err, IsNil)
+ c.Assert(resp.Policy.UserName, Equals, "Bob")
+ c.Assert(resp.Policy.Name, Equals, "AllAccessPolicy")
+ c.Assert(strings.TrimSpace(resp.Policy.Document), Equals, `{"Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}`)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+}
+
+func (s *S) TestPutUserPolicy(c *C) {
+ document := `{
+ "Statement": [
+ {
+ "Action": [
+ "s3:*"
+ ],
+ "Effect": "Allow",
+ "Resource": [
+ "arn:aws:s3:::8shsns19s90ajahadsj/*",
+ "arn:aws:s3:::8shsns19s90ajahadsj"
+ ]
+ }]
+ }`
+ testServer.Response(200, nil, RequestIdExample)
+ resp, err := s.iam.PutUserPolicy("Bob", "AllAccessPolicy", document)
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "POST")
+ c.Assert(req.FormValue("Action"), Equals, "PutUserPolicy")
+ c.Assert(req.FormValue("PolicyName"), Equals, "AllAccessPolicy")
+ c.Assert(req.FormValue("UserName"), Equals, "Bob")
+ c.Assert(req.FormValue("PolicyDocument"), Equals, document)
+ c.Assert(req.FormValue("Version"), Equals, "2010-05-08")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+}
+
+func (s *S) TestDeleteUserPolicy(c *C) {
+ testServer.Response(200, nil, RequestIdExample)
+ resp, err := s.iam.DeleteUserPolicy("Bob", "AllAccessPolicy")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "DeleteUserPolicy")
+ c.Assert(values.Get("PolicyName"), Equals, "AllAccessPolicy")
+ c.Assert(values.Get("UserName"), Equals, "Bob")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+}
+
+func (s *S) TestAddUserToGroup(c *C) {
+ testServer.Response(200, nil, AddUserToGroupExample)
+ resp, err := s.iam.AddUserToGroup("admin1", "Admins")
+ values := testServer.WaitRequest().URL.Query()
+ c.Assert(values.Get("Action"), Equals, "AddUserToGroup")
+ c.Assert(values.Get("GroupName"), Equals, "Admins")
+ c.Assert(values.Get("UserName"), Equals, "admin1")
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iami_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iami_test.go
new file mode 100644
index 00000000..61e5be0f
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iami_test.go
@@ -0,0 +1,208 @@
+package iam_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/iam"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "net/url"
+)
+
+// AmazonServer represents an Amazon AWS server.
+type AmazonServer struct {
+ auth aws.Auth
+}
+
+func (s *AmazonServer) SetUp(c *C) {
+ auth, err := aws.EnvAuth()
+ if err != nil {
+ c.Fatal(err)
+ }
+ s.auth = auth
+}
+
+var _ = Suite(&AmazonClientSuite{})
+
+// AmazonClientSuite tests the client against a live AWS server.
+type AmazonClientSuite struct {
+ srv AmazonServer
+ ClientTests
+}
+
+func (s *AmazonClientSuite) SetUpSuite(c *C) {
+ if !testutil.Amazon {
+ c.Skip("AmazonClientSuite tests not enabled")
+ }
+ s.srv.SetUp(c)
+ s.iam = iam.New(s.srv.auth, aws.USEast)
+}
+
+// ClientTests defines integration tests designed to test the client.
+// It is not used as a test suite in itself, but embedded within
+// another type.
+type ClientTests struct {
+ iam *iam.IAM
+}
+
+func (s *ClientTests) TestCreateAndDeleteUser(c *C) {
+ createResp, err := s.iam.CreateUser("gopher", "/gopher/")
+ c.Assert(err, IsNil)
+ getResp, err := s.iam.GetUser("gopher")
+ c.Assert(err, IsNil)
+ c.Assert(createResp.User, DeepEquals, getResp.User)
+ _, err = s.iam.DeleteUser("gopher")
+ c.Assert(err, IsNil)
+}
+
+func (s *ClientTests) TestCreateUserError(c *C) {
+ _, err := s.iam.CreateUser("gopher", "/gopher/")
+ c.Assert(err, IsNil)
+ defer s.iam.DeleteUser("gopher")
+ _, err = s.iam.CreateUser("gopher", "/")
+ iamErr, ok := err.(*iam.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(iamErr.StatusCode, Equals, 409)
+ c.Assert(iamErr.Code, Equals, "EntityAlreadyExists")
+ c.Assert(iamErr.Message, Equals, "User with name gopher already exists.")
+}
+
+func (s *ClientTests) TestDeleteUserError(c *C) {
+ _, err := s.iam.DeleteUser("gopher")
+ iamErr, ok := err.(*iam.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(iamErr.StatusCode, Equals, 404)
+ c.Assert(iamErr.Code, Equals, "NoSuchEntity")
+ c.Assert(iamErr.Message, Equals, "The user with name gopher cannot be found.")
+}
+
+func (s *ClientTests) TestGetUserError(c *C) {
+ _, err := s.iam.GetUser("gopher")
+ iamErr, ok := err.(*iam.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(iamErr.StatusCode, Equals, 404)
+ c.Assert(iamErr.Code, Equals, "NoSuchEntity")
+ c.Assert(iamErr.Message, Equals, "The user with name gopher cannot be found.")
+}
+
+func (s *ClientTests) TestCreateListAndDeleteAccessKey(c *C) {
+ createUserResp, err := s.iam.CreateUser("gopher", "/gopher/")
+ c.Assert(err, IsNil)
+ defer s.iam.DeleteUser(createUserResp.User.Name)
+ createKeyResp, err := s.iam.CreateAccessKey(createUserResp.User.Name)
+ c.Assert(err, IsNil)
+ listKeyResp, err := s.iam.AccessKeys(createUserResp.User.Name)
+ c.Assert(err, IsNil)
+ c.Assert(listKeyResp.AccessKeys, HasLen, 1)
+ createKeyResp.AccessKey.Secret = ""
+ c.Assert(listKeyResp.AccessKeys[0], DeepEquals, createKeyResp.AccessKey)
+ _, err = s.iam.DeleteAccessKey(createKeyResp.AccessKey.Id, createUserResp.User.Name)
+ c.Assert(err, IsNil)
+}
+
+func (s *ClientTests) TestCreateAccessKeyError(c *C) {
+ _, err := s.iam.CreateAccessKey("unknowngopher")
+ c.Assert(err, NotNil)
+ iamErr, ok := err.(*iam.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(iamErr.StatusCode, Equals, 404)
+ c.Assert(iamErr.Code, Equals, "NoSuchEntity")
+ c.Assert(iamErr.Message, Equals, "The user with name unknowngopher cannot be found.")
+}
+
+func (s *ClientTests) TestListAccessKeysUserNotFound(c *C) {
+ _, err := s.iam.AccessKeys("unknowngopher")
+ c.Assert(err, NotNil)
+ iamErr, ok := err.(*iam.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(iamErr.StatusCode, Equals, 404)
+ c.Assert(iamErr.Code, Equals, "NoSuchEntity")
+ c.Assert(iamErr.Message, Equals, "The user with name unknowngopher cannot be found.")
+}
+
+func (s *ClientTests) TestListAccessKeysUserWithoutKeys(c *C) {
+ createUserResp, err := s.iam.CreateUser("gopher", "/")
+ c.Assert(err, IsNil)
+ defer s.iam.DeleteUser(createUserResp.User.Name)
+ resp, err := s.iam.AccessKeys(createUserResp.User.Name)
+ c.Assert(err, IsNil)
+ c.Assert(resp.AccessKeys, HasLen, 0)
+}
+
+func (s *ClientTests) TestCreateListAndDeleteGroup(c *C) {
+ cResp1, err := s.iam.CreateGroup("Finances", "/finances/")
+ c.Assert(err, IsNil)
+ cResp2, err := s.iam.CreateGroup("DevelopmentManagers", "/development/managers/")
+ c.Assert(err, IsNil)
+ lResp, err := s.iam.Groups("/development/")
+ c.Assert(err, IsNil)
+ c.Assert(lResp.Groups, HasLen, 1)
+ c.Assert(cResp2.Group, DeepEquals, lResp.Groups[0])
+ lResp, err = s.iam.Groups("")
+ c.Assert(err, IsNil)
+ c.Assert(lResp.Groups, HasLen, 2)
+ if lResp.Groups[0].Name == cResp1.Group.Name {
+ c.Assert([]iam.Group{cResp1.Group, cResp2.Group}, DeepEquals, lResp.Groups)
+ } else {
+ c.Assert([]iam.Group{cResp2.Group, cResp1.Group}, DeepEquals, lResp.Groups)
+ }
+ _, err = s.iam.DeleteGroup("DevelopmentManagers")
+ c.Assert(err, IsNil)
+ lResp, err = s.iam.Groups("/development/")
+ c.Assert(err, IsNil)
+ c.Assert(lResp.Groups, HasLen, 0)
+ _, err = s.iam.DeleteGroup("Finances")
+ c.Assert(err, IsNil)
+}
+
+func (s *ClientTests) TestCreateGroupError(c *C) {
+ _, err := s.iam.CreateGroup("Finances", "/finances/")
+ c.Assert(err, IsNil)
+ defer s.iam.DeleteGroup("Finances")
+ _, err = s.iam.CreateGroup("Finances", "/something-else/")
+ iamErr, ok := err.(*iam.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(iamErr.StatusCode, Equals, 409)
+ c.Assert(iamErr.Code, Equals, "EntityAlreadyExists")
+ c.Assert(iamErr.Message, Equals, "Group with name Finances already exists.")
+}
+
+func (s *ClientTests) TestDeleteGroupError(c *C) {
+ _, err := s.iam.DeleteGroup("Finances")
+ iamErr, ok := err.(*iam.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(iamErr.StatusCode, Equals, 404)
+ c.Assert(iamErr.Code, Equals, "NoSuchEntity")
+ c.Assert(iamErr.Message, Equals, "The group with name Finances cannot be found.")
+}
+
+func (s *ClientTests) TestPutGetAndDeleteUserPolicy(c *C) {
+ userResp, err := s.iam.CreateUser("gopher", "/gopher/")
+ c.Assert(err, IsNil)
+ defer s.iam.DeleteUser(userResp.User.Name)
+ document := `{
+ "Statement": [
+ {
+ "Action": [
+ "s3:*"
+ ],
+ "Effect": "Allow",
+ "Resource": [
+ "arn:aws:s3:::8shsns19s90ajahadsj/*",
+ "arn:aws:s3:::8shsns19s90ajahadsj"
+ ]
+ }]
+ }`
+ _, err = s.iam.PutUserPolicy(userResp.User.Name, "EverythingS3", document)
+ c.Assert(err, IsNil)
+ resp, err := s.iam.GetUserPolicy(userResp.User.Name, "EverythingS3")
+ c.Assert(err, IsNil)
+ c.Assert(resp.Policy.Name, Equals, "EverythingS3")
+ c.Assert(resp.Policy.UserName, Equals, userResp.User.Name)
+ gotDocument, err := url.QueryUnescape(resp.Policy.Document)
+ c.Assert(err, IsNil)
+ c.Assert(gotDocument, Equals, document)
+ _, err = s.iam.DeleteUserPolicy(userResp.User.Name, "EverythingS3")
+ c.Assert(err, IsNil)
+ _, err = s.iam.GetUserPolicy(userResp.User.Name, "EverythingS3")
+ c.Assert(err, NotNil)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iamt_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iamt_test.go
new file mode 100644
index 00000000..2e3449b7
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iamt_test.go
@@ -0,0 +1,39 @@
+package iam_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/iam"
+ "github.com/mitchellh/goamz/iam/iamtest"
+ . "github.com/motain/gocheck"
+)
+
+// LocalServer represents a local ec2test fake server.
+type LocalServer struct {
+ auth aws.Auth
+ region aws.Region
+ srv *iamtest.Server
+}
+
+func (s *LocalServer) SetUp(c *C) {
+ srv, err := iamtest.NewServer()
+ c.Assert(err, IsNil)
+ c.Assert(srv, NotNil)
+
+ s.srv = srv
+ s.region = aws.Region{IAMEndpoint: srv.URL()}
+}
+
+// LocalServerSuite defines tests that will run
+// against the local iamtest server. It includes
+// tests from ClientTests.
+type LocalServerSuite struct {
+ srv LocalServer
+ ClientTests
+}
+
+var _ = Suite(&LocalServerSuite{})
+
+func (s *LocalServerSuite) SetUpSuite(c *C) {
+ s.srv.SetUp(c)
+ s.ClientTests.iam = iam.New(s.srv.auth, s.srv.region)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iamtest/server.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iamtest/server.go
new file mode 100644
index 00000000..34e06978
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/iamtest/server.go
@@ -0,0 +1,432 @@
+// Package iamtest implements a fake IAM provider with the capability of
+// inducing errors on any given operation, and retrospectively determining what
+// operations have been carried out.
+package iamtest
+
+import (
+ "encoding/json"
+ "encoding/xml"
+ "fmt"
+ "github.com/mitchellh/goamz/iam"
+ "net"
+ "net/http"
+ "strings"
+ "sync"
+)
+
+type action struct {
+ srv *Server
+ w http.ResponseWriter
+ req *http.Request
+ reqId string
+}
+
+// Server implements an IAM simulator for use in tests.
+type Server struct {
+ reqId int
+ url string
+ listener net.Listener
+ users []iam.User
+ groups []iam.Group
+ accessKeys []iam.AccessKey
+ userPolicies []iam.UserPolicy
+ mutex sync.Mutex
+}
+
+func NewServer() (*Server, error) {
+ l, err := net.Listen("tcp", "localhost:0")
+ if err != nil {
+ return nil, fmt.Errorf("cannot listen on localhost: %v", err)
+ }
+ srv := &Server{
+ listener: l,
+ url: "http://" + l.Addr().String(),
+ }
+ go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ srv.serveHTTP(w, req)
+ }))
+ return srv, nil
+}
+
+// Quit closes down the server.
+func (srv *Server) Quit() error {
+ return srv.listener.Close()
+}
+
+// URL returns a URL for the server.
+func (srv *Server) URL() string {
+ return srv.url
+}
+
+type xmlErrors struct {
+ XMLName string `xml:"ErrorResponse"`
+ Error iam.Error
+}
+
+func (srv *Server) error(w http.ResponseWriter, err *iam.Error) {
+ w.WriteHeader(err.StatusCode)
+ xmlErr := xmlErrors{Error: *err}
+ if e := xml.NewEncoder(w).Encode(xmlErr); e != nil {
+ panic(e)
+ }
+}
+
+func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
+ req.ParseForm()
+ srv.mutex.Lock()
+ defer srv.mutex.Unlock()
+ action := req.FormValue("Action")
+ if action == "" {
+ srv.error(w, &iam.Error{
+ StatusCode: 400,
+ Code: "MissingAction",
+ Message: "Missing action",
+ })
+ }
+ if a, ok := actions[action]; ok {
+ reqId := fmt.Sprintf("req%0X", srv.reqId)
+ srv.reqId++
+ if resp, err := a(srv, w, req, reqId); err == nil {
+ if err := xml.NewEncoder(w).Encode(resp); err != nil {
+ panic(err)
+ }
+ } else {
+ switch err.(type) {
+ case *iam.Error:
+ srv.error(w, err.(*iam.Error))
+ default:
+ panic(err)
+ }
+ }
+ } else {
+ srv.error(w, &iam.Error{
+ StatusCode: 400,
+ Code: "InvalidAction",
+ Message: "Invalid action: " + action,
+ })
+ }
+}
+
+func (srv *Server) createUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"UserName"}); err != nil {
+ return nil, err
+ }
+ path := req.FormValue("Path")
+ if path == "" {
+ path = "/"
+ }
+ name := req.FormValue("UserName")
+ for _, user := range srv.users {
+ if user.Name == name {
+ return nil, &iam.Error{
+ StatusCode: 409,
+ Code: "EntityAlreadyExists",
+ Message: fmt.Sprintf("User with name %s already exists.", name),
+ }
+ }
+ }
+ user := iam.User{
+ Id: "USER" + reqId + "EXAMPLE",
+ Arn: fmt.Sprintf("arn:aws:iam:::123456789012:user%s%s", path, name),
+ Name: name,
+ Path: path,
+ }
+ srv.users = append(srv.users, user)
+ return iam.CreateUserResp{
+ RequestId: reqId,
+ User: user,
+ }, nil
+}
+
+func (srv *Server) getUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"UserName"}); err != nil {
+ return nil, err
+ }
+ name := req.FormValue("UserName")
+ index, err := srv.findUser(name)
+ if err != nil {
+ return nil, err
+ }
+ return iam.GetUserResp{RequestId: reqId, User: srv.users[index]}, nil
+}
+
+func (srv *Server) deleteUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"UserName"}); err != nil {
+ return nil, err
+ }
+ name := req.FormValue("UserName")
+ index, err := srv.findUser(name)
+ if err != nil {
+ return nil, err
+ }
+ copy(srv.users[index:], srv.users[index+1:])
+ srv.users = srv.users[:len(srv.users)-1]
+ return iam.SimpleResp{RequestId: reqId}, nil
+}
+
+func (srv *Server) createAccessKey(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"UserName"}); err != nil {
+ return nil, err
+ }
+ userName := req.FormValue("UserName")
+ if _, err := srv.findUser(userName); err != nil {
+ return nil, err
+ }
+ key := iam.AccessKey{
+ Id: fmt.Sprintf("%s%d", userName, len(srv.accessKeys)),
+ Secret: "",
+ UserName: userName,
+ Status: "Active",
+ }
+ srv.accessKeys = append(srv.accessKeys, key)
+ return iam.CreateAccessKeyResp{RequestId: reqId, AccessKey: key}, nil
+}
+
+func (srv *Server) deleteAccessKey(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"AccessKeyId", "UserName"}); err != nil {
+ return nil, err
+ }
+ key := req.FormValue("AccessKeyId")
+ index := -1
+ for i, ak := range srv.accessKeys {
+ if ak.Id == key {
+ index = i
+ break
+ }
+ }
+ if index < 0 {
+ return nil, &iam.Error{
+ StatusCode: 404,
+ Code: "NoSuchEntity",
+ Message: "No such key.",
+ }
+ }
+ copy(srv.accessKeys[index:], srv.accessKeys[index+1:])
+ srv.accessKeys = srv.accessKeys[:len(srv.accessKeys)-1]
+ return iam.SimpleResp{RequestId: reqId}, nil
+}
+
+func (srv *Server) listAccessKeys(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"UserName"}); err != nil {
+ return nil, err
+ }
+ userName := req.FormValue("UserName")
+ if _, err := srv.findUser(userName); err != nil {
+ return nil, err
+ }
+ var keys []iam.AccessKey
+ for _, k := range srv.accessKeys {
+ if k.UserName == userName {
+ keys = append(keys, k)
+ }
+ }
+ return iam.AccessKeysResp{
+ RequestId: reqId,
+ AccessKeys: keys,
+ }, nil
+}
+
+func (srv *Server) createGroup(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"GroupName"}); err != nil {
+ return nil, err
+ }
+ name := req.FormValue("GroupName")
+ path := req.FormValue("Path")
+ for _, group := range srv.groups {
+ if group.Name == name {
+ return nil, &iam.Error{
+ StatusCode: 409,
+ Code: "EntityAlreadyExists",
+ Message: fmt.Sprintf("Group with name %s already exists.", name),
+ }
+ }
+ }
+ group := iam.Group{
+ Id: "GROUP " + reqId + "EXAMPLE",
+ Arn: fmt.Sprintf("arn:aws:iam:::123456789012:group%s%s", path, name),
+ Name: name,
+ Path: path,
+ }
+ srv.groups = append(srv.groups, group)
+ return iam.CreateGroupResp{
+ RequestId: reqId,
+ Group: group,
+ }, nil
+}
+
+func (srv *Server) listGroups(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ pathPrefix := req.FormValue("PathPrefix")
+ if pathPrefix == "" {
+ return iam.GroupsResp{
+ RequestId: reqId,
+ Groups: srv.groups,
+ }, nil
+ }
+ var groups []iam.Group
+ for _, group := range srv.groups {
+ if strings.HasPrefix(group.Path, pathPrefix) {
+ groups = append(groups, group)
+ }
+ }
+ return iam.GroupsResp{
+ RequestId: reqId,
+ Groups: groups,
+ }, nil
+}
+
+func (srv *Server) deleteGroup(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"GroupName"}); err != nil {
+ return nil, err
+ }
+ name := req.FormValue("GroupName")
+ index := -1
+ for i, group := range srv.groups {
+ if group.Name == name {
+ index = i
+ break
+ }
+ }
+ if index == -1 {
+ return nil, &iam.Error{
+ StatusCode: 404,
+ Code: "NoSuchEntity",
+ Message: fmt.Sprintf("The group with name %s cannot be found.", name),
+ }
+ }
+ copy(srv.groups[index:], srv.groups[index+1:])
+ srv.groups = srv.groups[:len(srv.groups)-1]
+ return iam.SimpleResp{RequestId: reqId}, nil
+}
+
+func (srv *Server) putUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"UserName", "PolicyDocument", "PolicyName"}); err != nil {
+ return nil, err
+ }
+ var exists bool
+ policyName := req.FormValue("PolicyName")
+ userName := req.FormValue("UserName")
+ for _, policy := range srv.userPolicies {
+ if policyName == policy.Name && userName == policy.UserName {
+ exists = true
+ break
+ }
+ }
+ if !exists {
+ policy := iam.UserPolicy{
+ Name: policyName,
+ UserName: userName,
+ Document: req.FormValue("PolicyDocument"),
+ }
+ var dumb interface{}
+ if err := json.Unmarshal([]byte(policy.Document), &dumb); err != nil {
+ return nil, &iam.Error{
+ StatusCode: 400,
+ Code: "MalformedPolicyDocument",
+ Message: "Malformed policy document",
+ }
+ }
+ srv.userPolicies = append(srv.userPolicies, policy)
+ }
+ return iam.SimpleResp{RequestId: reqId}, nil
+}
+
+func (srv *Server) deleteUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"UserName", "PolicyName"}); err != nil {
+ return nil, err
+ }
+ policyName := req.FormValue("PolicyName")
+ userName := req.FormValue("UserName")
+ index := -1
+ for i, policy := range srv.userPolicies {
+ if policyName == policy.Name && userName == policy.UserName {
+ index = i
+ break
+ }
+ }
+ if index < 0 {
+ return nil, &iam.Error{
+ StatusCode: 404,
+ Code: "NoSuchEntity",
+ Message: "No such user policy",
+ }
+ }
+ copy(srv.userPolicies[index:], srv.userPolicies[index+1:])
+ srv.userPolicies = srv.userPolicies[:len(srv.userPolicies)-1]
+ return iam.SimpleResp{RequestId: reqId}, nil
+}
+
+func (srv *Server) getUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
+ if err := srv.validate(req, []string{"UserName", "PolicyName"}); err != nil {
+ return nil, err
+ }
+ policyName := req.FormValue("PolicyName")
+ userName := req.FormValue("UserName")
+ index := -1
+ for i, policy := range srv.userPolicies {
+ if policyName == policy.Name && userName == policy.UserName {
+ index = i
+ break
+ }
+ }
+ if index < 0 {
+ return nil, &iam.Error{
+ StatusCode: 404,
+ Code: "NoSuchEntity",
+ Message: "No such user policy",
+ }
+ }
+ return iam.GetUserPolicyResp{
+ Policy: srv.userPolicies[index],
+ RequestId: reqId,
+ }, nil
+}
+
+func (srv *Server) findUser(userName string) (int, error) {
+ var (
+ err error
+ index = -1
+ )
+ for i, user := range srv.users {
+ if user.Name == userName {
+ index = i
+ break
+ }
+ }
+ if index < 0 {
+ err = &iam.Error{
+ StatusCode: 404,
+ Code: "NoSuchEntity",
+ Message: fmt.Sprintf("The user with name %s cannot be found.", userName),
+ }
+ }
+ return index, err
+}
+
+// Validates the presence of required request parameters.
+func (srv *Server) validate(req *http.Request, required []string) error {
+ for _, r := range required {
+ if req.FormValue(r) == "" {
+ return &iam.Error{
+ StatusCode: 400,
+ Code: "InvalidParameterCombination",
+ Message: fmt.Sprintf("%s is required.", r),
+ }
+ }
+ }
+ return nil
+}
+
+var actions = map[string]func(*Server, http.ResponseWriter, *http.Request, string) (interface{}, error){
+ "CreateUser": (*Server).createUser,
+ "DeleteUser": (*Server).deleteUser,
+ "GetUser": (*Server).getUser,
+ "CreateAccessKey": (*Server).createAccessKey,
+ "DeleteAccessKey": (*Server).deleteAccessKey,
+ "ListAccessKeys": (*Server).listAccessKeys,
+ "PutUserPolicy": (*Server).putUserPolicy,
+ "DeleteUserPolicy": (*Server).deleteUserPolicy,
+ "GetUserPolicy": (*Server).getUserPolicy,
+ "CreateGroup": (*Server).createGroup,
+ "DeleteGroup": (*Server).deleteGroup,
+ "ListGroups": (*Server).listGroups,
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/responses_test.go
new file mode 100644
index 00000000..97335901
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/responses_test.go
@@ -0,0 +1,163 @@
+package iam_test
+
+// http://goo.gl/EUIvl
+var CreateUserExample = `
+
+
+
+ /division_abc/subdivision_xyz/
+ Bob
+ AIDACKCEVSQ6C2EXAMPLE
+ arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob
+
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
+
+var DuplicateUserExample = `
+
+
+ Sender
+ EntityAlreadyExists
+ User with name Bob already exists.
+
+ 1d5f5000-1316-11e2-a60f-91a8e6fb6d21
+
+`
+
+var GetUserExample = `
+
+
+
+ /division_abc/subdivision_xyz/
+ Bob
+ AIDACKCEVSQ6C2EXAMPLE
+ arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob
+
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
+
+var CreateGroupExample = `
+
+
+
+ /admins/
+ Admins
+ AGPACKCEVSQ6C2EXAMPLE
+ arn:aws:iam::123456789012:group/Admins
+
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
+
+var ListGroupsExample = `
+
+
+
+
+ /division_abc/subdivision_xyz/
+ Admins
+ AGPACKCEVSQ6C2EXAMPLE
+ arn:aws:iam::123456789012:group/Admins
+
+
+ /division_abc/subdivision_xyz/product_1234/engineering/
+ Test
+ AGP2MAB8DPLSRHEXAMPLE
+ arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/engineering/Test
+
+
+ /division_abc/subdivision_xyz/product_1234/
+ Managers
+ AGPIODR4TAW7CSEXAMPLE
+ arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/Managers
+
+
+ false
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
+
+var RequestIdExample = `
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
+
+var CreateAccessKeyExample = `
+
+
+
+ Bob
+ AKIAIOSFODNN7EXAMPLE
+ Active
+ wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
+
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
+
+var ListAccessKeyExample = `
+
+
+ Bob
+
+
+ Bob
+ AKIAIOSFODNN7EXAMPLE
+ Active
+
+
+ Bob
+ AKIAI44QH8DHBEXAMPLE
+ Inactive
+
+
+ false
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
+
+var GetUserPolicyExample = `
+
+
+ Bob
+ AllAccessPolicy
+
+ {"Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}
+
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
+
+var AddUserToGroupExample = `
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/sign.go
new file mode 100644
index 00000000..bb1fa3f5
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/iam/sign.go
@@ -0,0 +1,38 @@
+package iam
+
+import (
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+ "sort"
+ "strings"
+)
+
+// ----------------------------------------------------------------------------
+// Version 2 signing (http://goo.gl/RSRp5)
+
+var b64 = base64.StdEncoding
+
+func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
+ params["AWSAccessKeyId"] = auth.AccessKey
+ params["SignatureVersion"] = "2"
+ params["SignatureMethod"] = "HmacSHA256"
+ if auth.Token != "" {
+ params["SecurityToken"] = auth.Token
+ }
+
+ var sarray []string
+ for k, v := range params {
+ sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v))
+ }
+ sort.StringSlice(sarray).Sort()
+ joined := strings.Join(sarray, "&")
+ payload := method + "\n" + host + "\n" + path + "\n" + joined
+ hash := hmac.New(sha256.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ params["Signature"] = string(signature)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/rds.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/rds.go
new file mode 100644
index 00000000..05933227
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/rds.go
@@ -0,0 +1,439 @@
+// The rds package provides types and functions for interaction with the AWS
+// Relational Database service (rds)
+package rds
+
+import (
+ "encoding/xml"
+ "github.com/mitchellh/goamz/aws"
+ "net/http"
+ "net/url"
+ "strconv"
+ "time"
+)
+
+// The Rds type encapsulates operations operations with the Rds endpoint.
+type Rds struct {
+ aws.Auth
+ aws.Region
+ httpClient *http.Client
+}
+
+const APIVersion = "2013-09-09"
+
+// New creates a new Rds instance.
+func New(auth aws.Auth, region aws.Region) *Rds {
+ return NewWithClient(auth, region, aws.RetryingClient)
+}
+
+func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *Rds {
+ return &Rds{auth, region, httpClient}
+}
+
+func (rds *Rds) query(params map[string]string, resp interface{}) error {
+ params["Version"] = APIVersion
+ params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
+
+ endpoint, err := url.Parse(rds.Region.RdsEndpoint)
+ if err != nil {
+ return err
+ }
+
+ sign(rds.Auth, "GET", "/", params, endpoint.Host)
+ endpoint.RawQuery = multimap(params).Encode()
+ r, err := rds.httpClient.Get(endpoint.String())
+
+ if err != nil {
+ return err
+ }
+ defer r.Body.Close()
+ if r.StatusCode > 200 {
+ return buildError(r)
+ }
+
+ decoder := xml.NewDecoder(r.Body)
+ decodedBody := decoder.Decode(resp)
+
+ return decodedBody
+}
+
+func buildError(r *http.Response) error {
+ var (
+ err Error
+ errors xmlErrors
+ )
+ xml.NewDecoder(r.Body).Decode(&errors)
+ if len(errors.Errors) > 0 {
+ err = errors.Errors[0]
+ }
+ err.StatusCode = r.StatusCode
+ if err.Message == "" {
+ err.Message = r.Status
+ }
+ return &err
+}
+
+func multimap(p map[string]string) url.Values {
+ q := make(url.Values, len(p))
+ for k, v := range p {
+ q[k] = []string{v}
+ }
+ return q
+}
+
+func makeParams(action string) map[string]string {
+ params := make(map[string]string)
+ params["Action"] = action
+ return params
+}
+
+// ----------------------------------------------------------------------------
+// Rds objects
+
+type DBInstance struct {
+ Address string `xml:"Endpoint>Address"`
+ AllocatedStorage int `xml:"AllocatedStorage"`
+ AvailabilityZone string `xml:"AvailabilityZone"`
+ BackupRetentionPeriod int `xml:"BackupRetentionPeriod"`
+ DBInstanceClass string `xml:"DBInstanceClass"`
+ DBInstanceIdentifier string `xml:"DBInstanceIdentifier"`
+ DBInstanceStatus string `xml:"DBInstanceStatus"`
+ DBName string `xml:"DBName"`
+ Engine string `xml:"Engine"`
+ EngineVersion string `xml:"EngineVersion"`
+ MasterUsername string `xml:"MasterUsername"`
+ MultiAZ bool `xml:"MultiAZ"`
+ Port int `xml:"Endpoint>Port"`
+ PreferredBackupWindow string `xml:"PreferredBackupWindow"`
+ PreferredMaintenanceWindow string `xml:"PreferredMaintenanceWindow"`
+ VpcSecurityGroupIds []string `xml:"VpcSecurityGroups"`
+ DBSecurityGroupNames []string `xml:"DBSecurityGroups>DBSecurityGroup>DBSecurityGroupName"`
+}
+
+type DBSecurityGroup struct {
+ Description string `xml:"DBSecurityGroupDescription"`
+ Name string `xml:"DBSecurityGroupName"`
+ EC2SecurityGroupIds []string `xml:"EC2SecurityGroups>EC2SecurityGroup>EC2SecurityGroupId"`
+ EC2SecurityGroupOwnerIds []string `xml:"EC2SecurityGroups>EC2SecurityGroup>EC2SecurityGroupOwnerId"`
+ EC2SecurityGroupStatuses []string `xml:"EC2SecurityGroups>EC2SecurityGroup>Status"`
+ CidrIps []string `xml:"IPRanges>IPRange>CIDRIP"`
+ CidrStatuses []string `xml:"IPRanges>IPRange>Status"`
+}
+
+// ----------------------------------------------------------------------------
+// Create
+
+// The CreateDBInstance request parameters
+type CreateDBInstance struct {
+ AllocatedStorage int
+ AvailabilityZone string
+ BackupRetentionPeriod int
+ DBInstanceClass string
+ DBInstanceIdentifier string
+ DBName string
+ DBSubnetGroupName string
+ Engine string
+ EngineVersion string
+ Iops int
+ MasterUsername string
+ MasterUserPassword string
+ MultiAZ bool
+ Port int
+ PreferredBackupWindow string // hh24:mi-hh24:mi
+ PreferredMaintenanceWindow string // ddd:hh24:mi-ddd:hh24:mi
+ PubliclyAccessible bool
+ VpcSecurityGroupIds []string
+ DBSecurityGroupNames []string
+
+ SetAllocatedStorage bool
+ SetBackupRetentionPeriod bool
+ SetIops bool
+ SetPort bool
+}
+
+func (rds *Rds) CreateDBInstance(options *CreateDBInstance) (resp *SimpleResp, err error) {
+ params := makeParams("CreateDBInstance")
+
+ if options.SetAllocatedStorage {
+ params["AllocatedStorage"] = strconv.Itoa(options.AllocatedStorage)
+ }
+
+ if options.SetBackupRetentionPeriod {
+ params["BackupRetentionPeriod"] = strconv.Itoa(options.BackupRetentionPeriod)
+ }
+
+ if options.SetIops {
+ params["Iops"] = strconv.Itoa(options.Iops)
+ }
+
+ if options.SetPort {
+ params["Port"] = strconv.Itoa(options.Port)
+ }
+
+ if options.AvailabilityZone != "" {
+ params["AvailabilityZone"] = options.AvailabilityZone
+ }
+
+ if options.DBInstanceClass != "" {
+ params["DBInstanceClass"] = options.DBInstanceClass
+ }
+
+ if options.DBInstanceIdentifier != "" {
+ params["DBInstanceIdentifier"] = options.DBInstanceIdentifier
+ }
+
+ if options.DBName != "" {
+ params["DBName"] = options.DBName
+ }
+
+ if options.DBSubnetGroupName != "" {
+ params["DBSubnetGroupName"] = options.DBSubnetGroupName
+ }
+
+ if options.Engine != "" {
+ params["Engine"] = options.Engine
+ }
+
+ if options.EngineVersion != "" {
+ params["Engine"] = options.EngineVersion
+ }
+
+ if options.MasterUsername != "" {
+ params["MasterUsername"] = options.MasterUsername
+ }
+
+ if options.MasterUserPassword != "" {
+ params["MasterUserPassword"] = options.MasterUserPassword
+ }
+
+ if options.MultiAZ {
+ params["MultiAZ"] = "true"
+ }
+
+ if options.PreferredBackupWindow != "" {
+ params["PreferredBackupWindow"] = options.PreferredBackupWindow
+ }
+
+ if options.PreferredMaintenanceWindow != "" {
+ params["PreferredMaintenanceWindow"] = options.PreferredMaintenanceWindow
+ }
+
+ if options.PubliclyAccessible {
+ params["PubliclyAccessible"] = "true"
+ }
+
+ for j, group := range options.VpcSecurityGroupIds {
+ params["VpcSecurityGroupIds.member."+strconv.Itoa(j+1)] = group
+ }
+
+ for j, group := range options.DBSecurityGroupNames {
+ params["DBSecurityGroups.member."+strconv.Itoa(j+1)] = group
+ }
+
+ resp = &SimpleResp{}
+
+ err = rds.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// The CreateDBSecurityGroup request parameters
+type CreateDBSecurityGroup struct {
+ DBSecurityGroupName string
+ DBSecurityGroupDescription string
+}
+
+func (rds *Rds) CreateDBSecurityGroup(options *CreateDBSecurityGroup) (resp *SimpleResp, err error) {
+ params := makeParams("CreateDBSecurityGroup")
+
+ params["DBSecurityGroupName"] = options.DBSecurityGroupName
+ params["DBSecurityGroupDescription"] = options.DBSecurityGroupDescription
+
+ resp = &SimpleResp{}
+
+ err = rds.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// The CreateDBSecurityGroup request parameters
+type AuthorizeDBSecurityGroupIngress struct {
+ Cidr string
+ DBSecurityGroupName string
+ EC2SecurityGroupId string
+ EC2SecurityGroupName string
+ EC2SecurityGroupOwnerId string
+}
+
+func (rds *Rds) AuthorizeDBSecurityGroupIngress(options *AuthorizeDBSecurityGroupIngress) (resp *SimpleResp, err error) {
+ params := makeParams("AuthorizeDBSecurityGroupIngress")
+
+ if attr := options.Cidr; attr != "" {
+ params["CIDRIP"] = attr
+ }
+
+ if attr := options.EC2SecurityGroupId; attr != "" {
+ params["EC2SecurityGroupId"] = attr
+ }
+
+ if attr := options.EC2SecurityGroupOwnerId; attr != "" {
+ params["EC2SecurityGroupOwnerId"] = attr
+ }
+
+ if attr := options.EC2SecurityGroupName; attr != "" {
+ params["EC2SecurityGroupName"] = attr
+ }
+
+ params["DBSecurityGroupName"] = options.DBSecurityGroupName
+
+ resp = &SimpleResp{}
+
+ err = rds.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// Describe
+
+// DescribeDBInstances request params
+type DescribeDBInstances struct {
+ DBInstanceIdentifier string
+}
+
+type DescribeDBInstancesResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ DBInstances []DBInstance `xml:"DescribeDBInstancesResult>DBInstances>DBInstance"`
+}
+
+func (rds *Rds) DescribeDBInstances(options *DescribeDBInstances) (resp *DescribeDBInstancesResp, err error) {
+ params := makeParams("DescribeDBInstances")
+
+ params["DBInstanceIdentifier"] = options.DBInstanceIdentifier
+
+ resp = &DescribeDBInstancesResp{}
+
+ err = rds.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// DescribeDBSecurityGroups request params
+type DescribeDBSecurityGroups struct {
+ DBSecurityGroupName string
+}
+
+type DescribeDBSecurityGroupsResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+ DBSecurityGroups []DBSecurityGroup `xml:"DescribeDBSecurityGroupsResult>DBSecurityGroups>DBSecurityGroup"`
+}
+
+func (rds *Rds) DescribeDBSecurityGroups(options *DescribeDBSecurityGroups) (resp *DescribeDBSecurityGroupsResp, err error) {
+ params := makeParams("DescribeDBSecurityGroups")
+
+ params["DBSecurityGroupName"] = options.DBSecurityGroupName
+
+ resp = &DescribeDBSecurityGroupsResp{}
+
+ err = rds.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// DeleteDBInstance request params
+type DeleteDBInstance struct {
+ DBInstanceIdentifier string
+ SkipFinalSnapshot bool
+}
+
+func (rds *Rds) DeleteDBInstance(options *DeleteDBInstance) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteDBInstance")
+
+ params["DBInstanceIdentifier"] = options.DBInstanceIdentifier
+
+ if options.SkipFinalSnapshot {
+ params["SkipFinalSnapshot"] = "true"
+ }
+
+ resp = &SimpleResp{}
+
+ err = rds.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// DeleteDBSecurityGroup request params
+type DeleteDBSecurityGroup struct {
+ DBSecurityGroupName string
+}
+
+func (rds *Rds) DeleteDBSecurityGroup(options *DeleteDBSecurityGroup) (resp *SimpleResp, err error) {
+ params := makeParams("DeleteDBSecurityGroup")
+
+ params["DBSecurityGroupName"] = options.DBSecurityGroupName
+
+ resp = &SimpleResp{}
+
+ err = rds.query(params, resp)
+
+ if err != nil {
+ resp = nil
+ }
+
+ return
+}
+
+// Responses
+
+type SimpleResp struct {
+ RequestId string `xml:"ResponseMetadata>RequestId"`
+}
+
+type xmlErrors struct {
+ Errors []Error `xml:"Error"`
+}
+
+// Error encapsulates an Rds error.
+type Error struct {
+ // HTTP status code of the error.
+ StatusCode int
+
+ // AWS code of the error.
+ Code string
+
+ // Message explaining the error.
+ Message string
+}
+
+func (e *Error) Error() string {
+ var prefix string
+ if e.Code != "" {
+ prefix = e.Code + ": "
+ }
+ if prefix == "" && e.StatusCode > 0 {
+ prefix = strconv.Itoa(e.StatusCode) + ": "
+ }
+ return prefix + e.Message
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/rds_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/rds_test.go
new file mode 100644
index 00000000..2ea4e06c
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/rds_test.go
@@ -0,0 +1,172 @@
+package rds_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/rds"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+type S struct {
+ rds *rds.Rds
+}
+
+var _ = Suite(&S{})
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ s.rds = rds.NewWithClient(auth, aws.Region{RdsEndpoint: testServer.URL}, testutil.DefaultClient)
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) Test_CreateDBInstance(c *C) {
+ testServer.Response(200, nil, CreateDBInstanceExample)
+
+ options := rds.CreateDBInstance{
+ BackupRetentionPeriod: 30,
+ MultiAZ: false,
+ DBInstanceIdentifier: "foobarbaz",
+ PreferredBackupWindow: "10:07-10:37",
+ PreferredMaintenanceWindow: "sun:06:13-sun:06:43",
+ AvailabilityZone: "us-west-2b",
+ Engine: "mysql",
+ EngineVersion: "",
+ DBName: "5.6.13",
+ AllocatedStorage: 10,
+ MasterUsername: "foobar",
+ MasterUserPassword: "bazbarbaz",
+ DBInstanceClass: "db.m1.small",
+ DBSecurityGroupNames: []string{"foo", "bar"},
+
+ SetBackupRetentionPeriod: true,
+ }
+
+ resp, err := s.rds.CreateDBInstance(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateDBInstance"})
+ c.Assert(req.Form["Engine"], DeepEquals, []string{"mysql"})
+ c.Assert(req.Form["DBSecurityGroups.member.1"], DeepEquals, []string{"foo"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "523e3218-afc7-11c3-90f5-f90431260ab4")
+}
+
+func (s *S) Test_CreateDBSecurityGroup(c *C) {
+ testServer.Response(200, nil, CreateDBSecurityGroupExample)
+
+ options := rds.CreateDBSecurityGroup{
+ DBSecurityGroupName: "foobarbaz",
+ DBSecurityGroupDescription: "test description",
+ }
+
+ resp, err := s.rds.CreateDBSecurityGroup(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"CreateDBSecurityGroup"})
+ c.Assert(req.Form["DBSecurityGroupName"], DeepEquals, []string{"foobarbaz"})
+ c.Assert(req.Form["DBSecurityGroupDescription"], DeepEquals, []string{"test description"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "e68ef6fa-afc1-11c3-845a-476777009d19")
+}
+
+func (s *S) Test_DescribeDBInstances(c *C) {
+ testServer.Response(200, nil, DescribeDBInstancesExample)
+
+ options := rds.DescribeDBInstances{
+ DBInstanceIdentifier: "foobarbaz",
+ }
+
+ resp, err := s.rds.DescribeDBInstances(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeDBInstances"})
+ c.Assert(req.Form["DBInstanceIdentifier"], DeepEquals, []string{"foobarbaz"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "01b2685a-b978-11d3-f272-7cd6cce12cc5")
+ c.Assert(resp.DBInstances[0].DBName, Equals, "mysampledb")
+ c.Assert(resp.DBInstances[0].DBSecurityGroupNames, DeepEquals, []string{"my-db-secgroup"})
+}
+
+func (s *S) Test_DescribeDBSecurityGroups(c *C) {
+ testServer.Response(200, nil, DescribeDBSecurityGroupsExample)
+
+ options := rds.DescribeDBSecurityGroups{
+ DBSecurityGroupName: "foobarbaz",
+ }
+
+ resp, err := s.rds.DescribeDBSecurityGroups(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeDBSecurityGroups"})
+ c.Assert(req.Form["DBSecurityGroupName"], DeepEquals, []string{"foobarbaz"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "b76e692c-b98c-11d3-a907-5a2c468b9cb0")
+ c.Assert(resp.DBSecurityGroups[0].EC2SecurityGroupIds, DeepEquals, []string{"sg-7f476617"})
+ c.Assert(resp.DBSecurityGroups[0].EC2SecurityGroupOwnerIds, DeepEquals, []string{"803#########"})
+ c.Assert(resp.DBSecurityGroups[0].EC2SecurityGroupStatuses, DeepEquals, []string{"authorized"})
+ c.Assert(resp.DBSecurityGroups[0].CidrIps, DeepEquals, []string{"192.0.0.0/24", "190.0.1.0/29", "190.0.2.0/29", "10.0.0.0/8"})
+ c.Assert(resp.DBSecurityGroups[0].CidrStatuses, DeepEquals, []string{"authorized", "authorized", "authorized", "authorized"})
+}
+
+func (s *S) Test_DeleteDBInstance(c *C) {
+ testServer.Response(200, nil, DeleteDBInstanceExample)
+
+ options := rds.DeleteDBInstance{
+ DBInstanceIdentifier: "foobarbaz",
+ SkipFinalSnapshot: true,
+ }
+
+ resp, err := s.rds.DeleteDBInstance(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteDBInstance"})
+ c.Assert(req.Form["DBInstanceIdentifier"], DeepEquals, []string{"foobarbaz"})
+ c.Assert(req.Form["SkipFinalSnapshot"], DeepEquals, []string{"true"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7369556f-b70d-11c3-faca-6ba18376ea1b")
+}
+
+func (s *S) Test_DeleteDBSecurityGroup(c *C) {
+ testServer.Response(200, nil, DeleteDBSecurityGroupExample)
+
+ options := rds.DeleteDBSecurityGroup{
+ DBSecurityGroupName: "foobarbaz",
+ }
+
+ resp, err := s.rds.DeleteDBSecurityGroup(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteDBSecurityGroup"})
+ c.Assert(req.Form["DBSecurityGroupName"], DeepEquals, []string{"foobarbaz"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "7aec7454-ba25-11d3-855b-576787000e19")
+}
+
+func (s *S) Test_AuthorizeDBSecurityGroupIngress(c *C) {
+ testServer.Response(200, nil, AuthorizeDBSecurityGroupIngressExample)
+
+ options := rds.AuthorizeDBSecurityGroupIngress{
+ DBSecurityGroupName: "foobarbaz",
+ EC2SecurityGroupOwnerId: "bar",
+ }
+
+ resp, err := s.rds.AuthorizeDBSecurityGroupIngress(&options)
+ req := testServer.WaitRequest()
+
+ c.Assert(req.Form["Action"], DeepEquals, []string{"AuthorizeDBSecurityGroupIngress"})
+ c.Assert(req.Form["DBSecurityGroupName"], DeepEquals, []string{"foobarbaz"})
+ c.Assert(req.Form["EC2SecurityGroupOwnerId"], DeepEquals, []string{"bar"})
+ c.Assert(err, IsNil)
+ c.Assert(resp.RequestId, Equals, "6176b5f8-bfed-11d3-f92b-31fa5e8dbc99")
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/responses_test.go
new file mode 100644
index 00000000..418fc6c2
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/responses_test.go
@@ -0,0 +1,329 @@
+package rds_test
+
+var ErrorDump = `
+
+UnsupportedOperation
+
+0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4
+`
+
+// http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html
+var DescribeDBInstancesExample = `
+
+
+
+
+ 1
+ false
+ available
+
+ mysqlexampledb
+ 10:07-10:37
+ sun:06:13-sun:06:43
+ us-west-2b
+ 2014-04-21T17:15:00Z
+
+ mysql
+
+ general-public-license
+
+
+ in-sync
+ default.mysql5.6
+
+
+
+ 3306
+ mysqlexampledb.c6c1rntzufv0.us-west-2.rds.amazonaws.com
+
+ 5.6.13
+
+
+ default:mysql-5-6
+ in-sync
+
+
+
+
+ active
+ my-db-secgroup
+
+
+ true
+ mysampledb
+ true
+ 2014-01-29T22:58:24.231Z
+ 5
+ myawsuser
+ db.t1.micro
+
+
+ 1
+ false
+ available
+
+ mysqlexampledb-restore
+ 10:07-10:37
+ sun:06:13-sun:06:43
+ us-west-2b
+ 2014-04-21T17:15:00Z
+
+ mysql
+
+ general-public-license
+
+
+ in-sync
+ default.mysql5.6
+
+
+
+ 3306
+ mysqlexampledb-restore.c6c2mntzugv0.us-west-2.rds.amazonaws.com
+
+ 5.6.13
+
+
+ default:mysql-5-6
+ in-sync
+
+
+
+
+ active
+ default
+
+
+ true
+ mysampledb
+ true
+ 2014-03-28T20:14:17.296Z
+ 5
+ myawsuser
+ db.t1.micro
+
+
+
+
+ 01b2685a-b978-11d3-f272-7cd6cce12cc5
+
+
+`
+
+var CreateDBInstanceExample = `
+
+
+
+ 1
+ creating
+ false
+
+ myawsuser-dbi01
+
+ 03:50-04:20
+ wed:06:38-wed:07:08
+
+ mysql
+
+ ****
+
+ general-public-license
+ 5.6.13
+
+
+ in-sync
+ default.mysql5.6
+
+
+
+
+ default:mysql-5-6
+ in-sync
+
+
+
+
+ active
+ default
+
+
+ true
+ true
+ 15
+ db.m1.large
+ myawsuser
+
+
+
+ 523e3218-afc7-11c3-90f5-f90431260ab4
+
+
+`
+
+var DeleteDBInstanceExample = `
+
+
+
+ 2
+ deleting
+ false
+
+ mydatabase
+ 08:14-08:44
+ fri:04:50-fri:05:20
+ us-east-1a
+
+ 2013-11-09T00:15:00Z
+ mysql
+
+ general-public-license
+ 5.6.13
+
+ 3306
+ mydatabase.cf037hpkuvjt.us-east-1.rds.amazonaws.com
+
+
+
+ in-sync
+ default.mysql5.6
+
+
+
+
+ default:mysql-5-6
+ in-sync
+
+
+ true
+
+
+ active
+ default
+
+
+ mysqldb
+ true
+ 2011-04-28T23:33:54.909Z
+ 100
+ myawsuser
+ db.m1.medium
+
+
+
+ 7369556f-b70d-11c3-faca-6ba18376ea1b
+
+`
+
+var DescribeDBSecurityGroupsExample = `
+
+
+
+
+
+
+ authorized
+ elasticbeanstalk-windows
+ 803#########
+ sg-7f476617
+
+
+ My security group
+
+
+ 192.0.0.0/24
+ authorized
+
+
+ 190.0.1.0/29
+ authorized
+
+
+ 190.0.2.0/29
+ authorized
+
+
+ 10.0.0.0/8
+ authorized
+
+
+ 803#########
+ my-secgrp
+
+
+
+ default
+
+ 803#########
+ default
+
+
+
+
+ b76e692c-b98c-11d3-a907-5a2c468b9cb0
+
+`
+
+var DeleteDBSecurityGroupExample = `
+
+
+ 7aec7454-ba25-11d3-855b-576787000e19
+
+
+`
+var CreateDBSecurityGroupExample = `
+
+
+
+
+ My new DB Security Group
+
+ 803#########
+ mydbsecuritygroup00
+
+
+
+ e68ef6fa-afc1-11c3-845a-476777009d19
+
+
+`
+
+var AuthorizeDBSecurityGroupIngressExample = `
+
+
+
+
+
+ authorized
+ elasticbeanstalk-windows
+ 803#########
+ sg-7f476617
+
+
+ default
+
+
+ 192.0.0.0/24
+ authorized
+
+
+ 190.0.1.0/29
+ authorized
+
+
+ 190.0.2.0/29
+ authorized
+
+
+ 10.0.0.0/8
+ authorized
+
+
+ 803#########
+ default
+
+
+
+ 6176b5f8-bfed-11d3-f92b-31fa5e8dbc99
+
+
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/sign.go
new file mode 100644
index 00000000..2157352a
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/rds/sign.go
@@ -0,0 +1,38 @@
+package rds
+
+import (
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+ "sort"
+ "strings"
+)
+
+// ----------------------------------------------------------------------------
+// Version 2 signing (http://goo.gl/RSRp5)
+
+var b64 = base64.StdEncoding
+
+func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
+ params["AWSAccessKeyId"] = auth.AccessKey
+ params["SignatureVersion"] = "2"
+ params["SignatureMethod"] = "HmacSHA256"
+ if auth.Token != "" {
+ params["SecurityToken"] = auth.Token
+ }
+
+ var sarray []string
+ for k, v := range params {
+ sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v))
+ }
+ sort.StringSlice(sarray).Sort()
+ joined := strings.Join(sarray, "&")
+ payload := method + "\n" + host + "\n" + path + "\n" + joined
+ hash := hmac.New(sha256.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ params["Signature"] = string(signature)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/responses_test.go
new file mode 100644
index 00000000..e14c6f0a
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/responses_test.go
@@ -0,0 +1,96 @@
+package route53
+
+var CreateHostedZoneExample = `
+
+
+ /hostedzone/Z1PA6795UKMFR9
+ example.com.
+ myUniqueIdentifier
+
+ This is my first hosted zone.
+
+ 2
+
+
+ /change/C1PA6795UKMFR9
+ PENDING
+ 2012-03-15T01:36:41.958Z
+
+
+
+ ns-2048.awsdns-64.com
+ ns-2049.awsdns-65.net
+ ns-2050.awsdns-66.org
+ ns-2051.awsdns-67.co.uk
+
+
+`
+
+var DeleteHostedZoneExample = `
+
+
+ /change/C1PA6795UKMFR9
+ PENDING
+ 2012-03-10T01:36:41.958Z
+
+`
+
+var GetHostedZoneExample = `
+
+
+ /hostedzone/Z1PA6795UKMFR9
+ example.com.
+ myUniqueIdentifier
+
+ This is my first hosted zone.
+
+ 17
+
+
+
+ ns-2048.awsdns-64.com
+ ns-2049.awsdns-65.net
+ ns-2050.awsdns-66.org
+ ns-2051.awsdns-67.co.uk
+
+
+`
+
+var GetChangeExample = `
+
+
+ C2682N5HXP0BZ4
+ INSYNC
+ 2011-09-10T01:36:41.958Z
+
+`
+
+var ChangeResourceRecordSetsExample = `
+
+
+ /change/asdf
+ PENDING
+ 2014
+
+`
+
+var ListResourceRecordSetsExample = `
+
+
+
+ example.com.
+ SOA
+ 900
+
+
+ ns-2048.awsdns-64.net. hostmaster.awsdns.com. 1 7200 900 1209600 86400
+
+
+
+
+ true
+ 1
+ testdoc2.example.com
+ NS
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/route53.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/route53.go
new file mode 100644
index 00000000..3300c249
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/route53.go
@@ -0,0 +1,307 @@
+// The elb package provides types and functions for interaction with the AWS
+// Route53 service
+package route53
+
+import (
+ "bytes"
+ "encoding/xml"
+ "fmt"
+ "io"
+ "net/http"
+ "net/url"
+ "reflect"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/mitchellh/goamz/aws"
+)
+
+// The Route53 type encapsulates operations operations with the route53 endpoint.
+type Route53 struct {
+ aws.Auth
+ aws.Region
+ httpClient *http.Client
+}
+
+const APIVersion = "2013-04-01"
+
+// New creates a new ELB instance.
+func New(auth aws.Auth, region aws.Region) *Route53 {
+ return NewWithClient(auth, region, aws.RetryingClient)
+}
+
+func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *Route53 {
+ return &Route53{auth, region, httpClient}
+}
+
+type CreateHostedZoneRequest struct {
+ Name string `xml:"Name"`
+ CallerReference string `xml:"CallerReference"`
+ Comment string `xml:"HostedZoneConfig>Comment"`
+}
+
+type CreateHostedZoneResponse struct {
+ HostedZone HostedZone `xml:"HostedZone"`
+ ChangeInfo ChangeInfo `xml:"ChangeInfo"`
+ DelegationSet DelegationSet `xml:"DelegationSet"`
+}
+
+type HostedZone struct {
+ ID string `xml:"Id"`
+ Name string `xml:"Name"`
+ CallerReference string `xml:"CallerReference"`
+ Comment string `xml:"Config>Comment"`
+ ResourceCount int `xml:"ResourceRecordSetCount"`
+}
+
+type ChangeInfo struct {
+ ID string `xml:"Id"`
+ Status string `xml:"Status"`
+ SubmittedAt string `xml:"SubmittedAt"`
+}
+
+type DelegationSet struct {
+ NameServers []string `xml:"NameServers>NameServer"`
+}
+
+func (r *Route53) query(method, path string, req, resp interface{}) error {
+ params := make(map[string]string)
+ endpoint, err := url.Parse(r.Region.Route53Endpoint)
+ if err != nil {
+ return err
+ }
+ endpoint.Path = path
+ sign(r.Auth, endpoint.Path, params)
+
+ // If they look like url.Values, just encode...
+ if queryArgs, ok := req.(url.Values); ok {
+ endpoint.RawQuery = queryArgs.Encode()
+ req = nil
+ }
+
+ // Encode the body
+ var body io.ReadWriter
+ if req != nil {
+ bodyBuf := bytes.NewBuffer(nil)
+ enc := xml.NewEncoder(bodyBuf)
+ start := xml.StartElement{
+ Name: xml.Name{
+ Space: "",
+ Local: reflect.Indirect(reflect.ValueOf(req)).Type().Name(),
+ },
+ Attr: []xml.Attr{{xml.Name{"", "xmlns"}, "https://route53.amazonaws.com/doc/2013-04-01/"}},
+ }
+ if err := enc.EncodeElement(req, start); err != nil {
+ return err
+ }
+ body = bodyBuf
+ }
+
+ // Make the http request
+ hReq, err := http.NewRequest(method, endpoint.String(), body)
+ if err != nil {
+ return err
+ }
+ for k, v := range params {
+ hReq.Header.Set(k, v)
+ }
+ re, err := r.httpClient.Do(hReq)
+ if err != nil {
+ return err
+ }
+ defer re.Body.Close()
+
+ // Check the status code
+ switch re.StatusCode {
+ case 200:
+ case 201:
+ default:
+ var body bytes.Buffer
+ io.Copy(&body, re.Body)
+ return fmt.Errorf("Request failed, got status code: %d. Response: %s",
+ re.StatusCode, body.Bytes())
+ }
+
+ // Decode the response
+ decoder := xml.NewDecoder(re.Body)
+ return decoder.Decode(resp)
+}
+
+func multimap(p map[string]string) url.Values {
+ q := make(url.Values, len(p))
+ for k, v := range p {
+ q[k] = []string{v}
+ }
+ return q
+}
+
+// CreateHostedZone is used to create a new hosted zone
+func (r *Route53) CreateHostedZone(req *CreateHostedZoneRequest) (*CreateHostedZoneResponse, error) {
+ // Generate a unique caller reference if none provided
+ if req.CallerReference == "" {
+ req.CallerReference = time.Now().Format(time.RFC3339Nano)
+ }
+ out := &CreateHostedZoneResponse{}
+ if err := r.query("POST", fmt.Sprintf("/%s/hostedzone", APIVersion), req, out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+type DeleteHostedZoneResponse struct {
+ ChangeInfo ChangeInfo `xml:"ChangeInfo"`
+}
+
+func (r *Route53) DeleteHostedZone(ID string) (*DeleteHostedZoneResponse, error) {
+ // Remove the hostedzone prefix if given
+ ID = CleanZoneID(ID)
+ out := &DeleteHostedZoneResponse{}
+ err := r.query("DELETE", fmt.Sprintf("/%s/hostedzone/%s", APIVersion, ID), nil, out)
+ if err != nil {
+ return nil, err
+ }
+ return out, err
+}
+
+// CleanZoneID is used to remove the leading /hostedzone/
+func CleanZoneID(ID string) string {
+ if strings.HasPrefix(ID, "/hostedzone/") {
+ ID = strings.TrimPrefix(ID, "/hostedzone/")
+ }
+ return ID
+}
+
+// CleanChangeID is used to remove the leading /change/
+func CleanChangeID(ID string) string {
+ if strings.HasPrefix(ID, "/change/") {
+ ID = strings.TrimPrefix(ID, "/change/")
+ }
+ return ID
+}
+
+type GetHostedZoneResponse struct {
+ HostedZone HostedZone `xml:"HostedZone"`
+ DelegationSet DelegationSet `xml:"DelegationSet"`
+}
+
+func (r *Route53) GetHostedZone(ID string) (*GetHostedZoneResponse, error) {
+ // Remove the hostedzone prefix if given
+ ID = CleanZoneID(ID)
+ out := &GetHostedZoneResponse{}
+ err := r.query("GET", fmt.Sprintf("/%s/hostedzone/%s", APIVersion, ID), nil, out)
+ if err != nil {
+ return nil, err
+ }
+ return out, err
+}
+
+type GetChangeResponse struct {
+ ChangeInfo ChangeInfo `xml:"ChangeInfo"`
+}
+
+func (r *Route53) GetChange(ID string) (string, error) {
+ ID = CleanChangeID(ID)
+ out := &GetChangeResponse{}
+ err := r.query("GET", fmt.Sprintf("/%s/change/%s", APIVersion, ID), nil, out)
+ if err != nil {
+ return "", err
+ }
+ return out.ChangeInfo.Status, err
+}
+
+type ChangeResourceRecordSetsRequest struct {
+ Comment string `xml:"ChangeBatch>Comment,omitempty"`
+ Changes []Change `xml:"ChangeBatch>Changes>Change"`
+}
+
+type Change struct {
+ Action string `xml:"Action"`
+ Record ResourceRecordSet `xml:"ResourceRecordSet"`
+}
+
+type AliasTarget struct {
+ HostedZoneId string
+ DNSName string
+ EvaluateTargetHealth bool
+}
+
+type ChangeResourceRecordSetsResponse struct {
+ ChangeInfo ChangeInfo `xml:"ChangeInfo"`
+}
+
+func (r *Route53) ChangeResourceRecordSets(zone string,
+ req *ChangeResourceRecordSetsRequest) (*ChangeResourceRecordSetsResponse, error) {
+ zone = CleanZoneID(zone)
+ out := &ChangeResourceRecordSetsResponse{}
+ if err := r.query("POST", fmt.Sprintf("/%s/hostedzone/%s/rrset", APIVersion,
+ zone), req, out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+type ListOpts struct {
+ Name string
+ Type string
+ Identifier string
+ MaxItems int
+}
+
+type ListResourceRecordSetsResponse struct {
+ Records []ResourceRecordSet `xml:"ResourceRecordSets>ResourceRecordSet"`
+ IsTruncated bool `xml:"IsTruncated"`
+ MaxItems int `xml:"MaxItems"`
+ NextRecordName string `xml:"NextRecordName"`
+ NextRecordType string `xml:"NextRecordType"`
+ NextRecordIdentifier string `xml:"NextRecordIdentifier"`
+}
+
+type ResourceRecordSet struct {
+ Name string `xml:"Name"`
+ Type string `xml:"Type"`
+ TTL int `xml:"TTL"`
+ Records []string `xml:"ResourceRecords>ResourceRecord>Value"`
+ SetIdentifier string `xml:"SetIdentifier,omitempty"`
+ Weight int `xml:"Weight,omitempty"`
+ HealthCheckId string `xml:"HealthCheckId,omitempty"`
+ Region string `xml:"Region,omitempty"`
+ Failover string `xml:"Failover,omitempty"`
+ AliasTarget *AliasTarget `xml:"AliasTarget,omitempty"`
+}
+
+func (r *Route53) ListResourceRecordSets(zone string, lopts *ListOpts) (*ListResourceRecordSetsResponse, error) {
+ if lopts == nil {
+ lopts = &ListOpts{}
+ }
+ params := make(map[string]string)
+ if lopts.Name != "" {
+ params["name"] = lopts.Name
+ }
+ if lopts.Type != "" {
+ params["type"] = lopts.Type
+ }
+ if lopts.Identifier != "" {
+ params["identifier"] = lopts.Identifier
+ }
+ if lopts.MaxItems != 0 {
+ params["maxitems"] = strconv.FormatInt(int64(lopts.MaxItems), 10)
+ }
+
+ req := multimap(params)
+ zone = CleanZoneID(zone)
+ out := &ListResourceRecordSetsResponse{}
+ if err := r.query("GET", fmt.Sprintf("/%s/hostedzone/%s/rrset", APIVersion, zone), req, out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func FQDN(name string) string {
+ n := len(name)
+ if n == 0 || name[n-1] == '.' {
+ return name
+ } else {
+ return name + "."
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/route53_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/route53_test.go
new file mode 100644
index 00000000..90316903
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/route53_test.go
@@ -0,0 +1,175 @@
+package route53
+
+import (
+ "bytes"
+ "encoding/xml"
+ "fmt"
+ "io"
+ "log"
+ "testing"
+
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/testutil"
+)
+
+var testServer *testutil.HTTPServer
+
+func init() {
+ testServer = testutil.NewHTTPServer()
+ testServer.Start()
+}
+
+func makeTestServer() *testutil.HTTPServer {
+ testServer.Flush()
+ log.Printf("Flush")
+ return testServer
+}
+
+func makeClient(server *testutil.HTTPServer) *Route53 {
+ auth := aws.Auth{"abc", "123", ""}
+ return NewWithClient(auth, aws.Region{Route53Endpoint: server.URL}, testutil.DefaultClient)
+}
+
+func TestCreateHostedZone(t *testing.T) {
+ testServer := makeTestServer()
+ client := makeClient(testServer)
+ testServer.Response(201, nil, CreateHostedZoneExample)
+
+ req := &CreateHostedZoneRequest{
+ Name: "example.com",
+ Comment: "Testing",
+ }
+
+ resp, err := client.CreateHostedZone(req)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if resp.HostedZone.ID != "/hostedzone/Z1PA6795UKMFR9" {
+ t.Fatalf("bad: %v", resp)
+ }
+ if resp.ChangeInfo.ID != "/change/C1PA6795UKMFR9" {
+ t.Fatalf("bad: %v", resp)
+ }
+ if resp.DelegationSet.NameServers[3] != "ns-2051.awsdns-67.co.uk" {
+ t.Fatalf("bad: %v", resp)
+ }
+
+ httpReq := testServer.WaitRequest()
+ if httpReq.URL.Path != "/2013-04-01/hostedzone" {
+ t.Fatalf("bad: %#v", httpReq)
+ }
+ if httpReq.Method != "POST" {
+ t.Fatalf("bad: %#v", httpReq)
+ }
+ if httpReq.ContentLength == 0 {
+ t.Fatalf("bad: %#v", httpReq)
+ }
+}
+
+func TestDeleteHostedZone(t *testing.T) {
+ testServer := makeTestServer()
+ client := makeClient(testServer)
+ testServer.Response(200, nil, DeleteHostedZoneExample)
+
+ resp, err := client.DeleteHostedZone("/hostedzone/foobarbaz")
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if resp.ChangeInfo.ID != "/change/C1PA6795UKMFR9" {
+ t.Fatalf("bad: %v", resp)
+ }
+}
+
+func TestGetHostedZone(t *testing.T) {
+ testServer := makeTestServer()
+ client := makeClient(testServer)
+ testServer.Response(200, nil, GetHostedZoneExample)
+
+ resp, err := client.GetHostedZone("/hostedzone/foobarbaz")
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if resp.HostedZone.CallerReference != "myUniqueIdentifier" {
+ t.Fatalf("bad: %v", resp)
+ }
+}
+
+func TestGetChange(t *testing.T) {
+ testServer := makeTestServer()
+ client := makeClient(testServer)
+ testServer.Response(200, nil, GetChangeExample)
+
+ status, err := client.GetChange("/change/abcd")
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if status != "INSYNC" {
+ t.Fatalf("bad: %v", status)
+ }
+}
+
+func TestChangeResourceRecordSets(t *testing.T) {
+ testServer := makeTestServer()
+ client := makeClient(testServer)
+ testServer.Response(200, nil, ChangeResourceRecordSetsExample)
+
+ req := &ChangeResourceRecordSetsRequest{
+ Comment: "Test",
+ Changes: []Change{
+ Change{
+ Action: "CREATE",
+ Record: ResourceRecordSet{
+ Name: "foo.hashicorp.com",
+ Type: "A",
+ TTL: 300,
+ Records: []string{"127.0.0.1"},
+ },
+ },
+ },
+ }
+
+ resp, err := client.ChangeResourceRecordSets("Z1234", req)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if resp.ChangeInfo.ID != "/change/asdf" {
+ t.Fatalf("bad: %v", resp)
+ }
+}
+
+func TestListResourceRecordSets(t *testing.T) {
+ testServer := makeTestServer()
+ client := makeClient(testServer)
+ testServer.Response(200, nil, ListResourceRecordSetsExample)
+
+ resp, err := client.ListResourceRecordSets("Z1234", nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if resp.Records[0].Name != "example.com." {
+ t.Fatalf("bad: %v", resp)
+ }
+}
+
+func decode(t *testing.T, r io.Reader, out interface{}) {
+ var buf1 bytes.Buffer
+ var buf2 bytes.Buffer
+ b, err := io.Copy(io.MultiWriter(&buf1, &buf2), r)
+ if err != nil {
+ panic(fmt.Errorf("copy failed: %v", err))
+ }
+ if b == 0 {
+ panic(fmt.Errorf("copy failed: zero bytes"))
+ }
+ dec := xml.NewDecoder(&buf1)
+ if err := dec.Decode(out); err != nil {
+ t.Errorf("body: %s||", buf2.Bytes())
+ panic(fmt.Errorf("decode failed: %v", err))
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/sign.go
new file mode 100644
index 00000000..0a3648e1
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/route53/sign.go
@@ -0,0 +1,25 @@
+package route53
+
+import (
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/base64"
+ "fmt"
+ "github.com/mitchellh/goamz/aws"
+ "time"
+)
+
+var b64 = base64.StdEncoding
+
+func sign(auth aws.Auth, path string, params map[string]string) {
+ date := time.Now().In(time.UTC).Format(time.RFC1123)
+ params["Date"] = date
+ hash := hmac.New(sha256.New, []byte(auth.SecretKey))
+ hash.Write([]byte(date))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ header := fmt.Sprintf("AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=HmacSHA256,Signature=%s",
+ auth.AccessKey, signature)
+ params["X-Amzn-Authorization"] = string(header)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/export_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/export_test.go
new file mode 100644
index 00000000..15bbd676
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/export_test.go
@@ -0,0 +1,27 @@
+package s3
+
+import (
+ "github.com/mitchellh/goamz/aws"
+)
+
+var originalStrategy = attempts
+
+func SetAttemptStrategy(s *aws.AttemptStrategy) {
+ if s == nil {
+ attempts = originalStrategy
+ } else {
+ attempts = *s
+ }
+}
+
+func Sign(auth aws.Auth, method, path string, params, headers map[string][]string) {
+ sign(auth, method, path, params, headers)
+}
+
+func SetListPartsMax(n int) {
+ listPartsMax = n
+}
+
+func SetListMultiMax(n int) {
+ listMultiMax = n
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/multi.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/multi.go
new file mode 100644
index 00000000..6e318b31
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/multi.go
@@ -0,0 +1,409 @@
+package s3
+
+import (
+ "bytes"
+ "crypto/md5"
+ "encoding/base64"
+ "encoding/hex"
+ "encoding/xml"
+ "errors"
+ "io"
+ "sort"
+ "strconv"
+)
+
+// Multi represents an unfinished multipart upload.
+//
+// Multipart uploads allow sending big objects in smaller chunks.
+// After all parts have been sent, the upload must be explicitly
+// completed by calling Complete with the list of parts.
+//
+// See http://goo.gl/vJfTG for an overview of multipart uploads.
+type Multi struct {
+ Bucket *Bucket
+ Key string
+ UploadId string
+}
+
+// That's the default. Here just for testing.
+var listMultiMax = 1000
+
+type listMultiResp struct {
+ NextKeyMarker string
+ NextUploadIdMarker string
+ IsTruncated bool
+ Upload []Multi
+ CommonPrefixes []string `xml:"CommonPrefixes>Prefix"`
+}
+
+// ListMulti returns the list of unfinished multipart uploads in b.
+//
+// The prefix parameter limits the response to keys that begin with the
+// specified prefix. You can use prefixes to separate a bucket into different
+// groupings of keys (to get the feeling of folders, for example).
+//
+// The delim parameter causes the response to group all of the keys that
+// share a common prefix up to the next delimiter in a single entry within
+// the CommonPrefixes field. You can use delimiters to separate a bucket
+// into different groupings of keys, similar to how folders would work.
+//
+// See http://goo.gl/ePioY for details.
+func (b *Bucket) ListMulti(prefix, delim string) (multis []*Multi, prefixes []string, err error) {
+ params := map[string][]string{
+ "uploads": {""},
+ "max-uploads": {strconv.FormatInt(int64(listMultiMax), 10)},
+ "prefix": {prefix},
+ "delimiter": {delim},
+ }
+ for attempt := attempts.Start(); attempt.Next(); {
+ req := &request{
+ method: "GET",
+ bucket: b.Name,
+ params: params,
+ }
+ var resp listMultiResp
+ err := b.S3.query(req, &resp)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ if err != nil {
+ return nil, nil, err
+ }
+ for i := range resp.Upload {
+ multi := &resp.Upload[i]
+ multi.Bucket = b
+ multis = append(multis, multi)
+ }
+ prefixes = append(prefixes, resp.CommonPrefixes...)
+ if !resp.IsTruncated {
+ return multis, prefixes, nil
+ }
+ params["key-marker"] = []string{resp.NextKeyMarker}
+ params["upload-id-marker"] = []string{resp.NextUploadIdMarker}
+ attempt = attempts.Start() // Last request worked.
+ }
+ panic("unreachable")
+}
+
+// Multi returns a multipart upload handler for the provided key
+// inside b. If a multipart upload exists for key, it is returned,
+// otherwise a new multipart upload is initiated with contType and perm.
+func (b *Bucket) Multi(key, contType string, perm ACL) (*Multi, error) {
+ multis, _, err := b.ListMulti(key, "")
+ if err != nil && !hasCode(err, "NoSuchUpload") {
+ return nil, err
+ }
+ for _, m := range multis {
+ if m.Key == key {
+ return m, nil
+ }
+ }
+ return b.InitMulti(key, contType, perm)
+}
+
+// InitMulti initializes a new multipart upload at the provided
+// key inside b and returns a value for manipulating it.
+//
+// See http://goo.gl/XP8kL for details.
+func (b *Bucket) InitMulti(key string, contType string, perm ACL) (*Multi, error) {
+ headers := map[string][]string{
+ "Content-Type": {contType},
+ "Content-Length": {"0"},
+ "x-amz-acl": {string(perm)},
+ }
+ params := map[string][]string{
+ "uploads": {""},
+ }
+ req := &request{
+ method: "POST",
+ bucket: b.Name,
+ path: key,
+ headers: headers,
+ params: params,
+ }
+ var err error
+ var resp struct {
+ UploadId string `xml:"UploadId"`
+ }
+ for attempt := attempts.Start(); attempt.Next(); {
+ err = b.S3.query(req, &resp)
+ if !shouldRetry(err) {
+ break
+ }
+ }
+ if err != nil {
+ return nil, err
+ }
+ return &Multi{Bucket: b, Key: key, UploadId: resp.UploadId}, nil
+}
+
+// PutPart sends part n of the multipart upload, reading all the content from r.
+// Each part, except for the last one, must be at least 5MB in size.
+//
+// See http://goo.gl/pqZer for details.
+func (m *Multi) PutPart(n int, r io.ReadSeeker) (Part, error) {
+ partSize, _, md5b64, err := seekerInfo(r)
+ if err != nil {
+ return Part{}, err
+ }
+ return m.putPart(n, r, partSize, md5b64)
+}
+
+func (m *Multi) putPart(n int, r io.ReadSeeker, partSize int64, md5b64 string) (Part, error) {
+ headers := map[string][]string{
+ "Content-Length": {strconv.FormatInt(partSize, 10)},
+ "Content-MD5": {md5b64},
+ }
+ params := map[string][]string{
+ "uploadId": {m.UploadId},
+ "partNumber": {strconv.FormatInt(int64(n), 10)},
+ }
+ for attempt := attempts.Start(); attempt.Next(); {
+ _, err := r.Seek(0, 0)
+ if err != nil {
+ return Part{}, err
+ }
+ req := &request{
+ method: "PUT",
+ bucket: m.Bucket.Name,
+ path: m.Key,
+ headers: headers,
+ params: params,
+ payload: r,
+ }
+ err = m.Bucket.S3.prepare(req)
+ if err != nil {
+ return Part{}, err
+ }
+ resp, err := m.Bucket.S3.run(req, nil)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ if err != nil {
+ return Part{}, err
+ }
+ etag := resp.Header.Get("ETag")
+ if etag == "" {
+ return Part{}, errors.New("part upload succeeded with no ETag")
+ }
+ return Part{n, etag, partSize}, nil
+ }
+ panic("unreachable")
+}
+
+func seekerInfo(r io.ReadSeeker) (size int64, md5hex string, md5b64 string, err error) {
+ _, err = r.Seek(0, 0)
+ if err != nil {
+ return 0, "", "", err
+ }
+ digest := md5.New()
+ size, err = io.Copy(digest, r)
+ if err != nil {
+ return 0, "", "", err
+ }
+ sum := digest.Sum(nil)
+ md5hex = hex.EncodeToString(sum)
+ md5b64 = base64.StdEncoding.EncodeToString(sum)
+ return size, md5hex, md5b64, nil
+}
+
+type Part struct {
+ N int `xml:"PartNumber"`
+ ETag string
+ Size int64
+}
+
+type partSlice []Part
+
+func (s partSlice) Len() int { return len(s) }
+func (s partSlice) Less(i, j int) bool { return s[i].N < s[j].N }
+func (s partSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+
+type listPartsResp struct {
+ NextPartNumberMarker string
+ IsTruncated bool
+ Part []Part
+}
+
+// That's the default. Here just for testing.
+var listPartsMax = 1000
+
+// ListParts returns the list of previously uploaded parts in m,
+// ordered by part number.
+//
+// See http://goo.gl/ePioY for details.
+func (m *Multi) ListParts() ([]Part, error) {
+ params := map[string][]string{
+ "uploadId": {m.UploadId},
+ "max-parts": {strconv.FormatInt(int64(listPartsMax), 10)},
+ }
+ var parts partSlice
+ for attempt := attempts.Start(); attempt.Next(); {
+ req := &request{
+ method: "GET",
+ bucket: m.Bucket.Name,
+ path: m.Key,
+ params: params,
+ }
+ var resp listPartsResp
+ err := m.Bucket.S3.query(req, &resp)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ if err != nil {
+ return nil, err
+ }
+ parts = append(parts, resp.Part...)
+ if !resp.IsTruncated {
+ sort.Sort(parts)
+ return parts, nil
+ }
+ params["part-number-marker"] = []string{resp.NextPartNumberMarker}
+ attempt = attempts.Start() // Last request worked.
+ }
+ panic("unreachable")
+}
+
+type ReaderAtSeeker interface {
+ io.ReaderAt
+ io.ReadSeeker
+}
+
+// PutAll sends all of r via a multipart upload with parts no larger
+// than partSize bytes, which must be set to at least 5MB.
+// Parts previously uploaded are either reused if their checksum
+// and size match the new part, or otherwise overwritten with the
+// new content.
+// PutAll returns all the parts of m (reused or not).
+func (m *Multi) PutAll(r ReaderAtSeeker, partSize int64) ([]Part, error) {
+ old, err := m.ListParts()
+ if err != nil && !hasCode(err, "NoSuchUpload") {
+ return nil, err
+ }
+ reuse := 0 // Index of next old part to consider reusing.
+ current := 1 // Part number of latest good part handled.
+ totalSize, err := r.Seek(0, 2)
+ if err != nil {
+ return nil, err
+ }
+ first := true // Must send at least one empty part if the file is empty.
+ var result []Part
+NextSection:
+ for offset := int64(0); offset < totalSize || first; offset += partSize {
+ first = false
+ if offset+partSize > totalSize {
+ partSize = totalSize - offset
+ }
+ section := io.NewSectionReader(r, offset, partSize)
+ _, md5hex, md5b64, err := seekerInfo(section)
+ if err != nil {
+ return nil, err
+ }
+ for reuse < len(old) && old[reuse].N <= current {
+ // Looks like this part was already sent.
+ part := &old[reuse]
+ etag := `"` + md5hex + `"`
+ if part.N == current && part.Size == partSize && part.ETag == etag {
+ // Checksum matches. Reuse the old part.
+ result = append(result, *part)
+ current++
+ continue NextSection
+ }
+ reuse++
+ }
+
+ // Part wasn't found or doesn't match. Send it.
+ part, err := m.putPart(current, section, partSize, md5b64)
+ if err != nil {
+ return nil, err
+ }
+ result = append(result, part)
+ current++
+ }
+ return result, nil
+}
+
+type completeUpload struct {
+ XMLName xml.Name `xml:"CompleteMultipartUpload"`
+ Parts completeParts `xml:"Part"`
+}
+
+type completePart struct {
+ PartNumber int
+ ETag string
+}
+
+type completeParts []completePart
+
+func (p completeParts) Len() int { return len(p) }
+func (p completeParts) Less(i, j int) bool { return p[i].PartNumber < p[j].PartNumber }
+func (p completeParts) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+// Complete assembles the given previously uploaded parts into the
+// final object. This operation may take several minutes.
+//
+// See http://goo.gl/2Z7Tw for details.
+func (m *Multi) Complete(parts []Part) error {
+ params := map[string][]string{
+ "uploadId": {m.UploadId},
+ }
+ c := completeUpload{}
+ for _, p := range parts {
+ c.Parts = append(c.Parts, completePart{p.N, p.ETag})
+ }
+ sort.Sort(c.Parts)
+ data, err := xml.Marshal(&c)
+ if err != nil {
+ return err
+ }
+ for attempt := attempts.Start(); attempt.Next(); {
+ req := &request{
+ method: "POST",
+ bucket: m.Bucket.Name,
+ path: m.Key,
+ params: params,
+ payload: bytes.NewReader(data),
+ }
+ err := m.Bucket.S3.query(req, nil)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ return err
+ }
+ panic("unreachable")
+}
+
+// Abort deletes an unifinished multipart upload and any previously
+// uploaded parts for it.
+//
+// After a multipart upload is aborted, no additional parts can be
+// uploaded using it. However, if any part uploads are currently in
+// progress, those part uploads might or might not succeed. As a result,
+// it might be necessary to abort a given multipart upload multiple
+// times in order to completely free all storage consumed by all parts.
+//
+// NOTE: If the described scenario happens to you, please report back to
+// the goamz authors with details. In the future such retrying should be
+// handled internally, but it's not clear what happens precisely (Is an
+// error returned? Is the issue completely undetectable?).
+//
+// See http://goo.gl/dnyJw for details.
+func (m *Multi) Abort() error {
+ params := map[string][]string{
+ "uploadId": {m.UploadId},
+ }
+ for attempt := attempts.Start(); attempt.Next(); {
+ req := &request{
+ method: "DELETE",
+ bucket: m.Bucket.Name,
+ path: m.Key,
+ params: params,
+ }
+ err := m.Bucket.S3.query(req, nil)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ return err
+ }
+ panic("unreachable")
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/multi_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/multi_test.go
new file mode 100644
index 00000000..fbb03e04
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/multi_test.go
@@ -0,0 +1,370 @@
+package s3_test
+
+import (
+ "encoding/xml"
+ "github.com/mitchellh/goamz/s3"
+ . "github.com/motain/gocheck"
+ "io"
+ "io/ioutil"
+ "strings"
+)
+
+func (s *S) TestInitMulti(c *C) {
+ testServer.Response(200, nil, InitMultiResultDump)
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "POST")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Header["Content-Type"], DeepEquals, []string{"text/plain"})
+ c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
+ c.Assert(req.Form["uploads"], DeepEquals, []string{""})
+
+ c.Assert(multi.UploadId, Matches, "JNbR_[A-Za-z0-9.]+QQ--")
+}
+
+func (s *S) TestMultiNoPreviousUpload(c *C) {
+ // Don't retry the NoSuchUpload error.
+ s.DisableRetries()
+
+ testServer.Response(404, nil, NoSuchUploadErrorDump)
+ testServer.Response(200, nil, InitMultiResultDump)
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.Multi("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/sample/")
+ c.Assert(req.Form["uploads"], DeepEquals, []string{""})
+ c.Assert(req.Form["prefix"], DeepEquals, []string{"multi"})
+
+ req = testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "POST")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form["uploads"], DeepEquals, []string{""})
+
+ c.Assert(multi.UploadId, Matches, "JNbR_[A-Za-z0-9.]+QQ--")
+}
+
+func (s *S) TestMultiReturnOld(c *C) {
+ testServer.Response(200, nil, ListMultiResultDump)
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.Multi("multi1", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+ c.Assert(multi.Key, Equals, "multi1")
+ c.Assert(multi.UploadId, Equals, "iUVug89pPvSswrikD")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/sample/")
+ c.Assert(req.Form["uploads"], DeepEquals, []string{""})
+ c.Assert(req.Form["prefix"], DeepEquals, []string{"multi1"})
+}
+
+func (s *S) TestListParts(c *C) {
+ testServer.Response(200, nil, InitMultiResultDump)
+ testServer.Response(200, nil, ListPartsResultDump1)
+ testServer.Response(404, nil, NoSuchUploadErrorDump) // :-(
+ testServer.Response(200, nil, ListPartsResultDump2)
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ parts, err := multi.ListParts()
+ c.Assert(err, IsNil)
+ c.Assert(parts, HasLen, 3)
+ c.Assert(parts[0].N, Equals, 1)
+ c.Assert(parts[0].Size, Equals, int64(5))
+ c.Assert(parts[0].ETag, Equals, `"ffc88b4ca90a355f8ddba6b2c3b2af5c"`)
+ c.Assert(parts[1].N, Equals, 2)
+ c.Assert(parts[1].Size, Equals, int64(5))
+ c.Assert(parts[1].ETag, Equals, `"d067a0fa9dc61a6e7195ca99696b5a89"`)
+ c.Assert(parts[2].N, Equals, 3)
+ c.Assert(parts[2].Size, Equals, int64(5))
+ c.Assert(parts[2].ETag, Equals, `"49dcd91231f801159e893fb5c6674985"`)
+ testServer.WaitRequest()
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
+ c.Assert(req.Form["max-parts"], DeepEquals, []string{"1000"})
+
+ testServer.WaitRequest() // The internal error.
+ req = testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
+ c.Assert(req.Form["max-parts"], DeepEquals, []string{"1000"})
+ c.Assert(req.Form["part-number-marker"], DeepEquals, []string{"2"})
+}
+
+func (s *S) TestPutPart(c *C) {
+ headers := map[string]string{
+ "ETag": `"26f90efd10d614f100252ff56d88dad8"`,
+ }
+ testServer.Response(200, nil, InitMultiResultDump)
+ testServer.Response(200, headers, "")
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ part, err := multi.PutPart(1, strings.NewReader(""))
+ c.Assert(err, IsNil)
+ c.Assert(part.N, Equals, 1)
+ c.Assert(part.Size, Equals, int64(8))
+ c.Assert(part.ETag, Equals, headers["ETag"])
+
+ testServer.WaitRequest()
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
+ c.Assert(req.Form["partNumber"], DeepEquals, []string{"1"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"8"})
+ c.Assert(req.Header["Content-Md5"], DeepEquals, []string{"JvkO/RDWFPEAJS/1bYja2A=="})
+}
+
+func readAll(r io.Reader) string {
+ data, err := ioutil.ReadAll(r)
+ if err != nil {
+ panic(err)
+ }
+ return string(data)
+}
+
+func (s *S) TestPutAllNoPreviousUpload(c *C) {
+ // Don't retry the NoSuchUpload error.
+ s.DisableRetries()
+
+ etag1 := map[string]string{"ETag": `"etag1"`}
+ etag2 := map[string]string{"ETag": `"etag2"`}
+ etag3 := map[string]string{"ETag": `"etag3"`}
+ testServer.Response(200, nil, InitMultiResultDump)
+ testServer.Response(404, nil, NoSuchUploadErrorDump)
+ testServer.Response(200, etag1, "")
+ testServer.Response(200, etag2, "")
+ testServer.Response(200, etag3, "")
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ parts, err := multi.PutAll(strings.NewReader("part1part2last"), 5)
+ c.Assert(parts, HasLen, 3)
+ c.Assert(parts[0].ETag, Equals, `"etag1"`)
+ c.Assert(parts[1].ETag, Equals, `"etag2"`)
+ c.Assert(parts[2].ETag, Equals, `"etag3"`)
+ c.Assert(err, IsNil)
+
+ // Init
+ testServer.WaitRequest()
+
+ // List old parts. Won't find anything.
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+
+ // Send part 1.
+ req = testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form["partNumber"], DeepEquals, []string{"1"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"5"})
+ c.Assert(readAll(req.Body), Equals, "part1")
+
+ // Send part 2.
+ req = testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form["partNumber"], DeepEquals, []string{"2"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"5"})
+ c.Assert(readAll(req.Body), Equals, "part2")
+
+ // Send part 3 with shorter body.
+ req = testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form["partNumber"], DeepEquals, []string{"3"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"4"})
+ c.Assert(readAll(req.Body), Equals, "last")
+}
+
+func (s *S) TestPutAllZeroSizeFile(c *C) {
+ // Don't retry the NoSuchUpload error.
+ s.DisableRetries()
+
+ etag1 := map[string]string{"ETag": `"etag1"`}
+ testServer.Response(200, nil, InitMultiResultDump)
+ testServer.Response(404, nil, NoSuchUploadErrorDump)
+ testServer.Response(200, etag1, "")
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ // Must send at least one part, so that completing it will work.
+ parts, err := multi.PutAll(strings.NewReader(""), 5)
+ c.Assert(parts, HasLen, 1)
+ c.Assert(parts[0].ETag, Equals, `"etag1"`)
+ c.Assert(err, IsNil)
+
+ // Init
+ testServer.WaitRequest()
+
+ // List old parts. Won't find anything.
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+
+ // Send empty part.
+ req = testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form["partNumber"], DeepEquals, []string{"1"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"0"})
+ c.Assert(readAll(req.Body), Equals, "")
+}
+
+func (s *S) TestPutAllResume(c *C) {
+ etag2 := map[string]string{"ETag": `"etag2"`}
+ testServer.Response(200, nil, InitMultiResultDump)
+ testServer.Response(200, nil, ListPartsResultDump1)
+ testServer.Response(200, nil, ListPartsResultDump2)
+ testServer.Response(200, etag2, "")
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ // "part1" and "part3" match the checksums in ResultDump1.
+ // The middle one is a mismatch (it refers to "part2").
+ parts, err := multi.PutAll(strings.NewReader("part1partXpart3"), 5)
+ c.Assert(parts, HasLen, 3)
+ c.Assert(parts[0].N, Equals, 1)
+ c.Assert(parts[0].Size, Equals, int64(5))
+ c.Assert(parts[0].ETag, Equals, `"ffc88b4ca90a355f8ddba6b2c3b2af5c"`)
+ c.Assert(parts[1].N, Equals, 2)
+ c.Assert(parts[1].Size, Equals, int64(5))
+ c.Assert(parts[1].ETag, Equals, `"etag2"`)
+ c.Assert(parts[2].N, Equals, 3)
+ c.Assert(parts[2].Size, Equals, int64(5))
+ c.Assert(parts[2].ETag, Equals, `"49dcd91231f801159e893fb5c6674985"`)
+ c.Assert(err, IsNil)
+
+ // Init
+ testServer.WaitRequest()
+
+ // List old parts, broken in two requests.
+ for i := 0; i < 2; i++ {
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ }
+
+ // Send part 2, as it didn't match the checksum.
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form["partNumber"], DeepEquals, []string{"2"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"5"})
+ c.Assert(readAll(req.Body), Equals, "partX")
+}
+
+func (s *S) TestMultiComplete(c *C) {
+ testServer.Response(200, nil, InitMultiResultDump)
+ // Note the 200 response. Completing will hold the connection on some
+ // kind of long poll, and may return a late error even after a 200.
+ testServer.Response(200, nil, InternalErrorDump)
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ err = multi.Complete([]s3.Part{{2, `"ETag2"`, 32}, {1, `"ETag1"`, 64}})
+ c.Assert(err, IsNil)
+
+ testServer.WaitRequest()
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "POST")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
+
+ var payload struct {
+ XMLName xml.Name
+ Part []struct {
+ PartNumber int
+ ETag string
+ }
+ }
+
+ dec := xml.NewDecoder(req.Body)
+ err = dec.Decode(&payload)
+ c.Assert(err, IsNil)
+
+ c.Assert(payload.XMLName.Local, Equals, "CompleteMultipartUpload")
+ c.Assert(len(payload.Part), Equals, 2)
+ c.Assert(payload.Part[0].PartNumber, Equals, 1)
+ c.Assert(payload.Part[0].ETag, Equals, `"ETag1"`)
+ c.Assert(payload.Part[1].PartNumber, Equals, 2)
+ c.Assert(payload.Part[1].ETag, Equals, `"ETag2"`)
+}
+
+func (s *S) TestMultiAbort(c *C) {
+ testServer.Response(200, nil, InitMultiResultDump)
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("sample")
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+
+ err = multi.Abort()
+ c.Assert(err, IsNil)
+
+ testServer.WaitRequest()
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "DELETE")
+ c.Assert(req.URL.Path, Equals, "/sample/multi")
+ c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
+}
+
+func (s *S) TestListMulti(c *C) {
+ testServer.Response(200, nil, ListMultiResultDump)
+
+ b := s.s3.Bucket("sample")
+
+ multis, prefixes, err := b.ListMulti("", "/")
+ c.Assert(err, IsNil)
+ c.Assert(prefixes, DeepEquals, []string{"a/", "b/"})
+ c.Assert(multis, HasLen, 2)
+ c.Assert(multis[0].Key, Equals, "multi1")
+ c.Assert(multis[0].UploadId, Equals, "iUVug89pPvSswrikD")
+ c.Assert(multis[1].Key, Equals, "multi2")
+ c.Assert(multis[1].UploadId, Equals, "DkirwsSvPp98guVUi")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/sample/")
+ c.Assert(req.Form["uploads"], DeepEquals, []string{""})
+ c.Assert(req.Form["prefix"], DeepEquals, []string{""})
+ c.Assert(req.Form["delimiter"], DeepEquals, []string{"/"})
+ c.Assert(req.Form["max-uploads"], DeepEquals, []string{"1000"})
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/responses_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/responses_test.go
new file mode 100644
index 00000000..98bba563
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/responses_test.go
@@ -0,0 +1,241 @@
+package s3_test
+
+var GetObjectErrorDump = `
+
+NoSuchBucketThe specified bucket does not exist
+non-existent-bucket3F1B667FAD71C3D8
+L4ee/zrm1irFXY5F45fKXIRdOf9ktsKY/8TDVawuMK2jWRb1RF84i1uBzkdNqS5D
+`
+
+var GetListResultDump1 = `
+
+
+ quotes
+ N
+ false
+
+ Nelson
+ 2006-01-01T12:00:00.000Z
+ "828ef3fdfa96f00ad9f27c383fc9ac7f"
+ 5
+ STANDARD
+
+ bcaf161ca5fb16fd081034f
+ webfile
+
+
+
+ Neo
+ 2006-01-01T12:00:00.000Z
+ "828ef3fdfa96f00ad9f27c383fc9ac7f"
+ 4
+ STANDARD
+
+ bcaf1ffd86a5fb16fd081034f
+ webfile
+
+
+
+`
+
+var GetListResultDump2 = `
+
+ example-bucket
+ photos/2006/
+ some-marker
+ 1000
+ /
+ false
+
+
+ photos/2006/feb/
+
+
+ photos/2006/jan/
+
+
+`
+
+var InitMultiResultDump = `
+
+
+ sample
+ multi
+ JNbR_cMdwnGiD12jKAd6WK2PUkfj2VxA7i4nCwjE6t71nI9Tl3eVDPFlU0nOixhftH7I17ZPGkV3QA.l7ZD.QQ--
+
+`
+
+var ListPartsResultDump1 = `
+
+
+ sample
+ multi
+ JNbR_cMdwnGiD12jKAd6WK2PUkfj2VxA7i4nCwjE6t71nI9Tl3eVDPFlU0nOixhftH7I17ZPGkV3QA.l7ZD.QQ--
+
+ bb5c0f63b0b25f2d099c
+ joe
+
+
+ bb5c0f63b0b25f2d099c
+ joe
+
+ STANDARD
+ 0
+ 2
+ 2
+ true
+
+ 1
+ 2013-01-30T13:45:51.000Z
+ "ffc88b4ca90a355f8ddba6b2c3b2af5c"
+ 5
+
+
+ 2
+ 2013-01-30T13:45:52.000Z
+ "d067a0fa9dc61a6e7195ca99696b5a89"
+ 5
+
+
+`
+
+var ListPartsResultDump2 = `
+
+
+ sample
+ multi
+ JNbR_cMdwnGiD12jKAd6WK2PUkfj2VxA7i4nCwjE6t71nI9Tl3eVDPFlU0nOixhftH7I17ZPGkV3QA.l7ZD.QQ--
+
+ bb5c0f63b0b25f2d099c
+ joe
+
+
+ bb5c0f63b0b25f2d099c
+ joe
+
+ STANDARD
+ 2
+ 3
+ 2
+ false
+
+ 3
+ 2013-01-30T13:46:50.000Z
+ "49dcd91231f801159e893fb5c6674985"
+ 5
+
+
+`
+
+var ListMultiResultDump = `
+
+
+ goamz-test-bucket-us-east-1-akiajk3wyewhctyqbf7a
+
+
+ multi1
+ iUVug89pPvSswrikD72p8uO62EzhNtpDxRmwC5WSiWDdK9SfzmDqe3xpP1kMWimyimSnz4uzFc3waVM5ufrKYQ--
+ /
+ 1000
+ false
+
+ multi1
+ iUVug89pPvSswrikD
+
+ bb5c0f63b0b25f2d0
+ gustavoniemeyer
+
+
+ bb5c0f63b0b25f2d0
+ gustavoniemeyer
+
+ STANDARD
+ 2013-01-30T18:15:47.000Z
+
+
+ multi2
+ DkirwsSvPp98guVUi
+
+ bb5c0f63b0b25f2d0
+ joe
+
+
+ bb5c0f63b0b25f2d0
+ joe
+
+ STANDARD
+ 2013-01-30T18:15:47.000Z
+
+
+ a/
+
+
+ b/
+
+
+`
+
+var NoSuchUploadErrorDump = `
+
+
+ NoSuchUpload
+ Not relevant
+ sample
+ 3F1B667FAD71C3D8
+ kjhwqk
+
+`
+
+var InternalErrorDump = `
+
+
+ InternalError
+ Not relevant
+ sample
+ 3F1B667FAD71C3D8
+ kjhwqk
+
+`
+
+var GetKeyHeaderDump = map[string]string{
+ "x-amz-id-2": "ef8yU9AS1ed4OpIszj7UDNEHGran",
+ "x-amz-request-id": "318BC8BC143432E5",
+ "x-amz-version-id": "3HL4kqtJlcpXroDTDmjVBH40Nrjfkd",
+ "Date": "Wed, 28 Oct 2009 22:32:00 GMT",
+ "Last-Modified": "Sun, 1 Jan 2006 12:00:00 GMT",
+ "ETag": "fba9dede5f27731c9771645a39863328",
+ "Content-Length": "434234",
+ "Content-Type": "text/plain",
+}
+
+var GetListBucketsDump = `
+
+
+
+ bb5c0f63b0b25f2d0
+ joe
+
+
+
+ bucket1
+ 2012-01-01T02:03:04.000Z
+
+
+ bucket2
+ 2014-01-11T02:03:04.000Z
+
+
+
+`
+
+var MultiDelDump = `
+
+
+
+ a.go
+
+
+ b.go
+
+
+`
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3.go
new file mode 100644
index 00000000..989d6783
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3.go
@@ -0,0 +1,874 @@
+//
+// goamz - Go packages to interact with the Amazon Web Services.
+//
+// https://wiki.ubuntu.com/goamz
+//
+// Copyright (c) 2011 Canonical Ltd.
+//
+// Written by Gustavo Niemeyer
+//
+
+package s3
+
+import (
+ "bytes"
+ "crypto/md5"
+ "encoding/base64"
+ "encoding/xml"
+ "fmt"
+ "github.com/mitchellh/goamz/aws"
+ "io"
+ "io/ioutil"
+ "log"
+ "net"
+ "net/http"
+ "net/http/httputil"
+ "net/url"
+ "strconv"
+ "strings"
+ "time"
+)
+
+const debug = false
+
+// The S3 type encapsulates operations with an S3 region.
+type S3 struct {
+ aws.Auth
+ aws.Region
+ private byte // Reserve the right of using private data.
+}
+
+// The Bucket type encapsulates operations with an S3 bucket.
+type Bucket struct {
+ *S3
+ Name string
+}
+
+// The Owner type represents the owner of the object in an S3 bucket.
+type Owner struct {
+ ID string
+ DisplayName string
+}
+
+var attempts = aws.AttemptStrategy{
+ Min: 5,
+ Total: 5 * time.Second,
+ Delay: 200 * time.Millisecond,
+}
+
+// New creates a new S3.
+func New(auth aws.Auth, region aws.Region) *S3 {
+ return &S3{auth, region, 0}
+}
+
+// Bucket returns a Bucket with the given name.
+func (s3 *S3) Bucket(name string) *Bucket {
+ if s3.Region.S3BucketEndpoint != "" || s3.Region.S3LowercaseBucket {
+ name = strings.ToLower(name)
+ }
+ return &Bucket{s3, name}
+}
+
+var createBucketConfiguration = `
+ %s
+`
+
+// locationConstraint returns an io.Reader specifying a LocationConstraint if
+// required for the region.
+//
+// See http://goo.gl/bh9Kq for details.
+func (s3 *S3) locationConstraint() io.Reader {
+ constraint := ""
+ if s3.Region.S3LocationConstraint {
+ constraint = fmt.Sprintf(createBucketConfiguration, s3.Region.Name)
+ }
+ return strings.NewReader(constraint)
+}
+
+type ACL string
+
+const (
+ Private = ACL("private")
+ PublicRead = ACL("public-read")
+ PublicReadWrite = ACL("public-read-write")
+ AuthenticatedRead = ACL("authenticated-read")
+ BucketOwnerRead = ACL("bucket-owner-read")
+ BucketOwnerFull = ACL("bucket-owner-full-control")
+)
+
+// The ListBucketsResp type holds the results of a List buckets operation.
+type ListBucketsResp struct {
+ Buckets []Bucket `xml:">Bucket"`
+}
+
+// ListBuckets lists all buckets
+//
+// See: http://goo.gl/NqlyMN
+func (s3 *S3) ListBuckets() (result *ListBucketsResp, err error) {
+ req := &request{
+ path: "/",
+ }
+ result = &ListBucketsResp{}
+ for attempt := attempts.Start(); attempt.Next(); {
+ err = s3.query(req, result)
+ if !shouldRetry(err) {
+ break
+ }
+ }
+ if err != nil {
+ return nil, err
+ }
+ // set S3 instance on buckets
+ for i := range result.Buckets {
+ result.Buckets[i].S3 = s3
+ }
+ return result, nil
+}
+
+// PutBucket creates a new bucket.
+//
+// See http://goo.gl/ndjnR for details.
+func (b *Bucket) PutBucket(perm ACL) error {
+ headers := map[string][]string{
+ "x-amz-acl": {string(perm)},
+ }
+ req := &request{
+ method: "PUT",
+ bucket: b.Name,
+ path: "/",
+ headers: headers,
+ payload: b.locationConstraint(),
+ }
+ return b.S3.query(req, nil)
+}
+
+// DelBucket removes an existing S3 bucket. All objects in the bucket must
+// be removed before the bucket itself can be removed.
+//
+// See http://goo.gl/GoBrY for details.
+func (b *Bucket) DelBucket() (err error) {
+ req := &request{
+ method: "DELETE",
+ bucket: b.Name,
+ path: "/",
+ }
+ for attempt := attempts.Start(); attempt.Next(); {
+ err = b.S3.query(req, nil)
+ if !shouldRetry(err) {
+ break
+ }
+ }
+ return err
+}
+
+// Get retrieves an object from an S3 bucket.
+//
+// See http://goo.gl/isCO7 for details.
+func (b *Bucket) Get(path string) (data []byte, err error) {
+ body, err := b.GetReader(path)
+ if err != nil {
+ return nil, err
+ }
+ data, err = ioutil.ReadAll(body)
+ body.Close()
+ return data, err
+}
+
+// GetReader retrieves an object from an S3 bucket.
+// It is the caller's responsibility to call Close on rc when
+// finished reading.
+func (b *Bucket) GetReader(path string) (rc io.ReadCloser, err error) {
+ resp, err := b.GetResponse(path)
+ if resp != nil {
+ return resp.Body, err
+ }
+ return nil, err
+}
+
+// GetResponse retrieves an object from an S3 bucket returning the http response
+// It is the caller's responsibility to call Close on rc when
+// finished reading.
+func (b *Bucket) GetResponse(path string) (*http.Response, error) {
+ req := &request{
+ bucket: b.Name,
+ path: path,
+ }
+ err := b.S3.prepare(req)
+ if err != nil {
+ return nil, err
+ }
+ for attempt := attempts.Start(); attempt.Next(); {
+ resp, err := b.S3.run(req, nil)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+ }
+ panic("unreachable")
+}
+
+func (b *Bucket) Head(path string) (*http.Response, error) {
+ req := &request{
+ method: "HEAD",
+ bucket: b.Name,
+ path: path,
+ }
+ err := b.S3.prepare(req)
+ if err != nil {
+ return nil, err
+ }
+ for attempt := attempts.Start(); attempt.Next(); {
+ resp, err := b.S3.run(req, nil)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+ }
+ panic("unreachable")
+}
+
+// Put inserts an object into the S3 bucket.
+//
+// See http://goo.gl/FEBPD for details.
+func (b *Bucket) Put(path string, data []byte, contType string, perm ACL) error {
+ body := bytes.NewBuffer(data)
+ return b.PutReader(path, body, int64(len(data)), contType, perm)
+}
+
+/*
+PutHeader - like Put, inserts an object into the S3 bucket.
+Instead of Content-Type string, pass in custom headers to override defaults.
+*/
+func (b *Bucket) PutHeader(path string, data []byte, customHeaders map[string][]string, perm ACL) error {
+ body := bytes.NewBuffer(data)
+ return b.PutReaderHeader(path, body, int64(len(data)), customHeaders, perm)
+}
+
+// PutReader inserts an object into the S3 bucket by consuming data
+// from r until EOF.
+func (b *Bucket) PutReader(path string, r io.Reader, length int64, contType string, perm ACL) error {
+ headers := map[string][]string{
+ "Content-Length": {strconv.FormatInt(length, 10)},
+ "Content-Type": {contType},
+ "x-amz-acl": {string(perm)},
+ }
+ req := &request{
+ method: "PUT",
+ bucket: b.Name,
+ path: path,
+ headers: headers,
+ payload: r,
+ }
+ return b.S3.query(req, nil)
+}
+
+/*
+PutReaderHeader - like PutReader, inserts an object into S3 from a reader.
+Instead of Content-Type string, pass in custom headers to override defaults.
+*/
+func (b *Bucket) PutReaderHeader(path string, r io.Reader, length int64, customHeaders map[string][]string, perm ACL) error {
+ // Default headers
+ headers := map[string][]string{
+ "Content-Length": {strconv.FormatInt(length, 10)},
+ "Content-Type": {"application/text"},
+ "x-amz-acl": {string(perm)},
+ }
+
+ // Override with custom headers
+ for key, value := range customHeaders {
+ headers[key] = value
+ }
+
+ req := &request{
+ method: "PUT",
+ bucket: b.Name,
+ path: path,
+ headers: headers,
+ payload: r,
+ }
+ return b.S3.query(req, nil)
+}
+
+/*
+Copy - copy objects inside bucket
+*/
+func (b *Bucket) Copy(oldPath, newPath string, perm ACL) error {
+ if !strings.HasPrefix(oldPath, "/") {
+ oldPath = "/" + oldPath
+ }
+
+ req := &request{
+ method: "PUT",
+ bucket: b.Name,
+ path: newPath,
+ headers: map[string][]string{
+ "x-amz-copy-source": {amazonEscape("/" + b.Name + oldPath)},
+ "x-amz-acl": {string(perm)},
+ },
+ }
+
+ err := b.S3.prepare(req)
+ if err != nil {
+ return err
+ }
+
+ for attempt := attempts.Start(); attempt.Next(); {
+ _, err = b.S3.run(req, nil)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ if err != nil {
+ return err
+ }
+ return nil
+ }
+ panic("unreachable")
+}
+
+// Del removes an object from the S3 bucket.
+//
+// See http://goo.gl/APeTt for details.
+func (b *Bucket) Del(path string) error {
+ req := &request{
+ method: "DELETE",
+ bucket: b.Name,
+ path: path,
+ }
+ return b.S3.query(req, nil)
+}
+
+type Object struct {
+ Key string
+}
+
+type MultiObjectDeleteBody struct {
+ XMLName xml.Name `xml:"Delete"`
+ Quiet bool
+ Object []Object
+}
+
+func base64md5(data []byte) string {
+ h := md5.New()
+ h.Write(data)
+ return base64.StdEncoding.EncodeToString(h.Sum(nil))
+}
+
+// MultiDel removes multiple objects from the S3 bucket efficiently.
+// A maximum of 1000 keys at once may be specified.
+//
+// See http://goo.gl/WvA5sj for details.
+func (b *Bucket) MultiDel(paths []string) error {
+ // create XML payload
+ v := MultiObjectDeleteBody{}
+ v.Object = make([]Object, len(paths))
+ for i, path := range paths {
+ v.Object[i] = Object{path}
+ }
+ data, _ := xml.Marshal(v)
+
+ // Content-MD5 is required
+ md5hash := base64md5(data)
+ req := &request{
+ method: "POST",
+ bucket: b.Name,
+ path: "/",
+ params: url.Values{"delete": {""}},
+ headers: http.Header{"Content-MD5": {md5hash}},
+ payload: bytes.NewReader(data),
+ }
+
+ return b.S3.query(req, nil)
+}
+
+// The ListResp type holds the results of a List bucket operation.
+type ListResp struct {
+ Name string
+ Prefix string
+ Delimiter string
+ Marker string
+ NextMarker string
+ MaxKeys int
+ // IsTruncated is true if the results have been truncated because
+ // there are more keys and prefixes than can fit in MaxKeys.
+ // N.B. this is the opposite sense to that documented (incorrectly) in
+ // http://goo.gl/YjQTc
+ IsTruncated bool
+ Contents []Key
+ CommonPrefixes []string `xml:">Prefix"`
+}
+
+// The Key type represents an item stored in an S3 bucket.
+type Key struct {
+ Key string
+ LastModified string
+ Size int64
+ // ETag gives the hex-encoded MD5 sum of the contents,
+ // surrounded with double-quotes.
+ ETag string
+ StorageClass string
+ Owner Owner
+}
+
+// List returns information about objects in an S3 bucket.
+//
+// The prefix parameter limits the response to keys that begin with the
+// specified prefix.
+//
+// The delim parameter causes the response to group all of the keys that
+// share a common prefix up to the next delimiter in a single entry within
+// the CommonPrefixes field. You can use delimiters to separate a bucket
+// into different groupings of keys, similar to how folders would work.
+//
+// The marker parameter specifies the key to start with when listing objects
+// in a bucket. Amazon S3 lists objects in alphabetical order and
+// will return keys alphabetically greater than the marker.
+//
+// The max parameter specifies how many keys + common prefixes to return in
+// the response. The default is 1000.
+//
+// For example, given these keys in a bucket:
+//
+// index.html
+// index2.html
+// photos/2006/January/sample.jpg
+// photos/2006/February/sample2.jpg
+// photos/2006/February/sample3.jpg
+// photos/2006/February/sample4.jpg
+//
+// Listing this bucket with delimiter set to "/" would yield the
+// following result:
+//
+// &ListResp{
+// Name: "sample-bucket",
+// MaxKeys: 1000,
+// Delimiter: "/",
+// Contents: []Key{
+// {Key: "index.html", "index2.html"},
+// },
+// CommonPrefixes: []string{
+// "photos/",
+// },
+// }
+//
+// Listing the same bucket with delimiter set to "/" and prefix set to
+// "photos/2006/" would yield the following result:
+//
+// &ListResp{
+// Name: "sample-bucket",
+// MaxKeys: 1000,
+// Delimiter: "/",
+// Prefix: "photos/2006/",
+// CommonPrefixes: []string{
+// "photos/2006/February/",
+// "photos/2006/January/",
+// },
+// }
+//
+// See http://goo.gl/YjQTc for details.
+func (b *Bucket) List(prefix, delim, marker string, max int) (result *ListResp, err error) {
+ params := map[string][]string{
+ "prefix": {prefix},
+ "delimiter": {delim},
+ "marker": {marker},
+ }
+ if max != 0 {
+ params["max-keys"] = []string{strconv.FormatInt(int64(max), 10)}
+ }
+ req := &request{
+ bucket: b.Name,
+ params: params,
+ }
+ result = &ListResp{}
+ for attempt := attempts.Start(); attempt.Next(); {
+ err = b.S3.query(req, result)
+ if !shouldRetry(err) {
+ break
+ }
+ }
+ if err != nil {
+ return nil, err
+ }
+ return result, nil
+}
+
+// Returns a mapping of all key names in this bucket to Key objects
+func (b *Bucket) GetBucketContents() (*map[string]Key, error) {
+ bucket_contents := map[string]Key{}
+ prefix := ""
+ path_separator := ""
+ marker := ""
+ for {
+ contents, err := b.List(prefix, path_separator, marker, 1000)
+ if err != nil {
+ return &bucket_contents, err
+ }
+ last_key := ""
+ for _, key := range contents.Contents {
+ bucket_contents[key.Key] = key
+ last_key = key.Key
+ }
+ if contents.IsTruncated {
+ marker = contents.NextMarker
+ if marker == "" {
+ // From the s3 docs: If response does not include the
+ // NextMarker and it is truncated, you can use the value of the
+ // last Key in the response as the marker in the subsequent
+ // request to get the next set of object keys.
+ marker = last_key
+ }
+ } else {
+ break
+ }
+ }
+
+ return &bucket_contents, nil
+}
+
+// Get metadata from the key without returning the key content
+func (b *Bucket) GetKey(path string) (*Key, error) {
+ req := &request{
+ bucket: b.Name,
+ path: path,
+ method: "HEAD",
+ }
+ err := b.S3.prepare(req)
+ if err != nil {
+ return nil, err
+ }
+ key := &Key{}
+ for attempt := attempts.Start(); attempt.Next(); {
+ resp, err := b.S3.run(req, nil)
+ if shouldRetry(err) && attempt.HasNext() {
+ continue
+ }
+ if err != nil {
+ return nil, err
+ }
+ key.Key = path
+ key.LastModified = resp.Header.Get("Last-Modified")
+ key.ETag = resp.Header.Get("ETag")
+ contentLength := resp.Header.Get("Content-Length")
+ size, err := strconv.ParseInt(contentLength, 10, 64)
+ if err != nil {
+ return key, fmt.Errorf("bad s3 content-length %v: %v",
+ contentLength, err)
+ }
+ key.Size = size
+ return key, nil
+ }
+ panic("unreachable")
+}
+
+// URL returns a non-signed URL that allows retriving the
+// object at path. It only works if the object is publicly
+// readable (see SignedURL).
+func (b *Bucket) URL(path string) string {
+ req := &request{
+ bucket: b.Name,
+ path: path,
+ }
+ err := b.S3.prepare(req)
+ if err != nil {
+ panic(err)
+ }
+ u, err := req.url(true)
+ if err != nil {
+ panic(err)
+ }
+ u.RawQuery = ""
+ return u.String()
+}
+
+// SignedURL returns a signed URL that allows anyone holding the URL
+// to retrieve the object at path. The signature is valid until expires.
+func (b *Bucket) SignedURL(path string, expires time.Time) string {
+ req := &request{
+ bucket: b.Name,
+ path: path,
+ params: url.Values{"Expires": {strconv.FormatInt(expires.Unix(), 10)}},
+ }
+ err := b.S3.prepare(req)
+ if err != nil {
+ panic(err)
+ }
+ u, err := req.url(true)
+ if err != nil {
+ panic(err)
+ }
+ return u.String()
+}
+
+type request struct {
+ method string
+ bucket string
+ path string
+ signpath string
+ params url.Values
+ headers http.Header
+ baseurl string
+ payload io.Reader
+ prepared bool
+}
+
+// amazonShouldEscape returns true if byte should be escaped
+func amazonShouldEscape(c byte) bool {
+ return !((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
+ (c >= '0' && c <= '9') || c == '_' || c == '-' || c == '~' || c == '.' || c == '/')
+}
+
+// amazonEscape does uri escaping exactly as Amazon does
+func amazonEscape(s string) string {
+ hexCount := 0
+
+ for i := 0; i < len(s); i++ {
+ if amazonShouldEscape(s[i]) {
+ hexCount++
+ }
+ }
+
+ if hexCount == 0 {
+ return s
+ }
+
+ t := make([]byte, len(s)+2*hexCount)
+ j := 0
+ for i := 0; i < len(s); i++ {
+ if c := s[i]; amazonShouldEscape(c) {
+ t[j] = '%'
+ t[j+1] = "0123456789ABCDEF"[c>>4]
+ t[j+2] = "0123456789ABCDEF"[c&15]
+ j += 3
+ } else {
+ t[j] = s[i]
+ j++
+ }
+ }
+ return string(t)
+}
+
+// url returns url to resource, either full (with host/scheme) or
+// partial for HTTP request
+func (req *request) url(full bool) (*url.URL, error) {
+ u, err := url.Parse(req.baseurl)
+ if err != nil {
+ return nil, fmt.Errorf("bad S3 endpoint URL %q: %v", req.baseurl, err)
+ }
+
+ u.Opaque = amazonEscape(req.path)
+ if full {
+ u.Opaque = "//" + u.Host + u.Opaque
+ }
+ u.RawQuery = req.params.Encode()
+
+ return u, nil
+}
+
+// query prepares and runs the req request.
+// If resp is not nil, the XML data contained in the response
+// body will be unmarshalled on it.
+func (s3 *S3) query(req *request, resp interface{}) error {
+ err := s3.prepare(req)
+ if err == nil {
+ var httpResponse *http.Response
+ httpResponse, err = s3.run(req, resp)
+ if resp == nil && httpResponse != nil {
+ httpResponse.Body.Close()
+ }
+ }
+ return err
+}
+
+// prepare sets up req to be delivered to S3.
+func (s3 *S3) prepare(req *request) error {
+ if !req.prepared {
+ req.prepared = true
+ if req.method == "" {
+ req.method = "GET"
+ }
+ // Copy so they can be mutated without affecting on retries.
+ params := make(url.Values)
+ headers := make(http.Header)
+ for k, v := range req.params {
+ params[k] = v
+ }
+ for k, v := range req.headers {
+ headers[k] = v
+ }
+ req.params = params
+ req.headers = headers
+ if !strings.HasPrefix(req.path, "/") {
+ req.path = "/" + req.path
+ }
+ req.signpath = req.path
+ // signpath includes subresource, if present: "?acl", "?delete", "?location", "?logging", or "?torrent"
+ if req.params["acl"] != nil {
+ req.signpath += "?acl"
+ }
+ if req.params["delete"] != nil {
+ req.signpath += "?delete"
+ }
+ if req.params["location"] != nil {
+ req.signpath += "?location"
+ }
+ if req.params["logging"] != nil {
+ req.signpath += "?logging"
+ }
+ if req.params["torrent"] != nil {
+ req.signpath += "?torrent"
+ }
+
+ if req.bucket != "" {
+ req.baseurl = s3.Region.S3BucketEndpoint
+ if req.baseurl == "" {
+ // Use the path method to address the bucket.
+ req.baseurl = s3.Region.S3Endpoint
+ req.path = "/" + req.bucket + req.path
+ } else {
+ // Just in case, prevent injection.
+ if strings.IndexAny(req.bucket, "/:@") >= 0 {
+ return fmt.Errorf("bad S3 bucket: %q", req.bucket)
+ }
+ req.baseurl = strings.Replace(req.baseurl, "${bucket}", req.bucket, -1)
+ }
+ req.signpath = "/" + req.bucket + req.signpath
+ } else {
+ req.baseurl = s3.Region.S3Endpoint
+ }
+ }
+
+ // Always sign again as it's not clear how far the
+ // server has handled a previous attempt.
+ u, err := url.Parse(req.baseurl)
+ if err != nil {
+ return fmt.Errorf("bad S3 endpoint URL %q: %v", req.baseurl, err)
+ }
+ req.headers["Host"] = []string{u.Host}
+ req.headers["Date"] = []string{time.Now().In(time.UTC).Format(time.RFC1123)}
+ sign(s3.Auth, req.method, amazonEscape(req.signpath), req.params, req.headers)
+ return nil
+}
+
+// run sends req and returns the http response from the server.
+// If resp is not nil, the XML data contained in the response
+// body will be unmarshalled on it.
+func (s3 *S3) run(req *request, resp interface{}) (*http.Response, error) {
+ if debug {
+ log.Printf("Running S3 request: %#v", req)
+ }
+
+ u, err := req.url(false)
+ if err != nil {
+ return nil, err
+ }
+
+ hreq := http.Request{
+ URL: u,
+ Method: req.method,
+ ProtoMajor: 1,
+ ProtoMinor: 1,
+ Close: true,
+ Header: req.headers,
+ }
+
+ if v, ok := req.headers["Content-Length"]; ok {
+ hreq.ContentLength, _ = strconv.ParseInt(v[0], 10, 64)
+ delete(req.headers, "Content-Length")
+ }
+ if req.payload != nil {
+ hreq.Body = ioutil.NopCloser(req.payload)
+ }
+
+ hresp, err := http.DefaultClient.Do(&hreq)
+ if err != nil {
+ return nil, err
+ }
+ if debug {
+ dump, _ := httputil.DumpResponse(hresp, true)
+ log.Printf("} -> %s\n", dump)
+ }
+ if hresp.StatusCode != 200 && hresp.StatusCode != 204 {
+ defer hresp.Body.Close()
+ return nil, buildError(hresp)
+ }
+ if resp != nil {
+ err = xml.NewDecoder(hresp.Body).Decode(resp)
+ hresp.Body.Close()
+ }
+ return hresp, err
+}
+
+// Error represents an error in an operation with S3.
+type Error struct {
+ StatusCode int // HTTP status code (200, 403, ...)
+ Code string // EC2 error code ("UnsupportedOperation", ...)
+ Message string // The human-oriented error message
+ BucketName string
+ RequestId string
+ HostId string
+}
+
+func (e *Error) Error() string {
+ return e.Message
+}
+
+func buildError(r *http.Response) error {
+ if debug {
+ log.Printf("got error (status code %v)", r.StatusCode)
+ data, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ log.Printf("\tread error: %v", err)
+ } else {
+ log.Printf("\tdata:\n%s\n\n", data)
+ }
+ r.Body = ioutil.NopCloser(bytes.NewBuffer(data))
+ }
+
+ err := Error{}
+ // TODO return error if Unmarshal fails?
+ xml.NewDecoder(r.Body).Decode(&err)
+ r.Body.Close()
+ err.StatusCode = r.StatusCode
+ if err.Message == "" {
+ err.Message = r.Status
+ }
+ if debug {
+ log.Printf("err: %#v\n", err)
+ }
+ return &err
+}
+
+func shouldRetry(err error) bool {
+ if err == nil {
+ return false
+ }
+ switch err {
+ case io.ErrUnexpectedEOF, io.EOF:
+ return true
+ }
+ switch e := err.(type) {
+ case *net.DNSError:
+ return true
+ case *net.OpError:
+ switch e.Op {
+ case "read", "write":
+ return true
+ }
+ case *Error:
+ switch e.Code {
+ case "InternalError", "NoSuchUpload", "NoSuchBucket":
+ return true
+ }
+ }
+ return false
+}
+
+func hasCode(err error, code string) bool {
+ s3err, ok := err.(*Error)
+ return ok && s3err.Code == code
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3_test.go
new file mode 100644
index 00000000..12286a03
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3_test.go
@@ -0,0 +1,429 @@
+package s3_test
+
+import (
+ "bytes"
+ "io/ioutil"
+ "net/http"
+ "testing"
+
+ "time"
+
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/s3"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+)
+
+func Test(t *testing.T) {
+ TestingT(t)
+}
+
+type S struct {
+ s3 *s3.S3
+}
+
+var _ = Suite(&S{})
+
+var testServer = testutil.NewHTTPServer()
+
+func (s *S) SetUpSuite(c *C) {
+ testServer.Start()
+ auth := aws.Auth{"abc", "123", ""}
+ s.s3 = s3.New(auth, aws.Region{Name: "faux-region-1", S3Endpoint: testServer.URL})
+}
+
+func (s *S) TearDownSuite(c *C) {
+ s3.SetAttemptStrategy(nil)
+}
+
+func (s *S) SetUpTest(c *C) {
+ attempts := aws.AttemptStrategy{
+ Total: 300 * time.Millisecond,
+ Delay: 100 * time.Millisecond,
+ }
+ s3.SetAttemptStrategy(&attempts)
+}
+
+func (s *S) TearDownTest(c *C) {
+ testServer.Flush()
+}
+
+func (s *S) DisableRetries() {
+ s3.SetAttemptStrategy(&aws.AttemptStrategy{})
+}
+
+// PutBucket docs: http://goo.gl/kBTCu
+
+func (s *S) TestPutBucket(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ err := b.PutBucket(s3.Private)
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/bucket/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+}
+
+// DeleteBucket docs: http://goo.gl/GoBrY
+
+func (s *S) TestDelBucket(c *C) {
+ testServer.Response(204, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ err := b.DelBucket()
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "DELETE")
+ c.Assert(req.URL.Path, Equals, "/bucket/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+}
+
+// ListBuckets: http://goo.gl/NqlyMN
+
+func (s *S) TestListBuckets(c *C) {
+ testServer.Response(200, nil, GetListBucketsDump)
+
+ buckets, err := s.s3.ListBuckets()
+ c.Assert(err, IsNil)
+ c.Assert(len(buckets.Buckets), Equals, 2)
+ c.Assert(buckets.Buckets[0].Name, Equals, "bucket1")
+ c.Assert(buckets.Buckets[1].Name, Equals, "bucket2")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/")
+}
+
+// GetObject docs: http://goo.gl/isCO7
+
+func (s *S) TestGet(c *C) {
+ testServer.Response(200, nil, "content")
+
+ b := s.s3.Bucket("bucket")
+ data, err := b.Get("name")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Equals, "content")
+}
+
+func (s *S) TestHead(c *C) {
+ testServer.Response(200, nil, "")
+ b := s.s3.Bucket("bucket")
+ resp, err := b.Head("name")
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "HEAD")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(err, IsNil)
+ body, err := ioutil.ReadAll(resp.Body)
+ c.Assert(err, IsNil)
+ c.Assert(len(body), Equals, 0)
+}
+
+func (s *S) TestURL(c *C) {
+ testServer.Response(200, nil, "content")
+
+ b := s.s3.Bucket("bucket")
+ url := b.URL("name")
+ r, err := http.Get(url)
+ c.Assert(err, IsNil)
+ data, err := ioutil.ReadAll(r.Body)
+ r.Body.Close()
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Equals, "content")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+}
+
+func (s *S) TestGetReader(c *C) {
+ testServer.Response(200, nil, "content")
+
+ b := s.s3.Bucket("bucket")
+ rc, err := b.GetReader("name")
+ c.Assert(err, IsNil)
+ data, err := ioutil.ReadAll(rc)
+ rc.Close()
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Equals, "content")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+}
+
+func (s *S) TestGetNotFound(c *C) {
+ for i := 0; i < 10; i++ {
+ testServer.Response(404, nil, GetObjectErrorDump)
+ }
+
+ b := s.s3.Bucket("non-existent-bucket")
+ data, err := b.Get("non-existent")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/non-existent-bucket/non-existent")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ s3err, _ := err.(*s3.Error)
+ c.Assert(s3err, NotNil)
+ c.Assert(s3err.StatusCode, Equals, 404)
+ c.Assert(s3err.BucketName, Equals, "non-existent-bucket")
+ c.Assert(s3err.RequestId, Equals, "3F1B667FAD71C3D8")
+ c.Assert(s3err.HostId, Equals, "L4ee/zrm1irFXY5F45fKXIRdOf9ktsKY/8TDVawuMK2jWRb1RF84i1uBzkdNqS5D")
+ c.Assert(s3err.Code, Equals, "NoSuchBucket")
+ c.Assert(s3err.Message, Equals, "The specified bucket does not exist")
+ c.Assert(s3err.Error(), Equals, "The specified bucket does not exist")
+ c.Assert(data, IsNil)
+}
+
+// PutObject docs: http://goo.gl/FEBPD
+
+func (s *S) TestPutObject(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ err := b.Put("name", []byte("content"), "content-type", s3.Private)
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
+ c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
+ //c.Assert(req.Header["Content-MD5"], DeepEquals, "...")
+ c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
+}
+
+func (s *S) TestPutObjectHeader(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ err := b.PutHeader(
+ "name",
+ []byte("content"),
+ map[string][]string{"Content-Type": {"content-type"}},
+ s3.Private,
+ )
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
+ c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
+ //c.Assert(req.Header["Content-MD5"], DeepEquals, "...")
+ c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
+}
+
+func (s *S) TestPutReader(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ buf := bytes.NewBufferString("content")
+ err := b.PutReader("name", buf, int64(buf.Len()), "content-type", s3.Private)
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
+ c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
+ //c.Assert(req.Header["Content-MD5"], Equals, "...")
+ c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
+}
+
+func (s *S) TestPutReaderHeader(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ buf := bytes.NewBufferString("content")
+ err := b.PutReaderHeader(
+ "name",
+ buf,
+ int64(buf.Len()),
+ map[string][]string{"Content-Type": {"content-type"}},
+ s3.Private,
+ )
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
+ c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
+ //c.Assert(req.Header["Content-MD5"], Equals, "...")
+ c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
+}
+
+func (s *S) TestCopy(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ err := b.Copy(
+ "old/file",
+ "new/file",
+ s3.Private,
+ )
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.URL.Path, Equals, "/bucket/new/file")
+ c.Assert(req.Header["X-Amz-Copy-Source"], DeepEquals, []string{"/bucket/old/file"})
+ c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
+}
+
+func (s *S) TestPlusInURL(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ err := b.Copy(
+ "dir/old+f?le",
+ "dir/new+f?le",
+ s3.Private,
+ )
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "PUT")
+ c.Assert(req.RequestURI, Equals, "/bucket/dir/new%2Bf%3Fle")
+ c.Assert(req.Header["X-Amz-Copy-Source"], DeepEquals, []string{"/bucket/dir/old%2Bf%3Fle"})
+ c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
+}
+
+// DelObject docs: http://goo.gl/APeTt
+
+func (s *S) TestDelObject(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ err := b.Del("name")
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "DELETE")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+}
+
+// Delete Multiple Objects docs: http://goo.gl/WvA5sj
+
+func (s *S) TestMultiDelObject(c *C) {
+ testServer.Response(200, nil, "")
+
+ b := s.s3.Bucket("bucket")
+ err := b.MultiDel([]string{"a", "b"})
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "POST")
+ c.Assert(req.URL.Path, Equals, "/bucket/")
+ c.Assert(req.RequestURI, Equals, "/bucket/?delete=")
+ c.Assert(req.Header["Content-Md5"], DeepEquals, []string{"nos/vZNvjGs17xIyjEFlwQ=="})
+ data, err := ioutil.ReadAll(req.Body)
+ req.Body.Close()
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Equals, "false")
+}
+
+// Bucket List Objects docs: http://goo.gl/YjQTc
+
+func (s *S) TestList(c *C) {
+ testServer.Response(200, nil, GetListResultDump1)
+
+ b := s.s3.Bucket("quotes")
+
+ data, err := b.List("N", "", "", 0)
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/quotes/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+ c.Assert(req.Form["prefix"], DeepEquals, []string{"N"})
+ c.Assert(req.Form["delimiter"], DeepEquals, []string{""})
+ c.Assert(req.Form["marker"], DeepEquals, []string{""})
+ c.Assert(req.Form["max-keys"], DeepEquals, []string(nil))
+
+ c.Assert(data.Name, Equals, "quotes")
+ c.Assert(data.Prefix, Equals, "N")
+ c.Assert(data.IsTruncated, Equals, false)
+ c.Assert(len(data.Contents), Equals, 2)
+
+ c.Assert(data.Contents[0].Key, Equals, "Nelson")
+ c.Assert(data.Contents[0].LastModified, Equals, "2006-01-01T12:00:00.000Z")
+ c.Assert(data.Contents[0].ETag, Equals, `"828ef3fdfa96f00ad9f27c383fc9ac7f"`)
+ c.Assert(data.Contents[0].Size, Equals, int64(5))
+ c.Assert(data.Contents[0].StorageClass, Equals, "STANDARD")
+ c.Assert(data.Contents[0].Owner.ID, Equals, "bcaf161ca5fb16fd081034f")
+ c.Assert(data.Contents[0].Owner.DisplayName, Equals, "webfile")
+
+ c.Assert(data.Contents[1].Key, Equals, "Neo")
+ c.Assert(data.Contents[1].LastModified, Equals, "2006-01-01T12:00:00.000Z")
+ c.Assert(data.Contents[1].ETag, Equals, `"828ef3fdfa96f00ad9f27c383fc9ac7f"`)
+ c.Assert(data.Contents[1].Size, Equals, int64(4))
+ c.Assert(data.Contents[1].StorageClass, Equals, "STANDARD")
+ c.Assert(data.Contents[1].Owner.ID, Equals, "bcaf1ffd86a5fb16fd081034f")
+ c.Assert(data.Contents[1].Owner.DisplayName, Equals, "webfile")
+}
+
+func (s *S) TestListWithDelimiter(c *C) {
+ testServer.Response(200, nil, GetListResultDump2)
+
+ b := s.s3.Bucket("quotes")
+
+ data, err := b.List("photos/2006/", "/", "some-marker", 1000)
+ c.Assert(err, IsNil)
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "GET")
+ c.Assert(req.URL.Path, Equals, "/quotes/")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+ c.Assert(req.Form["prefix"], DeepEquals, []string{"photos/2006/"})
+ c.Assert(req.Form["delimiter"], DeepEquals, []string{"/"})
+ c.Assert(req.Form["marker"], DeepEquals, []string{"some-marker"})
+ c.Assert(req.Form["max-keys"], DeepEquals, []string{"1000"})
+
+ c.Assert(data.Name, Equals, "example-bucket")
+ c.Assert(data.Prefix, Equals, "photos/2006/")
+ c.Assert(data.Delimiter, Equals, "/")
+ c.Assert(data.Marker, Equals, "some-marker")
+ c.Assert(data.IsTruncated, Equals, false)
+ c.Assert(len(data.Contents), Equals, 0)
+ c.Assert(data.CommonPrefixes, DeepEquals, []string{"photos/2006/feb/", "photos/2006/jan/"})
+}
+
+func (s *S) TestGetKey(c *C) {
+ testServer.Response(200, GetKeyHeaderDump, "")
+
+ b := s.s3.Bucket("bucket")
+ key, err := b.GetKey("name")
+
+ req := testServer.WaitRequest()
+ c.Assert(req.Method, Equals, "HEAD")
+ c.Assert(req.URL.Path, Equals, "/bucket/name")
+ c.Assert(req.Header["Date"], Not(Equals), "")
+
+ c.Assert(err, IsNil)
+ c.Assert(key.Key, Equals, "name")
+ c.Assert(key.LastModified, Equals, GetKeyHeaderDump["Last-Modified"])
+ c.Assert(key.Size, Equals, int64(434234))
+ c.Assert(key.ETag, Equals, GetKeyHeaderDump["ETag"])
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3i_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3i_test.go
new file mode 100644
index 00000000..24f9ad45
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3i_test.go
@@ -0,0 +1,615 @@
+package s3_test
+
+import (
+ "bytes"
+ "crypto/md5"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "strings"
+
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/s3"
+ "github.com/mitchellh/goamz/testutil"
+ . "github.com/motain/gocheck"
+ "net"
+ "sort"
+ "time"
+)
+
+// AmazonServer represents an Amazon S3 server.
+type AmazonServer struct {
+ auth aws.Auth
+}
+
+func (s *AmazonServer) SetUp(c *C) {
+ auth, err := aws.EnvAuth()
+ if err != nil {
+ c.Fatal(err.Error())
+ }
+ s.auth = auth
+}
+
+var _ = Suite(&AmazonClientSuite{Region: aws.USEast})
+var _ = Suite(&AmazonClientSuite{Region: aws.EUWest})
+var _ = Suite(&AmazonDomainClientSuite{Region: aws.USEast})
+
+// AmazonClientSuite tests the client against a live S3 server.
+type AmazonClientSuite struct {
+ aws.Region
+ srv AmazonServer
+ ClientTests
+}
+
+func (s *AmazonClientSuite) SetUpSuite(c *C) {
+ if !testutil.Amazon {
+ c.Skip("live tests against AWS disabled (no -amazon)")
+ }
+ s.srv.SetUp(c)
+ s.s3 = s3.New(s.srv.auth, s.Region)
+ // In case tests were interrupted in the middle before.
+ s.ClientTests.Cleanup()
+}
+
+func (s *AmazonClientSuite) TearDownTest(c *C) {
+ s.ClientTests.Cleanup()
+}
+
+// AmazonDomainClientSuite tests the client against a live S3
+// server using bucket names in the endpoint domain name rather
+// than the request path.
+type AmazonDomainClientSuite struct {
+ aws.Region
+ srv AmazonServer
+ ClientTests
+}
+
+func (s *AmazonDomainClientSuite) SetUpSuite(c *C) {
+ if !testutil.Amazon {
+ c.Skip("live tests against AWS disabled (no -amazon)")
+ }
+ s.srv.SetUp(c)
+ region := s.Region
+ region.S3BucketEndpoint = "https://${bucket}.s3.amazonaws.com"
+ s.s3 = s3.New(s.srv.auth, region)
+ s.ClientTests.Cleanup()
+}
+
+func (s *AmazonDomainClientSuite) TearDownTest(c *C) {
+ s.ClientTests.Cleanup()
+}
+
+// ClientTests defines integration tests designed to test the client.
+// It is not used as a test suite in itself, but embedded within
+// another type.
+type ClientTests struct {
+ s3 *s3.S3
+ authIsBroken bool
+}
+
+func (s *ClientTests) Cleanup() {
+ killBucket(testBucket(s.s3))
+}
+
+func testBucket(s *s3.S3) *s3.Bucket {
+ // Watch out! If this function is corrupted and made to match with something
+ // people own, killBucket will happily remove *everything* inside the bucket.
+ key := s.Auth.AccessKey
+ if len(key) >= 8 {
+ key = s.Auth.AccessKey[:8]
+ }
+ return s.Bucket(fmt.Sprintf("goamz-%s-%s", s.Region.Name, key))
+}
+
+var attempts = aws.AttemptStrategy{
+ Min: 5,
+ Total: 20 * time.Second,
+ Delay: 100 * time.Millisecond,
+}
+
+func killBucket(b *s3.Bucket) {
+ var err error
+ for attempt := attempts.Start(); attempt.Next(); {
+ err = b.DelBucket()
+ if err == nil {
+ return
+ }
+ if _, ok := err.(*net.DNSError); ok {
+ return
+ }
+ e, ok := err.(*s3.Error)
+ if ok && e.Code == "NoSuchBucket" {
+ return
+ }
+ if ok && e.Code == "BucketNotEmpty" {
+ // Errors are ignored here. Just retry.
+ resp, err := b.List("", "", "", 1000)
+ if err == nil {
+ for _, key := range resp.Contents {
+ _ = b.Del(key.Key)
+ }
+ }
+ multis, _, _ := b.ListMulti("", "")
+ for _, m := range multis {
+ _ = m.Abort()
+ }
+ }
+ }
+ message := "cannot delete test bucket"
+ if err != nil {
+ message += ": " + err.Error()
+ }
+ panic(message)
+}
+
+func get(url string) ([]byte, error) {
+ for attempt := attempts.Start(); attempt.Next(); {
+ resp, err := http.Get(url)
+ if err != nil {
+ if attempt.HasNext() {
+ continue
+ }
+ return nil, err
+ }
+ data, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ if attempt.HasNext() {
+ continue
+ }
+ return nil, err
+ }
+ return data, err
+ }
+ panic("unreachable")
+}
+
+func (s *ClientTests) TestBasicFunctionality(c *C) {
+ b := testBucket(s.s3)
+ err := b.PutBucket(s3.PublicRead)
+ c.Assert(err, IsNil)
+
+ err = b.Put("name", []byte("yo!"), "text/plain", s3.PublicRead)
+ c.Assert(err, IsNil)
+ defer b.Del("name")
+
+ data, err := b.Get("name")
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Equals, "yo!")
+
+ data, err = get(b.URL("name"))
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Equals, "yo!")
+
+ buf := bytes.NewBufferString("hey!")
+ err = b.PutReader("name2", buf, int64(buf.Len()), "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+ defer b.Del("name2")
+
+ rc, err := b.GetReader("name2")
+ c.Assert(err, IsNil)
+ data, err = ioutil.ReadAll(rc)
+ c.Check(err, IsNil)
+ c.Check(string(data), Equals, "hey!")
+ rc.Close()
+
+ data, err = get(b.SignedURL("name2", time.Now().Add(time.Hour)))
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Equals, "hey!")
+
+ if !s.authIsBroken {
+ data, err = get(b.SignedURL("name2", time.Now().Add(-time.Hour)))
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Matches, "(?s).*AccessDenied.*")
+ }
+
+ err = b.DelBucket()
+ c.Assert(err, NotNil)
+
+ s3err, ok := err.(*s3.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(s3err.Code, Equals, "BucketNotEmpty")
+ c.Assert(s3err.BucketName, Equals, b.Name)
+ c.Assert(s3err.Message, Equals, "The bucket you tried to delete is not empty")
+
+ err = b.Del("name")
+ c.Assert(err, IsNil)
+ err = b.Del("name2")
+ c.Assert(err, IsNil)
+
+ err = b.DelBucket()
+ c.Assert(err, IsNil)
+}
+
+func (s *ClientTests) TestCopy(c *C) {
+ b := testBucket(s.s3)
+ err := b.PutBucket(s3.PublicRead)
+
+ err = b.Put("name+1", []byte("yo!"), "text/plain", s3.PublicRead)
+ c.Assert(err, IsNil)
+ defer b.Del("name+1")
+
+ err = b.Copy("name+1", "name+2", s3.PublicRead)
+ c.Assert(err, IsNil)
+ defer b.Del("name+2")
+
+ data, err := b.Get("name+2")
+ c.Assert(err, IsNil)
+ c.Assert(string(data), Equals, "yo!")
+
+ err = b.Del("name+1")
+ c.Assert(err, IsNil)
+ err = b.Del("name+2")
+ c.Assert(err, IsNil)
+
+ err = b.DelBucket()
+ c.Assert(err, IsNil)
+}
+
+func (s *ClientTests) TestGetNotFound(c *C) {
+ b := s.s3.Bucket("goamz-" + s.s3.Auth.AccessKey)
+ data, err := b.Get("non-existent")
+
+ s3err, _ := err.(*s3.Error)
+ c.Assert(s3err, NotNil)
+ c.Assert(s3err.StatusCode, Equals, 404)
+ c.Assert(s3err.Code, Equals, "NoSuchBucket")
+ c.Assert(s3err.Message, Equals, "The specified bucket does not exist")
+ c.Assert(data, IsNil)
+}
+
+// Communicate with all endpoints to see if they are alive.
+func (s *ClientTests) TestRegions(c *C) {
+ errs := make(chan error, len(aws.Regions))
+ for _, region := range aws.Regions {
+ go func(r aws.Region) {
+ s := s3.New(s.s3.Auth, r)
+ b := s.Bucket("goamz-" + s.Auth.AccessKey)
+ _, err := b.Get("non-existent")
+ errs <- err
+ }(region)
+ }
+ for _ = range aws.Regions {
+ err := <-errs
+ if err != nil {
+ s3_err, ok := err.(*s3.Error)
+ if ok {
+ c.Check(s3_err.Code, Matches, "NoSuchBucket")
+ } else if _, ok = err.(*net.DNSError); ok {
+ // Okay as well.
+ } else {
+ c.Errorf("Non-S3 error: %s", err)
+ }
+ } else {
+ c.Errorf("Test should have errored but it seems to have succeeded")
+ }
+ }
+}
+
+var objectNames = []string{
+ "index.html",
+ "index2.html",
+ "photos/2006/February/sample2.jpg",
+ "photos/2006/February/sample3.jpg",
+ "photos/2006/February/sample4.jpg",
+ "photos/2006/January/sample.jpg",
+ "test/bar",
+ "test/foo",
+}
+
+func keys(names ...string) []s3.Key {
+ ks := make([]s3.Key, len(names))
+ for i, name := range names {
+ ks[i].Key = name
+ }
+ return ks
+}
+
+// As the ListResp specifies all the parameters to the
+// request too, we use it to specify request parameters
+// and expected results. The Contents field is
+// used only for the key names inside it.
+var listTests = []s3.ListResp{
+ // normal list.
+ {
+ Contents: keys(objectNames...),
+ }, {
+ Marker: objectNames[0],
+ Contents: keys(objectNames[1:]...),
+ }, {
+ Marker: objectNames[0] + "a",
+ Contents: keys(objectNames[1:]...),
+ }, {
+ Marker: "z",
+ },
+
+ // limited results.
+ {
+ MaxKeys: 2,
+ Contents: keys(objectNames[0:2]...),
+ IsTruncated: true,
+ }, {
+ MaxKeys: 2,
+ Marker: objectNames[0],
+ Contents: keys(objectNames[1:3]...),
+ IsTruncated: true,
+ }, {
+ MaxKeys: 2,
+ Marker: objectNames[len(objectNames)-2],
+ Contents: keys(objectNames[len(objectNames)-1:]...),
+ },
+
+ // with delimiter
+ {
+ Delimiter: "/",
+ CommonPrefixes: []string{"photos/", "test/"},
+ Contents: keys("index.html", "index2.html"),
+ }, {
+ Delimiter: "/",
+ Prefix: "photos/2006/",
+ CommonPrefixes: []string{"photos/2006/February/", "photos/2006/January/"},
+ }, {
+ Delimiter: "/",
+ Prefix: "t",
+ CommonPrefixes: []string{"test/"},
+ }, {
+ Delimiter: "/",
+ MaxKeys: 1,
+ Contents: keys("index.html"),
+ IsTruncated: true,
+ }, {
+ Delimiter: "/",
+ MaxKeys: 1,
+ Marker: "index2.html",
+ CommonPrefixes: []string{"photos/"},
+ IsTruncated: true,
+ }, {
+ Delimiter: "/",
+ MaxKeys: 1,
+ Marker: "photos/",
+ CommonPrefixes: []string{"test/"},
+ IsTruncated: false,
+ }, {
+ Delimiter: "Feb",
+ CommonPrefixes: []string{"photos/2006/Feb"},
+ Contents: keys("index.html", "index2.html", "photos/2006/January/sample.jpg", "test/bar", "test/foo"),
+ },
+}
+
+func (s *ClientTests) TestDoublePutBucket(c *C) {
+ b := testBucket(s.s3)
+ err := b.PutBucket(s3.PublicRead)
+ c.Assert(err, IsNil)
+
+ err = b.PutBucket(s3.PublicRead)
+ if err != nil {
+ c.Assert(err, FitsTypeOf, new(s3.Error))
+ c.Assert(err.(*s3.Error).Code, Equals, "BucketAlreadyOwnedByYou")
+ }
+}
+
+func (s *ClientTests) TestBucketList(c *C) {
+ b := testBucket(s.s3)
+ err := b.PutBucket(s3.Private)
+ c.Assert(err, IsNil)
+
+ objData := make(map[string][]byte)
+ for i, path := range objectNames {
+ data := []byte(strings.Repeat("a", i))
+ err := b.Put(path, data, "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+ defer b.Del(path)
+ objData[path] = data
+ }
+
+ for i, t := range listTests {
+ c.Logf("test %d", i)
+ resp, err := b.List(t.Prefix, t.Delimiter, t.Marker, t.MaxKeys)
+ c.Assert(err, IsNil)
+ c.Check(resp.Name, Equals, b.Name)
+ c.Check(resp.Delimiter, Equals, t.Delimiter)
+ c.Check(resp.IsTruncated, Equals, t.IsTruncated)
+ c.Check(resp.CommonPrefixes, DeepEquals, t.CommonPrefixes)
+ checkContents(c, resp.Contents, objData, t.Contents)
+ }
+}
+
+func etag(data []byte) string {
+ sum := md5.New()
+ sum.Write(data)
+ return fmt.Sprintf(`"%x"`, sum.Sum(nil))
+}
+
+func checkContents(c *C, contents []s3.Key, data map[string][]byte, expected []s3.Key) {
+ c.Assert(contents, HasLen, len(expected))
+ for i, k := range contents {
+ c.Check(k.Key, Equals, expected[i].Key)
+ // TODO mtime
+ c.Check(k.Size, Equals, int64(len(data[k.Key])))
+ c.Check(k.ETag, Equals, etag(data[k.Key]))
+ }
+}
+
+func (s *ClientTests) TestMultiInitPutList(c *C) {
+ b := testBucket(s.s3)
+ err := b.PutBucket(s3.Private)
+ c.Assert(err, IsNil)
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+ c.Assert(multi.UploadId, Matches, ".+")
+ defer multi.Abort()
+
+ var sent []s3.Part
+
+ for i := 0; i < 5; i++ {
+ p, err := multi.PutPart(i+1, strings.NewReader(fmt.Sprintf("", i+1)))
+ c.Assert(err, IsNil)
+ c.Assert(p.N, Equals, i+1)
+ c.Assert(p.Size, Equals, int64(8))
+ c.Assert(p.ETag, Matches, ".+")
+ sent = append(sent, p)
+ }
+
+ s3.SetListPartsMax(2)
+
+ parts, err := multi.ListParts()
+ c.Assert(err, IsNil)
+ c.Assert(parts, HasLen, len(sent))
+ for i := range parts {
+ c.Assert(parts[i].N, Equals, sent[i].N)
+ c.Assert(parts[i].Size, Equals, sent[i].Size)
+ c.Assert(parts[i].ETag, Equals, sent[i].ETag)
+ }
+
+ err = multi.Complete(parts)
+ s3err, failed := err.(*s3.Error)
+ c.Assert(failed, Equals, true)
+ c.Assert(s3err.Code, Equals, "EntityTooSmall")
+
+ err = multi.Abort()
+ c.Assert(err, IsNil)
+ _, err = multi.ListParts()
+ s3err, ok := err.(*s3.Error)
+ c.Assert(ok, Equals, true)
+ c.Assert(s3err.Code, Equals, "NoSuchUpload")
+}
+
+// This may take a minute or more due to the minimum size accepted S3
+// on multipart upload parts.
+func (s *ClientTests) TestMultiComplete(c *C) {
+ b := testBucket(s.s3)
+ err := b.PutBucket(s3.Private)
+ c.Assert(err, IsNil)
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+ c.Assert(multi.UploadId, Matches, ".+")
+ defer multi.Abort()
+
+ // Minimum size S3 accepts for all but the last part is 5MB.
+ data1 := make([]byte, 5*1024*1024)
+ data2 := []byte("")
+
+ part1, err := multi.PutPart(1, bytes.NewReader(data1))
+ c.Assert(err, IsNil)
+ part2, err := multi.PutPart(2, bytes.NewReader(data2))
+ c.Assert(err, IsNil)
+
+ // Purposefully reversed. The order requirement must be handled.
+ err = multi.Complete([]s3.Part{part2, part1})
+ c.Assert(err, IsNil)
+
+ data, err := b.Get("multi")
+ c.Assert(err, IsNil)
+
+ c.Assert(len(data), Equals, len(data1)+len(data2))
+ for i := range data1 {
+ if data[i] != data1[i] {
+ c.Fatalf("uploaded object at byte %d: want %d, got %d", data1[i], data[i])
+ }
+ }
+ c.Assert(string(data[len(data1):]), Equals, string(data2))
+}
+
+type multiList []*s3.Multi
+
+func (l multiList) Len() int { return len(l) }
+func (l multiList) Less(i, j int) bool { return l[i].Key < l[j].Key }
+func (l multiList) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
+
+func (s *ClientTests) TestListMulti(c *C) {
+ b := testBucket(s.s3)
+ err := b.PutBucket(s3.Private)
+ c.Assert(err, IsNil)
+
+ // Ensure an empty state before testing its behavior.
+ multis, _, err := b.ListMulti("", "")
+ for _, m := range multis {
+ err := m.Abort()
+ c.Assert(err, IsNil)
+ }
+
+ keys := []string{
+ "a/multi2",
+ "a/multi3",
+ "b/multi4",
+ "multi1",
+ }
+ for _, key := range keys {
+ m, err := b.InitMulti(key, "", s3.Private)
+ c.Assert(err, IsNil)
+ defer m.Abort()
+ }
+
+ // Amazon's implementation of the multiple-request listing for
+ // multipart uploads in progress seems broken in multiple ways.
+ // (next tokens are not provided, etc).
+ //s3.SetListMultiMax(2)
+
+ multis, prefixes, err := b.ListMulti("", "")
+ c.Assert(err, IsNil)
+ for attempt := attempts.Start(); attempt.Next() && len(multis) < len(keys); {
+ multis, prefixes, err = b.ListMulti("", "")
+ c.Assert(err, IsNil)
+ }
+ sort.Sort(multiList(multis))
+ c.Assert(prefixes, IsNil)
+ var gotKeys []string
+ for _, m := range multis {
+ gotKeys = append(gotKeys, m.Key)
+ }
+ c.Assert(gotKeys, DeepEquals, keys)
+ for _, m := range multis {
+ c.Assert(m.Bucket, Equals, b)
+ c.Assert(m.UploadId, Matches, ".+")
+ }
+
+ multis, prefixes, err = b.ListMulti("", "/")
+ for attempt := attempts.Start(); attempt.Next() && len(prefixes) < 2; {
+ multis, prefixes, err = b.ListMulti("", "")
+ c.Assert(err, IsNil)
+ }
+ c.Assert(err, IsNil)
+ c.Assert(prefixes, DeepEquals, []string{"a/", "b/"})
+ c.Assert(multis, HasLen, 1)
+ c.Assert(multis[0].Bucket, Equals, b)
+ c.Assert(multis[0].Key, Equals, "multi1")
+ c.Assert(multis[0].UploadId, Matches, ".+")
+
+ for attempt := attempts.Start(); attempt.Next() && len(multis) < 2; {
+ multis, prefixes, err = b.ListMulti("", "")
+ c.Assert(err, IsNil)
+ }
+ multis, prefixes, err = b.ListMulti("a/", "/")
+ c.Assert(err, IsNil)
+ c.Assert(prefixes, IsNil)
+ c.Assert(multis, HasLen, 2)
+ c.Assert(multis[0].Bucket, Equals, b)
+ c.Assert(multis[0].Key, Equals, "a/multi2")
+ c.Assert(multis[0].UploadId, Matches, ".+")
+ c.Assert(multis[1].Bucket, Equals, b)
+ c.Assert(multis[1].Key, Equals, "a/multi3")
+ c.Assert(multis[1].UploadId, Matches, ".+")
+}
+
+func (s *ClientTests) TestMultiPutAllZeroLength(c *C) {
+ b := testBucket(s.s3)
+ err := b.PutBucket(s3.Private)
+ c.Assert(err, IsNil)
+
+ multi, err := b.InitMulti("multi", "text/plain", s3.Private)
+ c.Assert(err, IsNil)
+ defer multi.Abort()
+
+ // This tests an edge case. Amazon requires at least one
+ // part for multiprat uploads to work, even the part is empty.
+ parts, err := multi.PutAll(strings.NewReader(""), 5*1024*1024)
+ c.Assert(err, IsNil)
+ c.Assert(parts, HasLen, 1)
+ c.Assert(parts[0].Size, Equals, int64(0))
+ c.Assert(parts[0].ETag, Equals, `"d41d8cd98f00b204e9800998ecf8427e"`)
+
+ err = multi.Complete(parts)
+ c.Assert(err, IsNil)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3t_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3t_test.go
new file mode 100644
index 00000000..d3d49966
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3t_test.go
@@ -0,0 +1,79 @@
+package s3_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/s3"
+ "github.com/mitchellh/goamz/s3/s3test"
+ . "github.com/motain/gocheck"
+)
+
+type LocalServer struct {
+ auth aws.Auth
+ region aws.Region
+ srv *s3test.Server
+ config *s3test.Config
+}
+
+func (s *LocalServer) SetUp(c *C) {
+ srv, err := s3test.NewServer(s.config)
+ c.Assert(err, IsNil)
+ c.Assert(srv, NotNil)
+
+ s.srv = srv
+ s.region = aws.Region{
+ Name: "faux-region-1",
+ S3Endpoint: srv.URL(),
+ S3LocationConstraint: true, // s3test server requires a LocationConstraint
+ }
+}
+
+// LocalServerSuite defines tests that will run
+// against the local s3test server. It includes
+// selected tests from ClientTests;
+// when the s3test functionality is sufficient, it should
+// include all of them, and ClientTests can be simply embedded.
+type LocalServerSuite struct {
+ srv LocalServer
+ clientTests ClientTests
+}
+
+var (
+ // run tests twice, once in us-east-1 mode, once not.
+ _ = Suite(&LocalServerSuite{})
+ _ = Suite(&LocalServerSuite{
+ srv: LocalServer{
+ config: &s3test.Config{
+ Send409Conflict: true,
+ },
+ },
+ })
+)
+
+func (s *LocalServerSuite) SetUpSuite(c *C) {
+ s.srv.SetUp(c)
+ s.clientTests.s3 = s3.New(s.srv.auth, s.srv.region)
+
+ // TODO Sadly the fake server ignores auth completely right now. :-(
+ s.clientTests.authIsBroken = true
+ s.clientTests.Cleanup()
+}
+
+func (s *LocalServerSuite) TearDownTest(c *C) {
+ s.clientTests.Cleanup()
+}
+
+func (s *LocalServerSuite) TestBasicFunctionality(c *C) {
+ s.clientTests.TestBasicFunctionality(c)
+}
+
+func (s *LocalServerSuite) TestGetNotFound(c *C) {
+ s.clientTests.TestGetNotFound(c)
+}
+
+func (s *LocalServerSuite) TestBucketList(c *C) {
+ s.clientTests.TestBucketList(c)
+}
+
+func (s *LocalServerSuite) TestDoublePutBucket(c *C) {
+ s.clientTests.TestDoublePutBucket(c)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3test/server.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3test/server.go
new file mode 100644
index 00000000..827d680d
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/s3test/server.go
@@ -0,0 +1,628 @@
+package s3test
+
+import (
+ "bytes"
+ "crypto/md5"
+ "encoding/hex"
+ "encoding/xml"
+ "fmt"
+ "github.com/mitchellh/goamz/s3"
+ "io"
+ "io/ioutil"
+ "log"
+ "net"
+ "net/http"
+ "net/url"
+ "regexp"
+ "sort"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+)
+
+const debug = false
+
+type s3Error struct {
+ statusCode int
+ XMLName struct{} `xml:"Error"`
+ Code string
+ Message string
+ BucketName string
+ RequestId string
+ HostId string
+}
+
+type action struct {
+ srv *Server
+ w http.ResponseWriter
+ req *http.Request
+ reqId string
+}
+
+// Config controls the internal behaviour of the Server. A nil config is the default
+// and behaves as if all configurations assume their default behaviour. Once passed
+// to NewServer, the configuration must not be modified.
+type Config struct {
+ // Send409Conflict controls how the Server will respond to calls to PUT on a
+ // previously existing bucket. The default is false, and corresponds to the
+ // us-east-1 s3 enpoint. Setting this value to true emulates the behaviour of
+ // all other regions.
+ // http://docs.amazonwebservices.com/AmazonS3/latest/API/ErrorResponses.html
+ Send409Conflict bool
+}
+
+func (c *Config) send409Conflict() bool {
+ if c != nil {
+ return c.Send409Conflict
+ }
+ return false
+}
+
+// Server is a fake S3 server for testing purposes.
+// All of the data for the server is kept in memory.
+type Server struct {
+ url string
+ reqId int
+ listener net.Listener
+ mu sync.Mutex
+ buckets map[string]*bucket
+ config *Config
+}
+
+type bucket struct {
+ name string
+ acl s3.ACL
+ ctime time.Time
+ objects map[string]*object
+}
+
+type object struct {
+ name string
+ mtime time.Time
+ meta http.Header // metadata to return with requests.
+ checksum []byte // also held as Content-MD5 in meta.
+ data []byte
+}
+
+// A resource encapsulates the subject of an HTTP request.
+// The resource referred to may or may not exist
+// when the request is made.
+type resource interface {
+ put(a *action) interface{}
+ get(a *action) interface{}
+ post(a *action) interface{}
+ delete(a *action) interface{}
+}
+
+func NewServer(config *Config) (*Server, error) {
+ l, err := net.Listen("tcp", "localhost:0")
+ if err != nil {
+ return nil, fmt.Errorf("cannot listen on localhost: %v", err)
+ }
+ srv := &Server{
+ listener: l,
+ url: "http://" + l.Addr().String(),
+ buckets: make(map[string]*bucket),
+ config: config,
+ }
+ go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ srv.serveHTTP(w, req)
+ }))
+ return srv, nil
+}
+
+// Quit closes down the server.
+func (srv *Server) Quit() {
+ srv.listener.Close()
+}
+
+// URL returns a URL for the server.
+func (srv *Server) URL() string {
+ return srv.url
+}
+
+func fatalf(code int, codeStr string, errf string, a ...interface{}) {
+ panic(&s3Error{
+ statusCode: code,
+ Code: codeStr,
+ Message: fmt.Sprintf(errf, a...),
+ })
+}
+
+// serveHTTP serves the S3 protocol.
+func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
+ // ignore error from ParseForm as it's usually spurious.
+ req.ParseForm()
+
+ srv.mu.Lock()
+ defer srv.mu.Unlock()
+
+ if debug {
+ log.Printf("s3test %q %q", req.Method, req.URL)
+ }
+ a := &action{
+ srv: srv,
+ w: w,
+ req: req,
+ reqId: fmt.Sprintf("%09X", srv.reqId),
+ }
+ srv.reqId++
+
+ var r resource
+ defer func() {
+ switch err := recover().(type) {
+ case *s3Error:
+ switch r := r.(type) {
+ case objectResource:
+ err.BucketName = r.bucket.name
+ case bucketResource:
+ err.BucketName = r.name
+ }
+ err.RequestId = a.reqId
+ // TODO HostId
+ w.Header().Set("Content-Type", `xml version="1.0" encoding="UTF-8"`)
+ w.WriteHeader(err.statusCode)
+ xmlMarshal(w, err)
+ case nil:
+ default:
+ panic(err)
+ }
+ }()
+
+ r = srv.resourceForURL(req.URL)
+
+ var resp interface{}
+ switch req.Method {
+ case "PUT":
+ resp = r.put(a)
+ case "GET", "HEAD":
+ resp = r.get(a)
+ case "DELETE":
+ resp = r.delete(a)
+ case "POST":
+ resp = r.post(a)
+ default:
+ fatalf(400, "MethodNotAllowed", "unknown http request method %q", req.Method)
+ }
+ if resp != nil && req.Method != "HEAD" {
+ xmlMarshal(w, resp)
+ }
+}
+
+// xmlMarshal is the same as xml.Marshal except that
+// it panics on error. The marshalling should not fail,
+// but we want to know if it does.
+func xmlMarshal(w io.Writer, x interface{}) {
+ if err := xml.NewEncoder(w).Encode(x); err != nil {
+ panic(fmt.Errorf("error marshalling %#v: %v", x, err))
+ }
+}
+
+// In a fully implemented test server, each of these would have
+// its own resource type.
+var unimplementedBucketResourceNames = map[string]bool{
+ "acl": true,
+ "lifecycle": true,
+ "policy": true,
+ "location": true,
+ "logging": true,
+ "notification": true,
+ "versions": true,
+ "requestPayment": true,
+ "versioning": true,
+ "website": true,
+ "uploads": true,
+}
+
+var unimplementedObjectResourceNames = map[string]bool{
+ "uploadId": true,
+ "acl": true,
+ "torrent": true,
+ "uploads": true,
+}
+
+var pathRegexp = regexp.MustCompile("/(([^/]+)(/(.*))?)?")
+
+// resourceForURL returns a resource object for the given URL.
+func (srv *Server) resourceForURL(u *url.URL) (r resource) {
+ m := pathRegexp.FindStringSubmatch(u.Path)
+ if m == nil {
+ fatalf(404, "InvalidURI", "Couldn't parse the specified URI")
+ }
+ bucketName := m[2]
+ objectName := m[4]
+ if bucketName == "" {
+ return nullResource{} // root
+ }
+ b := bucketResource{
+ name: bucketName,
+ bucket: srv.buckets[bucketName],
+ }
+ q := u.Query()
+ if objectName == "" {
+ for name := range q {
+ if unimplementedBucketResourceNames[name] {
+ return nullResource{}
+ }
+ }
+ return b
+
+ }
+ if b.bucket == nil {
+ fatalf(404, "NoSuchBucket", "The specified bucket does not exist")
+ }
+ objr := objectResource{
+ name: objectName,
+ version: q.Get("versionId"),
+ bucket: b.bucket,
+ }
+ for name := range q {
+ if unimplementedObjectResourceNames[name] {
+ return nullResource{}
+ }
+ }
+ if obj := objr.bucket.objects[objr.name]; obj != nil {
+ objr.object = obj
+ }
+ return objr
+}
+
+// nullResource has error stubs for all resource methods.
+type nullResource struct{}
+
+func notAllowed() interface{} {
+ fatalf(400, "MethodNotAllowed", "The specified method is not allowed against this resource")
+ return nil
+}
+
+func (nullResource) put(a *action) interface{} { return notAllowed() }
+func (nullResource) get(a *action) interface{} { return notAllowed() }
+func (nullResource) post(a *action) interface{} { return notAllowed() }
+func (nullResource) delete(a *action) interface{} { return notAllowed() }
+
+const timeFormat = "2006-01-02T15:04:05.000Z07:00"
+
+type bucketResource struct {
+ name string
+ bucket *bucket // non-nil if the bucket already exists.
+}
+
+// GET on a bucket lists the objects in the bucket.
+// http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGET.html
+func (r bucketResource) get(a *action) interface{} {
+ if r.bucket == nil {
+ fatalf(404, "NoSuchBucket", "The specified bucket does not exist")
+ }
+ delimiter := a.req.Form.Get("delimiter")
+ marker := a.req.Form.Get("marker")
+ maxKeys := -1
+ if s := a.req.Form.Get("max-keys"); s != "" {
+ i, err := strconv.Atoi(s)
+ if err != nil || i < 0 {
+ fatalf(400, "invalid value for max-keys: %q", s)
+ }
+ maxKeys = i
+ }
+ prefix := a.req.Form.Get("prefix")
+ a.w.Header().Set("Content-Type", "application/xml")
+
+ if a.req.Method == "HEAD" {
+ return nil
+ }
+
+ var objs orderedObjects
+
+ // first get all matching objects and arrange them in alphabetical order.
+ for name, obj := range r.bucket.objects {
+ if strings.HasPrefix(name, prefix) {
+ objs = append(objs, obj)
+ }
+ }
+ sort.Sort(objs)
+
+ if maxKeys <= 0 {
+ maxKeys = 1000
+ }
+ resp := &s3.ListResp{
+ Name: r.bucket.name,
+ Prefix: prefix,
+ Delimiter: delimiter,
+ Marker: marker,
+ MaxKeys: maxKeys,
+ }
+
+ var prefixes []string
+ for _, obj := range objs {
+ if !strings.HasPrefix(obj.name, prefix) {
+ continue
+ }
+ name := obj.name
+ isPrefix := false
+ if delimiter != "" {
+ if i := strings.Index(obj.name[len(prefix):], delimiter); i >= 0 {
+ name = obj.name[:len(prefix)+i+len(delimiter)]
+ if prefixes != nil && prefixes[len(prefixes)-1] == name {
+ continue
+ }
+ isPrefix = true
+ }
+ }
+ if name <= marker {
+ continue
+ }
+ if len(resp.Contents)+len(prefixes) >= maxKeys {
+ resp.IsTruncated = true
+ break
+ }
+ if isPrefix {
+ prefixes = append(prefixes, name)
+ } else {
+ // Contents contains only keys not found in CommonPrefixes
+ resp.Contents = append(resp.Contents, obj.s3Key())
+ }
+ }
+ resp.CommonPrefixes = prefixes
+ return resp
+}
+
+// orderedObjects holds a slice of objects that can be sorted
+// by name.
+type orderedObjects []*object
+
+func (s orderedObjects) Len() int {
+ return len(s)
+}
+func (s orderedObjects) Swap(i, j int) {
+ s[i], s[j] = s[j], s[i]
+}
+func (s orderedObjects) Less(i, j int) bool {
+ return s[i].name < s[j].name
+}
+
+func (obj *object) s3Key() s3.Key {
+ return s3.Key{
+ Key: obj.name,
+ LastModified: obj.mtime.Format(timeFormat),
+ Size: int64(len(obj.data)),
+ ETag: fmt.Sprintf(`"%x"`, obj.checksum),
+ // TODO StorageClass
+ // TODO Owner
+ }
+}
+
+// DELETE on a bucket deletes the bucket if it's not empty.
+func (r bucketResource) delete(a *action) interface{} {
+ b := r.bucket
+ if b == nil {
+ fatalf(404, "NoSuchBucket", "The specified bucket does not exist")
+ }
+ if len(b.objects) > 0 {
+ fatalf(400, "BucketNotEmpty", "The bucket you tried to delete is not empty")
+ }
+ delete(a.srv.buckets, b.name)
+ return nil
+}
+
+// PUT on a bucket creates the bucket.
+// http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUT.html
+func (r bucketResource) put(a *action) interface{} {
+ var created bool
+ if r.bucket == nil {
+ if !validBucketName(r.name) {
+ fatalf(400, "InvalidBucketName", "The specified bucket is not valid")
+ }
+ if loc := locationConstraint(a); loc == "" {
+ fatalf(400, "InvalidRequets", "The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.")
+ }
+ // TODO validate acl
+ r.bucket = &bucket{
+ name: r.name,
+ // TODO default acl
+ objects: make(map[string]*object),
+ }
+ a.srv.buckets[r.name] = r.bucket
+ created = true
+ }
+ if !created && a.srv.config.send409Conflict() {
+ fatalf(409, "BucketAlreadyOwnedByYou", "Your previous request to create the named bucket succeeded and you already own it.")
+ }
+ r.bucket.acl = s3.ACL(a.req.Header.Get("x-amz-acl"))
+ return nil
+}
+
+func (bucketResource) post(a *action) interface{} {
+ fatalf(400, "Method", "bucket POST method not available")
+ return nil
+}
+
+// validBucketName returns whether name is a valid bucket name.
+// Here are the rules, from:
+// http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/BucketRestrictions.html
+//
+// Can contain lowercase letters, numbers, periods (.), underscores (_),
+// and dashes (-). You can use uppercase letters for buckets only in the
+// US Standard region.
+//
+// Must start with a number or letter
+//
+// Must be between 3 and 255 characters long
+//
+// There's one extra rule (Must not be formatted as an IP address (e.g., 192.168.5.4)
+// but the real S3 server does not seem to check that rule, so we will not
+// check it either.
+//
+func validBucketName(name string) bool {
+ if len(name) < 3 || len(name) > 255 {
+ return false
+ }
+ r := name[0]
+ if !(r >= '0' && r <= '9' || r >= 'a' && r <= 'z') {
+ return false
+ }
+ for _, r := range name {
+ switch {
+ case r >= '0' && r <= '9':
+ case r >= 'a' && r <= 'z':
+ case r == '_' || r == '-':
+ case r == '.':
+ default:
+ return false
+ }
+ }
+ return true
+}
+
+var responseParams = map[string]bool{
+ "content-type": true,
+ "content-language": true,
+ "expires": true,
+ "cache-control": true,
+ "content-disposition": true,
+ "content-encoding": true,
+}
+
+type objectResource struct {
+ name string
+ version string
+ bucket *bucket // always non-nil.
+ object *object // may be nil.
+}
+
+// GET on an object gets the contents of the object.
+// http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html
+func (objr objectResource) get(a *action) interface{} {
+ obj := objr.object
+ if obj == nil {
+ fatalf(404, "NoSuchKey", "The specified key does not exist.")
+ }
+ h := a.w.Header()
+ // add metadata
+ for name, d := range obj.meta {
+ h[name] = d
+ }
+ // override header values in response to request parameters.
+ for name, vals := range a.req.Form {
+ if strings.HasPrefix(name, "response-") {
+ name = name[len("response-"):]
+ if !responseParams[name] {
+ continue
+ }
+ h.Set(name, vals[0])
+ }
+ }
+ if r := a.req.Header.Get("Range"); r != "" {
+ fatalf(400, "NotImplemented", "range unimplemented")
+ }
+ // TODO Last-Modified-Since
+ // TODO If-Modified-Since
+ // TODO If-Unmodified-Since
+ // TODO If-Match
+ // TODO If-None-Match
+ // TODO Connection: close ??
+ // TODO x-amz-request-id
+ h.Set("Content-Length", fmt.Sprint(len(obj.data)))
+ h.Set("ETag", hex.EncodeToString(obj.checksum))
+ h.Set("Last-Modified", obj.mtime.Format(time.RFC1123))
+ if a.req.Method == "HEAD" {
+ return nil
+ }
+ // TODO avoid holding the lock when writing data.
+ _, err := a.w.Write(obj.data)
+ if err != nil {
+ // we can't do much except just log the fact.
+ log.Printf("error writing data: %v", err)
+ }
+ return nil
+}
+
+var metaHeaders = map[string]bool{
+ "Content-MD5": true,
+ "x-amz-acl": true,
+ "Content-Type": true,
+ "Content-Encoding": true,
+ "Content-Disposition": true,
+}
+
+// PUT on an object creates the object.
+func (objr objectResource) put(a *action) interface{} {
+ // TODO Cache-Control header
+ // TODO Expires header
+ // TODO x-amz-server-side-encryption
+ // TODO x-amz-storage-class
+
+ // TODO is this correct, or should we erase all previous metadata?
+ obj := objr.object
+ if obj == nil {
+ obj = &object{
+ name: objr.name,
+ meta: make(http.Header),
+ }
+ }
+
+ var expectHash []byte
+ if c := a.req.Header.Get("Content-MD5"); c != "" {
+ var err error
+ expectHash, err = hex.DecodeString(c)
+ if err != nil || len(expectHash) != md5.Size {
+ fatalf(400, "InvalidDigest", "The Content-MD5 you specified was invalid")
+ }
+ }
+ sum := md5.New()
+ // TODO avoid holding lock while reading data.
+ data, err := ioutil.ReadAll(io.TeeReader(a.req.Body, sum))
+ if err != nil {
+ fatalf(400, "TODO", "read error")
+ }
+ gotHash := sum.Sum(nil)
+ if expectHash != nil && bytes.Compare(gotHash, expectHash) != 0 {
+ fatalf(400, "BadDigest", "The Content-MD5 you specified did not match what we received")
+ }
+ if a.req.ContentLength >= 0 && int64(len(data)) != a.req.ContentLength {
+ fatalf(400, "IncompleteBody", "You did not provide the number of bytes specified by the Content-Length HTTP header")
+ }
+
+ // PUT request has been successful - save data and metadata
+ for key, values := range a.req.Header {
+ key = http.CanonicalHeaderKey(key)
+ if metaHeaders[key] || strings.HasPrefix(key, "X-Amz-Meta-") {
+ obj.meta[key] = values
+ }
+ }
+ obj.data = data
+ obj.checksum = gotHash
+ obj.mtime = time.Now()
+ objr.bucket.objects[objr.name] = obj
+ return nil
+}
+
+func (objr objectResource) delete(a *action) interface{} {
+ delete(objr.bucket.objects, objr.name)
+ return nil
+}
+
+func (objr objectResource) post(a *action) interface{} {
+ fatalf(400, "MethodNotAllowed", "The specified method is not allowed against this resource")
+ return nil
+}
+
+type CreateBucketConfiguration struct {
+ LocationConstraint string
+}
+
+// locationConstraint parses the request body (if present).
+// If there is no body, an empty string will be returned.
+func locationConstraint(a *action) string {
+ var body bytes.Buffer
+ if _, err := io.Copy(&body, a.req.Body); err != nil {
+ fatalf(400, "InvalidRequest", err.Error())
+ }
+ if body.Len() == 0 {
+ return ""
+ }
+ var loc CreateBucketConfiguration
+ if err := xml.NewDecoder(&body).Decode(&loc); err != nil {
+ fatalf(400, "InvalidRequest", err.Error())
+ }
+ return loc.LocationConstraint
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/sign.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/sign.go
new file mode 100644
index 00000000..8d2d7985
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/sign.go
@@ -0,0 +1,118 @@
+package s3
+
+import (
+ "crypto/hmac"
+ "crypto/sha1"
+ "encoding/base64"
+ "github.com/mitchellh/goamz/aws"
+ "log"
+ "sort"
+ "strings"
+)
+
+var b64 = base64.StdEncoding
+
+// ----------------------------------------------------------------------------
+// S3 signing (http://goo.gl/G1LrK)
+
+var s3ParamsToSign = map[string]bool{
+ "acl": true,
+ "location": true,
+ "logging": true,
+ "notification": true,
+ "partNumber": true,
+ "policy": true,
+ "requestPayment": true,
+ "torrent": true,
+ "uploadId": true,
+ "uploads": true,
+ "versionId": true,
+ "versioning": true,
+ "versions": true,
+ "response-content-type": true,
+ "response-content-language": true,
+ "response-expires": true,
+ "response-cache-control": true,
+ "response-content-disposition": true,
+ "response-content-encoding": true,
+}
+
+func sign(auth aws.Auth, method, canonicalPath string, params, headers map[string][]string) {
+ var md5, ctype, date, xamz string
+ var xamzDate bool
+ var sarray []string
+
+ // add security token
+ if auth.Token != "" {
+ headers["x-amz-security-token"] = []string{auth.Token}
+ }
+
+ for k, v := range headers {
+ k = strings.ToLower(k)
+ switch k {
+ case "content-md5":
+ md5 = v[0]
+ case "content-type":
+ ctype = v[0]
+ case "date":
+ if !xamzDate {
+ date = v[0]
+ }
+ default:
+ if strings.HasPrefix(k, "x-amz-") {
+ vall := strings.Join(v, ",")
+ sarray = append(sarray, k+":"+vall)
+ if k == "x-amz-date" {
+ xamzDate = true
+ date = ""
+ }
+ }
+ }
+ }
+ if len(sarray) > 0 {
+ sort.StringSlice(sarray).Sort()
+ xamz = strings.Join(sarray, "\n") + "\n"
+ }
+
+ expires := false
+ if v, ok := params["Expires"]; ok {
+ // Query string request authentication alternative.
+ expires = true
+ date = v[0]
+ params["AWSAccessKeyId"] = []string{auth.AccessKey}
+ }
+
+ sarray = sarray[0:0]
+ for k, v := range params {
+ if s3ParamsToSign[k] {
+ for _, vi := range v {
+ if vi == "" {
+ sarray = append(sarray, k)
+ } else {
+ // "When signing you do not encode these values."
+ sarray = append(sarray, k+"="+vi)
+ }
+ }
+ }
+ }
+ if len(sarray) > 0 {
+ sort.StringSlice(sarray).Sort()
+ canonicalPath = canonicalPath + "?" + strings.Join(sarray, "&")
+ }
+
+ payload := method + "\n" + md5 + "\n" + ctype + "\n" + date + "\n" + xamz + canonicalPath
+ hash := hmac.New(sha1.New, []byte(auth.SecretKey))
+ hash.Write([]byte(payload))
+ signature := make([]byte, b64.EncodedLen(hash.Size()))
+ b64.Encode(signature, hash.Sum(nil))
+
+ if expires {
+ params["Signature"] = []string{string(signature)}
+ } else {
+ headers["Authorization"] = []string{"AWS " + auth.AccessKey + ":" + string(signature)}
+ }
+ if debug {
+ log.Printf("Signature payload: %q", payload)
+ log.Printf("Signature: %q", signature)
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/sign_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/sign_test.go
new file mode 100644
index 00000000..9c19970d
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/s3/sign_test.go
@@ -0,0 +1,151 @@
+package s3_test
+
+import (
+ "github.com/mitchellh/goamz/aws"
+ "github.com/mitchellh/goamz/s3"
+ . "github.com/motain/gocheck"
+)
+
+// S3 ReST authentication docs: http://goo.gl/G1LrK
+
+var testAuth = aws.Auth{"0PN5J17HBGZHT7JJ3X82", "uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o", ""}
+
+func (s *S) TestSignExampleObjectGet(c *C) {
+ method := "GET"
+ path := "/johnsmith/photos/puppy.jpg"
+ headers := map[string][]string{
+ "Host": {"johnsmith.s3.amazonaws.com"},
+ "Date": {"Tue, 27 Mar 2007 19:36:42 +0000"},
+ }
+ s3.Sign(testAuth, method, path, nil, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:xXjDGYUmKxnwqr5KXNPGldn5LbA="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+}
+
+func (s *S) TestSignExampleObjectPut(c *C) {
+ method := "PUT"
+ path := "/johnsmith/photos/puppy.jpg"
+ headers := map[string][]string{
+ "Host": {"johnsmith.s3.amazonaws.com"},
+ "Date": {"Tue, 27 Mar 2007 21:15:45 +0000"},
+ "Content-Type": {"image/jpeg"},
+ "Content-Length": {"94328"},
+ }
+ s3.Sign(testAuth, method, path, nil, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:hcicpDDvL9SsO6AkvxqmIWkmOuQ="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+}
+
+func (s *S) TestSignExampleList(c *C) {
+ method := "GET"
+ path := "/johnsmith/"
+ params := map[string][]string{
+ "prefix": {"photos"},
+ "max-keys": {"50"},
+ "marker": {"puppy"},
+ }
+ headers := map[string][]string{
+ "Host": {"johnsmith.s3.amazonaws.com"},
+ "Date": {"Tue, 27 Mar 2007 19:42:41 +0000"},
+ "User-Agent": {"Mozilla/5.0"},
+ }
+ s3.Sign(testAuth, method, path, params, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:jsRt/rhG+Vtp88HrYL706QhE4w4="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+}
+
+func (s *S) TestSignExampleFetch(c *C) {
+ method := "GET"
+ path := "/johnsmith/"
+ params := map[string][]string{
+ "acl": {""},
+ }
+ headers := map[string][]string{
+ "Host": {"johnsmith.s3.amazonaws.com"},
+ "Date": {"Tue, 27 Mar 2007 19:44:46 +0000"},
+ }
+ s3.Sign(testAuth, method, path, params, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:thdUi9VAkzhkniLj96JIrOPGi0g="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+}
+
+func (s *S) TestSignExampleDelete(c *C) {
+ method := "DELETE"
+ path := "/johnsmith/photos/puppy.jpg"
+ params := map[string][]string{}
+ headers := map[string][]string{
+ "Host": {"s3.amazonaws.com"},
+ "Date": {"Tue, 27 Mar 2007 21:20:27 +0000"},
+ "User-Agent": {"dotnet"},
+ "x-amz-date": {"Tue, 27 Mar 2007 21:20:26 +0000"},
+ }
+ s3.Sign(testAuth, method, path, params, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:k3nL7gH3+PadhTEVn5Ip83xlYzk="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+}
+
+func (s *S) TestSignExampleUpload(c *C) {
+ method := "PUT"
+ path := "/static.johnsmith.net/db-backup.dat.gz"
+ params := map[string][]string{}
+ headers := map[string][]string{
+ "Host": {"static.johnsmith.net:8080"},
+ "Date": {"Tue, 27 Mar 2007 21:06:08 +0000"},
+ "User-Agent": {"curl/7.15.5"},
+ "x-amz-acl": {"public-read"},
+ "content-type": {"application/x-download"},
+ "Content-MD5": {"4gJE4saaMU4BqNR0kLY+lw=="},
+ "X-Amz-Meta-ReviewedBy": {"joe@johnsmith.net,jane@johnsmith.net"},
+ "X-Amz-Meta-FileChecksum": {"0x02661779"},
+ "X-Amz-Meta-ChecksumAlgorithm": {"crc32"},
+ "Content-Disposition": {"attachment; filename=database.dat"},
+ "Content-Encoding": {"gzip"},
+ "Content-Length": {"5913339"},
+ }
+ s3.Sign(testAuth, method, path, params, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:C0FlOtU8Ylb9KDTpZqYkZPX91iI="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+}
+
+func (s *S) TestSignExampleListAllMyBuckets(c *C) {
+ method := "GET"
+ path := "/"
+ headers := map[string][]string{
+ "Host": {"s3.amazonaws.com"},
+ "Date": {"Wed, 28 Mar 2007 01:29:59 +0000"},
+ }
+ s3.Sign(testAuth, method, path, nil, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:Db+gepJSUbZKwpx1FR0DLtEYoZA="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+}
+
+func (s *S) TestSignExampleUnicodeKeys(c *C) {
+ method := "GET"
+ path := "/dictionary/fran%C3%A7ais/pr%c3%a9f%c3%a8re"
+ headers := map[string][]string{
+ "Host": {"s3.amazonaws.com"},
+ "Date": {"Wed, 28 Mar 2007 01:49:49 +0000"},
+ }
+ s3.Sign(testAuth, method, path, nil, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:dxhSBHoI6eVSPcXJqEghlUzZMnY="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+}
+
+// Not included in AWS documentation
+
+func (s *S) TestSignWithIAMToken(c *C) {
+ method := "GET"
+ path := "/"
+ headers := map[string][]string{
+ "Host": {"s3.amazonaws.com"},
+ "Date": {"Wed, 28 Mar 2007 01:29:59 +0000"},
+ }
+
+ authWithToken := testAuth
+ authWithToken.Token = "totallysecret"
+
+ s3.Sign(authWithToken, method, path, nil, headers)
+ expected := "AWS 0PN5J17HBGZHT7JJ3X82:SJ0yQO7NpHyXJ7zkxY+/fGQ6aUw="
+ c.Assert(headers["Authorization"], DeepEquals, []string{expected})
+ c.Assert(headers["x-amz-security-token"], DeepEquals, []string{authWithToken.Token})
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/testutil/http.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/testutil/http.go
new file mode 100644
index 00000000..ccc570cd
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/testutil/http.go
@@ -0,0 +1,180 @@
+package testutil
+
+import (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "net"
+ "net/http"
+ "net/url"
+ "os"
+ "time"
+)
+
+type HTTPServer struct {
+ URL string
+ Timeout time.Duration
+ started bool
+ request chan *http.Request
+ response chan ResponseFunc
+}
+
+type Response struct {
+ Status int
+ Headers map[string]string
+ Body string
+}
+
+var DefaultClient = &http.Client{
+ Transport: &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ },
+}
+
+func NewHTTPServer() *HTTPServer {
+ return &HTTPServer{URL: "http://localhost:4444", Timeout: 5 * time.Second}
+}
+
+type ResponseFunc func(path string) Response
+
+func (s *HTTPServer) Start() {
+ if s.started {
+ return
+ }
+ s.started = true
+ s.request = make(chan *http.Request, 1024)
+ s.response = make(chan ResponseFunc, 1024)
+ u, err := url.Parse(s.URL)
+ if err != nil {
+ panic(err)
+ }
+ l, err := net.Listen("tcp", u.Host)
+ if err != nil {
+ panic(err)
+ }
+ go http.Serve(l, s)
+
+ s.Response(203, nil, "")
+ for {
+ // Wait for it to be up.
+ resp, err := http.Get(s.URL)
+ if err == nil && resp.StatusCode == 203 {
+ break
+ }
+ time.Sleep(1e8)
+ }
+ s.WaitRequest() // Consume dummy request.
+}
+
+// Flush discards all pending requests and responses.
+func (s *HTTPServer) Flush() {
+ for {
+ select {
+ case <-s.request:
+ case <-s.response:
+ default:
+ return
+ }
+ }
+}
+
+func body(req *http.Request) string {
+ data, err := ioutil.ReadAll(req.Body)
+ if err != nil {
+ panic(err)
+ }
+ return string(data)
+}
+
+func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
+ req.ParseMultipartForm(1e6)
+ data, err := ioutil.ReadAll(req.Body)
+ if err != nil {
+ panic(err)
+ }
+ req.Body = ioutil.NopCloser(bytes.NewBuffer(data))
+ s.request <- req
+ var resp Response
+ select {
+ case respFunc := <-s.response:
+ resp = respFunc(req.URL.Path)
+ case <-time.After(s.Timeout):
+ const msg = "ERROR: Timeout waiting for test to prepare a response\n"
+ fmt.Fprintf(os.Stderr, msg)
+ resp = Response{500, nil, msg}
+ }
+ if resp.Headers != nil {
+ h := w.Header()
+ for k, v := range resp.Headers {
+ h.Set(k, v)
+ }
+ }
+ if resp.Status != 0 {
+ w.WriteHeader(resp.Status)
+ }
+ w.Write([]byte(resp.Body))
+}
+
+// WaitRequests returns the next n requests made to the http server from
+// the queue. If not enough requests were previously made, it waits until
+// the timeout value for them to be made.
+func (s *HTTPServer) WaitRequests(n int) []*http.Request {
+ reqs := make([]*http.Request, 0, n)
+ for i := 0; i < n; i++ {
+ select {
+ case req := <-s.request:
+ reqs = append(reqs, req)
+ case <-time.After(s.Timeout):
+ panic("Timeout waiting for request")
+ }
+ }
+ return reqs
+}
+
+// WaitRequest returns the next request made to the http server from
+// the queue. If no requests were previously made, it waits until the
+// timeout value for one to be made.
+func (s *HTTPServer) WaitRequest() *http.Request {
+ return s.WaitRequests(1)[0]
+}
+
+// ResponseFunc prepares the test server to respond the following n
+// requests using f to build each response.
+func (s *HTTPServer) ResponseFunc(n int, f ResponseFunc) {
+ for i := 0; i < n; i++ {
+ s.response <- f
+ }
+}
+
+// ResponseMap maps request paths to responses.
+type ResponseMap map[string]Response
+
+// ResponseMap prepares the test server to respond the following n
+// requests using the m to obtain the responses.
+func (s *HTTPServer) ResponseMap(n int, m ResponseMap) {
+ f := func(path string) Response {
+ for rpath, resp := range m {
+ if rpath == path {
+ return resp
+ }
+ }
+ body := "Path not found in response map: " + path
+ return Response{Status: 500, Body: body}
+ }
+ s.ResponseFunc(n, f)
+}
+
+// Responses prepares the test server to respond the following n requests
+// using the provided response parameters.
+func (s *HTTPServer) Responses(n int, status int, headers map[string]string, body string) {
+ f := func(path string) Response {
+ return Response{status, headers, body}
+ }
+ s.ResponseFunc(n, f)
+}
+
+// Response prepares the test server to respond the following request
+// using the provided response parameters.
+func (s *HTTPServer) Response(status int, headers map[string]string, body string) {
+ s.Responses(1, status, headers, body)
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/testutil/suite.go b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/testutil/suite.go
new file mode 100644
index 00000000..2d432a00
--- /dev/null
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/mitchellh/goamz/testutil/suite.go
@@ -0,0 +1,30 @@
+package testutil
+
+import (
+ "flag"
+ "github.com/mitchellh/goamz/aws"
+ . "github.com/motain/gocheck"
+)
+
+// Amazon must be used by all tested packages to determine whether to
+// run functional tests against the real AWS servers.
+var Amazon bool
+
+func init() {
+ flag.BoolVar(&Amazon, "amazon", false, "Enable tests against amazon server")
+}
+
+type LiveSuite struct {
+ auth aws.Auth
+}
+
+func (s *LiveSuite) SetUpSuite(c *C) {
+ if !Amazon {
+ c.Skip("amazon tests not enabled (-amazon flag)")
+ }
+ auth, err := aws.EnvAuth()
+ if err != nil {
+ c.Fatal(err.Error())
+ }
+ s.auth = auth
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/smira/commander/commands.go b/src/github.com/smira/aptly/_vendor/src/github.com/smira/commander/commands.go
index 5478cd00..0633faad 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/smira/commander/commands.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/smira/commander/commands.go
@@ -11,6 +11,7 @@ package commander
import (
"bytes"
+ "errors"
"fmt"
"io"
"os"
@@ -31,6 +32,11 @@ const (
Unlisted
)
+var (
+ ErrFlagError = errors.New("unable to parse flags")
+ ErrCommandError = errors.New("unable to parse command")
+)
+
// A Command is an implementation of a subcommand.
type Command struct {
@@ -192,7 +198,7 @@ func (c *Command) ParseFlags(args []string) (result *flag.FlagSet, argsNoFlags [
parseFlags := func(c *Command, args []string, flags *flag.FlagSet, setValue bool) (leftArgs []string, err error) {
flags.Usage = func() {
c.Usage()
- err = fmt.Errorf("Failed to parse flags.")
+ err = ErrFlagError
}
flags.Parse(args, setValue)
if err != nil {
@@ -306,7 +312,7 @@ func (c *Command) Dispatch(args []string) error {
if err := c.usage(); err != nil {
return err
}
- return nil
+ return ErrCommandError
}
func (c *Command) usage() error {
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/batch.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/batch.go
index 546a89dc..0d7911ec 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/batch.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/batch.go
@@ -27,10 +27,10 @@ type batchReplay interface {
// Batch is a write batch.
type Batch struct {
- buf []byte
- rLen int
- seq uint64
- sync bool
+ buf []byte
+ rLen, bLen int
+ seq uint64
+ sync bool
}
func (b *Batch) grow(n int) {
@@ -67,20 +67,21 @@ func (b *Batch) appendRec(t vType, key, value []byte) {
off += len(value)
}
b.buf = buf[:off]
+ b.rLen++
+ // Include 8-byte ikey header
+ b.bLen += len(key) + len(value) + 8
}
// Put appends 'put operation' of the given key/value pair to the batch.
// It is safe to modify the contents of the argument after Put returns.
func (b *Batch) Put(key, value []byte) {
b.appendRec(tVal, key, value)
- b.rLen++
}
// Delete appends 'delete operation' of the given key to the batch.
// It is safe to modify the contents of the argument after Delete returns.
func (b *Batch) Delete(key []byte) {
b.appendRec(tDel, key, nil)
- b.rLen++
}
// Reset resets the batch.
@@ -88,6 +89,7 @@ func (b *Batch) Reset() {
b.buf = nil
b.seq = 0
b.rLen = 0
+ b.bLen = 0
b.sync = false
}
@@ -125,7 +127,7 @@ func (b *Batch) len() int {
}
func (b *Batch) size() int {
- return len(b.buf)
+ return b.bLen
}
func (b *Batch) encode() []byte {
@@ -143,6 +145,8 @@ func (b *Batch) decode(buf []byte) error {
b.seq = binary.LittleEndian.Uint64(buf)
b.rLen = int(binary.LittleEndian.Uint32(buf[8:]))
+ // No need to be precise at this point, it won't be used anyway
+ b.bLen = len(buf) - kBatchHdrLen
b.buf = buf
return nil
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/batch_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/batch_test.go
index a41ca2e3..19b749b8 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/batch_test.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/batch_test.go
@@ -9,6 +9,9 @@ package leveldb
import (
"bytes"
"testing"
+
+ "github.com/syndtr/goleveldb/leveldb/comparer"
+ "github.com/syndtr/goleveldb/leveldb/memdb"
)
type tbRec struct {
@@ -98,3 +101,20 @@ func TestBatch_Append(t *testing.T) {
b2a.append(b2b)
compareBatch(t, b1, b2a)
}
+
+func TestBatch_Size(t *testing.T) {
+ b := new(Batch)
+ for i := 0; i < 2; i++ {
+ b.Put([]byte("key1"), []byte("value1"))
+ b.Put([]byte("key2"), []byte("value2"))
+ b.Delete([]byte("key1"))
+ b.Put([]byte("foo"), []byte("foovalue"))
+ b.Put([]byte("bar"), []byte("barvalue"))
+ mem := memdb.New(&iComparer{comparer.DefaultComparer}, 0)
+ b.memReplay(mem)
+ if b.size() != mem.Size() {
+ t.Errorf("invalid batch size calculation, want=%d got=%d", mem.Size(), b.size())
+ }
+ b.Reset()
+ }
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/config.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/config.go
index 350b3a6e..51105889 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/config.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/config.go
@@ -37,6 +37,4 @@ const (
// the lower level file set of a compaction if it would make the
// total compaction cover more than this many bytes.
kExpCompactionMaxBytes = 25 * kMaxTableSize
-
- kWriteBufferPercent = 110
)
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/corrupt_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/corrupt_test.go
index 1f8552f9..3910c593 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/corrupt_test.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/corrupt_test.go
@@ -10,6 +10,7 @@ import (
"bytes"
"fmt"
"io"
+ "math/rand"
"testing"
"github.com/syndtr/goleveldb/leveldb/cache"
@@ -23,13 +24,17 @@ type dbCorruptHarness struct {
dbHarness
}
-func newDbCorruptHarness(t *testing.T) *dbCorruptHarness {
+func newDbCorruptHarnessWopt(t *testing.T, o *opt.Options) *dbCorruptHarness {
h := new(dbCorruptHarness)
- h.init(t, &opt.Options{
+ h.init(t, o)
+ return h
+}
+
+func newDbCorruptHarness(t *testing.T) *dbCorruptHarness {
+ return newDbCorruptHarnessWopt(t, &opt.Options{
BlockCache: cache.NewLRUCache(100),
Strict: opt.StrictJournalChecksum,
})
- return h
}
func (h *dbCorruptHarness) recover() {
@@ -59,6 +64,38 @@ func (h *dbCorruptHarness) build(n int) {
}
}
+func (h *dbCorruptHarness) buildShuffled(n int, rnd *rand.Rand) {
+ p := &h.dbHarness
+ t := p.t
+ db := p.db
+
+ batch := new(Batch)
+ for i := range rnd.Perm(n) {
+ batch.Reset()
+ batch.Put(tkey(i), tval(i, ctValSize))
+ err := db.Write(batch, p.wo)
+ if err != nil {
+ t.Fatal("write error: ", err)
+ }
+ }
+}
+
+func (h *dbCorruptHarness) deleteRand(n, max int, rnd *rand.Rand) {
+ p := &h.dbHarness
+ t := p.t
+ db := p.db
+
+ batch := new(Batch)
+ for i := 0; i < n; i++ {
+ batch.Reset()
+ batch.Delete(tkey(rnd.Intn(max)))
+ err := db.Write(batch, p.wo)
+ if err != nil {
+ t.Fatal("write error: ", err)
+ }
+ }
+}
+
func (h *dbCorruptHarness) corrupt(ft storage.FileType, offset, n int) {
p := &h.dbHarness
t := p.t
@@ -216,15 +253,24 @@ func TestCorruptDB_TableIndex(t *testing.T) {
}
func TestCorruptDB_MissingManifest(t *testing.T) {
- h := newDbCorruptHarness(t)
+ rnd := rand.New(rand.NewSource(0x0badda7a))
+ h := newDbCorruptHarnessWopt(t, &opt.Options{
+ BlockCache: cache.NewLRUCache(100),
+ Strict: opt.StrictJournalChecksum,
+ WriteBuffer: 1000 * 60,
+ })
h.build(1000)
h.compactMem()
- h.build(1000)
+ h.buildShuffled(1000, rnd)
h.compactMem()
- h.build(1000)
+ h.deleteRand(500, 1000, rnd)
h.compactMem()
- h.build(1000)
+ h.buildShuffled(1000, rnd)
+ h.compactMem()
+ h.deleteRand(500, 1000, rnd)
+ h.compactMem()
+ h.buildShuffled(1000, rnd)
h.compactMem()
h.closeDB()
@@ -237,6 +283,7 @@ func TestCorruptDB_MissingManifest(t *testing.T) {
h.check(1000, 1000)
h.build(1000)
h.compactMem()
+ h.compactRange("", "")
h.closeDB()
h.recover()
@@ -338,3 +385,30 @@ func TestCorruptDB_UnrelatedKeys(t *testing.T) {
h.close()
}
+
+func TestCorruptDB_RecoverInvalidSeq_Issue53(t *testing.T) {
+ h := newDbCorruptHarness(t)
+
+ h.put("a", "v1")
+ h.put("b", "v1")
+ h.compactMem()
+ h.put("a", "v2")
+ h.put("b", "v2")
+ h.compactMem()
+ h.put("a", "v3")
+ h.put("b", "v3")
+ h.compactMem()
+ h.put("c", "v0")
+ h.put("d", "v0")
+ h.compactMem()
+ h.compactRangeAt(0, "", "")
+ h.closeDB()
+
+ h.recover()
+ h.getVal("a", "v3")
+ h.getVal("b", "v3")
+ h.getVal("c", "v0")
+ h.getVal("d", "v0")
+
+ h.close()
+}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db.go
index 2734f995..fe0de77d 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db.go
@@ -21,6 +21,7 @@ import (
"github.com/syndtr/goleveldb/leveldb/memdb"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/syndtr/goleveldb/leveldb/storage"
+ "github.com/syndtr/goleveldb/leveldb/table"
"github.com/syndtr/goleveldb/leveldb/util"
)
@@ -53,11 +54,12 @@ type DB struct {
snapsRoot snapshotElement
// Write
- writeCh chan *Batch
- writeLockCh chan struct{}
- writeAckCh chan error
- journalCh chan *Batch
- journalAckCh chan error
+ writeCh chan *Batch
+ writeMergedCh chan bool
+ writeLockCh chan struct{}
+ writeAckCh chan error
+ journalCh chan *Batch
+ journalAckCh chan error
// Compaction
compCh chan chan<- struct{}
@@ -83,11 +85,12 @@ func openDB(s *session) (*DB, error) {
// Initial sequence
seq: s.stSeq,
// Write
- writeCh: make(chan *Batch),
- writeLockCh: make(chan struct{}, 1),
- writeAckCh: make(chan error),
- journalCh: make(chan *Batch),
- journalAckCh: make(chan error),
+ writeCh: make(chan *Batch),
+ writeMergedCh: make(chan bool),
+ writeLockCh: make(chan struct{}, 1),
+ writeAckCh: make(chan error),
+ journalCh: make(chan *Batch),
+ journalAckCh: make(chan error),
// Compaction
compCh: make(chan chan<- struct{}, 1),
compMemCh: make(chan chan<- struct{}, 1),
@@ -208,102 +211,7 @@ func Recover(p storage.Storage, o *opt.Options) (db *DB, err error) {
}
}()
- // get all files
- ff0, err := s.getFiles(storage.TypeAll)
- if err != nil {
- return
- }
-
- ff := files(ff0)
- ff.sort()
-
- s.logf("db@recovery F·%d", len(ff))
-
- rec := new(sessionRecord)
-
- // recover tables
- var nt *tFile
- for _, f := range ff {
- if f.Type() != storage.TypeTable {
- continue
- }
-
- var r storage.Reader
- r, err = f.Open()
- if err != nil {
- return
- }
- var size int64
- size, err = r.Seek(0, 2)
- r.Close()
- if err != nil {
- return
- }
-
- t := newTFile(f, uint64(size), nil, nil)
- iter := s.tops.newIterator(t, nil, nil)
- // min ikey
- if iter.First() {
- t.min = iter.Key()
- } else {
- err = iter.Error()
- iter.Release()
- if err != nil {
- return
- } else {
- continue
- }
- }
- // max ikey
- if iter.Last() {
- t.max = iter.Key()
- } else {
- err = iter.Error()
- iter.Release()
- if err != nil {
- return
- } else {
- continue
- }
- }
- iter.Release()
- s.logf("db@recovery found table @%d S·%s %q:%q", t.file.Num(), shortenb(int(t.size)), t.min, t.max)
- // add table to level 0
- rec.addTableFile(0, t)
- nt = t
- }
-
- // extract largest seq number from newest table
- if nt != nil {
- var lseq uint64
- iter := s.tops.newIterator(nt, nil, nil)
- for iter.Next() {
- seq, _, ok := iKey(iter.Key()).parseNum()
- if !ok {
- continue
- }
- if seq > lseq {
- lseq = seq
- }
- }
- iter.Release()
- rec.setSeq(lseq)
- }
-
- // set file num based on largest one
- if len(ff) > 0 {
- s.stFileNum = ff[len(ff)-1].Num() + 1
- } else {
- s.stFileNum = 0
- }
-
- // create brand new manifest
- err = s.create()
- if err != nil {
- return
- }
- // commit record
- err = s.commit(rec)
+ err = recoverTable(s, o)
if err != nil {
return
}
@@ -333,6 +241,151 @@ func RecoverFile(path string, o *opt.Options) (db *DB, err error) {
return
}
+func recoverTable(s *session, o *opt.Options) error {
+ ff0, err := s.getFiles(storage.TypeTable)
+ if err != nil {
+ return err
+ }
+ ff1 := files(ff0)
+ ff1.sort()
+
+ var mSeq uint64
+ var good, corrupted int
+ rec := new(sessionRecord)
+ buildTable := func(iter iterator.Iterator) (tmp storage.File, size int64, err error) {
+ tmp = s.newTemp()
+ writer, err := tmp.Create()
+ if err != nil {
+ return
+ }
+ defer func() {
+ writer.Close()
+ if err != nil {
+ tmp.Remove()
+ tmp = nil
+ }
+ }()
+ tw := table.NewWriter(writer, o)
+ // Copy records.
+ for iter.Next() {
+ key := iter.Key()
+ if validIkey(key) {
+ err = tw.Append(key, iter.Value())
+ if err != nil {
+ return
+ }
+ }
+ }
+ err = iter.Error()
+ if err != nil {
+ return
+ }
+ err = tw.Close()
+ if err != nil {
+ return
+ }
+ err = writer.Sync()
+ if err != nil {
+ return
+ }
+ size = int64(tw.BytesLen())
+ return
+ }
+ recoverTable := func(file storage.File) error {
+ s.logf("table@recovery recovering @%d", file.Num())
+ reader, err := file.Open()
+ if err != nil {
+ return err
+ }
+ defer reader.Close()
+ // Get file size.
+ size, err := reader.Seek(0, 2)
+ if err != nil {
+ return err
+ }
+ var tSeq uint64
+ var tgood, tcorrupted, blockerr int
+ var min, max []byte
+ tr := table.NewReader(reader, size, nil, o)
+ iter := tr.NewIterator(nil, nil)
+ iter.(iterator.ErrorCallbackSetter).SetErrorCallback(func(err error) {
+ s.logf("table@recovery found error @%d %q", file.Num(), err)
+ blockerr++
+ })
+ // Scan the table.
+ for iter.Next() {
+ key := iter.Key()
+ _, seq, _, ok := parseIkey(key)
+ if !ok {
+ tcorrupted++
+ continue
+ }
+ tgood++
+ if seq > tSeq {
+ tSeq = seq
+ }
+ if min == nil {
+ min = append([]byte{}, key...)
+ }
+ max = append(max[:0], key...)
+ }
+ if err := iter.Error(); err != nil {
+ iter.Release()
+ return err
+ }
+ iter.Release()
+ if tgood > 0 {
+ if tcorrupted > 0 || blockerr > 0 {
+ // Rebuild the table.
+ s.logf("table@recovery rebuilding @%d", file.Num())
+ iter := tr.NewIterator(nil, nil)
+ tmp, newSize, err := buildTable(iter)
+ iter.Release()
+ if err != nil {
+ return err
+ }
+ reader.Close()
+ if err := file.Replace(tmp); err != nil {
+ return err
+ }
+ size = newSize
+ }
+ if tSeq > mSeq {
+ mSeq = tSeq
+ }
+ // Add table to level 0.
+ rec.addTable(0, file.Num(), uint64(size), min, max)
+ s.logf("table@recovery recovered @%d N·%d C·%d B·%d S·%d Q·%d", file.Num(), tgood, tcorrupted, blockerr, size, tSeq)
+ } else {
+ s.logf("table@recovery unrecoverable @%d C·%d B·%d S·%d", file.Num(), tcorrupted, blockerr, size)
+ }
+
+ good += tgood
+ corrupted += tcorrupted
+
+ return nil
+ }
+ // Recover all tables.
+ if len(ff1) > 0 {
+ s.logf("table@recovery F·%d", len(ff1))
+ s.markFileNum(ff1[len(ff1)-1].Num())
+ for _, file := range ff1 {
+ if err := recoverTable(file); err != nil {
+ return err
+ }
+ }
+ s.logf("table@recovery recovered F·%d N·%d C·%d Q·%d", len(ff1), good, corrupted, mSeq)
+ }
+ // Set sequence number.
+ rec.setSeq(mSeq + 1)
+ // Create new manifest.
+ if err := s.create(); err != nil {
+ return err
+ }
+ // Commit.
+ return s.commit(rec)
+}
+
func (d *DB) recoverJournal() error {
s := d.s
icmp := s.cmp
@@ -425,7 +478,7 @@ func (d *DB) recoverJournal() error {
// Recover all journals.
if len(ff2) > 0 {
s.logf("journal@recovery F·%d", len(ff2))
- mem = memdb.New(icmp, toPercent(writeBuffer, kWriteBufferPercent))
+ mem = memdb.New(icmp, writeBuffer)
for _, file := range ff2 {
if err := recoverJournal(file); err != nil {
return err
@@ -439,7 +492,7 @@ func (d *DB) recoverJournal() error {
}
}
// Create a new journal.
- if _, err := d.newMem(); err != nil {
+ if _, err := d.newMem(0); err != nil {
return err
}
// Commit.
@@ -726,5 +779,19 @@ func (d *DB) Close() error {
}
}
+ d.s = nil
+ d.mem = nil
+ d.frozenMem = nil
+ d.journal = nil
+ d.journalWriter = nil
+ d.journalFile = nil
+ d.frozenJournalFile = nil
+ d.snapsRoot = snapshotElement{}
+ d.closer = nil
+
+ close(d.writeCh)
+ close(d.journalCh)
+ close(d.compReqCh)
+
return err
}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go
index 1a84055d..9e7055ae 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go
@@ -81,7 +81,9 @@ func (c *cMem) flush(mem *memdb.DB, level int) error {
s := c.s
// Write memdb to table
- t, n, err := s.tops.createFrom(mem.NewIterator(nil))
+ iter := mem.NewIterator(nil)
+ defer iter.Release()
+ t, n, err := s.tops.createFrom(iter)
if err != nil {
return err
}
@@ -177,6 +179,14 @@ func (d *DB) memCompaction() {
s.logf("mem@flush N·%d S·%s", mem.Len(), shortenb(mem.Size()))
+ // Don't compact empty memdb.
+ if mem.Len() == 0 {
+ s.logf("mem@flush skipping")
+ // drop frozen mem
+ d.dropFrozenMem()
+ return
+ }
+
d.transact("mem@flush", func() (err error) {
stats.startTimer()
defer stats.stopTimer()
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go
index 8300ccd3..225b7cd5 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go
@@ -51,17 +51,19 @@ func (db *DB) acquireSnapshot() *snapshotElement {
// Releases given snapshot element.
func (db *DB) releaseSnapshot(elem *snapshotElement) {
- db.snapsMu.Lock()
- elem.ref--
- if elem.ref == 0 {
- elem.prev.next = elem.next
- elem.next.prev = elem.prev
- elem.next = nil
- elem.prev = nil
- } else if elem.ref < 0 {
- panic("leveldb: Snapshot: negative element reference")
+ if !db.isClosed() {
+ db.snapsMu.Lock()
+ elem.ref--
+ if elem.ref == 0 {
+ elem.prev.next = elem.next
+ elem.next.prev = elem.prev
+ elem.next = nil
+ elem.prev = nil
+ } else if elem.ref < 0 {
+ panic("leveldb: Snapshot: negative element reference")
+ }
+ db.snapsMu.Unlock()
}
- db.snapsMu.Unlock()
}
// Gets minimum sequence that not being snapshoted.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_state.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_state.go
index 4a545721..d662056f 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_state.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_state.go
@@ -25,7 +25,7 @@ func (d *DB) addSeq(delta uint64) {
// Create new memdb and froze the old one; need external synchronization.
// newMem only called synchronously by the writer.
-func (d *DB) newMem() (mem *memdb.DB, err error) {
+func (d *DB) newMem(n int) (mem *memdb.DB, err error) {
s := d.s
num := s.allocFileNum()
@@ -46,7 +46,7 @@ func (d *DB) newMem() (mem *memdb.DB, err error) {
d.journalWriter = w
d.journalFile = file
d.frozenMem = d.mem
- d.mem = memdb.New(s.cmp, toPercent(d.s.o.GetWriteBuffer(), kWriteBufferPercent))
+ d.mem = memdb.New(s.cmp, maxInt(d.s.o.GetWriteBuffer(), n))
mem = d.mem
// The seq only incremented by the writer.
d.frozenSeq = d.seq
@@ -85,7 +85,11 @@ func (d *DB) getFrozenMem() *memdb.DB {
// Drop frozen memdb; assume that frozen memdb isn't nil.
func (d *DB) dropFrozenMem() {
d.memMu.Lock()
- d.frozenJournalFile.Remove()
+ if err := d.frozenJournalFile.Remove(); err != nil {
+ d.s.logf("journal@remove removing @%d %q", d.frozenJournalFile.Num(), err)
+ } else {
+ d.s.logf("journal@remove removed @%d", d.frozenJournalFile.Num())
+ }
d.frozenJournalFile = nil
d.frozenMem = nil
d.memMu.Unlock()
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_test.go
index 777a6a25..58d1415b 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_test.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_test.go
@@ -317,7 +317,7 @@ func (h *dbHarness) compactMem() {
}
// create new memdb and journal
- _, err := db.newMem()
+ _, err := db.newMem(0)
if err != nil {
t.Error("newMem: got error: ", err)
return
@@ -584,7 +584,7 @@ func TestDb_EmptyBatch(t *testing.T) {
}
func TestDb_GetFromFrozen(t *testing.T) {
- h := newDbHarnessWopt(t, &opt.Options{WriteBuffer: 100000})
+ h := newDbHarnessWopt(t, &opt.Options{WriteBuffer: 100100})
defer h.close()
h.put("foo", "v1")
@@ -593,6 +593,13 @@ func TestDb_GetFromFrozen(t *testing.T) {
h.stor.DelaySync(storage.TypeTable) // Block sync calls
h.put("k1", strings.Repeat("x", 100000)) // Fill memtable
h.put("k2", strings.Repeat("y", 100000)) // Trigger compaction
+ for i := 0; h.db.getFrozenMem() == nil && i < 100; i++ {
+ time.Sleep(10 * time.Microsecond)
+ }
+ if h.db.getFrozenMem() == nil {
+ h.stor.ReleaseSync(storage.TypeTable)
+ t.Fatal("No frozen mem")
+ }
h.getVal("foo", "v1")
h.stor.ReleaseSync(storage.TypeTable) // Release sync calls
@@ -848,14 +855,12 @@ func TestDb_RecoverDuringMemtableCompaction(t *testing.T) {
truno(t, &opt.Options{WriteBuffer: 1000000}, func(h *dbHarness) {
h.stor.DelaySync(storage.TypeTable)
- h.put("foo", "v1")
h.put("big1", strings.Repeat("x", 10000000))
h.put("big2", strings.Repeat("y", 1000))
h.put("bar", "v2")
h.stor.ReleaseSync(storage.TypeTable)
h.reopenDB()
- h.getVal("foo", "v1")
h.getVal("bar", "v2")
h.getVal("big1", strings.Repeat("x", 10000000))
h.getVal("big2", strings.Repeat("y", 1000))
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_write.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_write.go
index 05014dbd..5cd13f43 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_write.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/db_write.go
@@ -44,7 +44,7 @@ func (d *DB) writeJournal() {
}
}
-func (d *DB) flush() (mem *memdb.DB, err error) {
+func (d *DB) flush(n int) (mem *memdb.DB, nn int, err error) {
s := d.s
delayed := false
@@ -52,11 +52,12 @@ func (d *DB) flush() (mem *memdb.DB, err error) {
v := s.version()
defer v.release()
mem = d.getEffectiveMem()
+ nn = mem.Free()
switch {
case v.tLen(0) >= kL0_SlowdownWritesTrigger && !delayed:
delayed = true
time.Sleep(time.Millisecond)
- case mem.Size() < s.o.GetWriteBuffer():
+ case nn >= n:
return false
case v.tLen(0) >= kL0_StopWritesTrigger:
delayed = true
@@ -65,6 +66,11 @@ func (d *DB) flush() (mem *memdb.DB, err error) {
return false
}
default:
+ // Allow memdb to grow if it has no entry.
+ if mem.Len() == 0 {
+ nn = n
+ return false
+ }
// Wait for pending memdb compaction.
select {
case _, _ = <-d.closeCh:
@@ -75,7 +81,7 @@ func (d *DB) flush() (mem *memdb.DB, err error) {
return false
}
// Create new memdb and journal.
- mem, err = d.newMem()
+ mem, err = d.newMem(n)
if err != nil {
return false
}
@@ -108,11 +114,15 @@ func (d *DB) Write(b *Batch, wo *opt.WriteOptions) (err error) {
b.init(wo.GetSync())
// The write happen synchronously.
+retry:
select {
case _, _ = <-d.closeCh:
return ErrClosed
case d.writeCh <- b:
- return <-d.writeAckCh
+ if <-d.writeMergedCh {
+ return <-d.writeAckCh
+ }
+ goto retry
case d.writeLockCh <- struct{}{}:
}
@@ -124,7 +134,7 @@ func (d *DB) Write(b *Batch, wo *opt.WriteOptions) (err error) {
}
}()
- mem, err := d.flush()
+ mem, memFree, err := d.flush(b.size())
if err != nil {
return
}
@@ -134,14 +144,21 @@ func (d *DB) Write(b *Batch, wo *opt.WriteOptions) (err error) {
if x := b.size(); x <= 128<<10 {
m = x + (128 << 10)
}
+ m = minInt(m, memFree)
// Merge with other batch.
drain:
- for b.size() <= m && !b.sync {
+ for b.size() < m && !b.sync {
select {
case nb := <-d.writeCh:
- b.append(nb)
- merged++
+ if b.size()+nb.size() <= m {
+ b.append(nb)
+ d.writeMergedCh <- true
+ merged++
+ } else {
+ d.writeMergedCh <- false
+ break drain
+ }
default:
break drain
}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go
index fb89f8e0..1e99a2bf 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go
@@ -28,6 +28,7 @@ type indexedIterator struct {
data Iterator
err error
+ errf func(err error)
}
func (i *indexedIterator) setData() {
@@ -50,6 +51,11 @@ func (i *indexedIterator) clearData() {
}
func (i *indexedIterator) dataErr() bool {
+ if i.errf != nil {
+ if err := i.data.Error(); err != nil {
+ i.errf(err)
+ }
+ }
if i.strict {
if err := i.data.Error(); err != nil {
i.err = err
@@ -196,6 +202,10 @@ func (i *indexedIterator) Error() error {
return nil
}
+func (i *indexedIterator) SetErrorCallback(f func(err error)) {
+ i.errf = f
+}
+
// NewIndexedIterator returns an indexed iterator. An index is iterator
// that returns another iterator, a data iterator. A data iterator is the
// iterator that contains actual key/value pairs.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go
index ea3d6f15..1b80184e 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go
@@ -89,6 +89,16 @@ type Iterator interface {
Value() []byte
}
+// ErrorCallbackSetter is the interface that wraps basic SetErrorCallback
+// method.
+//
+// ErrorCallbackSetter implemented by indexed and merged iterator.
+type ErrorCallbackSetter interface {
+ // SetErrorCallback allows set an error callback of the coresponding
+ // iterator. Use nil to clear the callback.
+ SetErrorCallback(f func(err error))
+}
+
type emptyIterator struct {
releaser util.Releaser
released bool
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go
index 4fd88e1a..c8314c4e 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go
@@ -36,16 +36,32 @@ type mergedIterator struct {
index int
dir dir
err error
+ errf func(err error)
releaser util.Releaser
}
func assertKey(key []byte) []byte {
if key == nil {
- panic("leveldb/iterator: nil valid key")
+ panic("leveldb/iterator: nil key")
}
return key
}
+func (i *mergedIterator) iterErr(iter Iterator) bool {
+ if i.errf != nil {
+ if err := iter.Error(); err != nil {
+ i.errf(err)
+ }
+ }
+ if i.strict {
+ if err := iter.Error(); err != nil {
+ i.err = err
+ return true
+ }
+ }
+ return false
+}
+
func (i *mergedIterator) Valid() bool {
return i.err == nil && i.dir > dirEOI
}
@@ -62,12 +78,8 @@ func (i *mergedIterator) First() bool {
switch {
case iter.First():
i.keys[x] = assertKey(iter.Key())
- case i.strict:
- if err := iter.Error(); err != nil {
- i.err = err
- return false
- }
- fallthrough
+ case i.iterErr(iter):
+ return false
default:
i.keys[x] = nil
}
@@ -88,12 +100,8 @@ func (i *mergedIterator) Last() bool {
switch {
case iter.Last():
i.keys[x] = assertKey(iter.Key())
- case i.strict:
- if err := iter.Error(); err != nil {
- i.err = err
- return false
- }
- fallthrough
+ case i.iterErr(iter):
+ return false
default:
i.keys[x] = nil
}
@@ -114,12 +122,8 @@ func (i *mergedIterator) Seek(key []byte) bool {
switch {
case iter.Seek(key):
i.keys[x] = assertKey(iter.Key())
- case i.strict:
- if err := iter.Error(); err != nil {
- i.err = err
- return false
- }
- fallthrough
+ case i.iterErr(iter):
+ return false
default:
i.keys[x] = nil
}
@@ -171,12 +175,8 @@ func (i *mergedIterator) Next() bool {
switch {
case iter.Next():
i.keys[x] = assertKey(iter.Key())
- case i.strict:
- if err := iter.Error(); err != nil {
- i.err = err
- return false
- }
- fallthrough
+ case i.iterErr(iter):
+ return false
default:
i.keys[x] = nil
}
@@ -223,12 +223,8 @@ func (i *mergedIterator) Prev() bool {
switch {
case seek && iter.Prev(), !seek && iter.Last():
i.keys[x] = assertKey(iter.Key())
- case i.strict:
- if err := iter.Error(); err != nil {
- i.err = err
- return false
- }
- fallthrough
+ case i.iterErr(iter):
+ return false
default:
i.keys[x] = nil
}
@@ -240,12 +236,8 @@ func (i *mergedIterator) Prev() bool {
switch {
case iter.Prev():
i.keys[x] = assertKey(iter.Key())
- case i.strict:
- if err := iter.Error(); err != nil {
- i.err = err
- return false
- }
- fallthrough
+ case i.iterErr(iter):
+ return false
default:
i.keys[x] = nil
}
@@ -291,6 +283,10 @@ func (i *mergedIterator) Error() error {
return i.err
}
+func (i *mergedIterator) SetErrorCallback(f func(err error)) {
+ i.errf = f
+}
+
// NewMergedIterator returns an iterator that merges its input. Walking the
// resultant iterator will return all key/value pairs of all input iterators
// in strictly increasing key order, as defined by cmp.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/key.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/key.go
index 676163ba..b9acf932 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/key.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/key.go
@@ -80,6 +80,11 @@ func parseIkey(p []byte) (ukey []byte, seq uint64, t vType, ok bool) {
return
}
+func validIkey(p []byte) bool {
+ _, _, _, ok := parseIkey(p)
+ return ok
+}
+
func (p iKey) assert() {
if p == nil {
panic("nil iKey")
@@ -89,6 +94,14 @@ func (p iKey) assert() {
}
}
+func (p iKey) ok() bool {
+ if len(p) < 8 {
+ return false
+ }
+ _, _, ok := p.parseNum()
+ return ok
+}
+
func (p iKey) ukey() []byte {
p.assert()
return p[:len(p)-8]
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go
index 096812ac..7bcae992 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go
@@ -71,6 +71,9 @@ func (i *dbIter) First() bool {
}
func (i *dbIter) Last() bool {
+ if i.p == nil {
+ return false
+ }
i.forward = false
i.p.mu.RLock()
defer i.p.mu.RUnlock()
@@ -83,6 +86,9 @@ func (i *dbIter) Last() bool {
}
func (i *dbIter) Seek(key []byte) bool {
+ if i.p == nil {
+ return false
+ }
i.forward = true
i.p.mu.RLock()
defer i.p.mu.RUnlock()
@@ -94,6 +100,9 @@ func (i *dbIter) Seek(key []byte) bool {
}
func (i *dbIter) Next() bool {
+ if i.p == nil {
+ return false
+ }
if i.node == 0 {
if !i.forward {
return i.First()
@@ -108,6 +117,9 @@ func (i *dbIter) Next() bool {
}
func (i *dbIter) Prev() bool {
+ if i.p == nil {
+ return false
+ }
if i.node == 0 {
if i.forward {
return i.Last()
@@ -131,6 +143,16 @@ func (i *dbIter) Value() []byte {
func (i *dbIter) Error() error { return nil }
+func (i *dbIter) Release() {
+ if i.p != nil {
+ i.p = nil
+ i.node = 0
+ i.key = nil
+ i.value = nil
+ i.BasicReleaser.Release()
+ }
+}
+
const (
nKV = iota
nKey
@@ -364,13 +386,29 @@ func (p *DB) NewIterator(slice *util.Range) iterator.Iterator {
return &dbIter{p: p, slice: slice}
}
-// Size returns sum of keys and values length.
+// Capacity returns keys/values buffer capacity.
+func (p *DB) Capacity() int {
+ p.mu.RLock()
+ defer p.mu.RUnlock()
+ return cap(p.kvData)
+}
+
+// Size returns sum of keys and values length. Note that deleted
+// key/value will not be accouted for, but it will still consume
+// the buffer, since the buffer is append only.
func (p *DB) Size() int {
p.mu.RLock()
defer p.mu.RUnlock()
return p.kvSize
}
+// Free returns keys/values free buffer before need to grow.
+func (p *DB) Free() int {
+ p.mu.RLock()
+ defer p.mu.RUnlock()
+ return cap(p.kvData) - len(p.kvData)
+}
+
// Len returns the number of entries in the DB.
func (p *DB) Len() int {
p.mu.RLock()
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/session.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/session.go
index 2c6d5994..e940915a 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/session.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/session.go
@@ -37,6 +37,7 @@ type session struct {
stJournalNum uint64 // current journal file number; need external synchronization
stPrevJournalNum uint64 // prev journal file number; no longer used; for compatibility with older version of leveldb
stSeq uint64 // last mem compacted seq; need external synchronization
+ stTempFileNum uint64
stor storage.Storage
storLock util.Releaser
@@ -68,6 +69,7 @@ func newSession(stor storage.Storage, o *opt.Options) (s *session, err error) {
s.setOptions(o)
s.tops = newTableOps(s, s.o.GetMaxOpenFiles())
s.setVersion(&version{s: s})
+ s.log("log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock D·DeletedEntry L·Level Q·SeqNum T·TimeElapsed")
return
}
@@ -83,6 +85,10 @@ func (s *session) close() {
if s.manifestWriter != nil {
s.manifestWriter.Close()
}
+ s.manifest = nil
+ s.manifestWriter = nil
+ s.manifestFile = nil
+ s.stVersion = nil
}
func (s *session) release() {
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/session_util.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/session_util.go
index dbbffa2e..863603d0 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/session_util.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/session_util.go
@@ -51,6 +51,11 @@ func (s *session) getFiles(t storage.FileType) ([]storage.File, error) {
return s.stor.GetFiles(t)
}
+func (s *session) newTemp() storage.File {
+ num := atomic.AddUint64(&s.stTempFileNum, 1) - 1
+ return s.stor.GetFile(num, storage.TypeTemp)
+}
+
// session state
// Get current version.
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go
index 27f09605..aef620db 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go
@@ -313,8 +313,7 @@ func (fs *fileStorage) SetManifest(f File) (err error) {
if err != nil {
return err
}
- err = rename(path, filepath.Join(fs.path, "CURRENT"))
- return
+ return rename(path, filepath.Join(fs.path, "CURRENT"))
}
func (fs *fileStorage) Close() error {
@@ -410,6 +409,22 @@ func (f *file) Create() (Writer, error) {
return fileWrap{of, f}, nil
}
+func (f *file) Replace(newfile File) error {
+ f.fs.mu.Lock()
+ defer f.fs.mu.Unlock()
+ if f.fs.open < 0 {
+ return ErrClosed
+ }
+ newfile2, ok := newfile.(*file)
+ if !ok {
+ return ErrInvalidFile
+ }
+ if f.open || newfile2.open {
+ return errFileOpen
+ }
+ return rename(newfile2.path(), f.path())
+}
+
func (f *file) Type() FileType {
return f.t
}
@@ -465,6 +480,8 @@ func (f *file) name() string {
return fmt.Sprintf("%06d.log", f.num)
case TypeTable:
return fmt.Sprintf("%06d.ldb", f.num)
+ case TypeTemp:
+ return fmt.Sprintf("%06d.tmp", f.num)
default:
panic("invalid file type")
}
@@ -484,6 +501,8 @@ func (f *file) parse(name string) bool {
f.t = TypeJournal
case "ldb", "sst":
f.t = TypeTable
+ case "tmp":
+ f.t = TypeTemp
default:
return false
}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_test.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_test.go
index a1bcfadb..92abcbb7 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_test.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_test.go
@@ -25,6 +25,7 @@ var cases = []struct {
{nil, "MANIFEST-000002", TypeManifest, 2},
{nil, "MANIFEST-000007", TypeManifest, 7},
{nil, "18446744073709551615.log", TypeJournal, 18446744073709551615},
+ {nil, "000100.tmp", TypeTemp, 100},
}
var invalidCases = []string{
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go
index 5facde2d..fc1c8165 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go
@@ -162,6 +162,27 @@ func (p *memFilePtr) Create() (Writer, error) {
return m, nil
}
+func (p *memFilePtr) Replace(newfile File) error {
+ p1, ok := newfile.(*memFilePtr)
+ if !ok {
+ return ErrInvalidFile
+ }
+ ms := p.ms
+ ms.mu.Lock()
+ defer ms.mu.Unlock()
+ m1, exist := ms.files[p1.x()]
+ if !exist {
+ return os.ErrNotExist
+ }
+ m0, exist := ms.files[p.x()]
+ if (exist && m0.open) || m1.open {
+ return errFileOpen
+ }
+ delete(ms.files, p1.x())
+ ms.files[p.x()] = m1
+ return nil
+}
+
func (p *memFilePtr) Type() FileType {
return p.t
}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/storage.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/storage.go
index c0572cfc..d951d975 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/storage.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/storage/storage.go
@@ -20,8 +20,9 @@ const (
TypeManifest FileType = 1 << iota
TypeJournal
TypeTable
+ TypeTemp
- TypeAll = TypeManifest | TypeJournal | TypeTable
+ TypeAll = TypeManifest | TypeJournal | TypeTable | TypeTemp
)
func (t FileType) String() string {
@@ -32,6 +33,8 @@ func (t FileType) String() string {
return "journal"
case TypeTable:
return "table"
+ case TypeTemp:
+ return "temp"
}
return ""
}
@@ -67,14 +70,18 @@ type Writer interface {
type File interface {
// Open opens the file for read. Returns os.ErrNotExist error
// if the file does not exist.
- // Open returns error if the underlying storage is closed.
+ // Returns ErrClosed if the underlying storage is closed.
Open() (r Reader, err error)
// Create creates the file for writting. Truncate the file if
// already exist.
- // Returns error if the underlying storage is closed.
+ // Returns ErrClosed if the underlying storage is closed.
Create() (w Writer, err error)
+ // Replace replaces file with newfile.
+ // Returns ErrClosed if the underlying storage is closed.
+ Replace(newfile File) error
+
// Type returns the file type
Type() FileType
@@ -82,7 +89,7 @@ type File interface {
Num() uint64
// Remove removes the file.
- // Returns error if the underlying storage is closed.
+ // Returns ErrClosed if the underlying storage is closed.
Remove() error
}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/table.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/table.go
index 82ed1f26..bc20c2f7 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/table.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/table.go
@@ -362,7 +362,11 @@ func (t *tOps) newIterator(f *tFile, slice *util.Range, ro *opt.ReadOptions) ite
func (t *tOps) remove(f *tFile) {
num := f.file.Num()
t.cacheNS.Delete(num, func(exist bool) {
- f.file.Remove()
+ if err := f.file.Remove(); err != nil {
+ t.s.logf("table@remove removing @%d %q", num, err)
+ } else {
+ t.s.logf("table@remove removed @%d", num)
+ }
if bc := t.s.o.GetBlockCache(); bc != nil {
bc.GetNamespace(num).Zap(false)
}
@@ -380,23 +384,19 @@ type tWriter struct {
w storage.Writer
tw *table.Writer
- notFirst bool
first, last []byte
}
func (w *tWriter) add(key, value []byte) error {
- if w.notFirst {
- w.last = append(w.last[:0], key...)
- } else {
- w.first = append(w.first[:0], key...)
- w.last = append(w.last[:0], key...)
- w.notFirst = true
+ if w.first == nil {
+ w.first = append([]byte{}, key...)
}
+ w.last = append(w.last[:0], key...)
return w.tw.Append(key, value)
}
func (w *tWriter) empty() bool {
- return !w.notFirst
+ return w.first == nil
}
func (w *tWriter) finish() (f *tFile, err error) {
@@ -406,6 +406,7 @@ func (w *tWriter) finish() (f *tFile, err error) {
}
err = w.w.Sync()
if err != nil {
+ w.w.Close()
return
}
w.w.Close()
@@ -420,4 +421,6 @@ func (w *tWriter) drop() {
w.w = nil
w.file = nil
w.tw = nil
+ w.first = nil
+ w.last = nil
}
diff --git a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/util.go b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/util.go
index 0a768cc6..a43d2e46 100644
--- a/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/util.go
+++ b/src/github.com/smira/aptly/_vendor/src/github.com/syndtr/goleveldb/leveldb/util.go
@@ -58,8 +58,18 @@ func sint(x int) string {
return fmt.Sprintf("%s%d", sign, x)
}
-func toPercent(n, percent int) int {
- return n * percent / 100
+func minInt(a, b int) int {
+ if a < b {
+ return a
+ }
+ return b
+}
+
+func maxInt(a, b int) int {
+ if a > b {
+ return a
+ }
+ return b
}
type files []storage.File
diff --git a/src/github.com/smira/aptly/aptly/interfaces.go b/src/github.com/smira/aptly/aptly/interfaces.go
index 47cf1140..c79b6e15 100644
--- a/src/github.com/smira/aptly/aptly/interfaces.go
+++ b/src/github.com/smira/aptly/aptly/interfaces.go
@@ -5,7 +5,6 @@ package aptly
import (
"github.com/smira/aptly/utils"
"io"
- "os"
)
// PackagePool is asbtraction of package pool storage.
@@ -26,26 +25,34 @@ type PackagePool interface {
// PublishedStorage is abstraction of filesystem storing all published repositories
type PublishedStorage interface {
- // PublicPath returns root of public part
- PublicPath() string
// MkDir creates directory recursively under public path
MkDir(path string) error
- // CreateFile creates file for writing under public path
- CreateFile(path string) (*os.File, error)
+ // PutFile puts file into published storage at specified path
+ PutFile(path string, sourceFilename string) error
// RemoveDirs removes directory structure under public path
RemoveDirs(path string, progress Progress) error
// Remove removes single file under public path
Remove(path string) error
// LinkFromPool links package file from pool to dist's pool location
- LinkFromPool(publishedDirectory string, sourcePool PackagePool, sourcePath string) error
+ LinkFromPool(publishedDirectory string, sourcePool PackagePool, sourcePath, sourceMD5 string, force bool) error
// Filelist returns list of files under prefix
Filelist(prefix string) ([]string, error)
- // ChecksumsForFile proxies requests to utils.ChecksumsForFile, joining public path
- ChecksumsForFile(path string) (utils.ChecksumInfo, error)
// RenameFile renames (moves) file
RenameFile(oldName, newName string) error
}
+// LocalPublishedStorage is published storage on local filesystem
+type LocalPublishedStorage interface {
+ // PublicPath returns root of public part
+ PublicPath() string
+}
+
+// PublishedStorageProvider is a thing that returns PublishedStorage by name
+type PublishedStorageProvider interface {
+ // GetPublishedStorage returns PublishedStorage by name
+ GetPublishedStorage(name string) PublishedStorage
+}
+
// Progress is a progress displaying entity, it allows progress bars & simple prints
type Progress interface {
// Writer interface to support progress bar ticking
diff --git a/src/github.com/smira/aptly/aptly/version.go b/src/github.com/smira/aptly/aptly/version.go
index 473dde13..a8eb503d 100644
--- a/src/github.com/smira/aptly/aptly/version.go
+++ b/src/github.com/smira/aptly/aptly/version.go
@@ -1,7 +1,7 @@
package aptly
// Version of aptly
-const Version = "0.5"
+const Version = "0.7.1"
// Enable debugging features?
const EnableDebug = false
diff --git a/src/github.com/smira/aptly/cmd/context.go b/src/github.com/smira/aptly/cmd/context.go
index 9594dbd3..58d322af 100644
--- a/src/github.com/smira/aptly/cmd/context.go
+++ b/src/github.com/smira/aptly/cmd/context.go
@@ -8,7 +8,9 @@ import (
"github.com/smira/aptly/deb"
"github.com/smira/aptly/files"
"github.com/smira/aptly/http"
+ "github.com/smira/aptly/s3"
"github.com/smira/aptly/utils"
+ "github.com/smira/commander"
"github.com/smira/flag"
"os"
"path/filepath"
@@ -27,7 +29,7 @@ type AptlyContext struct {
downloader aptly.Downloader
database database.Storage
packagePool aptly.PackagePool
- publishedStorage aptly.PublishedStorage
+ publishedStorages map[string]aptly.PublishedStorage
collectionFactory *deb.CollectionFactory
dependencyOptions int
architecturesList []string
@@ -39,6 +41,9 @@ type AptlyContext struct {
var context *AptlyContext
+// Check interface
+var _ aptly.PublishedStorageProvider = &AptlyContext{}
+
// FatalError is type for panicking to abort execution with non-zero
// exit code and print meaningful explanation
type FatalError struct {
@@ -48,7 +53,11 @@ type FatalError struct {
// Fatal panics and aborts execution with exit code 1
func Fatal(err error) {
- panic(&FatalError{ReturnCode: 1, Message: err.Error()})
+ returnCode := 1
+ if err == commander.ErrFlagError || err == commander.ErrCommandError {
+ returnCode = 2
+ }
+ panic(&FatalError{ReturnCode: returnCode, Message: err.Error()})
}
// Config loads and returns current configuration
@@ -138,7 +147,16 @@ func (context *AptlyContext) Progress() aptly.Progress {
// Downloader returns instance of current downloader
func (context *AptlyContext) Downloader() aptly.Downloader {
if context.downloader == nil {
- context.downloader = http.NewDownloader(context.Config().DownloadConcurrency, context.Progress())
+ var downloadLimit int64
+ limitFlag := context.flags.Lookup("download-limit")
+ if limitFlag != nil {
+ downloadLimit = limitFlag.Value.Get().(int64)
+ }
+ if downloadLimit == 0 {
+ downloadLimit = context.Config().DownloadLimit
+ }
+ context.downloader = http.NewDownloader(context.Config().DownloadConcurrency,
+ downloadLimit*1024, context.Progress())
}
return context.downloader
@@ -186,12 +204,30 @@ func (context *AptlyContext) PackagePool() aptly.PackagePool {
}
// PublishedStorage returns instance of PublishedStorage
-func (context *AptlyContext) PublishedStorage() aptly.PublishedStorage {
- if context.publishedStorage == nil {
- context.publishedStorage = files.NewPublishedStorage(context.Config().RootDir)
+func (context *AptlyContext) GetPublishedStorage(name string) aptly.PublishedStorage {
+ publishedStorage, ok := context.publishedStorages[name]
+ if !ok {
+ if name == "" {
+ publishedStorage = files.NewPublishedStorage(context.Config().RootDir)
+ } else if strings.HasPrefix(name, "s3:") {
+ params, ok := context.Config().S3PublishRoots[name[3:]]
+ if !ok {
+ Fatal(fmt.Errorf("published S3 storage %v not configured", name[3:]))
+ }
+
+ var err error
+ publishedStorage, err = s3.NewPublishedStorage(params.AccessKeyID, params.SecretAccessKey,
+ params.Region, params.Bucket, params.ACL, params.Prefix)
+ if err != nil {
+ Fatal(err)
+ }
+ } else {
+ Fatal(fmt.Errorf("unknown published storage format: %v", name))
+ }
+ context.publishedStorages[name] = publishedStorage
}
- return context.publishedStorage
+ return publishedStorage
}
// ShutdownContext shuts context down
@@ -227,7 +263,11 @@ func ShutdownContext() {
func InitContext(flags *flag.FlagSet) error {
var err error
- context = &AptlyContext{flags: flags, dependencyOptions: -1}
+ context = &AptlyContext{
+ flags: flags,
+ dependencyOptions: -1,
+ publishedStorages: map[string]aptly.PublishedStorage{},
+ }
if aptly.EnableDebug {
cpuprofile := flags.Lookup("cpuprofile").Value.String()
diff --git a/src/github.com/smira/aptly/cmd/db_cleanup.go b/src/github.com/smira/aptly/cmd/db_cleanup.go
index 18d1dda7..f522ebee 100644
--- a/src/github.com/smira/aptly/cmd/db_cleanup.go
+++ b/src/github.com/smira/aptly/cmd/db_cleanup.go
@@ -14,7 +14,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
if len(args) != 0 {
cmd.Usage()
- return err
+ return commander.ErrCommandError
}
// collect information about references packages...
diff --git a/src/github.com/smira/aptly/cmd/db_recover.go b/src/github.com/smira/aptly/cmd/db_recover.go
index 53f5a30d..127f775e 100644
--- a/src/github.com/smira/aptly/cmd/db_recover.go
+++ b/src/github.com/smira/aptly/cmd/db_recover.go
@@ -11,7 +11,7 @@ func aptlyDbRecover(cmd *commander.Command, args []string) error {
if len(args) != 0 {
cmd.Usage()
- return err
+ return commander.ErrCommandError
}
context.Progress().Printf("Recovering database...\n")
diff --git a/src/github.com/smira/aptly/cmd/graph.go b/src/github.com/smira/aptly/cmd/graph.go
index 32f6e349..28bbc969 100644
--- a/src/github.com/smira/aptly/cmd/graph.go
+++ b/src/github.com/smira/aptly/cmd/graph.go
@@ -13,14 +13,15 @@ import (
"strings"
)
-func graphvizEscape(s string) string {
- return fmt.Sprintf("\"%s\"", strings.Replace(s, "\"", "\\\"", 0))
-}
-
func aptlyGraph(cmd *commander.Command, args []string) error {
var err error
- graph := gographviz.NewGraph()
+ if len(args) != 0 {
+ cmd.Usage()
+ return commander.ErrCommandError
+ }
+
+ graph := gographviz.NewEscape()
graph.SetDir(true)
graph.SetName("aptly")
@@ -34,13 +35,13 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
return err
}
- graph.AddNode("aptly", graphvizEscape(repo.UUID), map[string]string{
+ graph.AddNode("aptly", repo.UUID, map[string]string{
"shape": "Mrecord",
"style": "filled",
"fillcolor": "darkgoldenrod1",
- "label": graphvizEscape(fmt.Sprintf("{Mirror %s|url: %s|dist: %s|comp: %s|arch: %s|pkgs: %d}",
+ "label": fmt.Sprintf("{Mirror %s|url: %s|dist: %s|comp: %s|arch: %s|pkgs: %d}",
repo.Name, repo.ArchiveRoot, repo.Distribution, strings.Join(repo.Components, ", "),
- strings.Join(repo.Architectures, ", "), repo.NumPackages())),
+ strings.Join(repo.Architectures, ", "), repo.NumPackages()),
})
existingNodes[repo.UUID] = true
return nil
@@ -58,12 +59,12 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
return err
}
- graph.AddNode("aptly", graphvizEscape(repo.UUID), map[string]string{
+ graph.AddNode("aptly", repo.UUID, map[string]string{
"shape": "Mrecord",
"style": "filled",
"fillcolor": "mediumseagreen",
- "label": graphvizEscape(fmt.Sprintf("{Repo %s|comment: %s|pkgs: %d}",
- repo.Name, repo.Comment, repo.NumPackages())),
+ "label": fmt.Sprintf("{Repo %s|comment: %s|pkgs: %d}",
+ repo.Name, repo.Comment, repo.NumPackages()),
})
existingNodes[repo.UUID] = true
return nil
@@ -91,18 +92,18 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
description = "Snapshot from repo"
}
- graph.AddNode("aptly", graphvizEscape(snapshot.UUID), map[string]string{
+ graph.AddNode("aptly", snapshot.UUID, map[string]string{
"shape": "Mrecord",
"style": "filled",
"fillcolor": "cadetblue1",
- "label": graphvizEscape(fmt.Sprintf("{Snapshot %s|%s|pkgs: %d}", snapshot.Name, description, snapshot.NumPackages())),
+ "label": fmt.Sprintf("{Snapshot %s|%s|pkgs: %d}", snapshot.Name, description, snapshot.NumPackages()),
})
if snapshot.SourceKind == "repo" || snapshot.SourceKind == "local" || snapshot.SourceKind == "snapshot" {
for _, uuid := range snapshot.SourceIDs {
_, exists := existingNodes[uuid]
if exists {
- graph.AddEdge(graphvizEscape(uuid), "", graphvizEscape(snapshot.UUID), "", true, nil)
+ graph.AddEdge(uuid, snapshot.UUID, true, nil)
}
}
}
@@ -116,16 +117,19 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
fmt.Printf("Loading published repos...\n")
context.CollectionFactory().PublishedRepoCollection().ForEach(func(repo *deb.PublishedRepo) error {
- graph.AddNode("aptly", graphvizEscape(repo.UUID), map[string]string{
+ graph.AddNode("aptly", repo.UUID, map[string]string{
"shape": "Mrecord",
"style": "filled",
"fillcolor": "darkolivegreen1",
- "label": graphvizEscape(fmt.Sprintf("{Published %s/%s|comp: %s|arch: %s}", repo.Prefix, repo.Distribution, repo.Component, strings.Join(repo.Architectures, ", "))),
+ "label": fmt.Sprintf("{Published %s/%s|comp: %s|arch: %s}", repo.Prefix, repo.Distribution,
+ strings.Join(repo.Components(), " "), strings.Join(repo.Architectures, ", ")),
})
- _, exists := existingNodes[repo.SourceUUID]
- if exists {
- graph.AddEdge(graphvizEscape(repo.SourceUUID), "", graphvizEscape(repo.UUID), "", true, nil)
+ for _, uuid := range repo.Sources {
+ _, exists := existingNodes[uuid]
+ if exists {
+ graph.AddEdge(uuid, repo.UUID, true, nil)
+ }
}
return nil
diff --git a/src/github.com/smira/aptly/cmd/mirror.go b/src/github.com/smira/aptly/cmd/mirror.go
index 13be9dd1..500ba189 100644
--- a/src/github.com/smira/aptly/cmd/mirror.go
+++ b/src/github.com/smira/aptly/cmd/mirror.go
@@ -54,6 +54,8 @@ func makeCmdMirror() *commander.Command {
makeCmdMirrorShow(),
makeCmdMirrorDrop(),
makeCmdMirrorUpdate(),
+ makeCmdMirrorRename(),
+ makeCmdMirrorEdit(),
},
}
}
diff --git a/src/github.com/smira/aptly/cmd/mirror_create.go b/src/github.com/smira/aptly/cmd/mirror_create.go
index 327ef2d0..b902b26c 100644
--- a/src/github.com/smira/aptly/cmd/mirror_create.go
+++ b/src/github.com/smira/aptly/cmd/mirror_create.go
@@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"github.com/smira/aptly/deb"
+ "github.com/smira/aptly/query"
"github.com/smira/commander"
"github.com/smira/flag"
"strings"
@@ -12,7 +13,7 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) error {
var err error
if !(len(args) == 2 && strings.HasPrefix(args[1], "ppa:") || len(args) >= 3) {
cmd.Usage()
- return err
+ return commander.ErrCommandError
}
downloadSources := context.Config().DownloadSourcePackages || context.flags.Lookup("with-sources").Value.Get().(bool)
@@ -37,6 +38,16 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) error {
return fmt.Errorf("unable to create mirror: %s", err)
}
+ repo.Filter = context.flags.Lookup("filter").Value.String()
+ repo.FilterWithDeps = context.flags.Lookup("filter-with-deps").Value.Get().(bool)
+
+ if repo.Filter != "" {
+ _, err = query.Parse(repo.Filter)
+ if err != nil {
+ return fmt.Errorf("unable to create mirror: %s", err)
+ }
+ }
+
verifier, err := getVerifier(context.flags)
if err != nil {
return fmt.Errorf("unable to initialize GPG verifier: %s", err)
@@ -63,7 +74,8 @@ func makeCmdMirrorCreate() *commander.Command {
Short: "create new mirror",
Long: `
Creates mirror of remote repository, aptly supports both regular and flat Debian repositories exported
-via HTTP. aptly would try download Release file from remote repository and verify its' signature.
+via HTTP. aptly would try download Release file from remote repository and verify its' signature. Command
+line format resembles apt utlitily sources.list(5).
PPA urls could specified in short format:
@@ -78,6 +90,8 @@ Example:
cmd.Flag.Bool("ignore-signatures", false, "disable verification of Release file signatures")
cmd.Flag.Bool("with-sources", false, "download source packages in addition to binary packages")
+ cmd.Flag.String("filter", "", "filter packages in mirror")
+ cmd.Flag.Bool("filter-with-deps", false, "when filtering, include dependencies of matching packages as well")
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)")
return cmd
diff --git a/src/github.com/smira/aptly/cmd/mirror_drop.go b/src/github.com/smira/aptly/cmd/mirror_drop.go
index c7a650ac..97c62e40 100644
--- a/src/github.com/smira/aptly/cmd/mirror_drop.go
+++ b/src/github.com/smira/aptly/cmd/mirror_drop.go
@@ -10,7 +10,7 @@ func aptlyMirrorDrop(cmd *commander.Command, args []string) error {
var err error
if len(args) != 1 {
cmd.Usage()
- return err
+ return commander.ErrCommandError
}
name := args[0]
diff --git a/src/github.com/smira/aptly/cmd/mirror_edit.go b/src/github.com/smira/aptly/cmd/mirror_edit.go
new file mode 100644
index 00000000..15f41f64
--- /dev/null
+++ b/src/github.com/smira/aptly/cmd/mirror_edit.go
@@ -0,0 +1,67 @@
+package cmd
+
+import (
+ "fmt"
+ "github.com/smira/aptly/query"
+ "github.com/smira/commander"
+ "github.com/smira/flag"
+)
+
+func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
+ var err error
+ if len(args) != 1 {
+ cmd.Usage()
+ return commander.ErrCommandError
+ }
+
+ repo, err := context.CollectionFactory().RemoteRepoCollection().ByName(args[0])
+ if err != nil {
+ return fmt.Errorf("unable to edit: %s", err)
+ }
+
+ context.flags.Visit(func(flag *flag.Flag) {
+ switch flag.Name {
+ case "filter":
+ repo.Filter = flag.Value.String()
+ case "filter-with-deps":
+ repo.FilterWithDeps = flag.Value.Get().(bool)
+ }
+ })
+
+ if repo.Filter != "" {
+ _, err = query.Parse(repo.Filter)
+ if err != nil {
+ return fmt.Errorf("unable to edit: %s", err)
+ }
+ }
+
+ err = context.CollectionFactory().RemoteRepoCollection().Update(repo)
+ if err != nil {
+ return fmt.Errorf("unable to edit: %s", err)
+ }
+
+ fmt.Printf("Mirror %s successfully updated.\n", repo)
+ return err
+}
+
+func makeCmdMirrorEdit() *commander.Command {
+ cmd := &commander.Command{
+ Run: aptlyMirrorEdit,
+ UsageLine: "edit ",
+ Short: "edit properties of mirorr",
+ Long: `
+Command edit allows to change settings of mirror:
+filters.
+
+Example:
+
+ $ aptly mirror edit -filter=nginx -filter-with-deps some-mirror
+`,
+ Flag: *flag.NewFlagSet("aptly-mirror-edit", flag.ExitOnError),
+ }
+
+ cmd.Flag.String("filter", "", "filter packages in mirror")
+ cmd.Flag.Bool("filter-with-deps", false, "when filtering, include dependencies of matching packages as well")
+
+ return cmd
+}
diff --git a/src/github.com/smira/aptly/cmd/mirror_list.go b/src/github.com/smira/aptly/cmd/mirror_list.go
index 11d9caba..933a5b6d 100644
--- a/src/github.com/smira/aptly/cmd/mirror_list.go
+++ b/src/github.com/smira/aptly/cmd/mirror_list.go
@@ -11,7 +11,7 @@ func aptlyMirrorList(cmd *commander.Command, args []string) error {
var err error
if len(args) != 0 {
cmd.Usage()
- return err
+ return commander.ErrCommandError
}
raw := cmd.Flag.Lookup("raw").Value.Get().(bool)
diff --git a/src/github.com/smira/aptly/cmd/mirror_rename.go b/src/github.com/smira/aptly/cmd/mirror_rename.go
new file mode 100644
index 00000000..5cbfebe5
--- /dev/null
+++ b/src/github.com/smira/aptly/cmd/mirror_rename.go
@@ -0,0 +1,59 @@
+package cmd
+
+import (
+ "fmt"
+ "github.com/smira/aptly/deb"
+ "github.com/smira/commander"
+)
+
+func aptlyMirrorRename(cmd *commander.Command, args []string) error {
+ var (
+ err error
+ repo *deb.RemoteRepo
+ )
+
+ if len(args) != 2 {
+ cmd.Usage()
+ return commander.ErrCommandError
+ }
+
+ oldName, newName := args[0], args[1]
+
+ repo, err = context.CollectionFactory().RemoteRepoCollection().ByName(oldName)
+ if err != nil {
+ return fmt.Errorf("unable to rename: %s", err)
+ }
+
+ _, err = context.CollectionFactory().RemoteRepoCollection().ByName(newName)
+ if err == nil {
+ return fmt.Errorf("unable to rename: mirror %s already exists", newName)
+ }
+
+ repo.Name = newName
+ err = context.CollectionFactory().RemoteRepoCollection().Update(repo)
+ if err != nil {
+ return fmt.Errorf("unable to rename: %s", err)
+ }
+
+ fmt.Printf("\nMirror %s -> %s has been successfully renamed.\n", oldName, newName)
+
+ return err
+}
+
+func makeCmdMirrorRename() *commander.Command {
+ cmd := &commander.Command{
+ Run: aptlyMirrorRename,
+ UsageLine: "rename
- {{end}} - {{.XML}} -