/src/github.com/ullaakut/cameradar/dictionaries/credentials.json", "The path on which to load a custom credentials JSON dictionary")
pflag.IntP("speed", "s", 4, "The nmap speed preset to use for discovery")
pflag.IntP("timeout", "T", 2000, "The timeout in miliseconds to use for attack attempts")
pflag.BoolP("log", "l", false, "Enable the logs for nmap's output to stdout")
diff --git a/cmrdr.go b/cmrdr.go
index 1702c38..d6ac420 100644
--- a/cmrdr.go
+++ b/cmrdr.go
@@ -3,7 +3,7 @@
// IP Cameras, often for surveillance.
//
// A simple example usage of the library can be found in
-// https://github.com/Ullaakut/cameradar/tree/master/cameradar
+// https://github.com/ullaakut/cameradar/tree/master/cameradar
//
// The example usage is complete enough for most users to
// ignore the library, but for users with specific needs
diff --git a/curl.go b/curl.go
index 64782f2..e9c7d7b 100644
--- a/curl.go
+++ b/curl.go
@@ -1,7 +1,7 @@
package cmrdr
import (
- curl "github.com/andelf/go-curl"
+ curl "github.com/ullaakut/go-curl"
)
// Curler is an interface that implements the CURL interface of the go-curl library
diff --git a/curl_test.go b/curl_test.go
index bc50a94..7728d4c 100644
--- a/curl_test.go
+++ b/curl_test.go
@@ -4,7 +4,7 @@ import (
"reflect"
"testing"
- curl "github.com/andelf/go-curl"
+ curl "github.com/ullaakut/go-curl"
)
func TestCurl(t *testing.T) {
diff --git a/discover.go b/discover.go
index ea13dc9..ca1d251 100644
--- a/discover.go
+++ b/discover.go
@@ -3,7 +3,7 @@ package cmrdr
import (
"strings"
- "github.com/Ullaakut/nmap"
+ "github.com/ullaakut/nmap"
)
// Discover scans the target networks and tries to find RTSP streams within them.
diff --git a/discover_test.go b/discover_test.go
index 9f036ab..3d17f1e 100644
--- a/discover_test.go
+++ b/discover_test.go
@@ -5,7 +5,7 @@ import (
"os"
"testing"
- "github.com/Ullaakut/nmap"
+ "github.com/ullaakut/nmap"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..470b283
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,17 @@
+module github.com/ullaakut/cameradar
+
+require (
+ github.com/Ullaakut/nmap v0.0.0-20190306183004-e38898a9bead // indirect
+ github.com/fatih/color v1.7.0 // indirect
+ github.com/gernest/wow v0.1.0 // indirect
+ github.com/go-playground/locales v0.12.1 // indirect
+ github.com/go-playground/universal-translator v0.16.0 // indirect
+ github.com/leodido/go-urn v1.1.0 // indirect
+ github.com/mattn/go-colorable v0.1.1 // indirect
+ github.com/mattn/go-isatty v0.0.6 // indirect
+ github.com/pkg/errors v0.8.1
+ github.com/spf13/viper v1.3.1 // indirect
+ github.com/ullaakut/go-curl v0.0.0-20190310175419-50acab4cef70
+ github.com/ullaakut/nmap v0.0.0-20190306183004-e38898a9bead
+ gopkg.in/go-playground/validator.v9 v9.27.0
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..a1561c5
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,67 @@
+github.com/Ullaakut/nmap v0.0.0-20190306183004-e38898a9bead h1:iclmd4In7CnuZGbbnnaeF1DtSePgXxN71pq5UNI1M7c=
+github.com/Ullaakut/nmap v0.0.0-20190306183004-e38898a9bead/go.mod h1:fkC066hwfcoKwlI7DS2ARTggSVtBTZYCjVH1TzuTMaQ=
+github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
+github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
+github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
+github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/gernest/wow v0.1.0 h1:g9xdwCwP0+xgVYlA2sopI0gZHqXe7HjI/7/LykG4fks=
+github.com/gernest/wow v0.1.0/go.mod h1:dEPabJRi5BneI1Nev1VWo0ZlcTWibHWp43qxKms4elY=
+github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc=
+github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
+github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM=
+github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
+github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8=
+github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
+github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
+github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
+github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
+github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mattn/go-isatty v0.0.6 h1:SrwhHcpV4nWrMGdNcC2kXpMfcBVYGDuTArqyhocJgvA=
+github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
+github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
+github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
+github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
+github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
+github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
+github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38=
+github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
+github.com/ullaakut/go-curl v0.0.0-20190310175419-50acab4cef70 h1:3q4hgRu9NT894aYmnoMFl5wPvdNhpHYmdi2+Njyxq5U=
+github.com/ullaakut/go-curl v0.0.0-20190310175419-50acab4cef70/go.mod h1:FTfXm4jC9Ff1yqc3/HMXCyr+SGO03vJyijJCQlNyF10=
+github.com/ullaakut/nmap v0.0.0-20190306183004-e38898a9bead h1:Pw5wKSAfxi8GcYJSc3GdcwtPG5tyg7zg9E3hAHbLPO0=
+github.com/ullaakut/nmap v0.0.0-20190306183004-e38898a9bead/go.mod h1:4CQy4PqZA4Snk3+MS26+1oAkJ8dCY8kGH6+kF42yajw=
+github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
+golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc h1:F5tKCVGp+MUAHhKp5MZtGqAlGX3+oCsiL1Q629FL90M=
+golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190116161447-11f53e031339 h1:g/Jesu8+QLnA0CPzF3E1pURg0Byr7i6jLoX5sqjcAh0=
+golang.org/x/sys v0.0.0-20190116161447-11f53e031339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
+golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/go-playground/validator.v9 v9.27.0 h1:wCg/0hk9RzcB0CYw8pYV6FiBYug1on0cpco9YZF8jqA=
+gopkg.in/go-playground/validator.v9 v9.27.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/github.com/Ullaakut/nmap/.gitignore b/vendor/github.com/Ullaakut/nmap/.gitignore
deleted file mode 100644
index 6409731..0000000
--- a/vendor/github.com/Ullaakut/nmap/.gitignore
+++ /dev/null
@@ -1,123 +0,0 @@
-## Golang
-
-### Binaries for programs and plugins
-*.exe
-*.exe~
-*.dll
-*.so
-*.dylib
-
-### Test binary, built with `go test -c`
-*.test
-
-### Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-## MacOS
-
-### General
-.DS_Store
-.AppleDouble
-.LSOverride
-
-### Icon must end with two \r
-Icon
-
-
-### Thumbnails
-._*
-
-### Files that might appear in the root of a volume
-.DocumentRevisions-V100
-.fseventsd
-.Spotlight-V100
-.TemporaryItems
-.Trashes
-.VolumeIcon.icns
-.com.apple.timemachine.donotpresent
-
-### Directories potentially created on remote AFP share
-.AppleDB
-.AppleDesktop
-Network Trash Folder
-Temporary Items
-.apdisk
-
-## IDEs
-
-### VSCode
-
-.vscode/*
-!.vscode/settings.json
-!.vscode/tasks.json
-!.vscode/launch.json
-!.vscode/extensions.json
-
-### JetBrains
-
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
-# User-specific stuff
-.idea/**/workspace.xml
-.idea/**/tasks.xml
-.idea/**/usage.statistics.xml
-.idea/**/dictionaries
-.idea/**/shelf
-
-# Generated files
-.idea/**/contentModel.xml
-
-# Sensitive or high-churn files
-.idea/**/dataSources/
-.idea/**/dataSources.ids
-.idea/**/dataSources.local.xml
-.idea/**/sqlDataSources.xml
-.idea/**/dynamic.xml
-.idea/**/uiDesigner.xml
-.idea/**/dbnavigator.xml
-
-# Gradle
-.idea/**/gradle.xml
-.idea/**/libraries
-
-# Gradle and Maven with auto-import
-# When using Gradle or Maven with auto-import, you should exclude module files,
-# since they will be recreated, and may cause churn. Uncomment if using
-# auto-import.
-# .idea/modules.xml
-# .idea/*.iml
-# .idea/modules
-
-# CMake
-cmake-build-*/
-
-# Mongo Explorer plugin
-.idea/**/mongoSettings.xml
-
-# File-based project format
-*.iws
-
-# IntelliJ
-out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Cursive Clojure plugin
-.idea/replstate.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-# Editor-based Rest Client
-.idea/httpRequests
-
-# Android studio 3.1+ serialized cache file
-.idea/caches/build_file_checksums.ser
diff --git a/vendor/github.com/Ullaakut/nmap/.golangci.yml b/vendor/github.com/Ullaakut/nmap/.golangci.yml
deleted file mode 100644
index 77d054b..0000000
--- a/vendor/github.com/Ullaakut/nmap/.golangci.yml
+++ /dev/null
@@ -1,159 +0,0 @@
-# This file contains all available configuration options
-# with their default values.
-
-# options for analysis running
-run:
- # timeout for analysis, e.g. 30s, 5m, default is 1m
- deadline: 1m
-
- tests: false
-
- # which dirs to skip: they won't be analyzed;
- # can use regexp here: generated.*, regexp is applied on full path;
- # default value is empty list, but next dirs are always skipped independently
- # from this option's value:
- # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
- skip-dirs:
- - pkg/osfamilies
-
-# output configuration options
-output:
- # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
- format: colored-line-number
-
- # print lines of code with issue, default is true
- print-issued-lines: true
-
- # print linter name in the end of issue text, default is true
- print-linter-name: true
-
-
-# all available settings of specific linters
-linters-settings:
- errcheck:
- # report about not checking of errors in type assetions: `a := b.(MyStruct)`;
- # default is false: such cases aren't reported by default.
- check-type-assertions: false
-
- # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
- # default is false: such cases aren't reported by default.
- check-blank: false
-
- # [deprecated] comma-separated list of pairs of the form pkg:regex
- # the regex is used to ignore names within pkg. (default "fmt:.*").
- # see https://github.com/kisielk/errcheck#the-deprecated-method for details
- ignore: fmt:.*,io/ioutil:^Read.*,os/exec:^Kill.*
-
- govet:
- # report about shadowed variables
- check-shadowing: true
- golint:
- # minimal confidence for issues, default is 0.8
- min-confidence: 0.8
- gofmt:
- # simplify code: gofmt with `-s` option, true by default
- simplify: true
- goimports:
- # put imports beginning with prefix after 3rd-party packages;
- # it's a comma-separated list of prefixes
- local-prefixes: github.com/org/project
- gocyclo:
- # minimal code complexity to report, 30 by default (but we recommend 10-20)
- min-complexity: 10
- maligned:
- # print struct with more effective memory layout or not, false by default
- suggest-new: true
- dupl:
- # tokens count to trigger issue, 150 by default
- threshold: 150
- goconst:
- # minimal length of string constant, 3 by default
- min-len: 3
- # minimal occurrences count to trigger, 3 by default
- min-occurrences: 3
- depguard:
- list-type: blacklist
- include-go-root: false
- packages:
- - github.com/davecgh/go-spew/spew
- misspell:
- # Correct spellings using locale preferences for US or UK.
- # Default is to use a neutral variety of English.
- # Setting locale to US will correct the British spelling of 'colour' to 'color'.
- locale: US
- lll:
- # max line length, lines longer will be reported. Default is 120.
- # '\t' is counted as 1 character by default, and can be changed with the tab-width option
- line-length: 120
- # tab width in spaces. Default to 1.
- tab-width: 1
- unused:
- # treat code as a program (not a library) and report unused exported identifiers; default is false.
- # XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
- # if it's called for subdir of a project it can't find funcs usages. All text editor integrations
- # with golangci-lint call it on a directory with the changed file.
- check-exported: false
- unparam:
- # call graph construction algorithm (cha, rta). In general, use cha for libraries,
- # and rta for programs with main packages. Default is cha.
- algo: cha
-
- # Inspect exported functions, default is false. Set to true if no external program/library imports your code.
- # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
- # if it's called for subdir of a project it can't find external interfaces. All text editor integrations
- # with golangci-lint call it on a directory with the changed file.
- check-exported: false
- nakedret:
- # make an issue if func has more lines of code than this setting and it has naked returns; default is 30
- max-func-lines: 30
- prealloc:
- # XXX: we don't recommend using this linter before doing performance profiling.
- # For most programs usage of prealloc will be a premature optimization.
-
- # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
- # True by default.
- simple: true
- range-loops: true # Report preallocation suggestions on range loops, true by default
- for-loops: false # Report preallocation suggestions on for loops, false by default
- gocritic:
- # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
- # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
- enabled-tags:
- - performance
-
-linters:
- enable:
- - megacheck
- - govet
- enable-all: false
- disable:
- - maligned
- - prealloc
- disable-all: false
- presets:
- - bugs
- - unused
- fast: false
-
-
-issues:
- # List of regexps of issue texts to exclude, empty list by default.
- # But independently from this option we use default exclude patterns,
- # it can be disabled by `exclude-use-default: false`. To list all
- # excluded by default patterns execute `golangci-lint run --help`
- exclude:
- - "Subprocess launching should be audited"
-
- # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
- max-per-linter: 0
-
- # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
- max-same-issues: 0
-
- # Show only new issues: if there are unstaged changes or untracked files,
- # only those changes are analyzed, else only changes in HEAD~ are analyzed.
- # It's a super-useful option for integration of golangci-lint into existing
- # large codebase. It's not practical to fix all existing issues at the moment
- # of integration: much better don't allow issues in new code.
- # Default is false.
- new: false
diff --git a/vendor/github.com/Ullaakut/nmap/.travis.yml b/vendor/github.com/Ullaakut/nmap/.travis.yml
deleted file mode 100644
index 6c35b31..0000000
--- a/vendor/github.com/Ullaakut/nmap/.travis.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-dist: trusty
-sudo: required
-language: go
-
-before_install:
-- sudo apt-get install -y nmap
-- go get github.com/mattn/goveralls
-
-script:
-# Run unit tests
-- go test -v -covermode=count -coverprofile=coverage.out
-- $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken=$COVERALLS_TOKEN
-# Ensure the examples compile
-- for dir in examples/*/; do go build -o $dir/bin $dir/main.go; done
-notifications:
- email:
- recipients:
- - brendan.le-glaunec@epitech.eu
- on_success: never
- on_failure: always
diff --git a/vendor/github.com/Ullaakut/nmap/LICENSE b/vendor/github.com/Ullaakut/nmap/LICENSE
deleted file mode 100644
index b92c230..0000000
--- a/vendor/github.com/Ullaakut/nmap/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2019 Ullaakut
-
-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/vendor/github.com/Ullaakut/nmap/README.md b/vendor/github.com/Ullaakut/nmap/README.md
deleted file mode 100644
index 64ae3b4..0000000
--- a/vendor/github.com/Ullaakut/nmap/README.md
+++ /dev/null
@@ -1,114 +0,0 @@
-# nmap
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-This library aims at providing idiomatic `nmap` bindings for go developers, in order to make it easier to write security audit tools using golang.
-
-
-
-## It's currently a work in progress
-
-This paragraph won't be removed until the library is ready to be used and properly documented.
-
-## Supported features
-
-- [x] All of `nmap`'s options as `WithXXX` methods.
-- [x] Cancellable contexts support.
-- [x] [Idiomatic go filters](examples/service_detection/main.go#L19).
-- [x] Helpful enums for most nmap commands. (time templates, os families, port states, etc.)
-- [x] Complete documentation of each option, mostly insipred from nmap's documentation.
-
-## TODO
-
-- [ ] Examples of usage - Work in progress (4/7 examples so far)
-- [ ] Complete unit tests - Work in progress (95% coverage so far)
-- [ ] Asynchronous scan
-
-## Example
-
-```go
-package main
-
-import (
- "context"
- "fmt"
- "log"
- "time"
-
- "github.com/Ullaakut/nmap"
-)
-
-func main() {
- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
- defer cancel()
-
- // Equivalent to `/usr/local/bin/nmap -p 80,443,843 google.com facebook.com youtube.com`,
- // with a 5 minute timeout.
- scanner, err := nmap.NewScanner(
- nmap.WithTargets("google.com", "facebook.com", "youtube.com"),
- nmap.WithPorts("80,443,843"),
- nmap.WithContext(ctx),
- )
- if err != nil {
- log.Fatalf("unable to create nmap scanner: %v", err)
- }
-
- result, err := scanner.Run()
- if err != nil {
- log.Fatalf("unable to run nmap scan: %v", err)
- }
-
- // Use the results to print an example output
- for _, host := range result.Hosts {
- if len(host.Ports) == 0 || len(host.Addresses) == 0 {
- continue
- }
-
- fmt.Printf("Host %q:\n", host.Addresses[0])
-
- for _, port := range host.Ports {
- fmt.Printf("\tPort %d/%s %s %s\n", port.ID, port.Protocol, port.State, port.Service.Name)
- }
- }
-
- fmt.Printf("Nmap done: %d hosts up scanned in %3f seconds\n", len(result.Hosts), result.Stats.Finished.Elapsed)
-}
-```
-
-The program above outputs:
-
-```bash
-Host "172.217.16.46":
- Port 80/tcp open http
- Port 443/tcp open https
- Port 843/tcp filtered unknown
-Host "31.13.81.36":
- Port 80/tcp open http
- Port 443/tcp open https
- Port 843/tcp open unknown
-Host "216.58.215.110":
- Port 80/tcp open http
- Port 443/tcp open https
- Port 843/tcp filtered unknown
-Nmap done: 3 hosts up scanned in 1.29 seconds
-```
diff --git a/vendor/github.com/Ullaakut/nmap/errors.go b/vendor/github.com/Ullaakut/nmap/errors.go
deleted file mode 100644
index 8bde456..0000000
--- a/vendor/github.com/Ullaakut/nmap/errors.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package nmap
-
-import (
- "errors"
-)
-
-var (
- // ErrNmapNotInstalled means that upon trying to manually locate nmap in the user's path,
- // it was not found. Either use the WithBinaryPath method to set it manually, or make sure that
- // the nmap binary is present in the user's $PATH.
- ErrNmapNotInstalled = errors.New("'nmap' binary was not found")
-
- // ErrScanTimeout means that the provided context was done before the scanner finished its scan.
- ErrScanTimeout = errors.New("nmap scan timed out")
-
- // ErrNoTargetsSpecified means that no targets were specified.
- ErrNoTargetsSpecified = errors.New("no targets specified")
-)
diff --git a/vendor/github.com/Ullaakut/nmap/examples_test.go b/vendor/github.com/Ullaakut/nmap/examples_test.go
deleted file mode 100644
index f61a21f..0000000
--- a/vendor/github.com/Ullaakut/nmap/examples_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package nmap
-
-import (
- "fmt"
- "log"
-)
-
-// A scanner can be instanciated with options to set the arguments
-// that are given to nmap.
-func ExampleScanner_simple() {
- s, err := NewScanner(
- WithTargets("google.com", "facebook.com", "youtube.com"),
- WithCustomDNSServers("8.8.8.8", "8.8.4.4"),
- WithTimingTemplate(TimingFastest),
- WithTCPScanFlags(FlagACK, FlagNULL, FlagRST),
- )
- if err != nil {
- log.Fatalf("unable to create nmap scanner: %v", err)
- }
-
- scanResult, err := s.Run()
- if err != nil {
- log.Fatalf("nmap encountered an error: %v", err)
- }
-
- fmt.Printf(
- "Scan successful: %d hosts up\n",
- scanResult.Stats.Hosts.Up,
- )
- // Output: Scan successful: 3 hosts up
-}
-
-// A scanner can be given custom idiomatic filters for both hosts
-// and ports.
-func ExampleScanner_filters() {
- s, err := NewScanner(
- WithTargets("google.com", "facebook.com"),
- WithPorts("843"),
- WithFilterHost(func(h Host) bool {
- // Filter out hosts with no open ports.
- for idx := range h.Ports {
- if h.Ports[idx].Status() == "open" {
- return true
- }
- }
- return false
- }),
- )
- if err != nil {
- log.Fatalf("unable to create nmap scanner: %v", err)
- }
-
- scanResult, err := s.Run()
- if err != nil {
- log.Fatalf("nmap encountered an error: %v", err)
- }
-
- fmt.Printf(
- "Filtered out hosts %d / Original number of hosts: %d\n",
- len(scanResult.Hosts),
- scanResult.Stats.Hosts.Total,
- )
- // Output: Filtered out hosts 1 / Original number of hosts: 2
-}
diff --git a/vendor/github.com/Ullaakut/nmap/nmap.go b/vendor/github.com/Ullaakut/nmap/nmap.go
deleted file mode 100644
index 5efdef6..0000000
--- a/vendor/github.com/Ullaakut/nmap/nmap.go
+++ /dev/null
@@ -1,1216 +0,0 @@
-// Package nmap provides idiomatic `nmap` bindings for go developers.
-package nmap
-
-import (
- "bytes"
- "context"
- "errors"
- "fmt"
- "os/exec"
- "strings"
- "time"
-)
-
-// ScanRunner represents something that can run a scan.
-type ScanRunner interface {
- Run() (*Run, error)
-}
-
-// Scanner represents an Nmap scanner.
-type Scanner struct {
- args []string
- binaryPath string
- ctx context.Context
-
- portFilter func(Port) bool
- hostFilter func(Host) bool
-}
-
-// NewScanner creates a new Scanner, and can take options to apply to the scanner.
-func NewScanner(options ...func(*Scanner)) (*Scanner, error) {
- scanner := &Scanner{}
-
- for _, option := range options {
- option(scanner)
- }
-
- if scanner.binaryPath == "" {
- var err error
- scanner.binaryPath, err = exec.LookPath("nmap")
- if err != nil {
- return nil, ErrNmapNotInstalled
- }
- }
-
- if scanner.ctx == nil {
- scanner.ctx = context.Background()
- }
-
- return scanner, nil
-}
-
-// Run runs nmap synchronously and returns the result of the scan.
-func (s *Scanner) Run() (*Run, error) {
- var stdout, stderr bytes.Buffer
-
- // Enable XML output
- s.args = append(s.args, "-oX")
-
- // Get XML output in stdout instead of writing it in a file
- s.args = append(s.args, "-")
-
- cmd := exec.Command(s.binaryPath, s.args...)
- cmd.Stdout = &stdout
- cmd.Stderr = &stderr
-
- err := cmd.Start()
- if err != nil {
- return nil, err
- }
-
- // Make a goroutine to notify the select when the scan is done.
- done := make(chan error)
- go func() {
- done <- cmd.Wait()
- }()
-
- select {
- case <-s.ctx.Done():
- // Context was done before the scan was finished.
- // The process is killed and a timeout error is returned.
- err := cmd.Process.Kill()
- if err != nil {
- return nil, ErrScanTimeout
- }
-
- return nil, ErrScanTimeout
- case <-done:
- // Scan finished before timeout.
- if stderr.Len() > 0 {
- return nil, errors.New(stderr.String())
- }
-
- result, err := Parse(stdout.Bytes())
- if err != nil {
- return nil, err
- }
-
- // Call filters if they are set.
- if s.portFilter != nil {
- result = choosePorts(result, s.portFilter)
- }
-
- if s.hostFilter != nil {
- result = chooseHosts(result, s.hostFilter)
- }
-
- return result, nil
- }
-}
-
-func chooseHosts(result *Run, filter func(Host) bool) *Run {
- var filteredHosts []Host
-
- for _, host := range result.Hosts {
- if filter(host) {
- filteredHosts = append(filteredHosts, host)
- }
- }
-
- result.Hosts = filteredHosts
-
- return result
-}
-
-func choosePorts(result *Run, filter func(Port) bool) *Run {
- for _, host := range result.Hosts {
- var filteredPorts []Port
-
- for _, port := range host.Ports {
- if filter(port) {
- filteredPorts = append(filteredPorts, port)
- }
- }
-
- host.Ports = filteredPorts
- }
-
- return result
-}
-
-func (s Scanner) String() string {
- return fmt.Sprint(s.binaryPath, s.args)
-}
-
-// WithContext adds a context to a scanner, to make it cancellable and able to timeout.
-func WithContext(ctx context.Context) func(*Scanner) {
- return func(s *Scanner) {
- s.ctx = ctx
- }
-}
-
-// WithBinaryPath sets the nmap binary path for a scanner.
-func WithBinaryPath(binaryPath string) func(*Scanner) {
- return func(s *Scanner) {
- s.binaryPath = binaryPath
- }
-}
-
-// WithCustomArguments sets custom arguments to give to the nmap binary.
-// There should be no reason to use this, unless you are using a custom build
-// of nmap or that this repository isn't up to date with the latest options
-// of the official nmap release.
-// You can use this as a quick way to paste an nmap command into your go code,
-// but remember that the whole purpose of this repository is to be idiomatic,
-// provide type checking, enums for the values that can be passed, etc.
-func WithCustomArguments(args ...string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, args...)
- }
-}
-
-// WithFilterPort allows to set a custom function to filter out ports that
-// don't fullfil a given condition. When the given function returns true,
-// the port is kept, otherwise it is removed from the result. Can be used
-// along with WithFilterHost.
-func WithFilterPort(portFilter func(Port) bool) func(*Scanner) {
- return func(s *Scanner) {
- s.portFilter = portFilter
- }
-}
-
-// WithFilterHost allows to set a custom function to filter out hosts that
-// don't fullfil a given condition. When the given function returns true,
-// the host is kept, otherwise it is removed from the result. Can be used
-// along with WithFilterPort.
-func WithFilterHost(hostFilter func(Host) bool) func(*Scanner) {
- return func(s *Scanner) {
- s.hostFilter = hostFilter
- }
-}
-
-/*** Target specification ***/
-
-// WithTargets sets the target of a scanner.
-func WithTargets(targets ...string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, targets...)
- }
-}
-
-// WithTargetExclusion sets the excluded targets of a scanner.
-func WithTargetExclusion(target string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--exclude")
- s.args = append(s.args, target)
- }
-}
-
-// WithTargetInput sets the input file name to set the targets.
-func WithTargetInput(inputFileName string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-iL")
- s.args = append(s.args, inputFileName)
- }
-}
-
-// WithTargetExclusionInput sets the input file name to set the target exclusions.
-func WithTargetExclusionInput(inputFileName string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--excludefile")
- s.args = append(s.args, inputFileName)
- }
-}
-
-// WithRandomTargets sets the amount of targets to randomly choose from the targets.
-func WithRandomTargets(randomTargets int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-iR")
- s.args = append(s.args, fmt.Sprint(randomTargets))
- }
-}
-
-/*** Host discovery ***/
-
-// WithListScan sets the discovery mode to simply list the targets to scan and not scan them.
-func WithListScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sL")
- }
-}
-
-// WithPingScan sets the discovery mode to simply ping the targets to scan and not scan them.
-func WithPingScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sn")
- }
-}
-
-// WithSkipHostDiscovery diables host discovery and considers all hosts as online.
-func WithSkipHostDiscovery() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-Pn")
- }
-}
-
-// WithSYNDiscovery sets the discovery mode to use SYN packets.
-// If the portList argument is empty, this will enable SYN discovery
-// for all ports. Otherwise, it will be only for the specified ports.
-func WithSYNDiscovery(ports ...string) func(*Scanner) {
- portList := strings.Join(ports, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("-PS%s", portList))
- }
-}
-
-// WithACKDiscovery sets the discovery mode to use ACK packets.
-// If the portList argument is empty, this will enable ACK discovery
-// for all ports. Otherwise, it will be only for the specified ports.
-func WithACKDiscovery(ports ...string) func(*Scanner) {
- portList := strings.Join(ports, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("-PA%s", portList))
- }
-}
-
-// WithUDPDiscovery sets the discovery mode to use UDP packets.
-// If the portList argument is empty, this will enable UDP discovery
-// for all ports. Otherwise, it will be only for the specified ports.
-func WithUDPDiscovery(ports ...string) func(*Scanner) {
- portList := strings.Join(ports, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("-PU%s", portList))
- }
-}
-
-// WithSCTPDiscovery sets the discovery mode to use SCTP packets
-// containing a minimal INIT chunk.
-// If the portList argument is empty, this will enable SCTP discovery
-// for all ports. Otherwise, it will be only for the specified ports.
-// Warning: on Unix, only the privileged user root is generally
-// able to send and receive raw SCTP packets.
-func WithSCTPDiscovery(ports ...string) func(*Scanner) {
- portList := strings.Join(ports, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("-PY%s", portList))
- }
-}
-
-// WithICMPEchoDiscovery sets the discovery mode to use an ICMP type 8
-// packet (an echo request), like the standard packets sent by the ping
-// command.
-// Many hosts and firewalls block these packets, so this is usually not
-// the best for exploring networks.
-func WithICMPEchoDiscovery() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-PE")
- }
-}
-
-// WithICMPTimestampDiscovery sets the discovery mode to use an ICMP type 13
-// packet (a timestamp request).
-// This query can be valuable when administrators specifically block echo
-// request packets while forgetting that other ICMP queries can be used
-// for the same purpose.
-func WithICMPTimestampDiscovery() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-PP")
- }
-}
-
-// WithICMPNetMaskDiscovery sets the discovery mode to use an ICMP type 17
-// packet (an address mask request).
-// This query can be valuable when administrators specifically block echo
-// request packets while forgetting that other ICMP queries can be used
-// for the same purpose.
-func WithICMPNetMaskDiscovery() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-PM")
- }
-}
-
-// WithIPProtocolPingDiscovery sets the discovery mode to use the IP
-// protocol ping.
-// If no protocols are specified, the default is to send multiple IP
-// packets for ICMP (protocol 1), IGMP (protocol 2), and IP-in-IP
-// (protocol 4).
-func WithIPProtocolPingDiscovery(protocols ...string) func(*Scanner) {
- protocolList := strings.Join(protocols, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("-PO%s", protocolList))
- }
-}
-
-// WithDisabledDNSResolution disables DNS resolution in the discovery
-// step of the nmap scan.
-func WithDisabledDNSResolution() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-n")
- }
-}
-
-// WithForcedDNSResolution enforces DNS resolution in the discovery
-// step of the nmap scan.
-func WithForcedDNSResolution() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-R")
- }
-}
-
-// WithCustomDNSServers sets custom DNS servers for the scan.
-// List format: dns1[,dns2],...
-func WithCustomDNSServers(dnsServers ...string) func(*Scanner) {
- dnsList := strings.Join(dnsServers, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, "--dns-servers")
- s.args = append(s.args, dnsList)
- }
-}
-
-// WithSystemDNS sets the scanner's DNS to the system's DNS.
-func WithSystemDNS() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--system-dns")
- }
-}
-
-// WithTraceRoute enables the tracing of the hop path to each host.
-func WithTraceRoute() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--traceroute")
- }
-}
-
-/*** Scan techniques ***/
-
-// WithSYNScan sets the scan technique to use SYN packets over TCP.
-// This is the default method, as it is fast, stealthy and not
-// hampered by restrictive firewalls.
-func WithSYNScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sS")
- }
-}
-
-// WithConnectScan sets the scan technique to use TCP connections.
-// This is the default method used when a user does not have raw
-// packet privileges. Target machines are likely to log these
-// connections.
-func WithConnectScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sT")
- }
-}
-
-// WithACKScan sets the scan technique to use ACK packets over TCP.
-// This scan is unable to determine if a port is open.
-// When scanning unfiltered systems, open and closed ports will both
-// return a RST packet.
-// Nmap then labels them as unfiltered, meaning that they are reachable
-// by the ACK packet, but whether they are open or closed is undetermined.
-func WithACKScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sA")
- }
-}
-
-// WithWindowScan sets the scan technique to use ACK packets over TCP and
-// examining the TCP window field of the RST packets returned.
-// Window scan is exactly the same as ACK scan except that it exploits
-// an implementation detail of certain systems to differentiate open ports
-// from closed ones, rather than always printing unfiltered when a RST
-// is returned.
-func WithWindowScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sW")
- }
-}
-
-// WithMaimonScan sends the same packets as NULL, FIN, and Xmas scans,
-// except that the probe is FIN/ACK. Many BSD-derived systems will drop
-// these packets if the port is open.
-func WithMaimonScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sM")
- }
-}
-
-// WithUDPScan sets the scan technique to use UDP packets.
-// It can be combined with a TCP scan type such as SYN scan
-// to check both protocols during the same run.
-// UDP scanning is generally slower than TCP, but should not
-// be ignored.
-func WithUDPScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sU")
- }
-}
-
-// WithTCPNullScan sets the scan technique to use TCP null packets.
-// (TCP flag header is 0). This scan method can be used to exploit
-// a loophole in the TCP RFC.
-// If an RST packet is received, the port is considered closed,
-// while no response means it is open|filtered.
-func WithTCPNullScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sN")
- }
-}
-
-// WithTCPFINScan sets the scan technique to use TCP packets with
-// the FIN flag set.
-// This scan method can be used to exploit a loophole in the TCP RFC.
-// If an RST packet is received, the port is considered closed,
-// while no response means it is open|filtered.
-func WithTCPFINScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sF")
- }
-}
-
-// WithTCPXmasScan sets the scan technique to use TCP packets with
-// the FIN, PSH and URG flags set.
-// This scan method can be used to exploit a loophole in the TCP RFC.
-// If an RST packet is received, the port is considered closed,
-// while no response means it is open|filtered.
-func WithTCPXmasScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sX")
- }
-}
-
-// TCPFlag represents a TCP flag.
-type TCPFlag int
-
-// Flag enumerations.
-const (
- FlagNULL TCPFlag = 0
- FlagFIN TCPFlag = 1
- FlagSYN TCPFlag = 2
- FlagRST TCPFlag = 4
- FlagPSH TCPFlag = 8
- FlagACK TCPFlag = 16
- FlagURG TCPFlag = 32
- FlagECE TCPFlag = 64
- FlagCWR TCPFlag = 128
- FlagNS TCPFlag = 256
-)
-
-// WithTCPScanFlags sets the scan technique to use custom TCP flags.
-func WithTCPScanFlags(flags ...TCPFlag) func(*Scanner) {
- var total int
- for _, flag := range flags {
- total += int(flag)
- }
-
- return func(s *Scanner) {
- s.args = append(s.args, "--scanflags")
- s.args = append(s.args, fmt.Sprintf("%x", total))
- }
-}
-
-// WithIdleScan sets the scan technique to use a zombie host to
-// allow for a truly blind TCP port scan of the target.
-// Besides being extraordinarily stealthy (due to its blind nature),
-// this scan type permits mapping out IP-based trust relationships
-// between machines.
-func WithIdleScan(zombieHost string, probePort int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sI")
-
- if probePort != 0 {
- s.args = append(s.args, fmt.Sprintf("%s:%d", zombieHost, probePort))
- } else {
- s.args = append(s.args, zombieHost)
- }
- }
-}
-
-// WithSCTPInitScan sets the scan technique to use SCTP packets
-// containing an INIT chunk.
-// It can be performed quickly, scanning thousands of ports per
-// second on a fast network not hampered by restrictive firewalls.
-// Like SYN scan, INIT scan is relatively unobtrusive and stealthy,
-// since it never completes SCTP associations.
-func WithSCTPInitScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sY")
- }
-}
-
-// WithSCTPCookieEchoScan sets the scan technique to use SCTP packets
-// containing a COOKIE-ECHO chunk.
-// The advantage of this scan type is that it is not as obvious a port
-// scan than an INIT scan. Also, there may be non-stateful firewall
-// rulesets blocking INIT chunks, but not COOKIE ECHO chunks.
-func WithSCTPCookieEchoScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sZ")
- }
-}
-
-// WithIPProtocolScan sets the scan technique to use the IP protocol.
-// IP protocol scan allows you to determine which IP protocols
-// (TCP, ICMP, IGMP, etc.) are supported by target machines. This isn't
-// technically a port scan, since it cycles through IP protocol numbers
-// rather than TCP or UDP port numbers.
-func WithIPProtocolScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sO")
- }
-}
-
-// WithFTPBounceScan sets the scan technique to use the an FTP relay host.
-// It takes an argument of the form ":@:. ".
-// You may omit :, in which case anonymous login credentials
-// (user: anonymous password:-wwwuser@) are used.
-// The port number (and preceding colon) may be omitted as well, in which case the
-// default FTP port (21) on is used.
-func WithFTPBounceScan(FTPRelayHost string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-b")
- s.args = append(s.args, FTPRelayHost)
- }
-}
-
-/*** Port specification and scan order ***/
-
-// WithPorts sets the ports which the scanner should scan on each host.
-func WithPorts(ports ...string) func(*Scanner) {
- portList := strings.Join(ports, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, "-p")
- s.args = append(s.args, portList)
- }
-}
-
-// WithPortExclusions sets the ports that the scanner should not scan on each host.
-func WithPortExclusions(ports ...string) func(*Scanner) {
- portList := strings.Join(ports, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, "--exclude-ports")
- s.args = append(s.args, portList)
- }
-}
-
-// WithFastMode makes the scan faster by scanning fewer ports than the default scan.
-func WithFastMode() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-F")
- }
-}
-
-// WithConsecutivePortScanning makes the scan go through ports consecutively instead of
-// picking them out randomly.
-func WithConsecutivePortScanning() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-r")
- }
-}
-
-// WithMostCommonPorts sets the scanner to go through the provided number of most
-// common ports.
-func WithMostCommonPorts(number int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--top-ports")
- s.args = append(s.args, fmt.Sprint(number))
- }
-}
-
-// WithPortRatio sets the scanner to go the ports more common than the given ratio.
-// Ratio must be a float between 0 and 1.
-func WithPortRatio(ratio float32) func(*Scanner) {
- return func(s *Scanner) {
- if ratio < 0 || ratio > 1 {
- panic("value given to nmap.WithPortRatio() should be between 0 and 1")
- }
-
- s.args = append(s.args, "--port-ratio")
- s.args = append(s.args, fmt.Sprintf("%.1f", ratio))
- }
-}
-
-/*** Service/Version detection ***/
-
-// WithServiceInfo enables the probing of open ports to determine service and version
-// info.
-func WithServiceInfo() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sV")
- }
-}
-
-// WithVersionIntensity sets the level of intensity with which nmap should
-// probe the open ports to get version information.
-// Intensity should be a value between 0 (light) and 9 (try all probes). The
-// default value is 7.
-func WithVersionIntensity(intensity int16) func(*Scanner) {
- return func(s *Scanner) {
- if intensity < 0 || intensity > 9 {
- panic("value given to nmap.WithVersionIntensity() should be between 0 and 9")
- }
-
- s.args = append(s.args, "--version-intensity")
- s.args = append(s.args, fmt.Sprint(intensity))
- }
-}
-
-// WithVersionLight sets the level of intensity with which nmap should probe the
-// open ports to get version information to 2. This will make version scanning much
-// faster, but slightly less likely to identify services.
-func WithVersionLight() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--version-light")
- }
-}
-
-// WithVersionAll sets the level of intensity with which nmap should probe the
-// open ports to get version information to 9. This will ensure that every single
-// probe is attempted against each port.
-func WithVersionAll() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--version-all")
- }
-}
-
-// WithVersionTrace causes Nmap to print out extensive debugging info about what
-// version scanning is doing.
-// TODO: See how this works along with XML output.
-func WithVersionTrace() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--version-trace")
- }
-}
-
-/*** Script scan ***/
-
-// WithDefaultScript sets the scanner to perform a script scan using the default
-// set of scripts. It is equivalent to --script=default. Some of the scripts in
-// this category are considered intrusive and should not be run against a target
-// network without permission.
-func WithDefaultScript() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-sC")
- }
-}
-
-// WithScripts sets the scanner to perform a script scan using the enumerated
-// scripts, script directories and script categories.
-func WithScripts(scripts ...string) func(*Scanner) {
- scriptList := strings.Join(scripts, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("--script=%s", scriptList))
- }
-}
-
-// WithScriptArguments provides arguments for scripts.
-func WithScriptArguments(arguments map[string]string) func(*Scanner) {
- var argList string
-
- // Properly format the argument list from the map.
- // Complex example:
- // user=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},xmpp-info.server_name=localhost
- for key, value := range arguments {
- argList = strings.Join([]string{
- argList,
- fmt.Sprintf("%s=%s", key, value),
- }, ",")
- }
-
- argList = strings.TrimLeft(argList, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("--script-args=%s", argList))
- }
-}
-
-// WithScriptArgumentsFile provides arguments for scripts from a file.
-func WithScriptArgumentsFile(inputFilePath string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("--script-args-file=%s", inputFilePath))
- }
-}
-
-// WithScriptTrace makes the scripts show all data sent and received.
-func WithScriptTrace() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--script-trace")
- }
-}
-
-// WithScriptUpdateDB updates the script database.
-func WithScriptUpdateDB() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--script-updatedb")
- }
-}
-
-/*** OS Detection ***/
-
-// WithOSDetection enables OS detection.
-func WithOSDetection() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-O")
- }
-}
-
-// WithOSScanLimit sets the scanner to not even try OS detection against
-// hosts that do have at least one open TCP port, as it is unlikely to be effective.
-// This can save substantial time, particularly on -Pn scans against many hosts.
-// It only matters when OS detection is requested with -O or -A.
-func WithOSScanLimit() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--osscan-limit")
- }
-}
-
-// WithOSScanGuess makes nmap attempt to guess the OS more aggressively.
-func WithOSScanGuess() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--osscan-guess")
- }
-}
-
-/*** Timing and performance ***/
-
-// Timing represents a timing template for nmap.
-// These are meant to be used with the WithTimingTemplate method.
-type Timing int16
-
-const (
- // TimingSlowest also called paranoiac NO PARALLELISM | 5min timeout | 100ms to 10s round-trip time timeout | 5mn scan delay
- TimingSlowest Timing = 0
- // TimingSneaky NO PARALLELISM | 15sec timeout | 100ms to 10s round-trip time timeout | 15s scan delay
- TimingSneaky Timing = 1
- // TimingPolite NO PARALLELISM | 1sec timeout | 100ms to 10s round-trip time timeout | 400ms scan delay
- TimingPolite Timing = 2
- // TimingNormal PARALLELISM | 1sec timeout | 100ms to 10s round-trip time timeout | 0s scan delay
- TimingNormal Timing = 3
- // TimingAggressive PARALLELISM | 500ms timeout | 100ms to 1250ms round-trip time timeout | 0s scan delay
- TimingAggressive Timing = 4
- // TimingFastest also called insane PARALLELISM | 250ms timeout | 50ms to 300ms round-trip time timeout | 0s scan delay
- TimingFastest Timing = 5
-)
-
-// WithTimingTemplate sets the timing template for nmap.
-func WithTimingTemplate(timing Timing) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, fmt.Sprintf("-T%d", timing))
- }
-}
-
-// WithMinHostgroup sets the minimal parallel host scan group size.
-func WithMinHostgroup(size int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--min-hostgroup")
- s.args = append(s.args, fmt.Sprint(size))
- }
-}
-
-// WithMaxHostgroup sets the maximal parallel host scan group size.
-func WithMaxHostgroup(size int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--max-hostgroup")
- s.args = append(s.args, fmt.Sprint(size))
- }
-}
-
-// WithMinParallelism sets the minimal number of parallel probes.
-func WithMinParallelism(probes int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--min-parallelism")
- s.args = append(s.args, fmt.Sprint(probes))
- }
-}
-
-// WithMaxParallelism sets the maximal number of parallel probes.
-func WithMaxParallelism(probes int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--max-parallelism")
- s.args = append(s.args, fmt.Sprint(probes))
- }
-}
-
-// WithMinRTTTimeout sets the minimal probe round trip time.
-func WithMinRTTTimeout(roundTripTime time.Duration) func(*Scanner) {
- milliseconds := roundTripTime.Round(time.Nanosecond).Nanoseconds() / 1000000
-
- return func(s *Scanner) {
- s.args = append(s.args, "--min-rtt-timeout")
- s.args = append(s.args, fmt.Sprintf("%dms", int(milliseconds)))
- }
-}
-
-// WithMaxRTTTimeout sets the maximal probe round trip time.
-func WithMaxRTTTimeout(roundTripTime time.Duration) func(*Scanner) {
- milliseconds := roundTripTime.Round(time.Nanosecond).Nanoseconds() / 1000000
-
- return func(s *Scanner) {
- s.args = append(s.args, "--max-rtt-timeout")
- s.args = append(s.args, fmt.Sprintf("%dms", int(milliseconds)))
- }
-}
-
-// WithInitialRTTTimeout sets the initial probe round trip time.
-func WithInitialRTTTimeout(roundTripTime time.Duration) func(*Scanner) {
- milliseconds := roundTripTime.Round(time.Nanosecond).Nanoseconds() / 1000000
-
- return func(s *Scanner) {
- s.args = append(s.args, "--initial-rtt-timeout")
- s.args = append(s.args, fmt.Sprintf("%dms", int(milliseconds)))
- }
-}
-
-// WithMaxRetries sets the maximal number of port scan probe retransmissions.
-func WithMaxRetries(tries int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--max-retries")
- s.args = append(s.args, fmt.Sprint(tries))
- }
-}
-
-// WithHostTimeout sets the time after which nmap should give up on a target host.
-func WithHostTimeout(timeout time.Duration) func(*Scanner) {
- milliseconds := timeout.Round(time.Nanosecond).Nanoseconds() / 1000000
-
- return func(s *Scanner) {
- s.args = append(s.args, "--host-timeout")
- s.args = append(s.args, fmt.Sprintf("%dms", int(milliseconds)))
- }
-}
-
-// WithScanDelay sets the minimum time to wait between each probe sent to a host.
-func WithScanDelay(timeout time.Duration) func(*Scanner) {
- milliseconds := timeout.Round(time.Nanosecond).Nanoseconds() / 1000000
-
- return func(s *Scanner) {
- s.args = append(s.args, "--scan-delay")
- s.args = append(s.args, fmt.Sprintf("%dms", int(milliseconds)))
- }
-}
-
-// WithMaxScanDelay sets the maximum time to wait between each probe sent to a host.
-func WithMaxScanDelay(timeout time.Duration) func(*Scanner) {
- milliseconds := timeout.Round(time.Nanosecond).Nanoseconds() / 1000000
-
- return func(s *Scanner) {
- s.args = append(s.args, "--max-scan-delay")
- s.args = append(s.args, fmt.Sprintf("%dms", int(milliseconds)))
- }
-}
-
-// WithMinRate sets the minimal number of packets sent per second.
-func WithMinRate(packetsPerSecond int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--min-rate")
- s.args = append(s.args, fmt.Sprint(packetsPerSecond))
- }
-}
-
-// WithMaxRate sets the maximal number of packets sent per second.
-func WithMaxRate(packetsPerSecond int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--max-rate")
- s.args = append(s.args, fmt.Sprint(packetsPerSecond))
- }
-}
-
-/*** Firewalls/IDS evasion and spoofing ***/
-
-// WithFragmentPackets enables the use of tiny fragmented IP packets in order to
-// split up the TCP header over several packets to make it harder for packet
-// filters, intrusion detection systems, and other annoyances to detect what
-// you are doing.
-// Some programs have trouble handling these tiny packets.
-func WithFragmentPackets() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-f")
- }
-}
-
-// WithMTU allows you to specify your own offset size for fragmenting IP packets.
-// Using fragmented packets allows to split up the TCP header over several packets
-// to make it harder for packet filters, intrusion detection systems, and other
-// annoyances to detect what you are doing.
-// Some programs have trouble handling these tiny packets.
-func WithMTU(offset int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--mtu")
- s.args = append(s.args, fmt.Sprint(offset))
- }
-}
-
-// WithDecoys causes a decoy scan to be performed, which makes it appear to the
-// remote host that the host(s) you specify as decoys are scanning the target
-// network too. Thus their IDS might report 5–10 port scans from unique IP
-// addresses, but they won't know which IP was scanning them and which were
-// innocent decoys.
-// While this can be defeated through router path tracing, response-dropping,
-// and other active mechanisms, it is generally an effective technique for
-// hiding your IP address.
-// You can optionally use ME as one of the decoys to represent the position
-// for your real IP address.
-// If you put ME in the sixth position or later, some common port scan
-// detectors are unlikely to show your IP address at all.
-func WithDecoys(decoys ...string) func(*Scanner) {
- decoyList := strings.Join(decoys, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, "-D")
- s.args = append(s.args, decoyList)
- }
-}
-
-// WithSpoofIPAddress spoofs the IP address of the machine which is running nmap.
-// This can be used if nmap is unable to determine your source address.
-// Another possible use of this flag is to spoof the scan to make the targets
-// think that someone else is scanning them. The WithInterface option and
-// WithSkipHostDiscovery are generally required for this sort of usage. Note
-// that you usually won't receive reply packets back (they will be addressed to
-// the IP you are spoofing), so Nmap won't produce useful reports.
-func WithSpoofIPAddress(ip string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-S")
- s.args = append(s.args, ip)
- }
-}
-
-// WithInterface specifies which network interface to use for scanning.
-func WithInterface(iface string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-e")
- s.args = append(s.args, iface)
- }
-}
-
-// WithSourcePort specifies from which port to scan.
-func WithSourcePort(port int16) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--source-port")
- s.args = append(s.args, fmt.Sprint(port))
- }
-}
-
-// WithProxies allows to relay connection through HTTP/SOCKS4 proxies.
-func WithProxies(proxies ...string) func(*Scanner) {
- proxyList := strings.Join(proxies, ",")
-
- return func(s *Scanner) {
- s.args = append(s.args, "--proxies")
- s.args = append(s.args, proxyList)
- }
-}
-
-// WithHexData appends a custom hex-encoded payload to sent packets.
-func WithHexData(data string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--data")
- s.args = append(s.args, data)
- }
-}
-
-// WithASCIIData appends a custom ascii-encoded payload to sent packets.
-func WithASCIIData(data string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--data-string")
- s.args = append(s.args, data)
- }
-}
-
-// WithDataLength appends a random payload of the given length to sent packets.
-func WithDataLength(length int) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--data-length")
- s.args = append(s.args, fmt.Sprint(length))
- }
-}
-
-// WithIPOptions uses the specified IP options to send packets.
-// You may be able to use the record route option to determine a
-// path to a target even when more traditional traceroute-style
-// approaches fail. See http://seclists.org/nmap-dev/2006/q3/52
-// for examples of use.
-func WithIPOptions(options string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--ip-options")
- s.args = append(s.args, options)
- }
-}
-
-// WithIPTimeToLive sets the IP time-to-live field of IP packets.
-func WithIPTimeToLive(ttl int16) func(*Scanner) {
- return func(s *Scanner) {
- if ttl < 0 || ttl > 255 {
- panic("value given to nmap.WithIPTimeToLive() should be between 0 and 255")
- }
-
- s.args = append(s.args, "--ttl")
- s.args = append(s.args, fmt.Sprint(ttl))
- }
-}
-
-// WithSpoofMAC uses the given MAC address for all of the raw
-// ethernet frames the scanner sends. This option implies
-// WithSendEthernet to ensure that Nmap actually sends ethernet-level
-// packets.
-// Valid argument examples are Apple, 0, 01:02:03:04:05:06,
-// deadbeefcafe, 0020F2, and Cisco.
-func WithSpoofMAC(argument string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--spoof-mac")
- s.args = append(s.args, argument)
- }
-}
-
-// WithBadSum makes nmap send an invalid TCP, UDP or SCTP checksum
-// for packets sent to target hosts. Since virtually all host IP
-// stacks properly drop these packets, any responses received are
-// likely coming from a firewall or IDS that didn't bother to
-// verify the checksum.
-func WithBadSum() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--badsum")
- }
-}
-
-/*** Output ***/
-
-// WithReason makes nmap specify why a port is in a particular state.
-func WithReason() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--reason")
- }
-}
-
-// WithOpenOnly makes nmap only show open ports.
-func WithOpenOnly() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--open")
- }
-}
-
-// WithPacketTrace makes nmap show all packets sent and received.
-func WithPacketTrace() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--packet-trace")
- }
-}
-
-// WithInterfaceList makes nmap print host interfaces and routes.
-func WithInterfaceList() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--iflist")
- }
-}
-
-// WithAppendOutput makes nmap append to files instead of overwriting them.
-// Currently does nothing, since this library doesn't write in files.
-func WithAppendOutput() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--append-output")
- }
-}
-
-// WithResumePreviousScan makes nmap continue a scan that was aborted,
-// from an output file.
-func WithResumePreviousScan(filePath string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--resume")
- s.args = append(s.args, filePath)
- }
-}
-
-// WithStylesheet makes nmap apply an XSL stylesheet to transform its
-// XML output to HTML.
-func WithStylesheet(stylesheetPath string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--stylesheet")
- s.args = append(s.args, stylesheetPath)
- }
-}
-
-// WithWebXML makes nmap apply the default nmap.org stylesheet to transform
-// XML output to HTML. The stylesheet can be found at
-// https://nmap.org/svn/docs/nmap.xsl
-func WithWebXML() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--webxml")
- }
-}
-
-// WithNoStylesheet prevents the use of XSL stylesheets with the XML output.
-func WithNoStylesheet() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--no-stylesheet")
- }
-}
-
-/*** Misc ***/
-
-// WithIPv6Scanning enables the use of IPv6 scanning.
-func WithIPv6Scanning() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-6")
- }
-}
-
-// WithAggressiveScan enables the use of aggressive scan options. This has
-// the same effect as using WithOSDetection, WithServiceInfo, WithDefaultScript
-// and WithTraceRoute at the same time.
-// Because script scanning with the default set is considered intrusive, you
-// should not use this method against target networks without permission.
-func WithAggressiveScan() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "-A")
- }
-}
-
-// WithDataDir specifies a custom data directory for nmap to get its
-// nmap-service-probes, nmap-services, nmap-protocols, nmap-rpc,
-// nmap-mac-prefixes, and nmap-os-db.
-func WithDataDir(directoryPath string) func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--datadir")
- s.args = append(s.args, directoryPath)
- }
-}
-
-// WithSendEthernet makes nmap send packets at the raw ethernet (data link)
-// layer rather than the higher IP (network) layer. By default, nmap chooses
-// the one which is generally best for the platform it is running on.
-func WithSendEthernet() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--send-eth")
- }
-}
-
-// WithSendIP makes nmap send packets via raw IP sockets rather than sending
-// lower level ethernet frames.
-func WithSendIP() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--send-ip")
- }
-}
-
-// WithPrivileged makes nmap assume that the user is fully privileged.
-func WithPrivileged() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--privileged")
- }
-}
-
-// WithUnprivileged makes nmap assume that the user lacks raw socket privileges.
-func WithUnprivileged() func(*Scanner) {
- return func(s *Scanner) {
- s.args = append(s.args, "--unprivileged")
- }
-}
diff --git a/vendor/github.com/Ullaakut/nmap/nmap_test.go b/vendor/github.com/Ullaakut/nmap/nmap_test.go
deleted file mode 100644
index 8699318..0000000
--- a/vendor/github.com/Ullaakut/nmap/nmap_test.go
+++ /dev/null
@@ -1,1781 +0,0 @@
-package nmap
-
-import (
- "context"
- "errors"
- "os/exec"
- "reflect"
- "strings"
- "testing"
- "time"
-)
-
-// func TestNewScanner(t *testing.T) {
-// tests := []struct {
-// description string
-
-// expectedErr error
-// expectedScanner *Scanner
-// }{
-// {
-// description: "valid targets, no errors",
-
-// targets: []string{"80"},
-
-// expectedScanner: &Scanner{
-// args: []string{"80"},
-// },
-// },
-// {
-// description: "invalid targets (nil), error",
-
-// targets: nil,
-
-// expectedErr: ErrNoTargetsSpecified,
-// },
-// {
-// description: "invalid targets (nil), error",
-
-// targets: []string{},
-
-// expectedErr: ErrNoTargetsSpecified,
-// },
-// }
-
-// for _, test := range tests {
-// t.Run(test.description, func(t *testing.T) {
-// s, err := NewScanner(test.targets)
-// if err != test.expectedErr {
-// t.Errorf("expected error to be %v, got %v", test.expectedErr, err)
-// }
-
-// if test.expectedScanner == nil && s != nil {
-// t.Errorf("expected scanner to be nil, got %+v", s)
-// } else if test.expectedScanner != nil && s == nil {
-// t.Errorf("expected scanner to be %+v, got nil", test.expectedScanner)
-// } else if test.expectedScanner != nil && s != nil {
-// if !reflect.DeepEqual(test.expectedScanner.args, s.args) {
-// t.Errorf("expected scanner arguments to be %v, got %v", test.expectedScanner.args, s.args)
-// }
-// }
-// })
-// }
-// }
-
-func TestRun(t *testing.T) {
- nmapPath, err := exec.LookPath("nmap")
- if err != nil {
- panic("nmap is required to run those tests")
- }
-
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- testTimeout bool
-
- expectedResult *Run
- expectedErr error
- }{
- {
- description: "invalid binary path",
-
- options: []func(*Scanner){
- WithTargets("0.0.0.0"),
- WithBinaryPath("/invalid"),
- },
-
- expectedResult: nil,
- expectedErr: errors.New("fork/exec /invalid: no such file or directory"),
- },
- {
- description: "context timeout",
-
- options: []func(*Scanner){
- WithTargets("0.0.0.0/16"),
- },
-
- testTimeout: true,
-
- expectedResult: nil,
- expectedErr: ErrScanTimeout,
- },
- {
- description: "scan localhost",
-
- options: []func(*Scanner){
- WithTargets("localhost"),
- WithTimingTemplate(TimingFastest),
- },
-
- expectedResult: &Run{
- Args: nmapPath + " -T5 -oX - localhost",
- Scanner: "nmap",
- },
- },
- {
- description: "scan localhost with filters",
- options: []func(*Scanner){
- WithTargets("localhost"),
- WithFilterHost(func(Host) bool {
- return true
- }),
- WithFilterPort(func(Port) bool {
- return true
- }),
- WithTimingTemplate(TimingFastest),
- },
-
- expectedResult: &Run{
- Args: nmapPath + " -T5 -oX - localhost",
- Scanner: "nmap",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- if test.testTimeout {
- ctx, cancel := context.WithTimeout(context.Background(), 99*time.Hour)
- test.options = append(test.options, WithContext(ctx))
-
- go (func() {
- // Cancel context to force timeout
- defer cancel()
- time.Sleep(1 * time.Millisecond)
- })()
- }
-
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err) // this is never supposed to err, as we are testing run and not new.
- }
-
- result, err := s.Run()
- if err != test.expectedErr {
- if err.Error() != test.expectedErr.Error() {
- t.Errorf("expected error %v got %v", test.expectedErr, err)
- }
- }
-
- if result == nil && test.expectedResult == nil {
- return
- } else if result == nil && test.expectedResult != nil {
- t.Error("expected non-nil result, got nil")
- return
- } else if result != nil && test.expectedResult == nil {
- t.Error("expected nil result, got non-nil")
- return
- }
-
- if result.Args != test.expectedResult.Args {
- t.Errorf("expected args %s got %s", test.expectedResult.Args, result.Args)
- }
-
- if result.Scanner != test.expectedResult.Scanner {
- t.Errorf("expected scanner %s got %s", test.expectedResult.Scanner, result.Scanner)
- }
- })
- }
-}
-
-func TestTargetSpecification(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedArgs []string
- }{
- {
- description: "custom arguments",
-
- options: []func(*Scanner){
- WithTargets("0.0.0.0/24"),
- WithCustomArguments("--invalid-argument"),
- },
-
- expectedArgs: []string{
- "0.0.0.0/24",
- "--invalid-argument",
- },
- },
- {
- description: "set target",
-
- options: []func(*Scanner){
- WithTargets("0.0.0.0/24"),
- },
-
- expectedArgs: []string{
- "0.0.0.0/24",
- },
- },
- {
- description: "set multiple targets",
-
- options: []func(*Scanner){
- WithTargets("0.0.0.0", "192.168.1.1"),
- },
-
- expectedArgs: []string{
- "0.0.0.0",
- "192.168.1.1",
- },
- },
- {
- description: "set target from file",
-
- options: []func(*Scanner){
- WithTargetInput("/targets.txt"),
- },
-
- expectedArgs: []string{
- "-iL",
- "/targets.txt",
- },
- },
- {
- description: "choose random targets",
-
- options: []func(*Scanner){
- WithRandomTargets(4),
- },
-
- expectedArgs: []string{
- "-iR",
- "4",
- },
- },
- {
- description: "target exclusion",
-
- options: []func(*Scanner){
- WithTargetExclusion("192.168.0.1,172.16.100.0/24"),
- },
-
- expectedArgs: []string{
- "--exclude",
- "192.168.0.1,172.16.100.0/24",
- },
- },
- {
- description: "target exclusion from file",
-
- options: []func(*Scanner){
- WithTargetExclusionInput("/exclude_targets.txt"),
- },
-
- expectedArgs: []string{
- "--excludefile",
- "/exclude_targets.txt",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestHostDiscovery(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedArgs []string
- }{
- {
- description: "list targets to scan",
-
- options: []func(*Scanner){
- WithListScan(),
- },
-
- expectedArgs: []string{
- "-sL",
- },
- },
- {
- description: "ping scan - disable port scan",
-
- options: []func(*Scanner){
- WithPingScan(),
- },
-
- expectedArgs: []string{
- "-sn",
- },
- },
- {
- description: "skip host discovery",
-
- options: []func(*Scanner){
- WithSkipHostDiscovery(),
- },
-
- expectedArgs: []string{
- "-Pn",
- },
- },
- {
- description: "TCP SYN packets for all ports",
-
- options: []func(*Scanner){
- WithSYNDiscovery(),
- },
-
- expectedArgs: []string{
- "-PS",
- },
- },
- {
- description: "TCP SYN packets for specific ports",
-
- options: []func(*Scanner){
- WithSYNDiscovery("443", "8443"),
- },
-
- expectedArgs: []string{
- "-PS443,8443",
- },
- },
- {
- description: "TCP ACK packets for all ports",
-
- options: []func(*Scanner){
- WithACKDiscovery(),
- },
-
- expectedArgs: []string{
- "-PA",
- },
- },
- {
- description: "TCP ACK packets for specific ports",
-
- options: []func(*Scanner){
- WithACKDiscovery("443", "8443"),
- },
-
- expectedArgs: []string{
- "-PA443,8443",
- },
- },
- {
- description: "UDP packets for all ports",
-
- options: []func(*Scanner){
- WithUDPDiscovery(),
- },
-
- expectedArgs: []string{
- "-PU",
- },
- },
- {
- description: "UDP packets for specific ports",
-
- options: []func(*Scanner){
- WithUDPDiscovery("443", "8443"),
- },
-
- expectedArgs: []string{
- "-PU443,8443",
- },
- },
- {
- description: "SCTP packets for all ports",
-
- options: []func(*Scanner){
- WithSCTPDiscovery(),
- },
-
- expectedArgs: []string{
- "-PY",
- },
- },
- {
- description: "SCTP packets for specific ports",
-
- options: []func(*Scanner){
- WithSCTPDiscovery("443", "8443"),
- },
-
- expectedArgs: []string{
- "-PY443,8443",
- },
- },
- {
- description: "ICMP echo request discovery probes",
-
- options: []func(*Scanner){
- WithICMPEchoDiscovery(),
- },
-
- expectedArgs: []string{
- "-PE",
- },
- },
- {
- description: "ICMP Timestamp request discovery probes",
-
- options: []func(*Scanner){
- WithICMPTimestampDiscovery(),
- },
-
- expectedArgs: []string{
- "-PP",
- },
- },
- {
- description: "ICMP NetMask request discovery probes",
-
- options: []func(*Scanner){
- WithICMPNetMaskDiscovery(),
- },
-
- expectedArgs: []string{
- "-PM",
- },
- },
- {
- description: "IP protocol ping",
-
- options: []func(*Scanner){
- WithIPProtocolPingDiscovery("1", "2", "4"),
- },
-
- expectedArgs: []string{
- "-PO1,2,4",
- },
- },
- {
- description: "disable DNS resolution during discovery",
-
- options: []func(*Scanner){
- WithDisabledDNSResolution(),
- },
-
- expectedArgs: []string{
- "-n",
- },
- },
- {
- description: "enforce DNS resolution during discovery",
-
- options: []func(*Scanner){
- WithForcedDNSResolution(),
- },
-
- expectedArgs: []string{
- "-R",
- },
- },
- {
- description: "custom DNS server",
-
- options: []func(*Scanner){
- WithCustomDNSServers("8.8.8.8", "8.8.4.4"),
- },
-
- expectedArgs: []string{
- "--dns-servers",
- "8.8.8.8,8.8.4.4",
- },
- },
- {
- description: "use system DNS",
-
- options: []func(*Scanner){
- WithSystemDNS(),
- },
-
- expectedArgs: []string{
- "--system-dns",
- },
- },
- {
- description: "traceroute",
-
- options: []func(*Scanner){
- WithTraceRoute(),
- },
-
- expectedArgs: []string{
- "--traceroute",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestScanTechniques(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedArgs []string
- }{
- {
- description: "TCP SYN scan",
-
- options: []func(*Scanner){
- WithSYNScan(),
- },
-
- expectedArgs: []string{
- "-sS",
- },
- },
- {
- description: "TCP Connect() scan",
-
- options: []func(*Scanner){
- WithConnectScan(),
- },
-
- expectedArgs: []string{
- "-sT",
- },
- },
- {
- description: "TCP ACK scan",
-
- options: []func(*Scanner){
- WithACKScan(),
- },
-
- expectedArgs: []string{
- "-sA",
- },
- },
- {
- description: "TCP Window scan",
-
- options: []func(*Scanner){
- WithWindowScan(),
- },
-
- expectedArgs: []string{
- "-sW",
- },
- },
- {
- description: "Maimon scan",
-
- options: []func(*Scanner){
- WithMaimonScan(),
- },
-
- expectedArgs: []string{
- "-sM",
- },
- },
- {
- description: "UDP scan",
-
- options: []func(*Scanner){
- WithUDPScan(),
- },
-
- expectedArgs: []string{
- "-sU",
- },
- },
- {
- description: "TCP Null scan",
-
- options: []func(*Scanner){
- WithTCPNullScan(),
- },
-
- expectedArgs: []string{
- "-sN",
- },
- },
- {
- description: "TCP FIN scan",
-
- options: []func(*Scanner){
- WithTCPFINScan(),
- },
-
- expectedArgs: []string{
- "-sF",
- },
- },
- {
- description: "TCP Xmas scan",
-
- options: []func(*Scanner){
- WithTCPXmasScan(),
- },
-
- expectedArgs: []string{
- "-sX",
- },
- },
- {
- description: "TCP custom scan flags",
-
- options: []func(*Scanner){
- WithTCPScanFlags(FlagACK, FlagFIN, FlagNULL),
- },
-
- expectedArgs: []string{
- "--scanflags",
- "11",
- },
- },
- {
- description: "idle scan through zombie host with probe port specified",
-
- options: []func(*Scanner){
- WithIdleScan("192.168.1.1", 61436),
- },
-
- expectedArgs: []string{
- "-sI",
- "192.168.1.1:61436",
- },
- },
- {
- description: "idle scan through zombie host without probe port specified",
-
- options: []func(*Scanner){
- WithIdleScan("192.168.1.1", 0),
- },
-
- expectedArgs: []string{
- "-sI",
- "192.168.1.1",
- },
- },
- {
- description: "SCTP INIT scan",
-
- options: []func(*Scanner){
- WithSCTPInitScan(),
- },
-
- expectedArgs: []string{
- "-sY",
- },
- },
- {
- description: "SCTP COOKIE-ECHO scan",
-
- options: []func(*Scanner){
- WithSCTPCookieEchoScan(),
- },
-
- expectedArgs: []string{
- "-sZ",
- },
- },
- {
- description: "IP protocol scan",
-
- options: []func(*Scanner){
- WithIPProtocolScan(),
- },
-
- expectedArgs: []string{
- "-sO",
- },
- },
- {
- description: "FTP bounce scan",
-
- options: []func(*Scanner){
- WithFTPBounceScan("192.168.0.254"),
- },
-
- expectedArgs: []string{
- "-b",
- "192.168.0.254",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestPortSpecAndScanOrder(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedPanic string
- expectedArgs []string
- }{
- {
- description: "specify ports to scan",
-
- options: []func(*Scanner){
- WithPorts("554", "8554"),
- },
-
- expectedArgs: []string{
- "-p",
- "554,8554",
- },
- },
- {
- description: "exclude ports to scan",
-
- options: []func(*Scanner){
- WithPortExclusions("554", "8554"),
- },
-
- expectedArgs: []string{
- "--exclude-ports",
- "554,8554",
- },
- },
- {
- description: "fast mode - scan fewer ports than the default scan",
-
- options: []func(*Scanner){
- WithFastMode(),
- },
-
- expectedArgs: []string{
- "-F",
- },
- },
- {
- description: "consecutive port scanning",
-
- options: []func(*Scanner){
- WithConsecutivePortScanning(),
- },
-
- expectedArgs: []string{
- "-r",
- },
- },
- {
- description: "scan most commonly open ports",
-
- options: []func(*Scanner){
- WithMostCommonPorts(5),
- },
-
- expectedArgs: []string{
- "--top-ports",
- "5",
- },
- },
- {
- description: "scan most commonly open ports given a ratio - should be rounded to 0.4",
-
- options: []func(*Scanner){
- WithPortRatio(0.42010101),
- },
-
- expectedArgs: []string{
- "--port-ratio",
- "0.4",
- },
- },
- {
- description: "scan most commonly open ports given a ratio - should be invalid and panic",
-
- options: []func(*Scanner){
- WithPortRatio(2),
- },
-
- expectedPanic: "value given to nmap.WithPortRatio() should be between 0 and 1",
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- if test.expectedPanic != "" {
- defer func() {
- recoveredMessage := recover()
-
- if recoveredMessage != test.expectedPanic {
- t.Errorf("expected panic message to be %q but got %q", test.expectedPanic, recoveredMessage)
- }
- }()
- }
-
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestServiceDetection(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedPanic string
- expectedArgs []string
- }{
- {
- description: "service detection",
-
- options: []func(*Scanner){
- WithServiceInfo(),
- },
-
- expectedArgs: []string{
- "-sV",
- },
- },
- {
- description: "service detection custom intensity",
-
- options: []func(*Scanner){
- WithVersionIntensity(1),
- },
-
- expectedArgs: []string{
- "--version-intensity",
- "1",
- },
- },
- {
- description: "service detection custom intensity - should panic since not between 0 and 9",
-
- options: []func(*Scanner){
- WithVersionIntensity(42),
- },
-
- expectedPanic: "value given to nmap.WithVersionIntensity() should be between 0 and 9",
- },
- {
- description: "service detection light intensity",
-
- options: []func(*Scanner){
- WithVersionLight(),
- },
-
- expectedArgs: []string{
- "--version-light",
- },
- },
- {
- description: "service detection highest intensity",
-
- options: []func(*Scanner){
- WithVersionAll(),
- },
-
- expectedArgs: []string{
- "--version-all",
- },
- },
- {
- description: "service detection enable trace",
-
- options: []func(*Scanner){
- WithVersionTrace(),
- },
-
- expectedArgs: []string{
- "--version-trace",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- if test.expectedPanic != "" {
- defer func() {
- recoveredMessage := recover()
-
- if recoveredMessage != test.expectedPanic {
- t.Errorf("expected panic message to be %q but got %q", test.expectedPanic, recoveredMessage)
- }
- }()
- }
-
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestScriptScan(t *testing.T) {
- tests := []struct {
- description string
-
- targets []string
- options []func(*Scanner)
- unorderedArgs bool
-
- expectedArgs []string
- }{
- {
- description: "default script scan",
-
- options: []func(*Scanner){
- WithDefaultScript(),
- },
-
- expectedArgs: []string{
- "-sC",
- },
- },
- {
- description: "custom script list",
-
- options: []func(*Scanner){
- WithScripts("./scripts/", "/etc/nmap/nse/scripts"),
- },
-
- expectedArgs: []string{
- "--script=./scripts/,/etc/nmap/nse/scripts",
- },
- },
- {
- description: "script arguments",
-
- options: []func(*Scanner){
- WithScriptArguments(map[string]string{
- "user": "foo",
- "pass": "\",{}=bar\"",
- "whois": "{whodb=nofollow+ripe}",
- "xmpp-info.server_name": "localhost",
- }),
- },
-
- unorderedArgs: true,
-
- expectedArgs: []string{
- "--script-args=",
- "user=foo",
- "pass=\",{}=bar\"",
- "whois={whodb=nofollow+ripe}",
- "xmpp-info.server_name=localhost",
- },
- },
- {
- description: "script arguments file",
-
- options: []func(*Scanner){
- WithScriptArgumentsFile("/script_args.txt"),
- },
-
- expectedArgs: []string{
- "--script-args-file=/script_args.txt",
- },
- },
- {
- description: "enable script trace",
-
- options: []func(*Scanner){
- WithScriptTrace(),
- },
-
- expectedArgs: []string{
- "--script-trace",
- },
- },
- {
- description: "update script database",
-
- options: []func(*Scanner){
- WithScriptUpdateDB(),
- },
-
- expectedArgs: []string{
- "--script-updatedb",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if test.unorderedArgs {
- for _, expectedArg := range test.expectedArgs {
- if !strings.Contains(s.args[0], expectedArg) {
- t.Errorf("missing argument %s in %v", expectedArg, s.args)
- }
- }
- return
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestOSDetection(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedArgs []string
- }{
- {
- description: "enable OS detection",
-
- options: []func(*Scanner){
- WithOSDetection(),
- },
-
- expectedArgs: []string{
- "-O",
- },
- },
- {
- description: "enable OS scan limit",
-
- options: []func(*Scanner){
- WithOSScanLimit(),
- },
-
- expectedArgs: []string{
- "--osscan-limit",
- },
- },
- {
- description: "enable OS scan guess",
-
- options: []func(*Scanner){
- WithOSScanGuess(),
- },
-
- expectedArgs: []string{
- "--osscan-guess",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestTimingAndPerformance(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedArgs []string
- }{
- {
- description: "set timing template",
-
- options: []func(*Scanner){
- WithTimingTemplate(TimingAggressive),
- },
-
- expectedArgs: []string{
- "-T4",
- },
- },
- {
- description: "set min hostgroup",
-
- options: []func(*Scanner){
- WithMinHostgroup(42),
- },
-
- expectedArgs: []string{
- "--min-hostgroup",
- "42",
- },
- },
- {
- description: "set max hostgroup",
-
- options: []func(*Scanner){
- WithMaxHostgroup(42),
- },
-
- expectedArgs: []string{
- "--max-hostgroup",
- "42",
- },
- },
- {
- description: "set min parallelism",
-
- options: []func(*Scanner){
- WithMinParallelism(42),
- },
-
- expectedArgs: []string{
- "--min-parallelism",
- "42",
- },
- },
- {
- description: "set max parallelism",
-
- options: []func(*Scanner){
- WithMaxParallelism(42),
- },
-
- expectedArgs: []string{
- "--max-parallelism",
- "42",
- },
- },
- {
- description: "set min rtt-timeout",
-
- options: []func(*Scanner){
- WithMinRTTTimeout(2 * time.Minute),
- },
-
- expectedArgs: []string{
- "--min-rtt-timeout",
- "120000ms",
- },
- },
- {
- description: "set max rtt-timeout",
-
- options: []func(*Scanner){
- WithMaxRTTTimeout(8 * time.Hour),
- },
-
- expectedArgs: []string{
- "--max-rtt-timeout",
- "28800000ms",
- },
- },
- {
- description: "set initial rtt-timeout",
-
- options: []func(*Scanner){
- WithInitialRTTTimeout(8 * time.Hour),
- },
-
- expectedArgs: []string{
- "--initial-rtt-timeout",
- "28800000ms",
- },
- },
- {
- description: "set max retries",
-
- options: []func(*Scanner){
- WithMaxRetries(42),
- },
-
- expectedArgs: []string{
- "--max-retries",
- "42",
- },
- },
- {
- description: "set host timeout",
-
- options: []func(*Scanner){
- WithHostTimeout(42 * time.Second),
- },
-
- expectedArgs: []string{
- "--host-timeout",
- "42000ms",
- },
- },
- {
- description: "set scan delay",
-
- options: []func(*Scanner){
- WithScanDelay(42 * time.Millisecond),
- },
-
- expectedArgs: []string{
- "--scan-delay",
- "42ms",
- },
- },
- {
- description: "set max scan delay",
-
- options: []func(*Scanner){
- WithMaxScanDelay(42 * time.Millisecond),
- },
-
- expectedArgs: []string{
- "--max-scan-delay",
- "42ms",
- },
- },
- {
- description: "set min rate",
-
- options: []func(*Scanner){
- WithMinRate(42),
- },
-
- expectedArgs: []string{
- "--min-rate",
- "42",
- },
- },
- {
- description: "set max rate",
-
- options: []func(*Scanner){
- WithMaxRate(42),
- },
-
- expectedArgs: []string{
- "--max-rate",
- "42",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestFirewallAndIDSEvasionAndSpoofing(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedPanic string
- expectedArgs []string
- }{
- {
- description: "fragment packets",
-
- options: []func(*Scanner){
- WithFragmentPackets(),
- },
-
- expectedArgs: []string{
- "-f",
- },
- },
- {
- description: "custom fragment packet size",
-
- options: []func(*Scanner){
- WithMTU(42),
- },
-
- expectedArgs: []string{
- "--mtu",
- "42",
- },
- },
- {
- description: "enable decoys",
-
- options: []func(*Scanner){
- WithDecoys(
- "192.168.1.1",
- "192.168.1.2",
- "192.168.1.3",
- "192.168.1.4",
- "192.168.1.5",
- "192.168.1.6",
- "ME",
- "192.168.1.8",
- ),
- },
-
- expectedArgs: []string{
- "-D",
- "192.168.1.1,192.168.1.2,192.168.1.3,192.168.1.4,192.168.1.5,192.168.1.6,ME,192.168.1.8",
- },
- },
- {
- description: "spoof IP address",
-
- options: []func(*Scanner){
- WithSpoofIPAddress("192.168.1.1"),
- },
-
- expectedArgs: []string{
- "-S",
- "192.168.1.1",
- },
- },
- {
- description: "set interface",
-
- options: []func(*Scanner){
- WithInterface("eth0"),
- },
-
- expectedArgs: []string{
- "-e",
- "eth0",
- },
- },
- {
- description: "set source port",
-
- options: []func(*Scanner){
- WithSourcePort(4242),
- },
-
- expectedArgs: []string{
- "--source-port",
- "4242",
- },
- },
- {
- description: "set proxies",
-
- options: []func(*Scanner){
- WithProxies("4242", "8484"),
- },
-
- expectedArgs: []string{
- "--proxies",
- "4242,8484",
- },
- },
- {
- description: "set custom hex payload",
-
- options: []func(*Scanner){
- WithHexData("0x8b6c42"),
- },
-
- expectedArgs: []string{
- "--data",
- "0x8b6c42",
- },
- },
- {
- description: "set custom ascii payload",
-
- options: []func(*Scanner){
- WithASCIIData("pale brownish"),
- },
-
- expectedArgs: []string{
- "--data-string",
- "pale brownish",
- },
- },
- {
- description: "set custom random payload length",
-
- options: []func(*Scanner){
- WithDataLength(42),
- },
-
- expectedArgs: []string{
- "--data-length",
- "42",
- },
- },
- {
- description: "set custom IP options",
-
- options: []func(*Scanner){
- WithIPOptions("S 192.168.1.1 10.0.0.3"),
- },
-
- expectedArgs: []string{
- "--ip-options",
- "S 192.168.1.1 10.0.0.3",
- },
- },
- {
- description: "set custom TTL",
-
- options: []func(*Scanner){
- WithIPTimeToLive(254),
- },
-
- expectedArgs: []string{
- "--ttl",
- "254",
- },
- },
- {
- description: "set custom TTL - invalid value should panic",
-
- options: []func(*Scanner){
- WithIPTimeToLive(-254),
- },
-
- expectedPanic: "value given to nmap.WithIPTimeToLive() should be between 0 and 255",
- },
- {
- description: "spoof mac address",
-
- options: []func(*Scanner){
- WithSpoofMAC("08:67:47:0A:78:E4"),
- },
-
- expectedArgs: []string{
- "--spoof-mac",
- "08:67:47:0A:78:E4",
- },
- },
- {
- description: "send packets with bad checksum",
-
- options: []func(*Scanner){
- WithBadSum(),
- },
-
- expectedArgs: []string{
- "--badsum",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- if test.expectedPanic != "" {
- defer func() {
- recoveredMessage := recover()
-
- if recoveredMessage != test.expectedPanic {
- t.Errorf("expected panic message to be %q but got %q", test.expectedPanic, recoveredMessage)
- }
- }()
- }
-
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestOutput(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedArgs []string
- }{
- {
- description: "display reason",
-
- options: []func(*Scanner){
- WithReason(),
- },
-
- expectedArgs: []string{
- "--reason",
- },
- },
- {
- description: "show only open ports",
-
- options: []func(*Scanner){
- WithOpenOnly(),
- },
-
- expectedArgs: []string{
- "--open",
- },
- },
- {
- description: "enable packet trace",
-
- options: []func(*Scanner){
- WithPacketTrace(),
- },
-
- expectedArgs: []string{
- "--packet-trace",
- },
- },
- {
- description: "enable interface listing",
-
- options: []func(*Scanner){
- WithInterfaceList(),
- },
-
- expectedArgs: []string{
- "--iflist",
- },
- },
- {
- description: "enable interface listing",
-
- options: []func(*Scanner){
- WithInterfaceList(),
- },
-
- expectedArgs: []string{
- "--iflist",
- },
- },
- {
- description: "enable appending output",
-
- options: []func(*Scanner){
- WithAppendOutput(),
- },
-
- expectedArgs: []string{
- "--append-output",
- },
- },
- {
- description: "resume scan from file",
-
- options: []func(*Scanner){
- WithResumePreviousScan("/nmap_scan.xml"),
- },
-
- expectedArgs: []string{
- "--resume",
- "/nmap_scan.xml",
- },
- },
- {
- description: "use stylesheet from file",
-
- options: []func(*Scanner){
- WithStylesheet("/nmap_stylesheet.xsl"),
- },
-
- expectedArgs: []string{
- "--stylesheet",
- "/nmap_stylesheet.xsl",
- },
- },
- {
- description: "use stylesheet from file",
-
- options: []func(*Scanner){
- WithStylesheet("/nmap_stylesheet.xsl"),
- },
-
- expectedArgs: []string{
- "--stylesheet",
- "/nmap_stylesheet.xsl",
- },
- },
- {
- description: "use default nmap stylesheet",
-
- options: []func(*Scanner){
- WithWebXML(),
- },
-
- expectedArgs: []string{
- "--webxml",
- },
- },
- {
- description: "disable stylesheets",
-
- options: []func(*Scanner){
- WithNoStylesheet(),
- },
-
- expectedArgs: []string{
- "--no-stylesheet",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
-
-func TestMiscellaneous(t *testing.T) {
- tests := []struct {
- description string
-
- options []func(*Scanner)
-
- expectedArgs []string
- }{
- {
- description: "enable ipv6 scanning",
-
- options: []func(*Scanner){
- WithIPv6Scanning(),
- },
-
- expectedArgs: []string{
- "-6",
- },
- },
- {
- description: "enable aggressive scanning",
-
- options: []func(*Scanner){
- WithAggressiveScan(),
- },
-
- expectedArgs: []string{
- "-A",
- },
- },
- {
- description: "set data dir",
-
- options: []func(*Scanner){
- WithDataDir("/etc/nmap/data"),
- },
-
- expectedArgs: []string{
- "--datadir",
- "/etc/nmap/data",
- },
- },
- {
- description: "send packets over ethernet",
-
- options: []func(*Scanner){
- WithSendEthernet(),
- },
-
- expectedArgs: []string{
- "--send-eth",
- },
- },
- {
- description: "send packets over IP",
-
- options: []func(*Scanner){
- WithSendIP(),
- },
-
- expectedArgs: []string{
- "--send-ip",
- },
- },
- {
- description: "assume user is privileged",
-
- options: []func(*Scanner){
- WithPrivileged(),
- },
-
- expectedArgs: []string{
- "--privileged",
- },
- },
- {
- description: "assume user is unprivileged",
-
- options: []func(*Scanner){
- WithUnprivileged(),
- },
-
- expectedArgs: []string{
- "--unprivileged",
- },
- },
- }
-
- for _, test := range tests {
- t.Run(test.description, func(t *testing.T) {
- s, err := NewScanner(test.options...)
- if err != nil {
- panic(err)
- }
-
- if !reflect.DeepEqual(s.args, test.expectedArgs) {
- t.Errorf("unexpected arguments, expected %s got %s", test.expectedArgs, s.args)
- }
- })
- }
-}
diff --git a/vendor/github.com/Ullaakut/nmap/pkg/osfamilies/os_families.go b/vendor/github.com/Ullaakut/nmap/pkg/osfamilies/os_families.go
deleted file mode 100644
index 0047776..0000000
--- a/vendor/github.com/Ullaakut/nmap/pkg/osfamilies/os_families.go
+++ /dev/null
@@ -1,644 +0,0 @@
-package osfamilies
-
-// OSFamily describes an OS Family, usually from a constructor or
-// a kernel.
-type OSFamily string
-
-// OSFamily definitions.
-const (
- TwoN OSFamily = "2N"
- TwoWire OSFamily = "2Wire"
- ThreeCom OSFamily = "3Com"
- ThreeM OSFamily = "3M"
- FourG OSFamily = "4G"
- ATec OSFamily = "A-Tec"
- ADIC OSFamily = "ADIC"
- AKCP OSFamily = "AKCP"
- AMX OSFamily = "AMX"
- APC OSFamily = "APC"
- ARCA OSFamily = "ARCA"
- ATandT OSFamily = "AT&T"
- AVM OSFamily = "AVM"
- AVtech OSFamily = "AVtech"
- AXIS OSFamily = "AXIS"
- Aastra OSFamily = "Aastra"
- AcBel OSFamily = "AcBel"
- Aceex OSFamily = "Aceex"
- Acer OSFamily = "Acer"
- Acme OSFamily = "Acme"
- Acorp OSFamily = "Acorp"
- Actiontec OSFamily = "Actiontec"
- Adaptec OSFamily = "Adaptec"
- Adtran OSFamily = "Adtran"
- Adva OSFamily = "Adva"
- Advanced OSFamily = "Advanced"
- Aerohive OSFamily = "Aerohive"
- Aethra OSFamily = "Aethra"
- Agfa OSFamily = "Agfa"
- AirLive OSFamily = "AirLive"
- AirMagnet OSFamily = "AirMagnet"
- AirSpan OSFamily = "AirSpan"
- Airaya OSFamily = "Airaya"
- Airlink101 OSFamily = "Airlink101"
- Airnet OSFamily = "Airnet"
- Airvana OSFamily = "Airvana"
- Alaxala OSFamily = "Alaxala"
- Alcatel OSFamily = "Alcatel"
- AlcatelLucent OSFamily = "Alcatel-Lucent"
- Alice OSFamily = "Alice"
- AllenBradley OSFamily = "Allen-Bradley"
- Allied OSFamily = "Allied"
- Allnet OSFamily = "Allnet"
- Allworx OSFamily = "Allworx"
- Alvarion OSFamily = "Alvarion"
- Amazon OSFamily = "Amazon"
- Ambit OSFamily = "Ambit"
- Amiga OSFamily = "Amiga"
- Anue OSFamily = "Anue"
- Apple OSFamily = "Apple"
- Arcor OSFamily = "Arcor"
- Areca OSFamily = "Areca"
- Argon OSFamily = "Argon"
- Argosy OSFamily = "Argosy"
- Arris OSFamily = "Arris"
- Aruba OSFamily = "Aruba"
- Asmax OSFamily = "Asmax"
- Asus OSFamily = "Asus"
- Atari OSFamily = "Atari"
- Atcom OSFamily = "Atcom"
- AudioCodes OSFamily = "AudioCodes"
- AudioControl OSFamily = "AudioControl"
- Avaya OSFamily = "Avaya"
- Avocent OSFamily = "Avocent"
- Axcient OSFamily = "Axcient"
- AzBox OSFamily = "AzBox"
- BECK OSFamily = "BECK"
- BSD OSFamily = "BSD"
- BSDI OSFamily = "BSDI"
- BT OSFamily = "BT"
- Barracuda OSFamily = "Barracuda"
- Barrelfish OSFamily = "Barrelfish"
- Basler OSFamily = "Basler"
- Bay OSFamily = "Bay"
- BeaconMedaes OSFamily = "BeaconMedaes"
- Beat OSFamily = "Beat"
- Belkin OSFamily = "Belkin"
- Bell OSFamily = "Bell"
- Billion OSFamily = "Billion"
- BinTec OSFamily = "BinTec"
- BlackBox OSFamily = "BlackBox"
- Blackboard OSFamily = "Blackboard"
- Blue OSFamily = "Blue"
- BlueArc OSFamily = "BlueArc"
- Bluebird OSFamily = "Bluebird"
- Bomara OSFamily = "Bomara"
- Bosch OSFamily = "Bosch"
- Bose OSFamily = "Bose"
- Boundless OSFamily = "Boundless"
- Bowers OSFamily = "Bowers"
- British OSFamily = "British"
- BroadMax OSFamily = "BroadMax"
- Brocade OSFamily = "Brocade"
- Brother OSFamily = "Brother"
- Buffalo OSFamily = "Buffalo"
- Burny OSFamily = "Burny"
- Bush OSFamily = "Bush"
- CNav OSFamily = "C-Nav"
- CAEN OSFamily = "CAEN"
- CMI OSFamily = "CMI"
- Cabletron OSFamily = "Cabletron"
- Caldera OSFamily = "Caldera"
- Calix OSFamily = "Calix"
- Cameo OSFamily = "Cameo"
- Canon OSFamily = "Canon"
- Casio OSFamily = "Casio"
- Cayman OSFamily = "Cayman"
- Ceedtec OSFamily = "Ceedtec"
- Check OSFamily = "Check"
- Chip OSFamily = "Chip"
- CipherLab OSFamily = "CipherLab"
- Cisco OSFamily = "Cisco"
- Citrix OSFamily = "Citrix"
- CoRAID OSFamily = "CoRAID"
- Cobalt OSFamily = "Cobalt"
- Cognex OSFamily = "Cognex"
- Comau OSFamily = "Comau"
- Compal OSFamily = "Compal"
- Compaq OSFamily = "Compaq"
- Comtrend OSFamily = "Comtrend"
- Conceptronic OSFamily = "Conceptronic"
- Control4 OSFamily = "Control4"
- Coyote OSFamily = "Coyote"
- Cray OSFamily = "Cray"
- Crestron OSFamily = "Crestron"
- CyanogenMod OSFamily = "CyanogenMod"
- Cyberoam OSFamily = "Cyberoam"
- Cymphonix OSFamily = "Cymphonix"
- DLink OSFamily = "D-Link"
- DEC OSFamily = "DEC"
- DMP OSFamily = "DMP"
- DTE OSFamily = "DTE"
- DVTel OSFamily = "DVTel"
- DYMO OSFamily = "DYMO"
- Data OSFamily = "Data"
- Datalogic OSFamily = "Datalogic"
- Daysequerra OSFamily = "Daysequerra"
- Decru OSFamily = "Decru"
- Dedicated OSFamily = "Dedicated"
- Dell OSFamily = "Dell"
- Denon OSFamily = "Denon"
- Denver OSFamily = "Denver"
- Develop OSFamily = "Develop"
- Dick OSFamily = "Dick"
- Digi OSFamily = "Digi"
- Digital OSFamily = "Digital"
- Digitus OSFamily = "Digitus"
- Digium OSFamily = "Digium"
- DirecTV OSFamily = "DirecTV"
- Dish OSFamily = "Dish"
- Dolby OSFamily = "Dolby"
- DragonFly OSFamily = "DragonFly"
- DragonWave OSFamily = "DragonWave"
- DrayTek OSFamily = "DrayTek"
- Draytek OSFamily = "Draytek"
- Drayton OSFamily = "Drayton"
- Dream OSFamily = "Dream"
- Drobo OSFamily = "Drobo"
- EMC OSFamily = "EMC"
- ESI OSFamily = "ESI"
- ETH OSFamily = "ETH"
- EasyPath OSFamily = "EasyPath"
- Eaton OSFamily = "Eaton"
- Efficient OSFamily = "Efficient"
- Eicon OSFamily = "Eicon"
- Elfiq OSFamily = "Elfiq"
- Elk OSFamily = "Elk"
- Elsag OSFamily = "Elsag"
- Ember OSFamily = "Ember"
- Emerson OSFamily = "Emerson"
- EnGenius OSFamily = "EnGenius"
- Encore OSFamily = "Encore"
- Endian OSFamily = "Endian"
- Enerdis OSFamily = "Enerdis"
- Engetron OSFamily = "Engetron"
- Enistic OSFamily = "Enistic"
- Enlogic OSFamily = "Enlogic"
- Enterasys OSFamily = "Enterasys"
- Epson OSFamily = "Epson"
- Ericsson OSFamily = "Ericsson"
- Espressif OSFamily = "Espressif"
- Essentia OSFamily = "Essentia"
- EtherWerX OSFamily = "EtherWerX"
- Exabyte OSFamily = "Exabyte"
- Excito OSFamily = "Excito"
- Express OSFamily = "Express"
- Exterity OSFamily = "Exterity"
- Extreme OSFamily = "Extreme"
- F5 OSFamily = "F5"
- FORE OSFamily = "FORE"
- Fatek OSFamily = "Fatek"
- FireBrick OSFamily = "FireBrick"
- Force10 OSFamily = "Force10"
- Fortinet OSFamily = "Fortinet"
- Foscam OSFamily = "Foscam"
- Foundry OSFamily = "Foundry"
- Free OSFamily = "Free"
- FreeBSD OSFamily = "FreeBSD"
- FreeNAS OSFamily = "FreeNAS"
- Freecom OSFamily = "Freecom"
- Fronius OSFamily = "Fronius"
- Frontier OSFamily = "Frontier"
- Fuji OSFamily = "Fuji"
- Fujian OSFamily = "Fujian"
- Fujitsu OSFamily = "Fujitsu"
- Funkwerk OSFamily = "Funkwerk"
- GNU OSFamily = "GNU"
- GalaxyMetalGear OSFamily = "GalaxyMetalGear"
- Gargoyle OSFamily = "Gargoyle"
- Garmin OSFamily = "Garmin"
- GbE2c OSFamily = "GbE2c"
- Geist OSFamily = "Geist"
- Gemtek OSFamily = "Gemtek"
- General OSFamily = "General"
- Generex OSFamily = "Generex"
- Gennet OSFamily = "Gennet"
- Genua OSFamily = "Genua"
- George OSFamily = "George"
- Geovision OSFamily = "Geovision"
- GlobespanVirata OSFamily = "GlobespanVirata"
- GoPro OSFamily = "GoPro"
- Google OSFamily = "Google"
- Grace OSFamily = "Grace"
- Grandstream OSFamily = "Grandstream"
- Green OSFamily = "Green"
- H3C OSFamily = "H3C"
- HID OSFamily = "HID"
- HP OSFamily = "HP"
- HW OSFamily = "HW"
- Haiku OSFamily = "Haiku"
- Hamlet OSFamily = "Hamlet"
- Harris OSFamily = "Harris"
- Hawking OSFamily = "Hawking"
- Hay OSFamily = "Hay"
- Head OSFamily = "Head"
- Henry OSFamily = "Henry"
- HighFlying OSFamily = "High-Flying"
- Hikvision OSFamily = "Hikvision"
- Hioki OSFamily = "Hioki"
- Hirschmann OSFamily = "Hirschmann"
- Hitron OSFamily = "Hitron"
- Hotway OSFamily = "Hotway"
- Huawei OSFamily = "Huawei"
- Hybertone OSFamily = "Hybertone"
- IBM OSFamily = "IBM"
- IEI OSFamily = "IEI"
- IGEL OSFamily = "IGEL"
- IHome OSFamily = "IHome"
- IOData OSFamily = "IO-Data"
- IOGear OSFamily = "IOGear"
- ION OSFamily = "ION"
- IPAD OSFamily = "IPAD"
- IPCop OSFamily = "IPCop"
- IPFire OSFamily = "IPFire"
- ISS OSFamily = "ISS"
- ITW OSFamily = "ITW"
- Icom OSFamily = "Icom"
- Icy OSFamily = "Icy"
- Imperva OSFamily = "Imperva"
- Infoblox OSFamily = "Infoblox"
- Infomir OSFamily = "Infomir"
- Infrant OSFamily = "Infrant"
- Inova OSFamily = "Inova"
- Instar OSFamily = "Instar"
- Intel OSFamily = "Intel"
- Interbell OSFamily = "Interbell"
- Interflex OSFamily = "Interflex"
- Intermec OSFamily = "Intermec"
- Interpeak OSFamily = "Interpeak"
- Intertex OSFamily = "Intertex"
- Intracom OSFamily = "Intracom"
- Inventel OSFamily = "Inventel"
- Iomega OSFamily = "Iomega"
- IronPort OSFamily = "IronPort"
- Isilon OSFamily = "Isilon"
- Iskratel OSFamily = "Iskratel"
- JTEKT OSFamily = "JTEKT"
- Joyent OSFamily = "Joyent"
- Juniper OSFamily = "Juniper"
- KA9Q OSFamily = "KA9Q"
- KCorp OSFamily = "KCorp"
- KWSoftware OSFamily = "KW-Software"
- KabaBenzing OSFamily = "Kaba-Benzing"
- Kaiomy OSFamily = "Kaiomy"
- Kapsch OSFamily = "Kapsch"
- Kartina OSFamily = "Kartina"
- Kemp OSFamily = "Kemp"
- Keyence OSFamily = "Keyence"
- Kodak OSFamily = "Kodak"
- Kongsberg OSFamily = "Kongsberg"
- Konica OSFamily = "Konica"
- Koukaam OSFamily = "Koukaam"
- Kronos OSFamily = "Kronos"
- Kyocera OSFamily = "Kyocera"
- LG OSFamily = "LG"
- LaCie OSFamily = "LaCie"
- LaCrosse OSFamily = "LaCrosse"
- LaSAT OSFamily = "LaSAT"
- Lancom OSFamily = "Lancom"
- Lanier OSFamily = "Lanier"
- Lantronix OSFamily = "Lantronix"
- Larus OSFamily = "Larus"
- Leica OSFamily = "Leica"
- Lenel OSFamily = "Lenel"
- Leolink OSFamily = "Leolink"
- LevelOne OSFamily = "LevelOne"
- Lexmark OSFamily = "Lexmark"
- Liebert OSFamily = "Liebert"
- LifeSize OSFamily = "LifeSize"
- Linksys OSFamily = "Linksys"
- Linux OSFamily = "Linux"
- LogiLink OSFamily = "LogiLink"
- Logitech OSFamily = "Logitech"
- Lorex OSFamily = "Lorex"
- Lucent OSFamily = "Lucent"
- Luminary OSFamily = "Luminary"
- Luxul OSFamily = "Luxul"
- Lyngsoe OSFamily = "Lyngsoe"
- MGE OSFamily = "MGE"
- MOXA OSFamily = "MOXA"
- MPI OSFamily = "MPI"
- Macsense OSFamily = "Macsense"
- Maipu OSFamily = "Maipu"
- Mapower OSFamily = "Mapower"
- Marantz OSFamily = "Marantz"
- McAfee OSFamily = "McAfee"
- Meinberg OSFamily = "Meinberg"
- Meru OSFamily = "Meru"
- Metrix OSFamily = "Metrix"
- MicroNet OSFamily = "MicroNet"
- Microsoft OSFamily = "Microsoft"
- Microware OSFamily = "Microware"
- MikroTik OSFamily = "MikroTik"
- Milight OSFamily = "Milight"
- Minix OSFamily = "Minix"
- Minolta OSFamily = "Minolta"
- Mirapoint OSFamily = "Mirapoint"
- Mitel OSFamily = "Mitel"
- Mitrastar OSFamily = "Mitrastar"
- Mitsubishi OSFamily = "Mitsubishi"
- Modtronix OSFamily = "Modtronix"
- Motorola OSFamily = "Motorola"
- MusicianLink OSFamily = "MusicianLink"
- NCR OSFamily = "NCR"
- NEC OSFamily = "NEC"
- NOXON OSFamily = "NOXON"
- NRG OSFamily = "NRG"
- NSFOCUS OSFamily = "NSFOCUS"
- NTI OSFamily = "NTI"
- NTT OSFamily = "NTT"
- Nashuatec OSFamily = "Nashuatec"
- National OSFamily = "National"
- NeXT OSFamily = "NeXT"
- Neopost OSFamily = "Neopost"
- Ness OSFamily = "Ness"
- Nest OSFamily = "Nest"
- NetApp OSFamily = "NetApp"
- NetBSD OSFamily = "NetBSD"
- NetBurner OSFamily = "NetBurner"
- NetOptics OSFamily = "NetOptics"
- Netasq OSFamily = "Netasq"
- Netcomm OSFamily = "Netcomm"
- Netgear OSFamily = "Netgear"
- Netgem OSFamily = "Netgem"
- Netopia OSFamily = "Netopia"
- Network OSFamily = "Network"
- NetworkAlchemy OSFamily = "NetworkAlchemy"
- NetworksAOK OSFamily = "NetworksAOK"
- Neuf OSFamily = "Neuf"
- Newave OSFamily = "Newave"
- NexStor OSFamily = "NexStor"
- Nexenta OSFamily = "Nexenta"
- Nexsan OSFamily = "Nexsan"
- Nibe OSFamily = "Nibe"
- Nintendo OSFamily = "Nintendo"
- NodeMCU OSFamily = "NodeMCU"
- Nokia OSFamily = "Nokia"
- Nomadix OSFamily = "Nomadix"
- Nortel OSFamily = "Nortel"
- Novatel OSFamily = "Novatel"
- Novell OSFamily = "Novell"
- NutOS OSFamily = "Nut/OS"
- OSRAM OSFamily = "OSRAM"
- Obihai OSFamily = "Obihai"
- Ocean OSFamily = "Ocean"
- Oki OSFamily = "Oki"
- Olivetti OSFamily = "Olivetti"
- Olympus OSFamily = "Olympus"
- Omron OSFamily = "Omron"
- On OSFamily = "On"
- OnStor OSFamily = "OnStor"
- Onboard OSFamily = "Onboard"
- OneAccess OSFamily = "OneAccess"
- OpenBSD OSFamily = "OpenBSD"
- OpenBox OSFamily = "OpenBox"
- Opto OSFamily = "Opto"
- Oracle OSFamily = "Oracle"
- Orange OSFamily = "Orange"
- Osmosys OSFamily = "Osmosys"
- Ouya OSFamily = "Ouya"
- PCBSD OSFamily = "PC-BSD"
- PCMeasure OSFamily = "PCMeasure"
- PORTech OSFamily = "PORTech"
- Packard OSFamily = "Packard"
- Packet8 OSFamily = "Packet8"
- PacketFront OSFamily = "PacketFront"
- Packeteer OSFamily = "Packeteer"
- Palmmicro OSFamily = "Palmmicro"
- Palo OSFamily = "Palo"
- Panasas OSFamily = "Panasas"
- Panasonic OSFamily = "Panasonic"
- Papouch OSFamily = "Papouch"
- Patton OSFamily = "Patton"
- Peplink OSFamily = "Peplink"
- Perfectone OSFamily = "Perfectone"
- Perle OSFamily = "Perle"
- Phar OSFamily = "Phar"
- PheeNet OSFamily = "PheeNet"
- Philips OSFamily = "Philips"
- Phoenix OSFamily = "Phoenix"
- Pingtel OSFamily = "Pingtel"
- Pioneer OSFamily = "Pioneer"
- Pirelli OSFamily = "Pirelli"
- Planet OSFamily = "Planet"
- Polycom OSFamily = "Polycom"
- Precise OSFamily = "Precise"
- Printronix OSFamily = "Printronix"
- Priva OSFamily = "Priva"
- Promise OSFamily = "Promise"
- Proxim OSFamily = "Proxim"
- QEMU OSFamily = "QEMU"
- QNAP OSFamily = "QNAP"
- QNX OSFamily = "QNX"
- QTech OSFamily = "QTech"
- Qualisys OSFamily = "Qualisys"
- Quantum OSFamily = "Quantum"
- Quarterdeck OSFamily = "Quarterdeck"
- RAD OSFamily = "RAD"
- RCA OSFamily = "RCA"
- RF OSFamily = "RF"
- RFSpace OSFamily = "RF-Space"
- RGB OSFamily = "RGB"
- RIM OSFamily = "RIM"
- RISCOS OSFamily = "RISCOS"
- RISE OSFamily = "RISE"
- RSA OSFamily = "RSA"
- Rabbit OSFamily = "Rabbit"
- Radware OSFamily = "Radware"
- Raritan OSFamily = "Raritan"
- ReactOS OSFamily = "ReactOS"
- RedM OSFamily = "Red-M"
- Redback OSFamily = "Redback"
- Reliable OSFamily = "Reliable"
- Repotech OSFamily = "Repotech"
- Revo OSFamily = "Revo"
- Ricoh OSFamily = "Ricoh"
- Rigol OSFamily = "Rigol"
- Rio OSFamily = "Rio"
- Riverbed OSFamily = "Riverbed"
- Roberts OSFamily = "Roberts"
- Rockwell OSFamily = "Rockwell"
- Roku OSFamily = "Roku"
- Ruckus OSFamily = "Ruckus"
- RuggedCom OSFamily = "RuggedCom"
- Ruijie OSFamily = "Ruijie"
- SCO OSFamily = "SCO"
- SEH OSFamily = "SEH"
- SGI OSFamily = "SGI"
- SMA OSFamily = "SMA"
- SMC OSFamily = "SMC"
- SNR OSFamily = "SNR"
- Sagem OSFamily = "Sagem"
- Sagemcom OSFamily = "Sagemcom"
- Samsung OSFamily = "Samsung"
- Sandstrom OSFamily = "Sandstrom"
- Sanyo OSFamily = "Sanyo"
- Sapling OSFamily = "Sapling"
- Satel OSFamily = "Satel"
- Savin OSFamily = "Savin"
- Schneider OSFamily = "Schneider"
- Schrack OSFamily = "Schrack"
- Schweitzer OSFamily = "Schweitzer"
- Scientific OSFamily = "Scientific"
- Seagate OSFamily = "Seagate"
- Secure OSFamily = "Secure"
- Seiko OSFamily = "Seiko"
- Senao OSFamily = "Senao"
- Sensatronics OSFamily = "Sensatronics"
- Sequent OSFamily = "Sequent"
- Sharp OSFamily = "Sharp"
- Shenzhen OSFamily = "Shenzhen"
- ShoreTel OSFamily = "ShoreTel"
- Siemens OSFamily = "Siemens"
- Silicondust OSFamily = "Silicondust"
- Sinus OSFamily = "Sinus"
- Sipura OSFamily = "Sipura"
- Sitecom OSFamily = "Sitecom"
- Sling OSFamily = "Sling"
- Slingbox OSFamily = "Slingbox"
- Smart OSFamily = "Smart"
- Smartlink OSFamily = "Smartlink"
- Snom OSFamily = "Snom"
- Solwise OSFamily = "Solwise"
- SonicWALL OSFamily = "SonicWALL"
- Sonos OSFamily = "Sonos"
- Sonus OSFamily = "Sonus"
- Sony OSFamily = "Sony"
- Source OSFamily = "Source"
- Specialix OSFamily = "Specialix"
- Sphairon OSFamily = "Sphairon"
- Star OSFamily = "Star"
- Starbridge OSFamily = "Starbridge"
- Stonewater OSFamily = "Stonewater"
- StorageTek OSFamily = "StorageTek"
- Stratus OSFamily = "Stratus"
- Suga OSFamily = "Suga"
- Sun OSFamily = "Sun"
- SunPower OSFamily = "SunPower"
- Supermicro OSFamily = "Supermicro"
- Syllable OSFamily = "Syllable"
- Symantec OSFamily = "Symantec"
- Symbian OSFamily = "Symbian"
- Symbol OSFamily = "Symbol"
- Symmetricon OSFamily = "Symmetricon"
- Synology OSFamily = "Synology"
- THome OSFamily = "T-Home"
- TMarc OSFamily = "T-Marc"
- TPLINK OSFamily = "TP-LINK"
- TPLink OSFamily = "TP-Link"
- TRENDnet OSFamily = "TRENDnet"
- Tadiran OSFamily = "Tadiran"
- Tahoe OSFamily = "Tahoe"
- Tandberg OSFamily = "Tandberg"
- Tandem OSFamily = "Tandem"
- TechniSat OSFamily = "TechniSat"
- Tektronix OSFamily = "Tektronix"
- Telco OSFamily = "Telco"
- Teldat OSFamily = "Teldat"
- Telekom OSFamily = "Telekom"
- Telewell OSFamily = "Telewell"
- Telex OSFamily = "Telex"
- Telsey OSFamily = "Telsey"
- Teltronics OSFamily = "Teltronics"
- TenAsys OSFamily = "TenAsys"
- Tenda OSFamily = "Tenda"
- Teradici OSFamily = "Teradici"
- Terratec OSFamily = "Terratec"
- Texas OSFamily = "Texas"
- Thales OSFamily = "Thales"
- Thecus OSFamily = "Thecus"
- Thomson OSFamily = "Thomson"
- Tiandy OSFamily = "Tiandy"
- Tibbo OSFamily = "Tibbo"
- Tigo OSFamily = "Tigo"
- Tintri OSFamily = "Tintri"
- TippingPoint OSFamily = "TippingPoint"
- Tizen OSFamily = "Tizen"
- Topfield OSFamily = "Topfield"
- Toptech OSFamily = "Toptech"
- Toshiba OSFamily = "Toshiba"
- Trane OSFamily = "Trane"
- TransAct OSFamily = "TransAct"
- Tranzeo OSFamily = "Tranzeo"
- Trapeze OSFamily = "Trapeze"
- Tripp OSFamily = "Tripp"
- Tut OSFamily = "Tut"
- Tyco OSFamily = "Tyco"
- USRobotics OSFamily = "USRobotics"
- UTStarcom OSFamily = "UTStarcom"
- Ubee OSFamily = "Ubee"
- Ubicom OSFamily = "Ubicom"
- Ubiquiti OSFamily = "Ubiquiti"
- Universal OSFamily = "Universal"
- VBrick OSFamily = "VBrick"
- VIPA OSFamily = "VIPA"
- VMware OSFamily = "VMware"
- VTrak OSFamily = "VTrak"
- Vantage OSFamily = "Vantage"
- Vegastream OSFamily = "Vegastream"
- Viasat OSFamily = "Viasat"
- Vilar OSFamily = "Vilar"
- Virdi OSFamily = "Virdi"
- Visual OSFamily = "Visual"
- Vocality OSFamily = "Vocality"
- Vodafone OSFamily = "Vodafone"
- Vodavi OSFamily = "Vodavi"
- Vonage OSFamily = "Vonage"
- WandT OSFamily = "W&T"
- WAGO OSFamily = "WAGO"
- WIZnet OSFamily = "WIZnet"
- Wago OSFamily = "Wago"
- Walker OSFamily = "Walker"
- WatchGuard OSFamily = "WatchGuard"
- WebSense OSFamily = "WebSense"
- Welltech OSFamily = "Welltech"
- Westell OSFamily = "Westell"
- Westermo OSFamily = "Westermo"
- Western OSFamily = "Western"
- Wind OSFamily = "Wind"
- Windows OSFamily = "Windows"
- World OSFamily = "World"
- WowWee OSFamily = "WowWee"
- Wyse OSFamily = "Wyse"
- XAVi OSFamily = "XAVi"
- XEUdotCom OSFamily = "XEU.com"
- XMOS OSFamily = "XMOS"
- Xerox OSFamily = "Xerox"
- Xiaomi OSFamily = "Xiaomi"
- Xirrus OSFamily = "Xirrus"
- Xylan OSFamily = "Xylan"
- Xyplex OSFamily = "Xyplex"
- Yamaha OSFamily = "Yamaha"
- Yealink OSFamily = "Yealink"
- ZKTeco OSFamily = "ZKTeco"
- ZTE OSFamily = "ZTE"
- Zebra OSFamily = "Zebra"
- Zelax OSFamily = "Zelax"
- Zerto OSFamily = "Zerto"
- Zhone OSFamily = "Zhone"
- Zipato OSFamily = "Zipato"
- ZoneAlarm OSFamily = "ZoneAlarm"
- Zoom OSFamily = "Zoom"
- ZyXEL OSFamily = "ZyXEL"
- Zyfer OSFamily = "Zyfer"
- cab OSFamily = "cab"
- eCosCentric OSFamily = "eCosCentric"
- iDirect OSFamily = "iDirect"
- iPXE OSFamily = "iPXE"
- iRobot OSFamily = "iRobot"
- illumos OSFamily = "illumos"
- ipTIME OSFamily = "ipTIME"
- lwIP OSFamily = "lwIP"
- m3 OSFamily = "m3"
- mbNet OSFamily = "mbNet"
- nCircle OSFamily = "nCircle"
-)
diff --git a/vendor/github.com/Ullaakut/nmap/xml.go b/vendor/github.com/Ullaakut/nmap/xml.go
deleted file mode 100644
index d8d819a..0000000
--- a/vendor/github.com/Ullaakut/nmap/xml.go
+++ /dev/null
@@ -1,508 +0,0 @@
-package nmap
-
-import (
- "encoding/xml"
- "io/ioutil"
- "strconv"
- "time"
-
- family "github.com/Ullaakut/nmap/pkg/osfamilies"
-)
-
-// Run represents an nmap scanning run.
-type Run struct {
- XMLName xml.Name `xml:"nmaprun"`
-
- Args string `xml:"args,attr" json:"args"`
- ProfileName string `xml:"profile_name,attr" json:"profile_name"`
- Scanner string `xml:"scanner,attr" json:"scanner"`
- StartStr string `xml:"startstr,attr" json:"start_str"`
- Version string `xml:"version,attr" json:"version"`
- XMLOutputVersion string `xml:"xmloutputversion,attr" json:"xml_output_version"`
- Debugging Debugging `xml:"debugging" json:"debugging"`
- Stats Stats `xml:"runstats" json:"run_stats"`
- ScanInfo ScanInfo `xml:"scaninfo" json:"scan_info"`
- Start Timestamp `xml:"start,attr" json:"start"`
- Verbose Verbose `xml:"verbose" json:"verbose"`
- Hosts []Host `xml:"host" json:"hosts"`
- PostScripts []Script `xml:"postscript>script" json:"post_scripts"`
- PreScripts []Script `xml:"prescript>script" json:"pre_scripts"`
- Targets []Target `xml:"target" json:"targets"`
- TaskBegin []Task `xml:"taskbegin" json:"task_begin"`
- TaskProgress []TaskProgress `xml:"taskprogress" json:"task_progress"`
- TaskEnd []Task `xml:"taskend" json:"task_end"`
-
- rawXML []byte
-}
-
-// ToFile writes a Run as XML into the specified file path.
-func (r Run) ToFile(filePath string) error {
- return ioutil.WriteFile(filePath, r.rawXML, 0666)
-}
-
-// ScanInfo represents the scan information.
-type ScanInfo struct {
- NumServices int `xml:"numservices,attr" json:"num_services"`
- Protocol string `xml:"protocol,attr" json:"protocol"`
- ScanFlags string `xml:"scanflags,attr" json:"scan_flags"`
- Services string `xml:"services,attr" json:"services"`
- Type string `xml:"type,attr" json:"type"`
-}
-
-// Verbose contains the verbosity level of the scan.
-type Verbose struct {
- Level int `xml:"level,attr" json:"level"`
-}
-
-// Debugging contains the debugging level of the scan.
-type Debugging struct {
- Level int `xml:"level,attr" json:"level"`
-}
-
-// Task contains information about a task.
-type Task struct {
- Time Timestamp `xml:"time,attr" json:"time"`
- Task string `xml:"task,attr" json:"task"`
- ExtraInfo string `xml:"extrainfo,attr" json:"extra_info"`
-}
-
-// TaskProgress contains information about the progression of a task.
-type TaskProgress struct {
- Percent float32 `xml:"percent,attr" json:"percent"`
- Remaining int `xml:"remaining,attr" json:"remaining"`
- Task string `xml:"task,attr" json:"task"`
- Etc Timestamp `xml:"etc,attr" json:"etc"`
- Time Timestamp `xml:"time,attr" json:"time"`
-}
-
-// Target represents a target, how it was specified when passed to nmap,
-// its status and the reason for its status. Example:
-//
-type Target struct {
- Specification string `xml:"specification,attr" json:"specification"`
- Status string `xml:"status,attr" json:"status"`
- Reason string `xml:"reason,attr" json:"reason"`
-}
-
-// Host represents a host that was scanned.
-type Host struct {
- Distance Distance `xml:"distance" json:"distance"`
- EndTime Timestamp `xml:"endtime,attr,omitempty" json:"end_time"`
- IPIDSequence IPIDSequence `xml:"ipidsequence" json:"ip_id_sequence"`
- OS OS `xml:"os" json:"os"`
- StartTime Timestamp `xml:"starttime,attr,omitempty" json:"start_time"`
- Status Status `xml:"status" json:"status"`
- TCPSequence TCPSequence `xml:"tcpsequence" json:"tcp_sequence"`
- TCPTSSequence TCPTSSequence `xml:"tcptssequence" json:"tcp_ts_sequence"`
- Times Times `xml:"times" json:"times"`
- Trace Trace `xml:"trace" json:"trace"`
- Uptime Uptime `xml:"uptime" json:"uptime"`
- Comment string `xml:"comment,attr" json:"comment"`
- Addresses []Address `xml:"address" json:"addresses"`
- ExtraPorts []ExtraPort `xml:"ports>extraports" json:"extra_ports"`
- Hostnames []Hostname `xml:"hostnames>hostname" json:"hostnames"`
- HostScripts []Script `xml:"hostscript>script" json:"host_scripts"`
- Ports []Port `xml:"ports>port" json:"ports"`
- Smurfs []Smurf `xml:"smurf" json:"smurfs"`
-}
-
-// Status represents a host's status.
-type Status struct {
- State string `xml:"state,attr" json:"state"`
- Reason string `xml:"reason,attr" json:"reason"`
- ReasonTTL float32 `xml:"reason_ttl,attr" json:"reason_ttl"`
-}
-
-func (s Status) String() string {
- return s.State
-}
-
-// Address contains a IPv4 or IPv6 address for a host.
-type Address struct {
- Addr string `xml:"addr,attr" json:"addr"`
- AddrType string `xml:"addrtype,attr" json:"addr_type"`
- Vendor string `xml:"vendor,attr" json:"vendor"`
-}
-
-func (a Address) String() string {
- return a.Addr
-}
-
-// Hostname is a name for a host.
-type Hostname struct {
- Name string `xml:"name,attr" json:"name"`
- Type string `xml:"type,attr" json:"type"`
-}
-
-func (h Hostname) String() string {
- return h.Name
-}
-
-// Smurf contains repsonses from a smurf attack.
-type Smurf struct {
- Responses string `xml:"responses,attr" json:"responses"`
-}
-
-// ExtraPort contains the information about the closed and filtered ports.
-type ExtraPort struct {
- State string `xml:"state,attr" json:"state"`
- Count int `xml:"count,attr" json:"count"`
- Reasons []Reason `xml:"extrareasons" json:"reasons"`
-}
-
-// Reason represents a reason why a port is closed or filtered.
-// This won't be in the scan results unless WithReason is used.
-type Reason struct {
- Reason string `xml:"reason,attr" json:"reason"`
- Count int `xml:"count,attr" json:"count"`
-}
-
-// Port contains all the information about a scanned port.
-type Port struct {
- ID uint16 `xml:"portid,attr" json:"id"`
- Protocol string `xml:"protocol,attr" json:"protocol"`
- Owner Owner `xml:"owner" json:"owner"`
- Service Service `xml:"service" json:"service"`
- State State `xml:"state" json:"state"`
- Scripts []Script `xml:"script" json:"scripts"`
-}
-
-// PortStatus represents a port's state.
-type PortStatus string
-
-// Enumerates the different possible state values.
-const (
- Open PortStatus = "open"
- Closed PortStatus = "closed"
- Filtered PortStatus = "filtered"
- Unfiltered PortStatus = "unfiltered"
-)
-
-// Status returns the status of a port.
-func (p Port) Status() PortStatus {
- return PortStatus(p.State.State)
-}
-
-// State contains information about a given port's status.
-// State will be open, closed, etc.
-type State struct {
- State string `xml:"state,attr" json:"state"`
- Reason string `xml:"reason,attr" json:"reason"`
- ReasonIP string `xml:"reason_ip,attr" json:"reason_ip"`
- ReasonTTL float32 `xml:"reason_ttl,attr" json:"reason_ttl"`
-}
-
-func (s State) String() string {
- return s.State
-}
-
-// Owner contains the name of a port's owner.
-type Owner struct {
- Name string `xml:"name,attr" json:"name"`
-}
-
-func (o Owner) String() string {
- return o.Name
-}
-
-// Service contains detailed information about a service on an open port.
-type Service struct {
- DeviceType string `xml:"devicetype,attr" json:"device_type"`
- ExtraInfo string `xml:"extrainfo,attr" json:"extra_info"`
- HighVersion string `xml:"highver,attr" json:"high_version"`
- Hostname string `xml:"hostname,attr" json:"hostname"`
- LowVersion string `xml:"lowver,attr" json:"low_version"`
- Method string `xml:"method,attr" json:"method"`
- Name string `xml:"name,attr" json:"name"`
- OSType string `xml:"ostype,attr" json:"os_type"`
- Product string `xml:"product,attr" json:"product"`
- Proto string `xml:"proto,attr" json:"proto"`
- RPCNum string `xml:"rpcnum,attr" json:"rpc_num"`
- ServiceFP string `xml:"servicefp,attr" json:"service_fp"`
- Tunnel string `xml:"tunnel,attr" json:"tunnel"`
- Version string `xml:"version,attr" json:"version"`
- Configuration int `xml:"conf,attr" json:"configuration"`
- CPEs []CPE `xml:"cpe" json:"cpes"`
-}
-
-func (s Service) String() string {
- return s.Name
-}
-
-// CPE (Common Platform Enumeration) is a standardized way to name software
-// applications, operating systems and hardware platforms.
-type CPE string
-
-// Script represents an Nmap Scripting Engine script.
-type Script struct {
- ID string `xml:"id,attr" json:"id"`
- Output string `xml:"output,attr" json:"output"`
- Tables Table `xml:"table" json:"tables"`
-}
-
-// Table contains the output of the script in an easily parsable form.
-type Table map[string]string
-
-// MarshalXML implements the xml.Marshaler interface.
-func (t Table) MarshalXML(e *xml.Encoder, startElem xml.StartElement) error {
- tokens := []xml.Token{startElem}
-
- // Add all key/value pairs as entries in the XML array.
- for key, value := range t {
- // Start of the XML element.
- start := xml.StartElement{
- Name: xml.Name{
- Local: "elem",
- },
- Attr: []xml.Attr{
- {
- Name: xml.Name{
- Local: "key",
- },
- Value: key,
- },
- },
- }
-
- // End of the XML element.
- end := xml.EndElement{
- Name: start.Name,
- }
-
- // Append the start, content and end of the new element to the list of XML tokens.
- tokens = append(tokens, start, xml.CharData(value), end)
- }
-
- tokens = append(tokens, xml.EndElement{
- Name: startElem.Name,
- })
-
- // Encode all tokens.
- for _, t := range tokens {
- err := e.EncodeToken(t)
- if err != nil {
- return err
- }
- }
-
- // Flush the encoder to ensure that the tokens are written.
- err := e.Flush()
- if err != nil {
- return err
- }
-
- return nil
-}
-
-// UnmarshalXML implements the xml.Unmarshaler interface.
-func (t *Table) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
- table := make(map[string]string)
-
- var (
- currentKey string
- currentValue string
- )
-
- for {
- token, err := d.Token()
- if err != nil {
- break
- }
-
- switch element := token.(type) {
- case xml.StartElement:
- for _, attribute := range element.Attr {
- if attribute.Name.Local == "key" {
- currentKey = attribute.Value
- break
- }
- }
- case xml.CharData:
- currentValue = string(element)
- case xml.EndElement:
- // Insert the current key/value pair.
- table[currentKey] = currentValue
-
- // Reset the temporary variables for the next pair.
- currentKey = ""
- currentValue = ""
- }
- }
-
- *t = table
-
- return nil
-}
-
-// OS contains the fingerprinted operating system for a host.
-type OS struct {
- PortsUsed []PortUsed `xml:"portused" json:"ports_used"`
- Matches []OSMatch `xml:"osmatch" json:"os_matches"`
- Fingerprints []OSFingerprint `xml:"osfingerprint" json:"os_fingerprints"`
- Classes []OSClass `xml:"osclass" json:"os_classes"`
-}
-
-// PortUsed is the port used to fingerprint an operating system.
-type PortUsed struct {
- State string `xml:"state,attr" json:"state"`
- Proto string `xml:"proto,attr" json:"proto"`
- ID int `xml:"portid,attr" json:"port_id"`
-}
-
-// OSMatch contains detailed information regarding an operating system fingerprint.
-type OSMatch struct {
- Name string `xml:"name,attr" json:"name"`
- Accuracy int `xml:"accuracy,attr" json:"accuracy"`
- Line int `xml:"line,attr" json:"line"`
-}
-
-// OSClass contains vendor information about an operating system.
-type OSClass struct {
- Vendor string `xml:"vendor,attr" json:"vendor"`
- OSGeneration string `xml:"osgen,attr" json:"os_generation"`
- Type string `xml:"type,attr" json:"type"`
- Accuracy int `xml:"accuracy,attr" json:"accuracy"`
- Family string `xml:"osfamily,attr" json:"os_family"`
- CPEs []CPE `xml:"cpe" json:"cpes"`
-}
-
-// OSFamily returns the OS family in an enumerated format.
-func (o OSClass) OSFamily() family.OSFamily {
- return family.OSFamily(o.Family)
-}
-
-// OSFingerprint is the actual fingerprint string of an operating system.
-type OSFingerprint struct {
- Fingerprint string `xml:"fingerprint,attr" json:"fingerprint"`
-}
-
-// Distance is the amount of hops to a particular host.
-type Distance struct {
- Value int `xml:"value,attr" json:"value"`
-}
-
-// Uptime is the amount of time the host has been up.
-type Uptime struct {
- Seconds int `xml:"seconds,attr" json:"seconds"`
- Lastboot string `xml:"lastboot,attr" json:"last_boot"`
-}
-
-// Sequence represents a detected sequence.
-type Sequence struct {
- Class string `xml:"class,attr" json:"class"`
- Values string `xml:"values,attr" json:"values"`
-}
-
-// TCPSequence represents a detected TCP sequence.
-type TCPSequence struct {
- Index int `xml:"index,attr" json:"index"`
- Difficulty string `xml:"difficulty,attr" json:"difficulty"`
- Values string `xml:"values,attr" json:"values"`
-}
-
-// IPIDSequence represents a detected IP ID sequence.
-type IPIDSequence Sequence
-
-// TCPTSSequence represents a detected TCP TS sequence.
-type TCPTSSequence Sequence
-
-// Trace represents the trace to a host, including the hops.
-type Trace struct {
- Proto string `xml:"proto,attr" json:"proto"`
- Port int `xml:"port,attr" json:"port"`
- Hops []Hop `xml:"hop" json:"hops"`
-}
-
-// Hop is an IP hop to a host.
-type Hop struct {
- TTL float32 `xml:"ttl,attr" json:"ttl"`
- RTT string `xml:"rtt,attr" json:"rtt"`
- IPAddr string `xml:"ipaddr,attr" json:"ip_addr"`
- Host string `xml:"host,attr" json:"host"`
-}
-
-// Times contains time statistics for an nmap scan.
-type Times struct {
- SRTT string `xml:"srtt,attr" json:"srtt"`
- RTT string `xml:"rttvar,attr" json:"rttv"`
- To string `xml:"to,attr" json:"to"`
-}
-
-// Stats contains statistics for an nmap scan.
-type Stats struct {
- Finished Finished `xml:"finished" json:"finished"`
- Hosts HostStats `xml:"hosts" json:"hosts"`
-}
-
-// Finished contains detailed statistics regarding a finished scan.
-type Finished struct {
- Time Timestamp `xml:"time,attr" json:"time"`
- TimeStr string `xml:"timestr,attr" json:"time_str"`
- Elapsed float32 `xml:"elapsed,attr" json:"elapsed"`
- Summary string `xml:"summary,attr" json:"summary"`
- Exit string `xml:"exit,attr" json:"exit"`
- ErrorMsg string `xml:"errormsg,attr" json:"error_msg"`
-}
-
-// HostStats contains the amount of up and down hosts and the total count.
-type HostStats struct {
- Up int `xml:"up,attr" json:"up"`
- Down int `xml:"down,attr" json:"down"`
- Total int `xml:"total,attr" json:"total"`
-}
-
-// Timestamp represents time as a UNIX timestamp in seconds.
-type Timestamp time.Time
-
-// ParseTime converts a UNIX timestamp string to a time.Time.
-func (t *Timestamp) ParseTime(s string) error {
- timestamp, err := strconv.ParseInt(s, 10, 64)
- if err != nil {
- return err
- }
-
- *t = Timestamp(time.Unix(timestamp, 0))
-
- return nil
-}
-
-// FormatTime formats the time.Time value as a UNIX timestamp string.
-func (t Timestamp) FormatTime() string {
- return strconv.FormatInt(time.Time(t).Unix(), 10)
-}
-
-// MarshalJSON implements the json.Marshaler interface.
-func (t Timestamp) MarshalJSON() ([]byte, error) {
- return []byte(t.FormatTime()), nil
-}
-
-// UnmarshalJSON implements the json.Unmarshaler interface.
-func (t *Timestamp) UnmarshalJSON(b []byte) error {
- return t.ParseTime(string(b))
-}
-
-// MarshalXMLAttr implements the xml.MarshalerAttr interface.
-func (t Timestamp) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
- if time.Time(t).IsZero() {
- return xml.Attr{}, nil
- }
-
- return xml.Attr{Name: name, Value: t.FormatTime()}, nil
-}
-
-// UnmarshalXMLAttr implements the xml.UnmarshalXMLAttr interface.
-func (t *Timestamp) UnmarshalXMLAttr(attr xml.Attr) (err error) {
- return t.ParseTime(attr.Value)
-}
-
-// Parse takes a byte array of nmap xml data and unmarshals it into a
-// Run struct.
-func Parse(content []byte) (*Run, error) {
- r := &Run{
- rawXML: content,
- }
-
- err := xml.Unmarshal(content, r)
-
- return r, err
-}
diff --git a/vendor/github.com/Ullaakut/nmap/xml_test.go b/vendor/github.com/Ullaakut/nmap/xml_test.go
deleted file mode 100644
index 05f5aa8..0000000
--- a/vendor/github.com/Ullaakut/nmap/xml_test.go
+++ /dev/null
@@ -1,939 +0,0 @@
-package nmap
-
-import (
- "bytes"
- "encoding/xml"
- "fmt"
- "io/ioutil"
- "reflect"
- "testing"
- "time"
-
- family "github.com/Ullaakut/nmap/pkg/osfamilies"
-)
-
-func TestParseTime(t *testing.T) {
- ts := Timestamp{}
-
- err := ts.ParseTime("invalid")
- if err == nil {
- t.Errorf("expected strconv.ParseInt: parsing \"invalid\": invalid syntax got %v", err)
- }
-}
-
-func TestFormatTime(t *testing.T) {
- originalStr := "123456789"
- ts := Timestamp{}
-
- err := ts.ParseTime(originalStr)
- if err != nil {
- panic(err)
- }
-
- result := ts.FormatTime()
-
- if result != originalStr {
- t.Errorf("expected %s got %s", originalStr, result)
- }
-}
-
-func TestOSFamily(t *testing.T) {
- osc := OSClass{
- Family: "Linux",
- }
-
- if osc.OSFamily() != family.Linux {
- t.Errorf("expected OSClass.OSFamily() to be equal to %v, got %v", family.Linux, osc.OSFamily())
- }
-}
-
-func TestParseTableXML(t *testing.T) {
- expectedTable := map[string]string{
- "key": "AAAAB3NzaC1yc2EAAAABIwAAAQEAwVKoTY/7GFG7BmKkG6qFAHY/f3ciDX2MXTBLMEJP0xyUJsoy/CVRYw2b4qUB/GCJ5lh2InP+LVnPD3ZdtpyIvbS0eRZs/BH+mVLGh9xA/wOEUiiCfzQRsHj1xn7cqeWViAzQtdGluk/5CVAvr1FU3HNaaWkg7KQOSiKAzgDwCBtQhlgI40xdXgbqMkrHeP4M1p4MxoEVpZMe4oObACWwazeHP/Xas1vy5rbnmE59MpEZaA8t7AfGlW4MrVMhAB1JsFMdd0qFLpy/l93H3ptSlx1+6PQ5gUyjhmDUjMR+k6fb0yOeGdOrjN8IrWPmebZRFBjK5aCJwubgY/03VsSBMQ==",
- "fingerprint": "79f809acd4e232421049d3bd208285ec",
- "type": "ssh-rsa",
- "bits": "2048",
- }
-
- input := []byte(fmt.Sprintf(
- ``,
- expectedTable["key"],
- expectedTable["fingerprint"],
- expectedTable["type"],
- expectedTable["bits"],
- ))
-
- var table Table
-
- err := xml.Unmarshal(input, &table)
- if err != nil {
- panic(err)
- }
-
- if table["key"] != expectedTable["key"] {
- t.Errorf("expected %v got %v", expectedTable["key"], table["key"])
- }
-
- if table["fingerprint"] != expectedTable["fingerprint"] {
- t.Errorf("expected %v got %v", expectedTable["fingerprint"], table["fingerprint"])
- }
-
- if table["type"] != expectedTable["type"] {
- t.Errorf("expected %v got %v", expectedTable["type"], table["type"])
- }
-
- if table["bits"] != expectedTable["bits"] {
- t.Errorf("expected %v got %v", expectedTable["bits"], table["bits"])
- }
-}
-
-func TestFormatTableXML(t *testing.T) {
- table := Table(map[string]string{
- "key": "AAAAB3NzaC1yc2EAAAABIwAAAQEAwVKoTY/7GFG7BmKkG6qFAHY/f3ciDX2MXTBLMEJP0xyUJsoy/CVRYw2b4qUB/GCJ5lh2InP+LVnPD3ZdtpyIvbS0eRZs/BH+mVLGh9xA/wOEUiiCfzQRsHj1xn7cqeWViAzQtdGluk/5CVAvr1FU3HNaaWkg7KQOSiKAzgDwCBtQhlgI40xdXgbqMkrHeP4M1p4MxoEVpZMe4oObACWwazeHP/Xas1vy5rbnmE59MpEZaA8t7AfGlW4MrVMhAB1JsFMdd0qFLpy/l93H3ptSlx1+6PQ5gUyjhmDUjMR+k6fb0yOeGdOrjN8IrWPmebZRFBjK5aCJwubgY/03VsSBMQ==",
- "fingerprint": "79f809acd4e232421049d3bd208285ec",
- "type": "ssh-rsa",
- "bits": "2048",
- })
-
- expectedXML := [][]byte{
- []byte(""),
- []byte(fmt.Sprintf(`%s`, table["key"])),
- []byte(fmt.Sprintf(`%s`, table["fingerprint"])),
- []byte(fmt.Sprintf(`%s`, table["type"])),
- []byte(fmt.Sprintf(`%s`, table["bits"])),
- []byte("
"),
- }
-
- XML, err := xml.Marshal(table)
- if err != nil {
- panic(err)
- }
-
- for _, expectedXMLElement := range expectedXML {
- if !bytes.Contains(XML, expectedXMLElement) {
- t.Errorf("missing %s in %s", expectedXMLElement, XML)
- }
- }
-}
-
-func TestParseRunXML(t *testing.T) {
- tests := []struct {
- inputFile string
-
- expectedResult *Run
- expectedError error
- }{
- {
- inputFile: "test_xml/scan01.xml",
-
- expectedResult: &Run{
- Args: "nmap -A -v -oX sample-03.xml freshmeat.net sourceforge.net nmap.org kernel.org openbsd.org netbsd.org google.com gmail.com",
- Scanner: "nmap",
- StartStr: "Sun Jan 27 21:10:02 2008",
- Version: "4.53",
- XMLOutputVersion: "1.01",
- ScanInfo: ScanInfo{
- NumServices: 1714,
- Protocol: "tcp",
- Services: "1-1027,1029-1033,1040,1043,1050,1058-1059,1067-1068,1076,1080,1083-1084,1103,1109-1110,1112,1127,1139,1155,1158,1178,1212,1214,1220,1222,1234,1241,1248,1270,1337,1346-1381,1383-1552,1600,1650-1652,1661-1672,1680,1720,1723,1755,1761-1764,1827,1900,1935,1984,1986-2028,2030,2032-2035,2038,2040-2049,2053,2064-2065,2067-2068,2105-2106,2108,2111-2112,2120-2121,2201,2232,2241,2301,2307,2401,2430-2433,2500-2501,2564,2600-2605,2627-2628,2638,2766,2784,2809,2903,2998,3000-3001,3005-3006,3025,3045,3049,3052,3064,3086,3128,3141,3264,3268-3269,3292,3299,3306,3333,3372,3389,3397-3399,3421,3455-3457,3462,3531,3632,3689,3900,3984-3986,3999-4000,4002,4008,4045,4125,4132-4133,4144,4199,4224,4321,4333,4343,4444,4480,4500,4557,4559,4660,4662,4672,4899,4987,4998,5000-5003,5009-5011,5050,5060,5100-5102,5145,5190-5193,5232,5236,5300-5305,5308,5400,5405,5432,5490,5500,5510,5520,5530,5540,5550,5555,5560,5631-5632,5679-5680,5713-5717,5800-5803,5900-5903,5977-5979,5997-6009,6017,6050,6101,6103,6105-6106,6110-6112,6141-6148,6222,6346-6347,6400-6401,6502,6543-6544,6547-6548,6558,6588,6662,6665-6670,6699-6701,6881,6969,7000-7010,7070,7100,7200-7201,7273,7326,7464,7597,7937-7938,8000,8007,8009,8021,8076,8080-8082,8118,8123,8443,8770,8888,8892,9040,9050-9051,9090,9100-9107,9111,9152,9535,9876,9991-9992,9999-10000,10005,10082-10083,11371,12000,12345-12346,13701-13702,13705-13706,13708-13718,13720-13722,13782-13783,14141,15126,15151,16080,16444,16959,17007,17300,18000,18181-18185,18187,19150,20005,22273,22289,22305,22321,22370,26208,27000-27010,27374,27665,31337,31416,32770-32780,32786-32787,38037,38292,43188,44334,44442-44443,47557,49400,50000,50002,54320,61439-61441,65301",
- Type: "syn",
- },
- Start: Timestamp(time.Unix(1201479002, 0)),
- Verbose: Verbose{
- Level: 1,
- },
- Stats: Stats{
- Finished: Finished{
- Time: Timestamp(time.Unix(1201481569, 0)),
- TimeStr: "Sun Jan 27 21:52:49 2008",
- },
- Hosts: HostStats{
- Up: 8,
- Total: 8,
- Down: 0,
- },
- },
- Hosts: []Host{
- {
- IPIDSequence: IPIDSequence{
- Class: "All zeros",
- Values: "0,0,0,0,0,0",
- },
- OS: OS{
- PortsUsed: []PortUsed{
- {
- State: "open",
- Proto: "tcp",
- ID: 80,
- },
- {
- State: "closed",
- Proto: "tcp",
- ID: 443,
- },
- },
- Matches: []OSMatch{
- {
- Name: "MicroTik RouterOS 2.9.46",
- Accuracy: 94,
- Line: 14788,
- },
- {
- Name: "Linksys WRT54GS WAP (Linux kernel)",
- Accuracy: 94,
- Line: 8292,
- },
- {
- Name: "Linux 2.4.18 - 2.4.32 (likely embedded)",
- Accuracy: 94,
- Line: 8499,
- },
- {
- Name: "Linux 2.4.21 - 2.4.33",
- Accuracy: 94,
- Line: 8624,
- },
- {
- Name: "Linux 2.4.27",
- Accuracy: 94,
- Line: 8675,
- },
- {
- Name: "Linux 2.4.28 - 2.4.30",
- Accuracy: 94,
- Line: 8693,
- },
- {
- Name: "Linux 2.6.5 - 2.6.18",
- Accuracy: 94,
- Line: 11411,
- },
- {
- Name: "Linux 2.6.8",
- Accuracy: 94,
- Line: 11485,
- },
- {
- Name: "WebVOIZE 120 IP phone",
- Accuracy: 94,
- Line: 18921,
- },
- {
- Name: "Linux 2.4.2 (Red Hat 7.1)",
- Accuracy: 91,
- Line: 8533,
- },
- },
- Fingerprints: []OSFingerprint{
- {
- Fingerprint: fingerprint,
- },
- },
- Classes: []OSClass{
- {
- Vendor: "MikroTik",
- OSGeneration: "2.X",
- Type: "software router",
- Accuracy: 94,
- Family: "RouterOS",
- },
- {
- Vendor: "Linksys",
- OSGeneration: "2.4.X",
- Type: "WAP",
- Accuracy: 94,
- Family: "Linux",
- },
- {
- Vendor: "Linux",
- OSGeneration: "2.4.X",
- Type: "general purpose",
- Accuracy: 94,
- Family: "Linux",
- },
- {
- Vendor: "Linux",
- OSGeneration: "2.6.X",
- Type: "general purpose",
- Accuracy: 94,
- Family: "Linux",
- },
- {
- Vendor: "WebVOIZE",
- Type: "VoIP phone",
- Accuracy: 94,
- Family: "embedded",
- },
- {
- Vendor: "D-Link",
- OSGeneration: "2.4.X",
- Type: "WAP",
- Accuracy: 91,
- Family: "Linux",
- },
- {
- Vendor: "Inventel",
- Type: "WAP",
- Accuracy: 91,
- Family: "embedded",
- },
- {
- Vendor: "USRobotics",
- Type: "broadband router",
- Accuracy: 91,
- Family: "embedded",
- },
- {
- Vendor: "Linux",
- OSGeneration: "2.4.X",
- Type: "broadband router",
- Accuracy: 91,
- Family: "Linux",
- },
- {
- Vendor: "Linux",
- OSGeneration: "2.4.X",
- Type: "WAP",
- Accuracy: 91,
- Family: "Linux",
- },
- {
- Vendor: "Linux",
- OSGeneration: "2.4.X",
- Type: "media device",
- Accuracy: 91,
- Family: "Linux",
- },
- {
- Vendor: "Linux",
- OSGeneration: "2.4.X",
- Type: "VoIP gateway",
- Accuracy: 91,
- Family: "Linux",
- },
- {
- Vendor: "Netgear",
- Type: "WAP",
- Accuracy: 91,
- Family: "embedded",
- },
- {
- Vendor: "QLogic",
- Type: "switch",
- Accuracy: 91,
- Family: "embedded",
- },
- {
- Vendor: "Sharp",
- OSGeneration: "2.4.X",
- Type: "PDA",
- Accuracy: 91,
- Family: "Linux",
- },
- {
- Vendor: "FON",
- OSGeneration: "2.6.X",
- Type: "WAP",
- Accuracy: 91,
- Family: "Linux",
- },
- {
- Vendor: "FON",
- OSGeneration: "2.4.X",
- Type: "WAP",
- Accuracy: 90,
- Family: "Linux",
- },
- {
- Vendor: "Belkin",
- Type: "WAP",
- Accuracy: 90,
- Family: "embedded",
- },
- {
- Vendor: "Asus",
- Type: "WAP",
- Accuracy: 90,
- Family: "embedded",
- },
- {
- Vendor: "Netgear",
- OSGeneration: "2.4.X",
- Type: "WAP",
- Accuracy: 90,
- Family: "Linux",
- },
- {
- Vendor: "Xerox",
- Type: "printer",
- Accuracy: 90,
- Family: "embedded",
- },
- {
- Vendor: "Aladdin",
- OSGeneration: "2.4.X",
- Type: "security-misc",
- Accuracy: 89,
- Family: "Linux",
- },
- {
- Vendor: "Occam",
- Type: "VoIP gateway",
- Accuracy: 89,
- Family: "embedded",
- },
- {
- Vendor: "Roku",
- Type: "media device",
- Accuracy: 89,
- Family: "embedded",
- },
- {
- Vendor: "Siemens",
- Type: "WAP",
- Accuracy: 89,
- Family: "Linux",
- },
- {
- Vendor: "3Com",
- OSGeneration: "2.4.X",
- Type: "broadband router",
- Accuracy: 89,
- Family: "Linux",
- },
- {
- Vendor: "Dream Multimedia",
- OSGeneration: "2.6.X",
- Type: "media device",
- Accuracy: 89,
- Family: "Linux",
- },
- {
- Vendor: "Iomega",
- OSGeneration: "2.6.X",
- Type: "storage-misc",
- Accuracy: 89,
- Family: "Linux",
- },
- },
- },
- Status: Status{
- State: "up",
- Reason: "reset",
- },
- TCPSequence: TCPSequence{
- Index: 242,
- Difficulty: "Good luck!",
- Values: "457B276,4584FC8,161C122C,161B185F,1605EA95,1614C498",
- },
- TCPTSSequence: TCPTSSequence{
- Class: "other",
- Values: "3FB03AA9,3FB03C75,45B26360,45B2636A,45B26374,45B2637E",
- },
- Times: Times{
- SRTT: "269788",
- RTT: "41141",
- To: "434352",
- },
- Trace: Trace{
- Proto: "tcp",
- Port: 80,
- Hops: []Hop{
- {
- TTL: 1,
- RTT: "1.83",
- IPAddr: "192.168.254.254",
- },
- {
- TTL: 2,
- RTT: "18.95",
- IPAddr: "200.217.89.32",
- },
- {
- TTL: 3,
- RTT: "18.33",
- IPAddr: "200.217.30.250",
- Host: "gigabitethernet5-1.80-cto-rn-rotd-02.telemar.net.br",
- },
- {
- TTL: 4,
- RTT: "45.05",
- IPAddr: "200.97.65.250",
- Host: "pos15-1-nbv-pe-rotd-03.telemar.net.br",
- },
- {
- TTL: 5,
- RTT: "43.49",
- IPAddr: "200.223.131.13",
- Host: "pos6-0-nbv-pe-rotn-01.telemar.net.br",
- },
- {
- TTL: 6,
- RTT: "91.27",
- IPAddr: "200.223.131.205",
- Host: "so-0-2-0-0-arc-rj-rotn-01.telemar.net.br",
- },
- {
- TTL: 8,
- RTT: "191.87",
- IPAddr: "200.223.131.110",
- Host: "PO0-3.ARC-RJ-ROTN-01.telemar.net.br",
- },
- {
- TTL: 9,
- RTT: "177.30",
- IPAddr: "208.173.90.89",
- Host: "bpr2-so-5-2-0.miamimit.savvis.net",
- },
- {
- TTL: 10,
- RTT: "181.50",
- IPAddr: "208.172.97.169",
- Host: "cr2-pos-0-3-1-0.miami.savvis.net",
- },
- {
- TTL: 11,
- RTT: "336.43",
- IPAddr: "206.24.210.70",
- Host: "cr1-loopback.sfo.savvis.net",
- },
- {
- TTL: 12,
- RTT: "245.32",
- IPAddr: "204.70.200.229",
- Host: "er1-te-1-0-1.SanJose3Equinix.savvis.net",
- },
- {
- TTL: 13,
- RTT: "238.47",
- IPAddr: "204.70.200.210",
- Host: "hr1-te-2-0-0.santaclarasc4.savvis.net",
- },
- {
- TTL: 14,
- RTT: "322.90",
- IPAddr: "204.70.200.217",
- Host: "hr1-te-2-0-0.santaclarasc9.savvis.net",
- },
- {
- TTL: 15,
- RTT: "330.96",
- IPAddr: "204.70.203.146",
- },
- {
- TTL: 16,
- RTT: "342.57",
- IPAddr: "66.35.194.59",
- Host: "csr2-ve242.santaclarasc8.savvis.net",
- },
- {
- TTL: 17,
- RTT: "248.22",
- IPAddr: "66.35.210.202",
- },
- {
- TTL: 18,
- RTT: "238.36",
- IPAddr: "66.35.250.168",
- Host: "freshmeat.net",
- },
- },
- },
- Uptime: Uptime{
- Seconds: 206,
- Lastboot: "Sun Jan 27 21:43:11 2008",
- },
- Addresses: []Address{
- {
- Addr: "66.35.250.168",
- AddrType: "ipv4",
- },
- },
- ExtraPorts: []ExtraPort{
- {
- State: "filtered",
- Count: 1712,
- Reasons: []Reason{
- {
- Reason: "host-prohibiteds",
- Count: 1712,
- },
- },
- },
- },
- Hostnames: []Hostname{
- {
- Name: "freshmeat.net",
- Type: "PTR",
- },
- },
- Ports: []Port{
- {
- ID: 80,
- Protocol: "tcp",
- Service: Service{
- Name: "http",
- ExtraInfo: "(Unix) PHP/4.4.7",
- Method: "probed",
- Product: "Apache httpd",
- Version: "1.3.39",
- Configuration: 10,
- },
- State: State{
- State: "open",
- Reason: "syn-ack",
- ReasonTTL: 45,
- },
- Scripts: []Script{
- {
- ID: "robots.txt",
- Output: "User-Agent: * /img/ /redir/ ",
- },
- {
- ID: "HTML title",
- Output: "freshmeat.net: Welcome to freshmeat.net",
- },
- },
- },
- {
- ID: 443,
- Protocol: "tcp",
- Service: Service{
- Name: "https",
- Method: "table",
- Configuration: 3,
- },
- State: State{
- State: "closed",
- Reason: "reset",
- ReasonTTL: 46,
- },
- },
- },
- },
- },
- TaskBegin: []Task{
- {
- Time: Timestamp(time.Unix(1201479013, 0)),
- Task: "Ping Scan",
- },
- {
- Time: Timestamp(time.Unix(1201479014, 0)),
- Task: "Parallel DNS resolution of 8 hosts.",
- },
- {
- Time: Timestamp(time.Unix(1201479015, 0)),
- Task: "System CNAME DNS resolution of 4 hosts.",
- },
- {
- Time: Timestamp(time.Unix(1201479016, 0)),
- Task: "SYN Stealth Scan",
- },
- {
- Time: Timestamp(time.Unix(1201480879, 0)),
- Task: "Service scan",
- },
- {
- Time: Timestamp(time.Unix(1201481006, 0)),
- Task: "Traceroute",
- },
- {
- Time: Timestamp(time.Unix(1201481028, 0)),
- Task: "Traceroute",
- },
- {
- Time: Timestamp(time.Unix(1201481059, 0)),
- Task: "Parallel DNS resolution of 85 hosts.",
- },
- {
- Time: Timestamp(time.Unix(1201481070, 0)),
- Task: "System CNAME DNS resolution of 8 hosts.",
- },
- {
- Time: Timestamp(time.Unix(1201481086, 0)),
- Task: "SCRIPT ENGINE",
- },
- },
- TaskProgress: []TaskProgress{
- {
- Percent: 3.22,
- Remaining: 903,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201479949, 0)),
- Time: Timestamp(time.Unix(1201479046, 0)),
- },
- {
- Percent: 56.66,
- Remaining: 325,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201479767, 0)),
- Time: Timestamp(time.Unix(1201479442, 0)),
- },
- {
- Percent: 77.02,
- Remaining: 225,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201479995, 0)),
- Time: Timestamp(time.Unix(1201479770, 0)),
- },
- {
- Percent: 81.95,
- Remaining: 215,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201480212, 0)),
- Time: Timestamp(time.Unix(1201479996, 0)),
- },
- {
- Percent: 86.79,
- Remaining: 182,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201480395, 0)),
- Time: Timestamp(time.Unix(1201480213, 0)),
- },
- {
- Percent: 87.84,
- Remaining: 172,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201480433, 0)),
- Time: Timestamp(time.Unix(1201480260, 0)),
- },
- {
- Percent: 91.65,
- Remaining: 129,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201480564, 0)),
- Time: Timestamp(time.Unix(1201480435, 0)),
- },
- {
- Percent: 94.43,
- Remaining: 91,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201480656, 0)),
- Time: Timestamp(time.Unix(1201480565, 0)),
- },
- {
- Percent: 96.35,
- Remaining: 62,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201480720, 0)),
- Time: Timestamp(time.Unix(1201480658, 0)),
- },
- {
- Percent: 97.76,
- Remaining: 39,
- Task: "SYN Stealth Scan",
- Etc: Timestamp(time.Unix(1201480760, 0)),
- Time: Timestamp(time.Unix(1201480721, 0)),
- },
- },
- TaskEnd: []Task{
- {
- Time: Timestamp(time.Unix(1201479014, 0)),
- Task: "Ping Scan",
- ExtraInfo: "8 total hosts",
- },
- {
- Time: Timestamp(time.Unix(1201479015, 0)),
- Task: "Parallel DNS resolution of 8 hosts.",
- },
- {
- Time: Timestamp(time.Unix(1201479016, 0)),
- Task: "System CNAME DNS resolution of 4 hosts.",
- },
- {
- Time: Timestamp(time.Unix(1201480878, 0)),
- Task: "SYN Stealth Scan",
- ExtraInfo: "8570 total ports",
- },
- {
- Time: Timestamp(time.Unix(1201480984, 0)),
- Task: "Service scan",
- ExtraInfo: "20 services on 5 hosts",
- },
- {
- Time: Timestamp(time.Unix(1201481028, 0)),
- Task: "Traceroute",
- },
- {
- Time: Timestamp(time.Unix(1201481059, 0)),
- Task: "Traceroute",
- },
- {
- Time: Timestamp(time.Unix(1201481070, 0)),
- Task: "Parallel DNS resolution of 85 hosts.",
- },
- {
- Time: Timestamp(time.Unix(1201481086, 0)),
- Task: "System CNAME DNS resolution of 8 hosts.",
- },
- {
- Time: Timestamp(time.Unix(1201481197, 0)),
- Task: "SCRIPT ENGINE",
- },
- },
- },
-
- expectedError: nil,
- },
- }
-
- for _, test := range tests {
- t.Run(test.inputFile, func(t *testing.T) {
- rawXML, err := ioutil.ReadFile(test.inputFile)
- if err != nil {
- t.Fatal(err)
- }
-
- result, err := Parse(rawXML)
-
- // Remove rawXML before comparing
- result.rawXML = []byte{}
-
- compareResults(t, test.expectedResult, result)
-
- if err != test.expectedError {
- t.Errorf("expected %v got %v", test.expectedError, err)
- }
- })
- }
-}
-
-func compareResults(t *testing.T, expected, got *Run) {
- if got.Args != expected.Args {
- t.Errorf("unexpected arguments, expected %v got %v", expected.Args, got.Args)
- }
-
- if got.ProfileName != expected.ProfileName {
- t.Errorf("unexpected arguments, expected %v got %v", expected.ProfileName, got.ProfileName)
- }
-
- if got.Scanner != expected.Scanner {
- t.Errorf("unexpected arguments, expected %v got %v", expected.Scanner, got.Scanner)
- }
-
- if got.StartStr != expected.StartStr {
- t.Errorf("unexpected arguments, expected %v got %v", expected.StartStr, got.StartStr)
- }
-
- if !reflect.DeepEqual(got.Debugging, expected.Debugging) {
- t.Errorf("unexpected debugging, expected %+v got %+v", expected.Debugging, got.Debugging)
- }
-
- if !reflect.DeepEqual(got.ScanInfo, expected.ScanInfo) {
- t.Errorf("unexpected scan info, expected %+v got %+v", expected.ScanInfo, got.ScanInfo)
- }
-
- if !reflect.DeepEqual(got.Start, expected.Start) {
- t.Errorf("unexpected start time, expected %+v got %+v", expected.Start, got.Start)
- }
-
- if !reflect.DeepEqual(got.Targets, expected.Targets) {
- t.Errorf("unexpected targets, expected %+v got %+v", expected.Targets, got.Targets)
- }
-
- if len(expected.TaskBegin) != len(got.TaskBegin) {
- t.Errorf("unexpected tasks begin entries, expected to have %d entries, got %d instead", len(expected.TaskBegin), len(got.TaskBegin))
- } else {
- for idx := range expected.TaskBegin {
- if !reflect.DeepEqual(got.TaskBegin[idx], expected.TaskBegin[idx]) {
- t.Errorf("unexpected task begin entry, expected %+v got %+v", expected.TaskBegin[idx], got.TaskBegin[idx])
- }
- }
- }
-
- if len(expected.TaskProgress) != len(got.TaskProgress) {
- t.Errorf("unexpected tasks progress entries, expected to have %d entries, got %d instead", len(expected.TaskProgress), len(got.TaskProgress))
- } else {
- for idx := range expected.TaskProgress {
- if !reflect.DeepEqual(got.TaskProgress[idx], expected.TaskProgress[idx]) {
- t.Errorf("unexpected task progress entry, expected %+v got %+v", expected.TaskProgress[idx], got.TaskProgress[idx])
- }
- }
- }
-
- if len(expected.TaskEnd) != len(got.TaskEnd) {
- t.Errorf("unexpected tasks end entries, expected to have %d entries, got %d instead", len(expected.TaskEnd), len(got.TaskEnd))
- } else {
- for idx := range expected.TaskEnd {
- if !reflect.DeepEqual(got.TaskEnd[idx], expected.TaskEnd[idx]) {
- t.Errorf("unexpected task end entry, expected %+v got %+v", expected.TaskEnd[idx], got.TaskEnd[idx])
- }
- }
- }
-
- if len(expected.Hosts) != len(got.Hosts) {
- t.Errorf("unexpected number of hosts, expected to have %d hosts, got %d instead", len(expected.Hosts), len(got.Hosts))
- } else {
- for idx := range expected.Hosts {
- if expected.Hosts[idx].Comment != got.Hosts[idx].Comment {
- t.Errorf("unexpected host comment, expected %v got %v", expected.Hosts[idx].Comment, got.Hosts[idx].Comment)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Addresses, got.Hosts[idx].Addresses) {
- t.Errorf("unexpected host addresses, expected %+v got %+v", expected.Hosts[idx].Addresses, got.Hosts[idx].Addresses)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Distance, got.Hosts[idx].Distance) {
- t.Errorf("unexpected host distance, expected %+v got %+v", expected.Hosts[idx].Distance, got.Hosts[idx].Distance)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].ExtraPorts, got.Hosts[idx].ExtraPorts) {
- t.Errorf("unexpected host extra ports, expected %+v got %+v", expected.Hosts[idx].ExtraPorts, got.Hosts[idx].ExtraPorts)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].HostScripts, got.Hosts[idx].HostScripts) {
- t.Errorf("unexpected host host scripts, expected %+v got %+v", expected.Hosts[idx].HostScripts, got.Hosts[idx].HostScripts)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Hostnames, got.Hosts[idx].Hostnames) {
- t.Errorf("unexpected host host names, expected %+v got %+v", expected.Hosts[idx].Hostnames, got.Hosts[idx].Hostnames)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].IPIDSequence, got.Hosts[idx].IPIDSequence) {
- t.Errorf("unexpected host IPIDSequence, expected %+v got %+v", expected.Hosts[idx].IPIDSequence, got.Hosts[idx].IPIDSequence)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].OS, got.Hosts[idx].OS) {
- t.Errorf("unexpected host OS, expected %+v got %+v", expected.Hosts[idx].OS, got.Hosts[idx].OS)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Ports, got.Hosts[idx].Ports) {
- t.Errorf("unexpected host ports, expected %+v got %+v", expected.Hosts[idx].Ports, got.Hosts[idx].Ports)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Smurfs, got.Hosts[idx].Smurfs) {
- t.Errorf("unexpected host smurfs, expected %+v got %+v", expected.Hosts[idx].Smurfs, got.Hosts[idx].Smurfs)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].StartTime, got.Hosts[idx].StartTime) {
- t.Errorf("unexpected host start time, expected %+v got %+v", expected.Hosts[idx].StartTime, got.Hosts[idx].StartTime)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Status, got.Hosts[idx].Status) {
- t.Errorf("unexpected host status, expected %+v got %+v", expected.Hosts[idx].Status, got.Hosts[idx].Status)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].TCPSequence, got.Hosts[idx].TCPSequence) {
- t.Errorf("unexpected host TCPSequence, expected %+v got %+v", expected.Hosts[idx].TCPSequence, got.Hosts[idx].TCPSequence)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].TCPTSSequence, got.Hosts[idx].TCPTSSequence) {
- t.Errorf("unexpected host TCPTSSequence, expected %+v got %+v", expected.Hosts[idx].TCPTSSequence, got.Hosts[idx].TCPTSSequence)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Times, got.Hosts[idx].Times) {
- t.Errorf("unexpected host times, expected %+v got %+v", expected.Hosts[idx].Times, got.Hosts[idx].Times)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Trace, got.Hosts[idx].Trace) {
- t.Errorf("unexpected host trace, expected %+v got %+v", expected.Hosts[idx].Trace, got.Hosts[idx].Trace)
- }
-
- if !reflect.DeepEqual(expected.Hosts[idx].Uptime, got.Hosts[idx].Uptime) {
- t.Errorf("unexpected host uptime, expected %+v got %+v", expected.Hosts[idx].Uptime, got.Hosts[idx].Uptime)
- }
- }
- }
-}
-
-const fingerprint = "SCAN(V=4.53%D=1/27%OT=80%CT=443%CU=%PV=N%G=N%TM=479D25ED%P=i686-pc-linux-gnu)\nSEQ(SP=F2%GCD=1%ISR=E9%TI=Z%TS=1C)\nOPS(O1=M5B4ST11NW0%O2=M5B4ST11NW0%O3=M5B4NNT11NW0%O4=M5B4ST11NW0%O5=M5B4ST11NW0%O6=M5B4ST11)\nWIN(W1=16A0%W2=16A0%W3=16A0%W4=16A0%W5=16A0%W6=16A0)\nECN(R=Y%DF=Y%TG=40%W=16D0%O=M5B4NNSNW0%CC=N%Q=)\nT1(R=Y%DF=Y%TG=40%S=O%A=S+%F=AS%RD=0%Q=)\nT2(R=N)\nT3(R=Y%DF=Y%TG=40%W=16A0%S=O%A=S+%F=AS%O=M5B4ST11NW0%RD=0%Q=)\nT4(R=Y%DF=Y%TG=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)\nT5(R=Y%DF=Y%TG=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)\nT6(R=Y%DF=Y%TG=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)\nT7(R=Y%DF=Y%TG=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)\nU1(R=N)\nIE(R=N)\n"
diff --git a/vendor/github.com/andelf/go-curl/.gitignore b/vendor/github.com/andelf/go-curl/.gitignore
deleted file mode 100644
index a4a1e00..0000000
--- a/vendor/github.com/andelf/go-curl/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.6
-*.o
-src/_cgo_*
-src/_obj/
diff --git a/vendor/github.com/andelf/go-curl/.travis.yml b/vendor/github.com/andelf/go-curl/.travis.yml
deleted file mode 100644
index 4149607..0000000
--- a/vendor/github.com/andelf/go-curl/.travis.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-language: go
-go:
- - 1.9
- - 1.8
- - 1.7
- - 1.6
-before_install:
- - sudo apt-get update -qq > apt-get.out 2>&1 || (cat apt-get.out && exit 1)
-install: go build -x -v
-script: go test -v
-notifications:
- email:
- recipients:
- - fledna@foxmail.com
- on_success: change
- on_failure: always
diff --git a/vendor/github.com/andelf/go-curl/LICENSE b/vendor/github.com/andelf/go-curl/LICENSE
deleted file mode 100644
index 07a5cea..0000000
--- a/vendor/github.com/andelf/go-curl/LICENSE
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright 2014 Shuyu Wang
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this project 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.
diff --git a/vendor/github.com/andelf/go-curl/README.md b/vendor/github.com/andelf/go-curl/README.md
deleted file mode 100644
index a299335..0000000
--- a/vendor/github.com/andelf/go-curl/README.md
+++ /dev/null
@@ -1,73 +0,0 @@
-go-curl
-=======
-
-[](http://travis-ci.org/andelf/go-curl)
-
-my golang libcurl(curl) binding.
-
-See more examples in ./examples/ directory~!
-
-LICENSE
--------
-
-go-curl is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).
-
-Current Development Status
---------------------------
-
- * currently stable
- * READ, WRITE, HEADER, PROGRESS function callback
- * a Multipart Form supports file uploading
- * Most curl_easy_setopt option
- * partly implement share & multi interface
- * new callback function prototype
-
-How to Install
---------------
-
-Make Sure You Have libcurl (and its develop headers, static/dynamic libs) installed!
-
-
- $ go get -u github.com/andelf/go-curl
-
-Current Status
---------------
-
- * Linux x64
- * passed go1 (ArchLinux)
- * Windows x86
- * passed go1 (win7, mingw-gcc 4.5.2, curl 7.22.0)
- * Mac OS
- * passed go1 (Mac OS X 10.7.3, curl 7.21.4)
-
-Sample Program
---------------
-
-```go
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
-)
-
-func main() {
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://www.baidu.com/")
-
- // make a callback function
- fooTest := func (buf []byte, userdata interface{}) bool {
- println("DEBUG: size=>", len(buf))
- println("DEBUG: content=>", string(buf))
- return true
- }
-
- easy.Setopt(curl.OPT_WRITEFUNCTION, fooTest)
-
- if err := easy.Perform(); err != nil {
- fmt.Printf("ERROR: %v\n", err)
- }
-}
-```
diff --git a/vendor/github.com/andelf/go-curl/c-callback.c b/vendor/github.com/andelf/go-curl/c-callback.c
deleted file mode 100644
index 7ebc80f..0000000
--- a/vendor/github.com/andelf/go-curl/c-callback.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include
-#include
-#include "callback.h"
-#include "_cgo_export.h"
-
-/* for OPT_HEADERFUNCTION */
-size_t header_function( char *ptr, size_t size, size_t nmemb, void *ctx) {
- return goCallHeaderFunction(ptr, size*nmemb, ctx);
-}
-
-void *return_header_function() {
- return (void *)&header_function;
-}
-
-
-/* for OPT_WRITEFUNCTION */
-size_t write_function( char *ptr, size_t size, size_t nmemb, void *ctx) {
- return goCallWriteFunction(ptr, size*nmemb, ctx);
-}
-
-void *return_write_function() {
- return (void *)&write_function;
-}
-
-/* for OPT_READFUNCTION */
-size_t read_function( char *ptr, size_t size, size_t nmemb, void *ctx) {
- return goCallReadFunction(ptr, size*nmemb, ctx);
-}
-
-void *return_read_function() {
- return (void *)&read_function;
-}
-
-
-/* for OPT_PROGRESSFUNCTION */
-int progress_function(void *ctx, double dltotal, double dlnow, double ultotal, double ulnow) {
- return goCallProgressFunction(dltotal, dlnow, ultotal, ulnow, ctx);
-}
-
-void *return_progress_function() {
- return (void *)progress_function;
-}
diff --git a/vendor/github.com/andelf/go-curl/callback.go b/vendor/github.com/andelf/go-curl/callback.go
deleted file mode 100644
index 8d76c7c..0000000
--- a/vendor/github.com/andelf/go-curl/callback.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package curl
-
-/*
-#cgo freebsd CFLAGS: -I/usr/local/include
-#cgo freebsd LDFLAGS: -L/usr/local/lib -lcurl
-#include
-#include
-#include
-
-*/
-import "C"
-
-import (
- "unsafe"
-)
-
-//export goCallHeaderFunction
-func goCallHeaderFunction(ptr *C.char, size C.size_t, ctx unsafe.Pointer) uintptr {
- curl := context_map.Get(uintptr(ctx))
- buf := C.GoBytes(unsafe.Pointer(ptr), C.int(size))
- if (*curl.headerFunction)(buf, curl.headerData) {
- return uintptr(size)
- }
- return C.CURL_WRITEFUNC_PAUSE
-}
-
-//export goCallWriteFunction
-func goCallWriteFunction(ptr *C.char, size C.size_t, ctx unsafe.Pointer) uintptr {
- curl := context_map.Get(uintptr(ctx))
- buf := C.GoBytes(unsafe.Pointer(ptr), C.int(size))
- if (*curl.writeFunction)(buf, curl.writeData) {
- return uintptr(size)
- }
- return C.CURL_WRITEFUNC_PAUSE
-}
-
-//export goCallProgressFunction
-func goCallProgressFunction(dltotal, dlnow, ultotal, ulnow C.double, ctx unsafe.Pointer) int {
- curl := context_map.Get(uintptr(ctx))
- if (*curl.progressFunction)(float64(dltotal), float64(dlnow),
- float64(ultotal), float64(ulnow),
- curl.progressData) {
- return 0
- }
- return 1
-}
-
-//export goCallReadFunction
-func goCallReadFunction(ptr *C.char, size C.size_t, ctx unsafe.Pointer) uintptr {
- curl := context_map.Get(uintptr(ctx))
- buf := C.GoBytes(unsafe.Pointer(ptr), C.int(size))
- ret := (*curl.readFunction)(buf, curl.readData)
- str := C.CString(string(buf))
- defer C.free(unsafe.Pointer(str))
- if C.memcpy(unsafe.Pointer(ptr), unsafe.Pointer(str), C.size_t(ret)) == nil {
- panic("read_callback memcpy error!")
- }
- return uintptr(ret)
-}
diff --git a/vendor/github.com/andelf/go-curl/callback.h b/vendor/github.com/andelf/go-curl/callback.h
deleted file mode 100644
index 498678a..0000000
--- a/vendor/github.com/andelf/go-curl/callback.h
+++ /dev/null
@@ -1,6 +0,0 @@
-
-void *return_header_function();
-void *return_write_function();
-void *return_read_function();
-
-void *return_progress_function();
diff --git a/vendor/github.com/andelf/go-curl/compat.h b/vendor/github.com/andelf/go-curl/compat.h
deleted file mode 100644
index 4552b52..0000000
--- a/vendor/github.com/andelf/go-curl/compat.h
+++ /dev/null
@@ -1,528 +0,0 @@
-
-/* generated by compatgen.py */
-#include
-
-
-
-#if (LIBCURL_VERSION_MINOR == 57 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 57
-#define CURL_VERSION_BROTLI 0
-#if (LIBCURL_VERSION_MINOR == 56 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 56
-#if (LIBCURL_VERSION_MINOR == 56 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 56
-#define CURLOPT_SSH_COMPRESSION 0
-#define CURLOPT_MIMEPOST 0
-#define CURL_VERSION_MULTI_SSL 0
-#if (LIBCURL_VERSION_MINOR == 55 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 55
-#if (LIBCURL_VERSION_MINOR == 55 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 55
-#define CURLOPT_REQUEST_TARGET 0
-#define CURLOPT_SOCKS5_AUTH 0
-#define CURLINFO_SIZE_UPLOAD_T 0
-#define CURLINFO_SIZE_DOWNLOAD_T 0
-#define CURLINFO_SPEED_DOWNLOAD_T 0
-#define CURLINFO_SPEED_UPLOAD_T 0
-#define CURLINFO_CONTENT_LENGTH_DOWNLOAD_T 0
-#define CURLINFO_CONTENT_LENGTH_UPLOAD_T 0
-#define CURLAUTH_GSSAPI 0
-#if (LIBCURL_VERSION_MINOR == 54 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 54
-#if (LIBCURL_VERSION_MINOR == 54 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 54
-#define CURLOPT_SUPPRESS_CONNECT_HEADERS 0
-#if (LIBCURL_VERSION_MINOR == 53 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 53
-#if (LIBCURL_VERSION_MINOR == 53 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 53
-#define CURLOPT_ABSTRACT_UNIX_SOCKET 0
-#if (LIBCURL_VERSION_MINOR == 52 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 52
-#if (LIBCURL_VERSION_MINOR == 52 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 52
-#define CURLOPT_PROXY_CAINFO 0
-#define CURLOPT_PROXY_CAPATH 0
-#define CURLOPT_PROXY_SSL_VERIFYPEER 0
-#define CURLOPT_PROXY_SSL_VERIFYHOST 0
-#define CURLOPT_PROXY_SSLVERSION 0
-#define CURLOPT_PROXY_TLSAUTH_USERNAME 0
-#define CURLOPT_PROXY_TLSAUTH_PASSWORD 0
-#define CURLOPT_PROXY_TLSAUTH_TYPE 0
-#define CURLOPT_PROXY_SSLCERT 0
-#define CURLOPT_PROXY_SSLCERTTYPE 0
-#define CURLOPT_PROXY_SSLKEY 0
-#define CURLOPT_PROXY_SSLKEYTYPE 0
-#define CURLOPT_PROXY_KEYPASSWD 0
-#define CURLOPT_PROXY_SSL_CIPHER_LIST 0
-#define CURLOPT_PROXY_CRLFILE 0
-#define CURLOPT_PROXY_SSL_OPTIONS 0
-#define CURLOPT_PRE_PROXY 0
-#define CURLOPT_PROXY_PINNEDPUBLICKEY 0
-#define CURLINFO_PROXY_SSL_VERIFYRESULT 0
-#define CURLINFO_PROTOCOL 0
-#define CURLINFO_SCHEME 0
-#define CURL_VERSION_HTTPS_PROXY 0
-#if (LIBCURL_VERSION_MINOR == 51 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 51
-#define CURLOPT_KEEP_SENDING_ON_ERROR 0
-#if (LIBCURL_VERSION_MINOR == 50 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 50
-#define CURLE_WEIRD_SERVER_REPLY -1
-#if (LIBCURL_VERSION_MINOR == 50 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 50
-#if (LIBCURL_VERSION_MINOR == 50 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 50
-#if (LIBCURL_VERSION_MINOR == 50 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 50
-#define CURLINFO_HTTP_VERSION 0
-#if (LIBCURL_VERSION_MINOR == 49 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 49
-#if (LIBCURL_VERSION_MINOR == 49 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 49
-#define CURLOPT_CONNECT_TO 0
-#define CURLOPT_TCP_FASTOPEN 0
-#define CURLE_TOO_MANY_REDIRECTS -1
-#define CURLE_TELNET_OPTION_SYNTAX -1
-#define CURLE_HTTP2_STREAM -1
-#if (LIBCURL_VERSION_MINOR == 48 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 48
-#define CURLOPT_TFTP_NO_OPTIONS 0
-#define CURLINFO_TLS_SSL_PTR 0
-#if (LIBCURL_VERSION_MINOR == 47 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 47
-#if (LIBCURL_VERSION_MINOR == 47 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 47
-#define CURL_VERSION_PSL 0
-#if (LIBCURL_VERSION_MINOR == 46 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 46
-#define CURLOPT_STREAM_WEIGHT 0
-#define CURLOPT_STREAM_DEPENDS 0
-#define CURLOPT_STREAM_DEPENDS_E 0
-#if (LIBCURL_VERSION_MINOR == 45 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 45
-#define CURLOPT_DEFAULT_PROTOCOL 0
-#define CURLINFO_ACTIVESOCKET 0
-#if (LIBCURL_VERSION_MINOR == 44 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 44
-#if (LIBCURL_VERSION_MINOR == 43 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 43
-#define CURLOPT_PROXY_SERVICE_NAME 0
-#define CURLOPT_SERVICE_NAME 0
-#define CURLOPT_PIPEWAIT 0
-#if (LIBCURL_VERSION_MINOR == 42 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 42
-#if (LIBCURL_VERSION_MINOR == 42 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 42
-#define CURLOPT_SSL_FALSESTART 0
-#define CURLOPT_PATH_AS_IS 0
-#if (LIBCURL_VERSION_MINOR == 41 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 41
-#define CURLOPT_SSL_VERIFYSTATUS 0
-#define CURLE_SSL_INVALIDCERTSTATUS -1
-#if (LIBCURL_VERSION_MINOR == 40 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 40
-#define CURLOPT_UNIX_SOCKET_PATH 0
-#define CURL_VERSION_KERBEROS5 0
-#define CURL_VERSION_UNIX_SOCKETS 0
-#if (LIBCURL_VERSION_MINOR == 39 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 39
-#define CURLOPT_PINNEDPUBLICKEY 0
-#define CURLE_SSL_PINNEDPUBKEYNOTMATCH -1
-#if (LIBCURL_VERSION_MINOR == 38 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 38
-#define CURLE_HTTP2 -1
-#define CURL_VERSION_GSSAPI 0
-#define CURLAUTH_NEGOTIATE 0
-#if (LIBCURL_VERSION_MINOR == 37 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 37
-#define CURLOPT_OBSOLETE40 0
-#define CURLOPT_OBSOLETE72 0
-#if (LIBCURL_VERSION_MINOR == 37 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 37
-#define CURLOPT_PROXYHEADER 0
-#define CURLOPT_HEADEROPT 0
-#if (LIBCURL_VERSION_MINOR == 36 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 36
-#define CURLOPT_SSL_ENABLE_NPN 0
-#define CURLOPT_SSL_ENABLE_ALPN 0
-#define CURLOPT_EXPECT_100_TIMEOUT_MS 0
-#if (LIBCURL_VERSION_MINOR == 35 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 35
-#if (LIBCURL_VERSION_MINOR == 34 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 34
-#define CURLOPT_LOGIN_OPTIONS 0
-#define CURLINFO_TLS_SESSION 0
-#if (LIBCURL_VERSION_MINOR == 33 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 33
-#define CURLOPT_XOAUTH2_BEARER 0
-#define CURLOPT_DNS_INTERFACE 0
-#define CURLOPT_DNS_LOCAL_IP4 0
-#define CURLOPT_DNS_LOCAL_IP6 0
-#define CURL_VERSION_HTTP2 0
-#if (LIBCURL_VERSION_MINOR == 32 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 32
-#define CURLOPT_XFERINFODATA 0
-#define CURLOPT_XFERINFOFUNCTION 0
-#if (LIBCURL_VERSION_MINOR == 31 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 31
-#define CURLOPT_SASL_IR 0
-#if (LIBCURL_VERSION_MINOR == 30 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 30
-#define CURLE_NO_CONNECTION_AVAILABLE -1
-#if (LIBCURL_VERSION_MINOR == 29 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 29
-#if (LIBCURL_VERSION_MINOR == 28 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 28
-#if (LIBCURL_VERSION_MINOR == 28 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 28
-#if (LIBCURL_VERSION_MINOR == 27 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 27
-#if (LIBCURL_VERSION_MINOR == 26 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 26
-#if (LIBCURL_VERSION_MINOR == 25 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 25
-#define CURLOPT_TCP_KEEPALIVE 0
-#define CURLOPT_TCP_KEEPIDLE 0
-#define CURLOPT_TCP_KEEPINTVL 0
-#define CURLOPT_SSL_OPTIONS 0
-#define CURLOPT_MAIL_AUTH 0
-#if (LIBCURL_VERSION_MINOR == 24 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 24
-#define CURLOPT_DNS_SERVERS 0
-#define CURLOPT_ACCEPTTIMEOUT_MS 0
-#define CURLE_FTP_ACCEPT_FAILED -1
-#define CURLE_FTP_ACCEPT_TIMEOUT -1
-#if (LIBCURL_VERSION_MINOR == 23 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 23
-#if (LIBCURL_VERSION_MINOR == 23 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 23
-#if (LIBCURL_VERSION_MINOR == 22 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 22
-#define CURLOPT_GSSAPI_DELEGATION 0
-#define CURL_VERSION_NTLM_WB 0
-#define CURLAUTH_NTLM_WB 0
-#if (LIBCURL_VERSION_MINOR == 21 && LIBCURL_VERSION_PATCH < 7) || LIBCURL_VERSION_MINOR < 21
-#define CURLOPT_CLOSESOCKETFUNCTION 0
-#define CURLOPT_CLOSESOCKETDATA 0
-#if (LIBCURL_VERSION_MINOR == 21 && LIBCURL_VERSION_PATCH < 6) || LIBCURL_VERSION_MINOR < 21
-#define CURLOPT_ACCEPT_ENCODING 0
-#define CURLOPT_TRANSFER_ENCODING 0
-#if (LIBCURL_VERSION_MINOR == 21 && LIBCURL_VERSION_PATCH < 5) || LIBCURL_VERSION_MINOR < 21
-#define CURLE_NOT_BUILT_IN -1
-#define CURLE_UNKNOWN_OPTION -1
-#if (LIBCURL_VERSION_MINOR == 21 && LIBCURL_VERSION_PATCH < 4) || LIBCURL_VERSION_MINOR < 21
-#define CURLOPT_TLSAUTH_USERNAME 0
-#define CURLOPT_TLSAUTH_PASSWORD 0
-#define CURLOPT_TLSAUTH_TYPE 0
-#define CURL_VERSION_TLSAUTH_SRP 0
-#if (LIBCURL_VERSION_MINOR == 21 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 21
-#define CURLOPT_RESOLVE 0
-#define CURLAUTH_ONLY 0
-#if (LIBCURL_VERSION_MINOR == 21 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 21
-#if (LIBCURL_VERSION_MINOR == 21 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 21
-#if (LIBCURL_VERSION_MINOR == 21 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 21
-#define CURLOPT_WILDCARDMATCH 0
-#define CURLOPT_CHUNK_BGN_FUNCTION 0
-#define CURLOPT_CHUNK_END_FUNCTION 0
-#define CURLOPT_FNMATCH_FUNCTION 0
-#define CURLOPT_CHUNK_DATA 0
-#define CURLOPT_FNMATCH_DATA 0
-#define CURLE_FTP_BAD_FILE_LIST -1
-#define CURLE_CHUNK_FAILED -1
-#define CURLINFO_PRIMARY_PORT 0
-#define CURLINFO_LOCAL_IP 0
-#define CURLINFO_LOCAL_PORT 0
-#if (LIBCURL_VERSION_MINOR == 20 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 20
-#if (LIBCURL_VERSION_MINOR == 20 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 20
-#define CURLOPT_SERVER_RESPONSE_TIMEOUT 0
-#define CURLOPT_MAIL_FROM 0
-#define CURLOPT_MAIL_RCPT 0
-#define CURLOPT_FTP_USE_PRET 0
-#define CURLOPT_RTSP_REQUEST 0
-#define CURLOPT_RTSP_SESSION_ID 0
-#define CURLOPT_RTSP_STREAM_URI 0
-#define CURLOPT_RTSP_TRANSPORT 0
-#define CURLOPT_RTSP_CLIENT_CSEQ 0
-#define CURLOPT_RTSP_SERVER_CSEQ 0
-#define CURLOPT_INTERLEAVEDATA 0
-#define CURLOPT_INTERLEAVEFUNCTION 0
-#define CURLOPT_RTSPHEADER 0
-#define CURLE_FTP_PRET_FAILED -1
-#define CURLE_RTSP_CSEQ_ERROR -1
-#define CURLE_RTSP_SESSION_ERROR -1
-#define CURLINFO_RTSP_SESSION_ID 0
-#define CURLINFO_RTSP_CLIENT_CSEQ 0
-#define CURLINFO_RTSP_SERVER_CSEQ 0
-#define CURLINFO_RTSP_CSEQ_RECV 0
-#if (LIBCURL_VERSION_MINOR == 19 && LIBCURL_VERSION_PATCH < 7) || LIBCURL_VERSION_MINOR < 19
-#if (LIBCURL_VERSION_MINOR == 19 && LIBCURL_VERSION_PATCH < 6) || LIBCURL_VERSION_MINOR < 19
-#define CURLOPT_SSH_KNOWNHOSTS 0
-#define CURLOPT_SSH_KEYFUNCTION 0
-#define CURLOPT_SSH_KEYDATA 0
-#define CURL_VERSION_CURLDEBUG 0
-#if (LIBCURL_VERSION_MINOR == 19 && LIBCURL_VERSION_PATCH < 5) || LIBCURL_VERSION_MINOR < 19
-#if (LIBCURL_VERSION_MINOR == 19 && LIBCURL_VERSION_PATCH < 4) || LIBCURL_VERSION_MINOR < 19
-#define CURLOPT_NOPROXY 0
-#define CURLOPT_TFTP_BLKSIZE 0
-#define CURLOPT_SOCKS5_GSSAPI_SERVICE 0
-#define CURLOPT_SOCKS5_GSSAPI_NEC 0
-#define CURLOPT_PROTOCOLS 0
-#define CURLOPT_REDIR_PROTOCOLS 0
-#define CURLINFO_CONDITION_UNMET 0
-#if (LIBCURL_VERSION_MINOR == 19 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 19
-#define CURLAUTH_DIGEST_IE 0
-#if (LIBCURL_VERSION_MINOR == 19 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 19
-#if (LIBCURL_VERSION_MINOR == 19 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 19
-#define CURLOPT_POSTREDIR 0
-#define CURLOPT_CERTINFO 0
-#define CURLOPT_USERNAME 0
-#define CURLOPT_PASSWORD 0
-#define CURLOPT_PROXYUSERNAME 0
-#define CURLOPT_PROXYPASSWORD 0
-#define CURLINFO_CERTINFO 0
-#if (LIBCURL_VERSION_MINOR == 19 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 19
-#define CURLOPT_CRLFILE 0
-#define CURLOPT_ISSUERCERT 0
-#define CURLOPT_ADDRESS_SCOPE 0
-#define CURLE_SSL_CRL_BADFILE -1
-#define CURLE_SSL_ISSUER_ERROR -1
-#define CURLINFO_PRIMARY_IP 0
-#define CURLINFO_APPCONNECT_TIME 0
-#if (LIBCURL_VERSION_MINOR == 18 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 18
-#define CURLE_AGAIN -1
-#define CURLINFO_REDIRECT_URL 0
-#if (LIBCURL_VERSION_MINOR == 18 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 18
-#if (LIBCURL_VERSION_MINOR == 18 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 18
-#define CURLOPT_PROXY_TRANSFER_MODE 0
-#define CURLOPT_SEEKFUNCTION 0
-#define CURLOPT_SEEKDATA 0
-#if (LIBCURL_VERSION_MINOR == 17 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 17
-#define CURLOPT_POST301 0
-#define CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 0
-#define CURLOPT_OPENSOCKETFUNCTION 0
-#define CURLOPT_OPENSOCKETDATA 0
-#define CURLOPT_COPYPOSTFIELDS 0
-#define CURLE_PEER_FAILED_VERIFICATION -1
-#if (LIBCURL_VERSION_MINOR == 17 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 17
-#define CURLOPT_LOW_SPEED_LIMIT 0
-#define CURLOPT_KEYPASSWD 0
-#define CURLOPT_DIRLISTONLY 0
-#define CURLOPT_APPEND 0
-#define CURLOPT_FTP_RESPONSE_TIMEOUT 0
-#define CURLOPT_USE_SSL 0
-#define CURLE_OBSOLETE4 -1
-#define CURLE_REMOTE_ACCESS_DENIED -1
-#define CURLE_OBSOLETE10 -1
-#define CURLE_OBSOLETE12 -1
-#define CURLE_OBSOLETE16 -1
-#define CURLE_FTP_COULDNT_SET_TYPE -1
-#define CURLE_OBSOLETE20 -1
-#define CURLE_QUOTE_ERROR -1
-#define CURLE_OBSOLETE24 -1
-#define CURLE_OBSOLETE29 -1
-#define CURLE_OBSOLETE32 -1
-#define CURLE_RANGE_ERROR -1
-#define CURLE_OBSOLETE40 -1
-#define CURLE_OBSOLETE44 -1
-#define CURLE_OBSOLETE46 -1
-#define CURLE_OBSOLETE50 -1
-#define CURLE_OBSOLETE57 -1
-#define CURLE_USE_SSL_FAILED -1
-#define CURLE_REMOTE_DISK_FULL -1
-#define CURLE_REMOTE_FILE_EXISTS -1
-#if (LIBCURL_VERSION_MINOR == 16 && LIBCURL_VERSION_PATCH < 4) || LIBCURL_VERSION_MINOR < 16
-#define CURLOPT_KRBLEVEL 0
-#define CURLOPT_NEW_FILE_PERMS 0
-#define CURLOPT_NEW_DIRECTORY_PERMS 0
-#if (LIBCURL_VERSION_MINOR == 16 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 16
-#define CURLE_UPLOAD_FAILED -1
-#if (LIBCURL_VERSION_MINOR == 16 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 16
-#define CURLOPT_TIMEOUT_MS 0
-#define CURLOPT_CONNECTTIMEOUT_MS 0
-#define CURLOPT_HTTP_TRANSFER_DECODING 0
-#define CURLOPT_HTTP_CONTENT_DECODING 0
-#if (LIBCURL_VERSION_MINOR == 16 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 16
-#define CURLOPT_SSH_AUTH_TYPES 0
-#define CURLOPT_SSH_PUBLIC_KEYFILE 0
-#define CURLOPT_SSH_PRIVATE_KEYFILE 0
-#define CURLOPT_FTP_SSL_CCC 0
-#define CURLE_REMOTE_FILE_NOT_FOUND -1
-#define CURLE_SSH -1
-#define CURLE_SSL_SHUTDOWN_FAILED -1
-#if (LIBCURL_VERSION_MINOR == 16 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 16
-#define CURLOPT_SOCKOPTFUNCTION 0
-#define CURLOPT_SOCKOPTDATA 0
-#define CURLOPT_SSL_SESSIONID_CACHE 0
-#define CURLE_SSL_CACERT_BADFILE -1
-#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 5) || LIBCURL_VERSION_MINOR < 15
-#define CURLOPT_MAX_SEND_SPEED_LARGE 0
-#define CURLOPT_MAX_RECV_SPEED_LARGE 0
-#define CURLOPT_FTP_ALTERNATIVE_TO_USER 0
-#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 4) || LIBCURL_VERSION_MINOR < 15
-#define CURLOPT_CONV_FROM_NETWORK_FUNCTION 0
-#define CURLOPT_CONV_TO_NETWORK_FUNCTION 0
-#define CURLOPT_CONV_FROM_UTF8_FUNCTION 0
-#define CURLE_CONV_FAILED -1
-#define CURLE_CONV_REQD -1
-#define CURLINFO_FTP_ENTRY_PATH 0
-#define CURL_VERSION_CONV 0
-#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 15
-#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 15
-#define CURLOPT_LOCALPORT 0
-#define CURLOPT_LOCALPORTRANGE 0
-#define CURLOPT_CONNECT_ONLY 0
-#define CURLINFO_LASTSOCKET 0
-#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 15
-#define CURLOPT_FTP_FILEMETHOD 0
-#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 15
-#define CURLOPT_FTP_SKIP_PASV_IP 0
-#define CURLE_TFTP_NOTFOUND -1
-#define CURLE_TFTP_PERM -1
-#define CURLE_TFTP_DISKFULL -1
-#define CURLE_TFTP_ILLEGAL -1
-#define CURLE_TFTP_UNKNOWNID -1
-#define CURLE_TFTP_EXISTS -1
-#define CURLE_TFTP_NOSUCHUSER -1
-#if (LIBCURL_VERSION_MINOR == 14 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 14
-#define CURLOPT_COOKIELIST 0
-#define CURLOPT_IGNORE_CONTENT_LENGTH 0
-#define CURLINFO_COOKIELIST 0
-#if (LIBCURL_VERSION_MINOR == 14 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 14
-#if (LIBCURL_VERSION_MINOR == 13 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 13
-#define CURL_VERSION_SSPI 0
-#if (LIBCURL_VERSION_MINOR == 13 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 13
-#define CURLE_LOGIN_DENIED -1
-#if (LIBCURL_VERSION_MINOR == 13 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 13
-#define CURLOPT_SOURCE_URL 0
-#define CURLOPT_SOURCE_QUOTE 0
-#define CURLOPT_FTP_ACCOUNT 0
-#if (LIBCURL_VERSION_MINOR == 12 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 12
-#define CURLOPT_IOCTLFUNCTION 0
-#define CURLOPT_IOCTLDATA 0
-#define CURLE_SEND_FAIL_REWIND -1
-#define CURLE_SSL_ENGINE_INITFAILED -1
-#define CURLINFO_NUM_CONNECTS 0
-#define CURLINFO_SSL_ENGINES 0
-#if (LIBCURL_VERSION_MINOR == 12 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 12
-#define CURLOPT_FTPSSLAUTH 0
-#define CURLINFO_OS_ERRNO 0
-#if (LIBCURL_VERSION_MINOR == 12 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 12
-#define CURLOPT_SOURCE_HOST 0
-#define CURLOPT_SOURCE_USERPWD 0
-#define CURLOPT_SOURCE_PATH 0
-#define CURLOPT_SOURCE_PORT 0
-#define CURLOPT_PASV_HOST 0
-#define CURLOPT_SOURCE_PREQUOTE 0
-#define CURLOPT_SOURCE_POSTQUOTE 0
-#if (LIBCURL_VERSION_MINOR == 12 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 12
-#define CURLE_INTERFACE_FAILED -1
-#define CURL_VERSION_IDN 0
-#if (LIBCURL_VERSION_MINOR == 11 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 11
-#define CURLOPT_TCP_NODELAY 0
-#if (LIBCURL_VERSION_MINOR == 11 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 11
-#define CURLOPT_POSTFIELDSIZE_LARGE 0
-#define CURL_VERSION_LARGEFILE 0
-#if (LIBCURL_VERSION_MINOR == 11 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 11
-#define CURLOPT_INFILESIZE_LARGE 0
-#define CURLOPT_RESUME_FROM_LARGE 0
-#define CURLOPT_MAXFILESIZE_LARGE 0
-#define CURLOPT_NETRC_FILE 0
-#define CURLOPT_FTP_SSL 0
-#define CURLE_FTP_SSL_FAILED -1
-#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 8) || LIBCURL_VERSION_MINOR < 10
-#define CURLOPT_IPRESOLVE 0
-#define CURLOPT_MAXFILESIZE 0
-#define CURLE_LDAP_INVALID_URL -1
-#define CURLE_FILESIZE_EXCEEDED -1
-#define CURLINFO_RESPONSE_CODE 0
-#define CURLINFO_HTTPAUTH_AVAIL 0
-#define CURLINFO_PROXYAUTH_AVAIL 0
-#define CURL_VERSION_SPNEGO 0
-#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 7) || LIBCURL_VERSION_MINOR < 10
-#define CURLOPT_FTP_CREATE_MISSING_DIRS 0
-#define CURLOPT_PROXYAUTH 0
-#define CURLINFO_HTTP_CONNECTCODE 0
-#define CURL_VERSION_ASYNCHDNS 0
-#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 6) || LIBCURL_VERSION_MINOR < 10
-#define CURLOPT_HTTPAUTH 0
-#define CURLOPT_SSL_CTX_FUNCTION 0
-#define CURLOPT_SSL_CTX_DATA 0
-#define CURL_VERSION_NTLM 0
-#define CURL_VERSION_GSSNEGOTIATE 0
-#define CURL_VERSION_DEBUG 0
-#define CURLAUTH_NONE 0
-#define CURLAUTH_BASIC 0
-#define CURLAUTH_DIGEST 0
-#define CURLAUTH_GSSNEGOTIATE 0
-#define CURLAUTH_NTLM 0
-#define CURLAUTH_ANY 0
-#define CURLAUTH_ANYSAFE 0
-#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 5) || LIBCURL_VERSION_MINOR < 10
-#define CURLOPT_FTP_USE_EPRT 0
-#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 4) || LIBCURL_VERSION_MINOR < 10
-#define CURLOPT_UNRESTRICTED_AUTH 0
-#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 10
-#define CURLOPT_PRIVATE 0
-#define CURLOPT_HTTP200ALIASES 0
-#define CURLE_HTTP_RETURNED_ERROR -1
-#define CURLINFO_PRIVATE 0
-#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 10
-#define CURLE_OPERATION_TIMEDOUT -1
-#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 10
-#error your version is TOOOOOOOO low
-#endif /* 7.10.1 */
-#endif /* 7.10.2 */
-#endif /* 7.10.3 */
-#endif /* 7.10.4 */
-#endif /* 7.10.5 */
-#endif /* 7.10.6 */
-#endif /* 7.10.7 */
-#endif /* 7.10.8 */
-#endif /* 7.11.0 */
-#endif /* 7.11.1 */
-#endif /* 7.11.2 */
-#endif /* 7.12.0 */
-#endif /* 7.12.1 */
-#endif /* 7.12.2 */
-#endif /* 7.12.3 */
-#endif /* 7.13.0 */
-#endif /* 7.13.1 */
-#endif /* 7.13.2 */
-#endif /* 7.14.0 */
-#endif /* 7.14.1 */
-#endif /* 7.15.0 */
-#endif /* 7.15.1 */
-#endif /* 7.15.2 */
-#endif /* 7.15.3 */
-#endif /* 7.15.4 */
-#endif /* 7.15.5 */
-#endif /* 7.16.0 */
-#endif /* 7.16.1 */
-#endif /* 7.16.2 */
-#endif /* 7.16.3 */
-#endif /* 7.16.4 */
-#endif /* 7.17.0 */
-#endif /* 7.17.1 */
-#endif /* 7.18.0 */
-#endif /* 7.18.1 */
-#endif /* 7.18.2 */
-#endif /* 7.19.0 */
-#endif /* 7.19.1 */
-#endif /* 7.19.2 */
-#endif /* 7.19.3 */
-#endif /* 7.19.4 */
-#endif /* 7.19.5 */
-#endif /* 7.19.6 */
-#endif /* 7.19.7 */
-#endif /* 7.20.0 */
-#endif /* 7.20.1 */
-#endif /* 7.21.0 */
-#endif /* 7.21.1 */
-#endif /* 7.21.2 */
-#endif /* 7.21.3 */
-#endif /* 7.21.4 */
-#endif /* 7.21.5 */
-#endif /* 7.21.6 */
-#endif /* 7.21.7 */
-#endif /* 7.22.0 */
-#endif /* 7.23.0 */
-#endif /* 7.23.1 */
-#endif /* 7.24.0 */
-#endif /* 7.25.0 */
-#endif /* 7.26.0 */
-#endif /* 7.27.0 */
-#endif /* 7.28.0 */
-#endif /* 7.28.1 */
-#endif /* 7.29.0 */
-#endif /* 7.30.0 */
-#endif /* 7.31.0 */
-#endif /* 7.32.0 */
-#endif /* 7.33.0 */
-#endif /* 7.34.0 */
-#endif /* 7.35.0 */
-#endif /* 7.36.0 */
-#endif /* 7.37.0 */
-#endif /* 7.37.1 */
-#endif /* 7.38.0 */
-#endif /* 7.39.0 */
-#endif /* 7.40.0 */
-#endif /* 7.41.0 */
-#endif /* 7.42.0 */
-#endif /* 7.42.1 */
-#endif /* 7.43.0 */
-#endif /* 7.44.0 */
-#endif /* 7.45.0 */
-#endif /* 7.46.0 */
-#endif /* 7.47.0 */
-#endif /* 7.47.1 */
-#endif /* 7.48.0 */
-#endif /* 7.49.0 */
-#endif /* 7.49.1 */
-#endif /* 7.50.0 */
-#endif /* 7.50.1 */
-#endif /* 7.50.2 */
-#endif /* 7.50.3 */
-#endif /* 7.51.0 */
-#endif /* 7.52.0 */
-#endif /* 7.52.1 */
-#endif /* 7.53.0 */
-#endif /* 7.53.1 */
-#endif /* 7.54.0 */
-#endif /* 7.54.1 */
-#endif /* 7.55.0 */
-#endif /* 7.55.1 */
-#endif /* 7.56.0 */
-#endif /* 7.56.1 */
-#endif /* 7.57.0 */
-/* generated ends */
diff --git a/vendor/github.com/andelf/go-curl/const.go b/vendor/github.com/andelf/go-curl/const.go
deleted file mode 100644
index 8635486..0000000
--- a/vendor/github.com/andelf/go-curl/const.go
+++ /dev/null
@@ -1,179 +0,0 @@
-package curl
-
-/*
-#include
-#include "compat.h"
-
-*/
-import "C"
-
-// for GlobalInit(flag)
-const (
- GLOBAL_SSL = C.CURL_GLOBAL_SSL
- GLOBAL_WIN32 = C.CURL_GLOBAL_WIN32
- GLOBAL_ALL = C.CURL_GLOBAL_ALL
- GLOBAL_NOTHING = C.CURL_GLOBAL_NOTHING
- GLOBAL_DEFAULT = C.CURL_GLOBAL_DEFAULT
-)
-
-// CURLMcode
-const (
- M_CALL_MULTI_PERFORM = C.CURLM_CALL_MULTI_PERFORM
- // M_OK = C.CURLM_OK
- M_BAD_HANDLE = C.CURLM_BAD_HANDLE
- M_BAD_EASY_HANDLE = C.CURLM_BAD_EASY_HANDLE
- M_OUT_OF_MEMORY = C.CURLM_OUT_OF_MEMORY
- M_INTERNAL_ERROR = C.CURLM_INTERNAL_ERROR
- M_BAD_SOCKET = C.CURLM_BAD_SOCKET
- M_UNKNOWN_OPTION = C.CURLM_UNKNOWN_OPTION
-)
-
-// for multi.Setopt(flag, ...)
-const (
- MOPT_SOCKETFUNCTION = C.CURLMOPT_SOCKETFUNCTION
- MOPT_SOCKETDATA = C.CURLMOPT_SOCKETDATA
- MOPT_PIPELINING = C.CURLMOPT_PIPELINING
- MOPT_TIMERFUNCTION = C.CURLMOPT_TIMERFUNCTION
- MOPT_TIMERDATA = C.CURLMOPT_TIMERDATA
- MOPT_MAXCONNECTS = C.CURLMOPT_MAXCONNECTS
-)
-
-// CURLSHcode
-const (
- // SHE_OK = C.CURLSHE_OK
- SHE_BAD_OPTION = C.CURLSHE_BAD_OPTION
- SHE_IN_USE = C.CURLSHE_IN_USE
- SHE_INVALID = C.CURLSHE_INVALID
- SHE_NOMEM = C.CURLSHE_NOMEM
-)
-
-// for share.Setopt(flat, ...)
-const (
- SHOPT_SHARE = C.CURLSHOPT_SHARE
- SHOPT_UNSHARE = C.CURLSHOPT_UNSHARE
- SHOPT_LOCKFUNC = C.CURLSHOPT_LOCKFUNC
- SHOPT_UNLOCKFUNC = C.CURLSHOPT_UNLOCKFUNC
- SHOPT_USERDATA = C.CURLSHOPT_USERDATA
-)
-
-// for share.Setopt(SHOPT_SHARE/SHOPT_UNSHARE, flag)
-const (
- LOCK_DATA_SHARE = C.CURL_LOCK_DATA_SHARE
- LOCK_DATA_COOKIE = C.CURL_LOCK_DATA_COOKIE
- LOCK_DATA_DNS = C.CURL_LOCK_DATA_DNS
- LOCK_DATA_SSL_SESSION = C.CURL_LOCK_DATA_SSL_SESSION
- LOCK_DATA_CONNECT = C.CURL_LOCK_DATA_CONNECT
-)
-
-// for VersionInfo(flag)
-const (
- VERSION_FIRST = C.CURLVERSION_FIRST
- VERSION_SECOND = C.CURLVERSION_SECOND
- VERSION_THIRD = C.CURLVERSION_THIRD
- // VERSION_FOURTH = C.CURLVERSION_FOURTH
- VERSION_LAST = C.CURLVERSION_LAST
- VERSION_NOW = C.CURLVERSION_NOW
-)
-
-// for VersionInfo(...).Features mask flag
-const (
- VERSION_IPV6 = C.CURL_VERSION_IPV6
- VERSION_KERBEROS4 = C.CURL_VERSION_KERBEROS4
- VERSION_SSL = C.CURL_VERSION_SSL
- VERSION_LIBZ = C.CURL_VERSION_LIBZ
- VERSION_NTLM = C.CURL_VERSION_NTLM
- VERSION_GSSNEGOTIATE = C.CURL_VERSION_GSSNEGOTIATE
- VERSION_DEBUG = C.CURL_VERSION_DEBUG
- VERSION_ASYNCHDNS = C.CURL_VERSION_ASYNCHDNS
- VERSION_SPNEGO = C.CURL_VERSION_SPNEGO
- VERSION_LARGEFILE = C.CURL_VERSION_LARGEFILE
- VERSION_IDN = C.CURL_VERSION_IDN
- VERSION_SSPI = C.CURL_VERSION_SSPI
- VERSION_CONV = C.CURL_VERSION_CONV
- VERSION_CURLDEBUG = C.CURL_VERSION_CURLDEBUG
- VERSION_TLSAUTH_SRP = C.CURL_VERSION_TLSAUTH_SRP
- VERSION_NTLM_WB = C.CURL_VERSION_NTLM_WB
-)
-
-// for OPT_READFUNCTION, return a int flag
-const (
- READFUNC_ABORT = C.CURL_READFUNC_ABORT
- READFUNC_PAUSE = C.CURL_READFUNC_PAUSE
-)
-
-// for easy.Setopt(OPT_HTTP_VERSION, flag)
-const (
- HTTP_VERSION_NONE = C.CURL_HTTP_VERSION_NONE
- HTTP_VERSION_1_0 = C.CURL_HTTP_VERSION_1_0
- HTTP_VERSION_1_1 = C.CURL_HTTP_VERSION_1_1
-)
-
-// for easy.Setopt(OPT_PROXYTYPE, flag)
-const (
- PROXY_HTTP = C.CURLPROXY_HTTP /* added in 7.10, new in 7.19.4 default is to use CONNECT HTTP/1.1 */
- PROXY_HTTP_1_0 = C.CURLPROXY_HTTP_1_0 /* added in 7.19.4, force to use CONNECT HTTP/1.0 */
- PROXY_SOCKS4 = C.CURLPROXY_SOCKS4 /* support added in 7.15.2, enum existed already in 7.10 */
- PROXY_SOCKS5 = C.CURLPROXY_SOCKS5 /* added in 7.10 */
- PROXY_SOCKS4A = C.CURLPROXY_SOCKS4A /* added in 7.18.0 */
- // Use the SOCKS5 protocol but pass along the host name rather than the IP address.
- PROXY_SOCKS5_HOSTNAME = C.CURLPROXY_SOCKS5_HOSTNAME
-)
-
-// for easy.Setopt(OPT_SSLVERSION, flag)
-const (
- SSLVERSION_DEFAULT = C.CURL_SSLVERSION_DEFAULT
- SSLVERSION_TLSv1 = C.CURL_SSLVERSION_TLSv1
- SSLVERSION_SSLv2 = C.CURL_SSLVERSION_SSLv2
- SSLVERSION_SSLv3 = C.CURL_SSLVERSION_SSLv3
-)
-
-// for easy.Setopt(OPT_TIMECONDITION, flag)
-const (
- TIMECOND_NONE = C.CURL_TIMECOND_NONE
- TIMECOND_IFMODSINCE = C.CURL_TIMECOND_IFMODSINCE
- TIMECOND_IFUNMODSINCE = C.CURL_TIMECOND_IFUNMODSINCE
- TIMECOND_LASTMOD = C.CURL_TIMECOND_LASTMOD
-)
-
-// for easy.Setopt(OPT_NETRC, flag)
-const (
- NETRC_IGNORED = C.CURL_NETRC_IGNORED
- NETRC_OPTIONAL = C.CURL_NETRC_OPTIONAL
- NETRC_REQUIRED = C.CURL_NETRC_REQUIRED
-)
-
-// for easy.Setopt(OPT_FTP_CREATE_MISSING_DIRS, flag)
-const (
- FTP_CREATE_DIR_NONE = C.CURLFTP_CREATE_DIR_NONE
- FTP_CREATE_DIR = C.CURLFTP_CREATE_DIR
- FTP_CREATE_DIR_RETRY = C.CURLFTP_CREATE_DIR_RETRY
-)
-
-// for easy.Setopt(OPT_IPRESOLVE, flag)
-const (
- IPRESOLVE_WHATEVER = C.CURL_IPRESOLVE_WHATEVER
- IPRESOLVE_V4 = C.CURL_IPRESOLVE_V4
- IPRESOLVE_V6 = C.CURL_IPRESOLVE_V6
-)
-
-// for easy.Setopt(OPT_SSL_OPTIONS, flag)
-const (
- SSLOPT_ALLOW_BEAST = 1
-)
-
-// for easy.Pause(flat)
-const (
- PAUSE_RECV = C.CURLPAUSE_RECV
- PAUSE_RECV_CONT = C.CURLPAUSE_RECV_CONT
- PAUSE_SEND = C.CURLPAUSE_SEND
- PAUSE_SEND_CONT = C.CURLPAUSE_SEND_CONT
- PAUSE_ALL = C.CURLPAUSE_ALL
- PAUSE_CONT = C.CURLPAUSE_CONT
-)
-
-// for multi.Info_read()
-const (
- CURLMSG_NONE = C.CURLMSG_NONE
- CURLMSG_DONE = C.CURLMSG_DONE
- CURLMSG_LAST = C.CURLMSG_LAST
-)
diff --git a/vendor/github.com/andelf/go-curl/const_gen.go b/vendor/github.com/andelf/go-curl/const_gen.go
deleted file mode 100644
index 4a9e88c..0000000
--- a/vendor/github.com/andelf/go-curl/const_gen.go
+++ /dev/null
@@ -1,488 +0,0 @@
-//go:generate /usr/bin/env python ./misc/codegen.py
-
-package curl
-/*
-#include
-#include "compat.h"
-*/
-import "C"
-
-// CURLcode
-const (
- E_UNSUPPORTED_PROTOCOL = C.CURLE_UNSUPPORTED_PROTOCOL
- E_FAILED_INIT = C.CURLE_FAILED_INIT
- E_URL_MALFORMAT = C.CURLE_URL_MALFORMAT
- E_NOT_BUILT_IN = C.CURLE_NOT_BUILT_IN
- E_COULDNT_RESOLVE_PROXY = C.CURLE_COULDNT_RESOLVE_PROXY
- E_COULDNT_RESOLVE_HOST = C.CURLE_COULDNT_RESOLVE_HOST
- E_COULDNT_CONNECT = C.CURLE_COULDNT_CONNECT
- E_WEIRD_SERVER_REPLY = C.CURLE_WEIRD_SERVER_REPLY
- E_REMOTE_ACCESS_DENIED = C.CURLE_REMOTE_ACCESS_DENIED
- E_FTP_ACCEPT_FAILED = C.CURLE_FTP_ACCEPT_FAILED
- E_FTP_WEIRD_PASS_REPLY = C.CURLE_FTP_WEIRD_PASS_REPLY
- E_FTP_ACCEPT_TIMEOUT = C.CURLE_FTP_ACCEPT_TIMEOUT
- E_FTP_WEIRD_PASV_REPLY = C.CURLE_FTP_WEIRD_PASV_REPLY
- E_FTP_WEIRD_227_FORMAT = C.CURLE_FTP_WEIRD_227_FORMAT
- E_FTP_CANT_GET_HOST = C.CURLE_FTP_CANT_GET_HOST
- E_HTTP2 = C.CURLE_HTTP2
- E_FTP_COULDNT_SET_TYPE = C.CURLE_FTP_COULDNT_SET_TYPE
- E_PARTIAL_FILE = C.CURLE_PARTIAL_FILE
- E_FTP_COULDNT_RETR_FILE = C.CURLE_FTP_COULDNT_RETR_FILE
- E_OBSOLETE20 = C.CURLE_OBSOLETE20
- E_QUOTE_ERROR = C.CURLE_QUOTE_ERROR
- E_HTTP_RETURNED_ERROR = C.CURLE_HTTP_RETURNED_ERROR
- E_WRITE_ERROR = C.CURLE_WRITE_ERROR
- E_OBSOLETE24 = C.CURLE_OBSOLETE24
- E_UPLOAD_FAILED = C.CURLE_UPLOAD_FAILED
- E_READ_ERROR = C.CURLE_READ_ERROR
- E_OUT_OF_MEMORY = C.CURLE_OUT_OF_MEMORY
- E_OPERATION_TIMEDOUT = C.CURLE_OPERATION_TIMEDOUT
- E_OBSOLETE29 = C.CURLE_OBSOLETE29
- E_FTP_PORT_FAILED = C.CURLE_FTP_PORT_FAILED
- E_FTP_COULDNT_USE_REST = C.CURLE_FTP_COULDNT_USE_REST
- E_OBSOLETE32 = C.CURLE_OBSOLETE32
- E_RANGE_ERROR = C.CURLE_RANGE_ERROR
- E_HTTP_POST_ERROR = C.CURLE_HTTP_POST_ERROR
- E_SSL_CONNECT_ERROR = C.CURLE_SSL_CONNECT_ERROR
- E_BAD_DOWNLOAD_RESUME = C.CURLE_BAD_DOWNLOAD_RESUME
- E_FILE_COULDNT_READ_FILE = C.CURLE_FILE_COULDNT_READ_FILE
- E_LDAP_CANNOT_BIND = C.CURLE_LDAP_CANNOT_BIND
- E_LDAP_SEARCH_FAILED = C.CURLE_LDAP_SEARCH_FAILED
- E_OBSOLETE40 = C.CURLE_OBSOLETE40
- E_FUNCTION_NOT_FOUND = C.CURLE_FUNCTION_NOT_FOUND
- E_ABORTED_BY_CALLBACK = C.CURLE_ABORTED_BY_CALLBACK
- E_BAD_FUNCTION_ARGUMENT = C.CURLE_BAD_FUNCTION_ARGUMENT
- E_OBSOLETE44 = C.CURLE_OBSOLETE44
- E_INTERFACE_FAILED = C.CURLE_INTERFACE_FAILED
- E_OBSOLETE46 = C.CURLE_OBSOLETE46
- E_TOO_MANY_REDIRECTS = C.CURLE_TOO_MANY_REDIRECTS
- E_UNKNOWN_OPTION = C.CURLE_UNKNOWN_OPTION
- E_TELNET_OPTION_SYNTAX = C.CURLE_TELNET_OPTION_SYNTAX
- E_OBSOLETE50 = C.CURLE_OBSOLETE50
- E_PEER_FAILED_VERIFICATION = C.CURLE_PEER_FAILED_VERIFICATION
- E_GOT_NOTHING = C.CURLE_GOT_NOTHING
- E_SSL_ENGINE_NOTFOUND = C.CURLE_SSL_ENGINE_NOTFOUND
- E_SSL_ENGINE_SETFAILED = C.CURLE_SSL_ENGINE_SETFAILED
- E_SEND_ERROR = C.CURLE_SEND_ERROR
- E_RECV_ERROR = C.CURLE_RECV_ERROR
- E_OBSOLETE57 = C.CURLE_OBSOLETE57
- E_SSL_CERTPROBLEM = C.CURLE_SSL_CERTPROBLEM
- E_SSL_CIPHER = C.CURLE_SSL_CIPHER
- E_SSL_CACERT = C.CURLE_SSL_CACERT
- E_BAD_CONTENT_ENCODING = C.CURLE_BAD_CONTENT_ENCODING
- E_LDAP_INVALID_URL = C.CURLE_LDAP_INVALID_URL
- E_FILESIZE_EXCEEDED = C.CURLE_FILESIZE_EXCEEDED
- E_USE_SSL_FAILED = C.CURLE_USE_SSL_FAILED
- E_SEND_FAIL_REWIND = C.CURLE_SEND_FAIL_REWIND
- E_SSL_ENGINE_INITFAILED = C.CURLE_SSL_ENGINE_INITFAILED
- E_LOGIN_DENIED = C.CURLE_LOGIN_DENIED
- E_TFTP_NOTFOUND = C.CURLE_TFTP_NOTFOUND
- E_TFTP_PERM = C.CURLE_TFTP_PERM
- E_REMOTE_DISK_FULL = C.CURLE_REMOTE_DISK_FULL
- E_TFTP_ILLEGAL = C.CURLE_TFTP_ILLEGAL
- E_TFTP_UNKNOWNID = C.CURLE_TFTP_UNKNOWNID
- E_REMOTE_FILE_EXISTS = C.CURLE_REMOTE_FILE_EXISTS
- E_TFTP_NOSUCHUSER = C.CURLE_TFTP_NOSUCHUSER
- E_CONV_FAILED = C.CURLE_CONV_FAILED
- E_CONV_REQD = C.CURLE_CONV_REQD
- E_SSL_CACERT_BADFILE = C.CURLE_SSL_CACERT_BADFILE
- E_REMOTE_FILE_NOT_FOUND = C.CURLE_REMOTE_FILE_NOT_FOUND
- E_SSH = C.CURLE_SSH
- E_SSL_SHUTDOWN_FAILED = C.CURLE_SSL_SHUTDOWN_FAILED
- E_AGAIN = C.CURLE_AGAIN
- E_SSL_CRL_BADFILE = C.CURLE_SSL_CRL_BADFILE
- E_SSL_ISSUER_ERROR = C.CURLE_SSL_ISSUER_ERROR
- E_FTP_PRET_FAILED = C.CURLE_FTP_PRET_FAILED
- E_RTSP_CSEQ_ERROR = C.CURLE_RTSP_CSEQ_ERROR
- E_RTSP_SESSION_ERROR = C.CURLE_RTSP_SESSION_ERROR
- E_FTP_BAD_FILE_LIST = C.CURLE_FTP_BAD_FILE_LIST
- E_CHUNK_FAILED = C.CURLE_CHUNK_FAILED
- E_NO_CONNECTION_AVAILABLE = C.CURLE_NO_CONNECTION_AVAILABLE
- E_SSL_PINNEDPUBKEYNOTMATCH = C.CURLE_SSL_PINNEDPUBKEYNOTMATCH
- E_SSL_INVALIDCERTSTATUS = C.CURLE_SSL_INVALIDCERTSTATUS
- E_HTTP2_STREAM = C.CURLE_HTTP2_STREAM
- E_OBSOLETE16 = C.CURLE_OBSOLETE16
- E_OBSOLETE10 = C.CURLE_OBSOLETE10
- E_OBSOLETE12 = C.CURLE_OBSOLETE12
- E_FTP_WEIRD_SERVER_REPLY = C.CURLE_FTP_WEIRD_SERVER_REPLY
- E_UNKNOWN_TELNET_OPTION = C.CURLE_UNKNOWN_TELNET_OPTION
- E_SSL_PEER_CERTIFICATE = C.CURLE_SSL_PEER_CERTIFICATE
- E_OBSOLETE = C.CURLE_OBSOLETE
- E_BAD_PASSWORD_ENTERED = C.CURLE_BAD_PASSWORD_ENTERED
- E_BAD_CALLING_ORDER = C.CURLE_BAD_CALLING_ORDER
- E_FTP_USER_PASSWORD_INCORRECT = C.CURLE_FTP_USER_PASSWORD_INCORRECT
- E_FTP_CANT_RECONNECT = C.CURLE_FTP_CANT_RECONNECT
- E_FTP_COULDNT_GET_SIZE = C.CURLE_FTP_COULDNT_GET_SIZE
- E_FTP_COULDNT_SET_ASCII = C.CURLE_FTP_COULDNT_SET_ASCII
- E_FTP_WEIRD_USER_REPLY = C.CURLE_FTP_WEIRD_USER_REPLY
- E_FTP_WRITE_ERROR = C.CURLE_FTP_WRITE_ERROR
- E_LIBRARY_NOT_FOUND = C.CURLE_LIBRARY_NOT_FOUND
- E_MALFORMAT_USER = C.CURLE_MALFORMAT_USER
- E_SHARE_IN_USE = C.CURLE_SHARE_IN_USE
- E_URL_MALFORMAT_USER = C.CURLE_URL_MALFORMAT_USER
- E_FTP_ACCESS_DENIED = C.CURLE_FTP_ACCESS_DENIED
- E_FTP_COULDNT_SET_BINARY = C.CURLE_FTP_COULDNT_SET_BINARY
- E_FTP_QUOTE_ERROR = C.CURLE_FTP_QUOTE_ERROR
- E_TFTP_DISKFULL = C.CURLE_TFTP_DISKFULL
- E_TFTP_EXISTS = C.CURLE_TFTP_EXISTS
- E_HTTP_RANGE_ERROR = C.CURLE_HTTP_RANGE_ERROR
- E_FTP_SSL_FAILED = C.CURLE_FTP_SSL_FAILED
- E_OPERATION_TIMEOUTED = C.CURLE_OPERATION_TIMEOUTED
- E_HTTP_NOT_FOUND = C.CURLE_HTTP_NOT_FOUND
- E_HTTP_PORT_FAILED = C.CURLE_HTTP_PORT_FAILED
- E_FTP_COULDNT_STOR_FILE = C.CURLE_FTP_COULDNT_STOR_FILE
- E_FTP_PARTIAL_FILE = C.CURLE_FTP_PARTIAL_FILE
- E_FTP_BAD_DOWNLOAD_RESUME = C.CURLE_FTP_BAD_DOWNLOAD_RESUME
- E_ALREADY_COMPLETE = C.CURLE_ALREADY_COMPLETE
-)
-
-// easy.Setopt(flag, ...)
-const (
- OPT_ENCODING = C.CURLOPT_ENCODING
- OPT_FILE = C.CURLOPT_FILE
- OPT_INFILE = C.CURLOPT_INFILE
- OPT_WRITEHEADER = C.CURLOPT_WRITEHEADER
- OPT_WRITEINFO = C.CURLOPT_WRITEINFO
- OPT_CLOSEPOLICY = C.CURLOPT_CLOSEPOLICY
- OPT_WRITEDATA = C.CURLOPT_WRITEDATA
- OPT_URL = C.CURLOPT_URL
- OPT_PORT = C.CURLOPT_PORT
- OPT_PROXY = C.CURLOPT_PROXY
- OPT_USERPWD = C.CURLOPT_USERPWD
- OPT_PROXYUSERPWD = C.CURLOPT_PROXYUSERPWD
- OPT_RANGE = C.CURLOPT_RANGE
- OPT_READDATA = C.CURLOPT_READDATA
- OPT_ERRORBUFFER = C.CURLOPT_ERRORBUFFER
- OPT_WRITEFUNCTION = C.CURLOPT_WRITEFUNCTION
- OPT_READFUNCTION = C.CURLOPT_READFUNCTION
- OPT_TIMEOUT = C.CURLOPT_TIMEOUT
- OPT_INFILESIZE = C.CURLOPT_INFILESIZE
- OPT_POSTFIELDS = C.CURLOPT_POSTFIELDS
- OPT_REFERER = C.CURLOPT_REFERER
- OPT_FTPPORT = C.CURLOPT_FTPPORT
- OPT_USERAGENT = C.CURLOPT_USERAGENT
- OPT_LOW_SPEED_LIMIT = C.CURLOPT_LOW_SPEED_LIMIT
- OPT_LOW_SPEED_TIME = C.CURLOPT_LOW_SPEED_TIME
- OPT_RESUME_FROM = C.CURLOPT_RESUME_FROM
- OPT_COOKIE = C.CURLOPT_COOKIE
- OPT_HTTPHEADER = C.CURLOPT_HTTPHEADER
- OPT_HTTPPOST = C.CURLOPT_HTTPPOST
- OPT_SSLCERT = C.CURLOPT_SSLCERT
- OPT_KEYPASSWD = C.CURLOPT_KEYPASSWD
- OPT_CRLF = C.CURLOPT_CRLF
- OPT_QUOTE = C.CURLOPT_QUOTE
- OPT_HEADERDATA = C.CURLOPT_HEADERDATA
- OPT_COOKIEFILE = C.CURLOPT_COOKIEFILE
- OPT_SSLVERSION = C.CURLOPT_SSLVERSION
- OPT_TIMECONDITION = C.CURLOPT_TIMECONDITION
- OPT_TIMEVALUE = C.CURLOPT_TIMEVALUE
- OPT_CUSTOMREQUEST = C.CURLOPT_CUSTOMREQUEST
- OPT_STDERR = C.CURLOPT_STDERR
- OPT_POSTQUOTE = C.CURLOPT_POSTQUOTE
- OPT_OBSOLETE40 = C.CURLOPT_OBSOLETE40
- OPT_VERBOSE = C.CURLOPT_VERBOSE
- OPT_HEADER = C.CURLOPT_HEADER
- OPT_NOPROGRESS = C.CURLOPT_NOPROGRESS
- OPT_NOBODY = C.CURLOPT_NOBODY
- OPT_FAILONERROR = C.CURLOPT_FAILONERROR
- OPT_UPLOAD = C.CURLOPT_UPLOAD
- OPT_POST = C.CURLOPT_POST
- OPT_DIRLISTONLY = C.CURLOPT_DIRLISTONLY
- OPT_APPEND = C.CURLOPT_APPEND
- OPT_NETRC = C.CURLOPT_NETRC
- OPT_FOLLOWLOCATION = C.CURLOPT_FOLLOWLOCATION
- OPT_TRANSFERTEXT = C.CURLOPT_TRANSFERTEXT
- OPT_PUT = C.CURLOPT_PUT
- OPT_PROGRESSFUNCTION = C.CURLOPT_PROGRESSFUNCTION
- OPT_PROGRESSDATA = C.CURLOPT_PROGRESSDATA
- OPT_XFERINFODATA = C.CURLOPT_XFERINFODATA
- OPT_AUTOREFERER = C.CURLOPT_AUTOREFERER
- OPT_PROXYPORT = C.CURLOPT_PROXYPORT
- OPT_POSTFIELDSIZE = C.CURLOPT_POSTFIELDSIZE
- OPT_HTTPPROXYTUNNEL = C.CURLOPT_HTTPPROXYTUNNEL
- OPT_INTERFACE = C.CURLOPT_INTERFACE
- OPT_KRBLEVEL = C.CURLOPT_KRBLEVEL
- OPT_SSL_VERIFYPEER = C.CURLOPT_SSL_VERIFYPEER
- OPT_CAINFO = C.CURLOPT_CAINFO
- OPT_MAXREDIRS = C.CURLOPT_MAXREDIRS
- OPT_FILETIME = C.CURLOPT_FILETIME
- OPT_TELNETOPTIONS = C.CURLOPT_TELNETOPTIONS
- OPT_MAXCONNECTS = C.CURLOPT_MAXCONNECTS
- OPT_OBSOLETE72 = C.CURLOPT_OBSOLETE72
- OPT_FRESH_CONNECT = C.CURLOPT_FRESH_CONNECT
- OPT_FORBID_REUSE = C.CURLOPT_FORBID_REUSE
- OPT_RANDOM_FILE = C.CURLOPT_RANDOM_FILE
- OPT_EGDSOCKET = C.CURLOPT_EGDSOCKET
- OPT_CONNECTTIMEOUT = C.CURLOPT_CONNECTTIMEOUT
- OPT_HEADERFUNCTION = C.CURLOPT_HEADERFUNCTION
- OPT_HTTPGET = C.CURLOPT_HTTPGET
- OPT_SSL_VERIFYHOST = C.CURLOPT_SSL_VERIFYHOST
- OPT_COOKIEJAR = C.CURLOPT_COOKIEJAR
- OPT_SSL_CIPHER_LIST = C.CURLOPT_SSL_CIPHER_LIST
- OPT_HTTP_VERSION = C.CURLOPT_HTTP_VERSION
- OPT_FTP_USE_EPSV = C.CURLOPT_FTP_USE_EPSV
- OPT_SSLCERTTYPE = C.CURLOPT_SSLCERTTYPE
- OPT_SSLKEY = C.CURLOPT_SSLKEY
- OPT_SSLKEYTYPE = C.CURLOPT_SSLKEYTYPE
- OPT_SSLENGINE = C.CURLOPT_SSLENGINE
- OPT_SSLENGINE_DEFAULT = C.CURLOPT_SSLENGINE_DEFAULT
- OPT_DNS_USE_GLOBAL_CACHE = C.CURLOPT_DNS_USE_GLOBAL_CACHE
- OPT_DNS_CACHE_TIMEOUT = C.CURLOPT_DNS_CACHE_TIMEOUT
- OPT_PREQUOTE = C.CURLOPT_PREQUOTE
- OPT_DEBUGFUNCTION = C.CURLOPT_DEBUGFUNCTION
- OPT_DEBUGDATA = C.CURLOPT_DEBUGDATA
- OPT_COOKIESESSION = C.CURLOPT_COOKIESESSION
- OPT_CAPATH = C.CURLOPT_CAPATH
- OPT_BUFFERSIZE = C.CURLOPT_BUFFERSIZE
- OPT_NOSIGNAL = C.CURLOPT_NOSIGNAL
- OPT_SHARE = C.CURLOPT_SHARE
- OPT_PROXYTYPE = C.CURLOPT_PROXYTYPE
- OPT_ACCEPT_ENCODING = C.CURLOPT_ACCEPT_ENCODING
- OPT_PRIVATE = C.CURLOPT_PRIVATE
- OPT_HTTP200ALIASES = C.CURLOPT_HTTP200ALIASES
- OPT_UNRESTRICTED_AUTH = C.CURLOPT_UNRESTRICTED_AUTH
- OPT_FTP_USE_EPRT = C.CURLOPT_FTP_USE_EPRT
- OPT_HTTPAUTH = C.CURLOPT_HTTPAUTH
- OPT_SSL_CTX_FUNCTION = C.CURLOPT_SSL_CTX_FUNCTION
- OPT_SSL_CTX_DATA = C.CURLOPT_SSL_CTX_DATA
- OPT_FTP_CREATE_MISSING_DIRS = C.CURLOPT_FTP_CREATE_MISSING_DIRS
- OPT_PROXYAUTH = C.CURLOPT_PROXYAUTH
- OPT_FTP_RESPONSE_TIMEOUT = C.CURLOPT_FTP_RESPONSE_TIMEOUT
- OPT_SERVER_RESPONSE_TIMEOUT = C.CURLOPT_SERVER_RESPONSE_TIMEOUT
- OPT_IPRESOLVE = C.CURLOPT_IPRESOLVE
- OPT_MAXFILESIZE = C.CURLOPT_MAXFILESIZE
- OPT_INFILESIZE_LARGE = C.CURLOPT_INFILESIZE_LARGE
- OPT_RESUME_FROM_LARGE = C.CURLOPT_RESUME_FROM_LARGE
- OPT_MAXFILESIZE_LARGE = C.CURLOPT_MAXFILESIZE_LARGE
- OPT_NETRC_FILE = C.CURLOPT_NETRC_FILE
- OPT_USE_SSL = C.CURLOPT_USE_SSL
- OPT_POSTFIELDSIZE_LARGE = C.CURLOPT_POSTFIELDSIZE_LARGE
- OPT_TCP_NODELAY = C.CURLOPT_TCP_NODELAY
- OPT_FTPSSLAUTH = C.CURLOPT_FTPSSLAUTH
- OPT_IOCTLFUNCTION = C.CURLOPT_IOCTLFUNCTION
- OPT_IOCTLDATA = C.CURLOPT_IOCTLDATA
- OPT_FTP_ACCOUNT = C.CURLOPT_FTP_ACCOUNT
- OPT_COOKIELIST = C.CURLOPT_COOKIELIST
- OPT_IGNORE_CONTENT_LENGTH = C.CURLOPT_IGNORE_CONTENT_LENGTH
- OPT_FTP_SKIP_PASV_IP = C.CURLOPT_FTP_SKIP_PASV_IP
- OPT_FTP_FILEMETHOD = C.CURLOPT_FTP_FILEMETHOD
- OPT_LOCALPORT = C.CURLOPT_LOCALPORT
- OPT_LOCALPORTRANGE = C.CURLOPT_LOCALPORTRANGE
- OPT_CONNECT_ONLY = C.CURLOPT_CONNECT_ONLY
- OPT_CONV_FROM_NETWORK_FUNCTION = C.CURLOPT_CONV_FROM_NETWORK_FUNCTION
- OPT_CONV_TO_NETWORK_FUNCTION = C.CURLOPT_CONV_TO_NETWORK_FUNCTION
- OPT_CONV_FROM_UTF8_FUNCTION = C.CURLOPT_CONV_FROM_UTF8_FUNCTION
- OPT_MAX_SEND_SPEED_LARGE = C.CURLOPT_MAX_SEND_SPEED_LARGE
- OPT_MAX_RECV_SPEED_LARGE = C.CURLOPT_MAX_RECV_SPEED_LARGE
- OPT_FTP_ALTERNATIVE_TO_USER = C.CURLOPT_FTP_ALTERNATIVE_TO_USER
- OPT_SOCKOPTFUNCTION = C.CURLOPT_SOCKOPTFUNCTION
- OPT_SOCKOPTDATA = C.CURLOPT_SOCKOPTDATA
- OPT_SSL_SESSIONID_CACHE = C.CURLOPT_SSL_SESSIONID_CACHE
- OPT_SSH_AUTH_TYPES = C.CURLOPT_SSH_AUTH_TYPES
- OPT_SSH_PUBLIC_KEYFILE = C.CURLOPT_SSH_PUBLIC_KEYFILE
- OPT_SSH_PRIVATE_KEYFILE = C.CURLOPT_SSH_PRIVATE_KEYFILE
- OPT_FTP_SSL_CCC = C.CURLOPT_FTP_SSL_CCC
- OPT_TIMEOUT_MS = C.CURLOPT_TIMEOUT_MS
- OPT_CONNECTTIMEOUT_MS = C.CURLOPT_CONNECTTIMEOUT_MS
- OPT_HTTP_TRANSFER_DECODING = C.CURLOPT_HTTP_TRANSFER_DECODING
- OPT_HTTP_CONTENT_DECODING = C.CURLOPT_HTTP_CONTENT_DECODING
- OPT_NEW_FILE_PERMS = C.CURLOPT_NEW_FILE_PERMS
- OPT_NEW_DIRECTORY_PERMS = C.CURLOPT_NEW_DIRECTORY_PERMS
- OPT_POSTREDIR = C.CURLOPT_POSTREDIR
- OPT_SSH_HOST_PUBLIC_KEY_MD5 = C.CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
- OPT_OPENSOCKETFUNCTION = C.CURLOPT_OPENSOCKETFUNCTION
- OPT_OPENSOCKETDATA = C.CURLOPT_OPENSOCKETDATA
- OPT_COPYPOSTFIELDS = C.CURLOPT_COPYPOSTFIELDS
- OPT_PROXY_TRANSFER_MODE = C.CURLOPT_PROXY_TRANSFER_MODE
- OPT_SEEKFUNCTION = C.CURLOPT_SEEKFUNCTION
- OPT_SEEKDATA = C.CURLOPT_SEEKDATA
- OPT_CRLFILE = C.CURLOPT_CRLFILE
- OPT_ISSUERCERT = C.CURLOPT_ISSUERCERT
- OPT_ADDRESS_SCOPE = C.CURLOPT_ADDRESS_SCOPE
- OPT_CERTINFO = C.CURLOPT_CERTINFO
- OPT_USERNAME = C.CURLOPT_USERNAME
- OPT_PASSWORD = C.CURLOPT_PASSWORD
- OPT_PROXYUSERNAME = C.CURLOPT_PROXYUSERNAME
- OPT_PROXYPASSWORD = C.CURLOPT_PROXYPASSWORD
- OPT_NOPROXY = C.CURLOPT_NOPROXY
- OPT_TFTP_BLKSIZE = C.CURLOPT_TFTP_BLKSIZE
- OPT_SOCKS5_GSSAPI_SERVICE = C.CURLOPT_SOCKS5_GSSAPI_SERVICE
- OPT_SOCKS5_GSSAPI_NEC = C.CURLOPT_SOCKS5_GSSAPI_NEC
- OPT_PROTOCOLS = C.CURLOPT_PROTOCOLS
- OPT_REDIR_PROTOCOLS = C.CURLOPT_REDIR_PROTOCOLS
- OPT_SSH_KNOWNHOSTS = C.CURLOPT_SSH_KNOWNHOSTS
- OPT_SSH_KEYFUNCTION = C.CURLOPT_SSH_KEYFUNCTION
- OPT_SSH_KEYDATA = C.CURLOPT_SSH_KEYDATA
- OPT_MAIL_FROM = C.CURLOPT_MAIL_FROM
- OPT_MAIL_RCPT = C.CURLOPT_MAIL_RCPT
- OPT_FTP_USE_PRET = C.CURLOPT_FTP_USE_PRET
- OPT_RTSP_REQUEST = C.CURLOPT_RTSP_REQUEST
- OPT_RTSP_SESSION_ID = C.CURLOPT_RTSP_SESSION_ID
- OPT_RTSP_STREAM_URI = C.CURLOPT_RTSP_STREAM_URI
- OPT_RTSP_TRANSPORT = C.CURLOPT_RTSP_TRANSPORT
- OPT_RTSP_CLIENT_CSEQ = C.CURLOPT_RTSP_CLIENT_CSEQ
- OPT_RTSP_SERVER_CSEQ = C.CURLOPT_RTSP_SERVER_CSEQ
- OPT_INTERLEAVEDATA = C.CURLOPT_INTERLEAVEDATA
- OPT_INTERLEAVEFUNCTION = C.CURLOPT_INTERLEAVEFUNCTION
- OPT_WILDCARDMATCH = C.CURLOPT_WILDCARDMATCH
- OPT_CHUNK_BGN_FUNCTION = C.CURLOPT_CHUNK_BGN_FUNCTION
- OPT_CHUNK_END_FUNCTION = C.CURLOPT_CHUNK_END_FUNCTION
- OPT_FNMATCH_FUNCTION = C.CURLOPT_FNMATCH_FUNCTION
- OPT_CHUNK_DATA = C.CURLOPT_CHUNK_DATA
- OPT_FNMATCH_DATA = C.CURLOPT_FNMATCH_DATA
- OPT_RESOLVE = C.CURLOPT_RESOLVE
- OPT_TLSAUTH_USERNAME = C.CURLOPT_TLSAUTH_USERNAME
- OPT_TLSAUTH_PASSWORD = C.CURLOPT_TLSAUTH_PASSWORD
- OPT_TLSAUTH_TYPE = C.CURLOPT_TLSAUTH_TYPE
- OPT_TRANSFER_ENCODING = C.CURLOPT_TRANSFER_ENCODING
- OPT_CLOSESOCKETFUNCTION = C.CURLOPT_CLOSESOCKETFUNCTION
- OPT_CLOSESOCKETDATA = C.CURLOPT_CLOSESOCKETDATA
- OPT_GSSAPI_DELEGATION = C.CURLOPT_GSSAPI_DELEGATION
- OPT_DNS_SERVERS = C.CURLOPT_DNS_SERVERS
- OPT_ACCEPTTIMEOUT_MS = C.CURLOPT_ACCEPTTIMEOUT_MS
- OPT_TCP_KEEPALIVE = C.CURLOPT_TCP_KEEPALIVE
- OPT_TCP_KEEPIDLE = C.CURLOPT_TCP_KEEPIDLE
- OPT_TCP_KEEPINTVL = C.CURLOPT_TCP_KEEPINTVL
- OPT_SSL_OPTIONS = C.CURLOPT_SSL_OPTIONS
- OPT_MAIL_AUTH = C.CURLOPT_MAIL_AUTH
- OPT_SASL_IR = C.CURLOPT_SASL_IR
- OPT_XFERINFOFUNCTION = C.CURLOPT_XFERINFOFUNCTION
- OPT_XOAUTH2_BEARER = C.CURLOPT_XOAUTH2_BEARER
- OPT_DNS_INTERFACE = C.CURLOPT_DNS_INTERFACE
- OPT_DNS_LOCAL_IP4 = C.CURLOPT_DNS_LOCAL_IP4
- OPT_DNS_LOCAL_IP6 = C.CURLOPT_DNS_LOCAL_IP6
- OPT_LOGIN_OPTIONS = C.CURLOPT_LOGIN_OPTIONS
- OPT_SSL_ENABLE_NPN = C.CURLOPT_SSL_ENABLE_NPN
- OPT_SSL_ENABLE_ALPN = C.CURLOPT_SSL_ENABLE_ALPN
- OPT_EXPECT_100_TIMEOUT_MS = C.CURLOPT_EXPECT_100_TIMEOUT_MS
- OPT_PROXYHEADER = C.CURLOPT_PROXYHEADER
- OPT_HEADEROPT = C.CURLOPT_HEADEROPT
- OPT_PINNEDPUBLICKEY = C.CURLOPT_PINNEDPUBLICKEY
- OPT_UNIX_SOCKET_PATH = C.CURLOPT_UNIX_SOCKET_PATH
- OPT_SSL_VERIFYSTATUS = C.CURLOPT_SSL_VERIFYSTATUS
- OPT_SSL_FALSESTART = C.CURLOPT_SSL_FALSESTART
- OPT_PATH_AS_IS = C.CURLOPT_PATH_AS_IS
- OPT_PROXY_SERVICE_NAME = C.CURLOPT_PROXY_SERVICE_NAME
- OPT_SERVICE_NAME = C.CURLOPT_SERVICE_NAME
- OPT_PIPEWAIT = C.CURLOPT_PIPEWAIT
- OPT_DEFAULT_PROTOCOL = C.CURLOPT_DEFAULT_PROTOCOL
- OPT_STREAM_WEIGHT = C.CURLOPT_STREAM_WEIGHT
- OPT_STREAM_DEPENDS = C.CURLOPT_STREAM_DEPENDS
- OPT_STREAM_DEPENDS_E = C.CURLOPT_STREAM_DEPENDS_E
- OPT_TFTP_NO_OPTIONS = C.CURLOPT_TFTP_NO_OPTIONS
- OPT_CONNECT_TO = C.CURLOPT_CONNECT_TO
- OPT_TCP_FASTOPEN = C.CURLOPT_TCP_FASTOPEN
- OPT_KEEP_SENDING_ON_ERROR = C.CURLOPT_KEEP_SENDING_ON_ERROR
- OPT_PROXY_CAINFO = C.CURLOPT_PROXY_CAINFO
- OPT_PROXY_CAPATH = C.CURLOPT_PROXY_CAPATH
- OPT_PROXY_SSL_VERIFYPEER = C.CURLOPT_PROXY_SSL_VERIFYPEER
- OPT_PROXY_SSL_VERIFYHOST = C.CURLOPT_PROXY_SSL_VERIFYHOST
- OPT_PROXY_SSLVERSION = C.CURLOPT_PROXY_SSLVERSION
- OPT_PROXY_TLSAUTH_USERNAME = C.CURLOPT_PROXY_TLSAUTH_USERNAME
- OPT_PROXY_TLSAUTH_PASSWORD = C.CURLOPT_PROXY_TLSAUTH_PASSWORD
- OPT_PROXY_TLSAUTH_TYPE = C.CURLOPT_PROXY_TLSAUTH_TYPE
- OPT_PROXY_SSLCERT = C.CURLOPT_PROXY_SSLCERT
- OPT_PROXY_SSLCERTTYPE = C.CURLOPT_PROXY_SSLCERTTYPE
- OPT_PROXY_SSLKEY = C.CURLOPT_PROXY_SSLKEY
- OPT_PROXY_SSLKEYTYPE = C.CURLOPT_PROXY_SSLKEYTYPE
- OPT_PROXY_KEYPASSWD = C.CURLOPT_PROXY_KEYPASSWD
- OPT_PROXY_SSL_CIPHER_LIST = C.CURLOPT_PROXY_SSL_CIPHER_LIST
- OPT_PROXY_CRLFILE = C.CURLOPT_PROXY_CRLFILE
- OPT_PROXY_SSL_OPTIONS = C.CURLOPT_PROXY_SSL_OPTIONS
- OPT_PRE_PROXY = C.CURLOPT_PRE_PROXY
- OPT_PROXY_PINNEDPUBLICKEY = C.CURLOPT_PROXY_PINNEDPUBLICKEY
- OPT_ABSTRACT_UNIX_SOCKET = C.CURLOPT_ABSTRACT_UNIX_SOCKET
- OPT_SUPPRESS_CONNECT_HEADERS = C.CURLOPT_SUPPRESS_CONNECT_HEADERS
- OPT_REQUEST_TARGET = C.CURLOPT_REQUEST_TARGET
- OPT_SOCKS5_AUTH = C.CURLOPT_SOCKS5_AUTH
- OPT_SSH_COMPRESSION = C.CURLOPT_SSH_COMPRESSION
- OPT_MIMEPOST = C.CURLOPT_MIMEPOST
- OPT_POST301 = C.CURLOPT_POST301
- OPT_SSLKEYPASSWD = C.CURLOPT_SSLKEYPASSWD
- OPT_FTPAPPEND = C.CURLOPT_FTPAPPEND
- OPT_FTPLISTONLY = C.CURLOPT_FTPLISTONLY
- OPT_FTP_SSL = C.CURLOPT_FTP_SSL
- OPT_SSLCERTPASSWD = C.CURLOPT_SSLCERTPASSWD
- OPT_KRB4LEVEL = C.CURLOPT_KRB4LEVEL
- OPT_RTSPHEADER = C.CURLOPT_RTSPHEADER
-)
-
-// easy.Getinfo(flag)
-const (
- INFO_TEXT = C.CURLINFO_TEXT
- INFO_EFFECTIVE_URL = C.CURLINFO_EFFECTIVE_URL
- INFO_RESPONSE_CODE = C.CURLINFO_RESPONSE_CODE
- INFO_TOTAL_TIME = C.CURLINFO_TOTAL_TIME
- INFO_NAMELOOKUP_TIME = C.CURLINFO_NAMELOOKUP_TIME
- INFO_CONNECT_TIME = C.CURLINFO_CONNECT_TIME
- INFO_PRETRANSFER_TIME = C.CURLINFO_PRETRANSFER_TIME
- INFO_SIZE_UPLOAD = C.CURLINFO_SIZE_UPLOAD
- INFO_SIZE_UPLOAD_T = C.CURLINFO_SIZE_UPLOAD_T
- INFO_SIZE_DOWNLOAD = C.CURLINFO_SIZE_DOWNLOAD
- INFO_SIZE_DOWNLOAD_T = C.CURLINFO_SIZE_DOWNLOAD_T
- INFO_SPEED_DOWNLOAD = C.CURLINFO_SPEED_DOWNLOAD
- INFO_SPEED_DOWNLOAD_T = C.CURLINFO_SPEED_DOWNLOAD_T
- INFO_SPEED_UPLOAD = C.CURLINFO_SPEED_UPLOAD
- INFO_SPEED_UPLOAD_T = C.CURLINFO_SPEED_UPLOAD_T
- INFO_HEADER_SIZE = C.CURLINFO_HEADER_SIZE
- INFO_REQUEST_SIZE = C.CURLINFO_REQUEST_SIZE
- INFO_SSL_VERIFYRESULT = C.CURLINFO_SSL_VERIFYRESULT
- INFO_FILETIME = C.CURLINFO_FILETIME
- INFO_CONTENT_LENGTH_DOWNLOAD = C.CURLINFO_CONTENT_LENGTH_DOWNLOAD
- INFO_CONTENT_LENGTH_DOWNLOAD_T = C.CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
- INFO_CONTENT_LENGTH_UPLOAD = C.CURLINFO_CONTENT_LENGTH_UPLOAD
- INFO_CONTENT_LENGTH_UPLOAD_T = C.CURLINFO_CONTENT_LENGTH_UPLOAD_T
- INFO_STARTTRANSFER_TIME = C.CURLINFO_STARTTRANSFER_TIME
- INFO_CONTENT_TYPE = C.CURLINFO_CONTENT_TYPE
- INFO_REDIRECT_TIME = C.CURLINFO_REDIRECT_TIME
- INFO_REDIRECT_COUNT = C.CURLINFO_REDIRECT_COUNT
- INFO_PRIVATE = C.CURLINFO_PRIVATE
- INFO_HTTP_CONNECTCODE = C.CURLINFO_HTTP_CONNECTCODE
- INFO_HTTPAUTH_AVAIL = C.CURLINFO_HTTPAUTH_AVAIL
- INFO_PROXYAUTH_AVAIL = C.CURLINFO_PROXYAUTH_AVAIL
- INFO_OS_ERRNO = C.CURLINFO_OS_ERRNO
- INFO_NUM_CONNECTS = C.CURLINFO_NUM_CONNECTS
- INFO_SSL_ENGINES = C.CURLINFO_SSL_ENGINES
- INFO_COOKIELIST = C.CURLINFO_COOKIELIST
- INFO_LASTSOCKET = C.CURLINFO_LASTSOCKET
- INFO_FTP_ENTRY_PATH = C.CURLINFO_FTP_ENTRY_PATH
- INFO_REDIRECT_URL = C.CURLINFO_REDIRECT_URL
- INFO_PRIMARY_IP = C.CURLINFO_PRIMARY_IP
- INFO_APPCONNECT_TIME = C.CURLINFO_APPCONNECT_TIME
- INFO_CERTINFO = C.CURLINFO_CERTINFO
- INFO_CONDITION_UNMET = C.CURLINFO_CONDITION_UNMET
- INFO_RTSP_SESSION_ID = C.CURLINFO_RTSP_SESSION_ID
- INFO_RTSP_CLIENT_CSEQ = C.CURLINFO_RTSP_CLIENT_CSEQ
- INFO_RTSP_SERVER_CSEQ = C.CURLINFO_RTSP_SERVER_CSEQ
- INFO_RTSP_CSEQ_RECV = C.CURLINFO_RTSP_CSEQ_RECV
- INFO_PRIMARY_PORT = C.CURLINFO_PRIMARY_PORT
- INFO_LOCAL_IP = C.CURLINFO_LOCAL_IP
- INFO_LOCAL_PORT = C.CURLINFO_LOCAL_PORT
- INFO_TLS_SESSION = C.CURLINFO_TLS_SESSION
- INFO_ACTIVESOCKET = C.CURLINFO_ACTIVESOCKET
- INFO_TLS_SSL_PTR = C.CURLINFO_TLS_SSL_PTR
- INFO_HTTP_VERSION = C.CURLINFO_HTTP_VERSION
- INFO_PROXY_SSL_VERIFYRESULT = C.CURLINFO_PROXY_SSL_VERIFYRESULT
- INFO_PROTOCOL = C.CURLINFO_PROTOCOL
- INFO_SCHEME = C.CURLINFO_SCHEME
- INFO_LASTONE = C.CURLINFO_LASTONE
- INFO_HTTP_CODE = C.CURLINFO_HTTP_CODE
-)
-
-// Auth
-const (
- AUTH_NONE = C.CURLAUTH_NONE & (1<<32 - 1)
- AUTH_BASIC = C.CURLAUTH_BASIC & (1<<32 - 1)
- AUTH_DIGEST = C.CURLAUTH_DIGEST & (1<<32 - 1)
- AUTH_NEGOTIATE = C.CURLAUTH_NEGOTIATE & (1<<32 - 1)
- AUTH_GSSNEGOTIATE = C.CURLAUTH_GSSNEGOTIATE & (1<<32 - 1)
- AUTH_GSSAPI = C.CURLAUTH_GSSAPI & (1<<32 - 1)
- AUTH_NTLM = C.CURLAUTH_NTLM & (1<<32 - 1)
- AUTH_DIGEST_IE = C.CURLAUTH_DIGEST_IE & (1<<32 - 1)
- AUTH_NTLM_WB = C.CURLAUTH_NTLM_WB & (1<<32 - 1)
- AUTH_ONLY = C.CURLAUTH_ONLY & (1<<32 - 1)
- AUTH_ANY = C.CURLAUTH_ANY & (1<<32 - 1)
- AUTH_ANYSAFE = C.CURLAUTH_ANYSAFE & (1<<32 - 1)
-)
-
-// generated ends
diff --git a/vendor/github.com/andelf/go-curl/core.go b/vendor/github.com/andelf/go-curl/core.go
deleted file mode 100644
index a4e0fc5..0000000
--- a/vendor/github.com/andelf/go-curl/core.go
+++ /dev/null
@@ -1,118 +0,0 @@
-// libcurl go bingding
-package curl
-
-/*
-#cgo linux pkg-config: libcurl
-#cgo darwin LDFLAGS: -lcurl
-#cgo windows LDFLAGS: -lcurl
-#include
-#include
-
-static char *string_array_index(char **p, int i) {
- return p[i];
-}
-*/
-import "C"
-
-import (
- "time"
- "unsafe"
-)
-
-// curl_global_init - Global libcurl initialisation
-func GlobalInit(flags int) error {
- return newCurlError(C.curl_global_init(C.long(flags)))
-}
-
-// curl_global_cleanup - global libcurl cleanup
-func GlobalCleanup() {
- C.curl_global_cleanup()
-}
-
-type VersionInfoData struct {
- Age C.CURLversion
- // age >= 0
- Version string
- VersionNum uint
- Host string
- Features int
- SslVersion string
- SslVersionNum int
- LibzVersion string
- Protocols []string
- // age >= 1
- Ares string
- AresNum int
- // age >= 2
- Libidn string
- // age >= 3
- IconvVerNum int
- LibsshVersion string
-}
-
-// curl_version - returns the libcurl version string
-func Version() string {
- return C.GoString(C.curl_version())
-}
-
-// curl_version_info - returns run-time libcurl version info
-func VersionInfo(ver C.CURLversion) *VersionInfoData {
- data := C.curl_version_info(ver)
- ret := new(VersionInfoData)
- ret.Age = data.age
- switch age := ret.Age; {
- case age >= 0:
- ret.Version = string(C.GoString(data.version))
- ret.VersionNum = uint(data.version_num)
- ret.Host = C.GoString(data.host)
- ret.Features = int(data.features)
- ret.SslVersion = C.GoString(data.ssl_version)
- ret.SslVersionNum = int(data.ssl_version_num)
- ret.LibzVersion = C.GoString(data.libz_version)
- // ugly but works
- ret.Protocols = []string{}
- for i := C.int(0); C.string_array_index(data.protocols, i) != nil; i++ {
- p := C.string_array_index(data.protocols, i)
- ret.Protocols = append(ret.Protocols, C.GoString(p))
- }
- fallthrough
- case age >= 1:
- ret.Ares = C.GoString(data.ares)
- ret.AresNum = int(data.ares_num)
- fallthrough
- case age >= 2:
- ret.Libidn = C.GoString(data.libidn)
- fallthrough
- case age >= 3:
- ret.IconvVerNum = int(data.iconv_ver_num)
- ret.LibsshVersion = C.GoString(data.libssh_version)
- }
- return ret
-}
-
-// curl_getdate - Convert a date string to number of seconds since January 1, 1970
-// In golang, we convert it to a *time.Time
-func Getdate(date string) *time.Time {
- datestr := C.CString(date)
- defer C.free(unsafe.Pointer(datestr))
- t := C.curl_getdate(datestr, nil)
- if t == -1 {
- return nil
- }
- unix := time.Unix(int64(t), 0).UTC()
- return &unix
-
- /*
- // curl_getenv - return value for environment name
- func Getenv(name string) string {
- namestr := C.CString(name)
- defer C.free(unsafe.Pointer(namestr))
- ret := C.curl_getenv(unsafe.Pointer(namestr))
- defer C.free(unsafe.Pointer(ret))
-
- return C.GoString(ret)
- }
- */
-}
-
-// TODO: curl_global_init_mem
diff --git a/vendor/github.com/andelf/go-curl/core_test.go b/vendor/github.com/andelf/go-curl/core_test.go
deleted file mode 100644
index 7943282..0000000
--- a/vendor/github.com/andelf/go-curl/core_test.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package curl
-
-import (
- "testing"
-)
-
-func TestVersionInfo(t *testing.T) {
- info := VersionInfo(VERSION_FIRST)
- expectedProtocols := []string{"dict", "file", "ftp", "ftps", "gopher", "http", "https", "imap", "imaps", "ldap", "ldaps", "pop3", "pop3s", "rtmp", "rtsp", "smtp", "smtps", "telnet", "tftp", "scp", "sftp", "smb", "smbs"}
- protocols := info.Protocols
- for _, protocol := range protocols {
- found := false
- for _, expectedProtocol := range expectedProtocols {
- if expectedProtocol == protocol {
- found = true
- break
- }
- }
- if !found {
- t.Errorf("protocol should be in %v and is %v.", expectedProtocols, protocol)
- }
- }
-}
diff --git a/vendor/github.com/andelf/go-curl/easy.go b/vendor/github.com/andelf/go-curl/easy.go
deleted file mode 100644
index e0cec43..0000000
--- a/vendor/github.com/andelf/go-curl/easy.go
+++ /dev/null
@@ -1,527 +0,0 @@
-package curl
-
-/*
-#include
-#include
-#include "callback.h"
-#include "compat.h"
-
-static CURLcode curl_easy_setopt_long(CURL *handle, CURLoption option, long parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-static CURLcode curl_easy_setopt_string(CURL *handle, CURLoption option, char *parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-static CURLcode curl_easy_setopt_slist(CURL *handle, CURLoption option, struct curl_slist *parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-static CURLcode curl_easy_setopt_pointer(CURL *handle, CURLoption option, void *parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-static CURLcode curl_easy_setopt_off_t(CURL *handle, CURLoption option, off_t parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-
-static CURLcode curl_easy_getinfo_string(CURL *curl, CURLINFO info, char **p) {
- return curl_easy_getinfo(curl, info, p);
-}
-static CURLcode curl_easy_getinfo_long(CURL *curl, CURLINFO info, long *p) {
- return curl_easy_getinfo(curl, info, p);
-}
-static CURLcode curl_easy_getinfo_double(CURL *curl, CURLINFO info, double *p) {
- return curl_easy_getinfo(curl, info, p);
-}
-static CURLcode curl_easy_getinfo_slist(CURL *curl, CURLINFO info, struct curl_slist **p) {
- return curl_easy_getinfo(curl, info, p);
-}
-
-static CURLFORMcode curl_formadd_name_content_length(
- struct curl_httppost **httppost, struct curl_httppost **last_post, char *name, char *content, int length) {
- return curl_formadd(httppost, last_post,
- CURLFORM_COPYNAME, name,
- CURLFORM_COPYCONTENTS, content,
- CURLFORM_CONTENTSLENGTH, length, CURLFORM_END);
-}
-static CURLFORMcode curl_formadd_name_content_length_type(
- struct curl_httppost **httppost, struct curl_httppost **last_post, char *name, char *content, int length, char *type) {
- return curl_formadd(httppost, last_post,
- CURLFORM_COPYNAME, name,
- CURLFORM_COPYCONTENTS, content,
- CURLFORM_CONTENTSLENGTH, length,
- CURLFORM_CONTENTTYPE, type, CURLFORM_END);
-}
-static CURLFORMcode curl_formadd_name_file_type(
- struct curl_httppost **httppost, struct curl_httppost **last_post, char *name, char *filename, char *type) {
- return curl_formadd(httppost, last_post,
- CURLFORM_COPYNAME, name,
- CURLFORM_FILE, filename,
- CURLFORM_CONTENTTYPE, type, CURLFORM_END);
-}
- // TODO: support multi file
-
-*/
-import "C"
-
-import (
- "fmt"
- "mime"
- "path"
- "unsafe"
- "sync"
-)
-
-type CurlInfo C.CURLINFO
-type CurlError C.CURLcode
-
-type CurlString *C.char
-
-func NewCurlString(s string) CurlString {
- return CurlString(unsafe.Pointer(C.CString(s)))
-}
-
-func FreeCurlString(s CurlString) {
- C.free(unsafe.Pointer(s))
-}
-
-func (e CurlError) Error() string {
- // ret is const char*, no need to free
- ret := C.curl_easy_strerror(C.CURLcode(e))
- return fmt.Sprintf("curl: %s", C.GoString(ret))
-}
-
-func newCurlError(errno C.CURLcode) error {
- if errno == C.CURLE_OK { // if nothing wrong
- return nil
- }
- return CurlError(errno)
-}
-
-// curl_easy interface
-type CURL struct {
- handle unsafe.Pointer
- // callback functions, bool ret means ok or not
- headerFunction, writeFunction *func([]byte, interface{}) bool
- readFunction *func([]byte, interface{}) int // return num of bytes writed to buf
- progressFunction *func(float64, float64, float64, float64, interface{}) bool
- fnmatchFunction *func(string, string, interface{}) int
- // callback datas
- headerData, writeData, readData, progressData, fnmatchData interface{}
- // list of C allocs
- mallocAllocs []*C.char
-}
-
-// concurrent safe context map
-type contextMap struct {
- items map[uintptr]*CURL
- sync.RWMutex
-}
-
-func (c *contextMap) Set(k uintptr, v *CURL) {
- c.Lock()
- defer c.Unlock()
-
- c.items[k] = v
-}
-
-func (c *contextMap) Get(k uintptr) *CURL {
- c.RLock()
- defer c.RUnlock()
-
- return c.items[k]
-}
-
-func (c *contextMap) Delete(k uintptr) {
- c.Lock()
- defer c.Unlock()
-
- delete(c.items, k)
-}
-
-var context_map = &contextMap {
- items: make(map[uintptr]*CURL),
-}
-
-// curl_easy_init - Start a libcurl easy session
-func EasyInit() *CURL {
- p := C.curl_easy_init()
- c := &CURL{handle: p, mallocAllocs: make([]*C.char, 0)} // other field defaults to nil
- context_map.Set(uintptr(p), c)
- return c
-}
-
-// curl_easy_duphandle - Clone a libcurl session handle
-func (curl *CURL) Duphandle() *CURL {
- p := C.curl_easy_duphandle(curl.handle)
- c := &CURL{handle: p}
- context_map.Set(uintptr(p), c)
- return c
-}
-
-// curl_easy_cleanup - End a libcurl easy session
-func (curl *CURL) Cleanup() {
- p := curl.handle
- C.curl_easy_cleanup(p)
- curl.MallocFreeAfter(0)
- context_map.Delete(uintptr(p))
-}
-
-// curl_easy_setopt - set options for a curl easy handle
-// WARNING: a function pointer is &fun, but function addr is reflect.ValueOf(fun).Pointer()
-func (curl *CURL) Setopt(opt int, param interface{}) error {
- p := curl.handle
- if param == nil {
- // NOTE: some option will crash program when got a nil param
- return newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), nil))
- }
- switch {
- // not really set
- case opt == OPT_READDATA: // OPT_INFILE
- curl.readData = param
- return nil
- case opt == OPT_PROGRESSDATA:
- curl.progressData = param
- return nil
- case opt == OPT_HEADERDATA: // also known as OPT_WRITEHEADER
- curl.headerData = param
- return nil
- case opt == OPT_WRITEDATA: // OPT_FILE
- curl.writeData = param
- return nil
-
- case opt == OPT_READFUNCTION:
- fun := param.(func([]byte, interface{}) int)
- curl.readFunction = &fun
-
- ptr := C.return_read_function()
- if err := newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), ptr)); err == nil {
- return newCurlError(C.curl_easy_setopt_pointer(p, OPT_READDATA, unsafe.Pointer(curl.handle)))
- } else {
- return err
- }
-
- case opt == OPT_PROGRESSFUNCTION:
- fun := param.(func(float64, float64, float64, float64, interface{}) bool)
- curl.progressFunction = &fun
-
- ptr := C.return_progress_function()
- if err := newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), ptr)); err == nil {
- return newCurlError(C.curl_easy_setopt_pointer(p, OPT_PROGRESSDATA, unsafe.Pointer(curl.handle)))
- } else {
- return err
- }
-
- case opt == OPT_HEADERFUNCTION:
- fun := param.(func([]byte, interface{}) bool)
- curl.headerFunction = &fun
-
- ptr := C.return_header_function()
- if err := newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), ptr)); err == nil {
- return newCurlError(C.curl_easy_setopt_pointer(p, OPT_HEADERDATA, unsafe.Pointer(curl.handle)))
- } else {
- return err
- }
-
- case opt == OPT_WRITEFUNCTION:
- fun := param.(func([]byte, interface{}) bool)
- curl.writeFunction = &fun
-
- ptr := C.return_write_function()
- if err := newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), ptr)); err == nil {
- return newCurlError(C.curl_easy_setopt_pointer(p, OPT_WRITEDATA, unsafe.Pointer(curl.handle)))
- } else {
- return err
- }
-
- // for OPT_HTTPPOST, use struct Form
- case opt == OPT_HTTPPOST:
- post := param.(*Form)
- ptr := post.head
- return newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), unsafe.Pointer(ptr)))
-
- case opt >= C.CURLOPTTYPE_OFF_T:
- val := C.off_t(0)
- switch t := param.(type) {
- case int:
- val = C.off_t(t)
- case uint64:
- val = C.off_t(t)
- default:
- panic("OFF_T conversion not supported")
- }
- return newCurlError(C.curl_easy_setopt_off_t(p, C.CURLoption(opt), val))
-
- case opt >= C.CURLOPTTYPE_FUNCTIONPOINT:
- // function pointer
- panic("function pointer not implemented yet!")
-
- case opt >= C.CURLOPTTYPE_OBJECTPOINT:
- switch t := param.(type) {
- case string:
- ptr := C.CString(t)
- curl.mallocAddPtr(ptr)
- return newCurlError(C.curl_easy_setopt_string(p, C.CURLoption(opt), ptr))
- case CurlString:
- ptr := (*C.char)(t)
- return newCurlError(C.curl_easy_setopt_string(p, C.CURLoption(opt), ptr))
- case []string:
- if len(t) > 0 {
- ptr := C.CString(t[0])
- curl.mallocAddPtr(ptr)
- a_slist := C.curl_slist_append(nil, ptr)
- for _, s := range t[1:] {
- ptr := C.CString(s)
- curl.mallocAddPtr(ptr)
- a_slist = C.curl_slist_append(a_slist, ptr)
- }
- return newCurlError(C.curl_easy_setopt_slist(p, C.CURLoption(opt), a_slist))
- } else {
- return newCurlError(C.curl_easy_setopt_slist(p, C.CURLoption(opt), nil))
- }
- case []CurlString:
- if len(t) > 0 {
- ptr := (*C.char)(t[0])
- a_slist := C.curl_slist_append(nil, ptr)
- for _, s := range t[1:] {
- ptr := (*C.char)(s)
- a_slist = C.curl_slist_append(a_slist, ptr)
- }
- return newCurlError(C.curl_easy_setopt_slist(p, C.CURLoption(opt), a_slist))
- } else {
- return newCurlError(C.curl_easy_setopt_slist(p, C.CURLoption(opt), nil))
- }
- default:
- // It panics if v's Kind is not Chan, Func, Map, Ptr, Slice, or UnsafePointer.
- // val := reflect.ValueOf(param)
- //fmt.Printf("DEBUG(Setopt): param=%x\n", val.Pointer())
- //println("DEBUG can addr =", val.Pointer(), "opt=", opt)
- // pass a pointer to GoInterface
- return newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt),
- unsafe.Pointer(¶m)))
- }
- case opt >= C.CURLOPTTYPE_LONG:
- val := C.long(0)
- switch t := param.(type) {
- case int:
- val = C.long(t)
- case bool:
- if t {
- val = 1
- }
- case int64:
- val = C.long(t)
- case int32:
- val = C.long(t)
- default:
- panic("not supported converstion to c long")
- }
- return newCurlError(C.curl_easy_setopt_long(p, C.CURLoption(opt), val))
- }
- panic("opt param error!")
-}
-
-// curl_easy_send - sends raw data over an "easy" connection
-func (curl *CURL) Send(buffer []byte) (int, error) {
- p := curl.handle
- buflen := len(buffer)
- n := C.size_t(0)
- ret := C.curl_easy_send(p, unsafe.Pointer(&buffer[0]), C.size_t(buflen), &n)
- return int(n), newCurlError(ret)
-}
-
-// curl_easy_recv - receives raw data on an "easy" connection
-func (curl *CURL) Recv(buffer []byte) (int, error) {
- p := curl.handle
- buflen := len(buffer)
- buf := C.CString(string(buffer))
- n := C.size_t(0)
- ret := C.curl_easy_recv(p, unsafe.Pointer(buf), C.size_t(buflen), &n)
- return copy(buffer, C.GoStringN(buf, C.int(n))), newCurlError(ret)
-}
-
-// curl_easy_perform - Perform a file transfer
-func (curl *CURL) Perform() error {
- p := curl.handle
- return newCurlError(C.curl_easy_perform(p))
-}
-
-// curl_easy_pause - pause and unpause a connection
-func (curl *CURL) Pause(bitmask int) error {
- p := curl.handle
- return newCurlError(C.curl_easy_pause(p, C.int(bitmask)))
-}
-
-// curl_easy_reset - reset all options of a libcurl session handle
-func (curl *CURL) Reset() {
- p := curl.handle
- C.curl_easy_reset(p)
-}
-
-// curl_easy_escape - URL encodes the given string
-func (curl *CURL) Escape(url string) string {
- p := curl.handle
- oldUrl := C.CString(url)
- defer C.free(unsafe.Pointer(oldUrl))
- newUrl := C.curl_easy_escape(p, oldUrl, 0)
- defer C.curl_free(unsafe.Pointer(newUrl))
- return C.GoString(newUrl)
-}
-
-// curl_easy_unescape - URL decodes the given string
-func (curl *CURL) Unescape(url string) string {
- p := curl.handle
- oldUrl := C.CString(url)
- outlength := C.int(0)
- defer C.free(unsafe.Pointer(oldUrl))
- // If outlength is non-NULL, the function will write the length of the
- // returned string in the integer it points to. This allows an
- // escaped string containing %00 to still get used properly after unescaping.
- newUrl := C.curl_easy_unescape(p, oldUrl, 0, &outlength)
- defer C.curl_free(unsafe.Pointer(newUrl))
- return C.GoStringN(newUrl, outlength)
-}
-
-// curl_easy_getinfo - extract information from a curl handle
-func (curl *CURL) Getinfo(info CurlInfo) (ret interface{}, err error) {
- p := curl.handle
- cInfo := C.CURLINFO(info)
- switch cInfo & C.CURLINFO_TYPEMASK {
- case C.CURLINFO_STRING:
- a_string := C.CString("")
- defer C.free(unsafe.Pointer(a_string))
- err := newCurlError(C.curl_easy_getinfo_string(p, cInfo, &a_string))
- ret := C.GoString(a_string)
- debugf("Getinfo %s", ret)
- return ret, err
- case C.CURLINFO_LONG:
- a_long := C.long(-1)
- err := newCurlError(C.curl_easy_getinfo_long(p, cInfo, &a_long))
- ret := int(a_long)
- debugf("Getinfo %s", ret)
- return ret, err
- case C.CURLINFO_DOUBLE:
- a_double := C.double(0.0)
- err := newCurlError(C.curl_easy_getinfo_double(p, cInfo, &a_double))
- ret := float64(a_double)
- debugf("Getinfo %s", ret)
- return ret, err
- case C.CURLINFO_SLIST:
- a_ptr_slist := new(_Ctype_struct_curl_slist)
- err := newCurlError(C.curl_easy_getinfo_slist(p, cInfo, &a_ptr_slist))
- ret := []string{}
- for a_ptr_slist != nil {
- debugf("Getinfo %s %v", C.GoString(a_ptr_slist.data), a_ptr_slist.next)
- ret = append(ret, C.GoString(a_ptr_slist.data))
- a_ptr_slist = a_ptr_slist.next
- }
- return ret, err
- default:
- panic("error calling Getinfo\n")
- }
- panic("not implemented yet!")
- return nil, nil
-}
-
-func (curl *CURL) GetHandle() unsafe.Pointer {
- return curl.handle
-}
-
-func (curl *CURL) MallocGetPos() int {
- return len(curl.mallocAllocs)
-}
-
-func (curl *CURL) MallocFreeAfter(from int) {
- l := len(curl.mallocAllocs)
- for idx := from; idx < l; idx++ {
- C.free(unsafe.Pointer(curl.mallocAllocs[idx]))
- curl.mallocAllocs[idx] = nil
- }
- curl.mallocAllocs = curl.mallocAllocs[0:from]
-}
-
-func (curl *CURL) mallocAddPtr(ptr *C.char) {
- curl.mallocAllocs = append(curl.mallocAllocs, ptr)
-}
-
-// A multipart/formdata HTTP POST form
-type Form struct {
- head, last *C.struct_curl_httppost
-}
-
-func NewForm() *Form {
- return &Form{}
-}
-
-func (form *Form) Add(name string, content interface{}) error {
- head, last := form.head, form.last
- namestr := C.CString(name)
- defer C.free(unsafe.Pointer(namestr))
- var (
- buffer *C.char
- length C.int
- )
- switch t := content.(type) {
- case string:
- buffer = C.CString(t)
- length = C.int(len(t))
- case []byte:
- buffer = C.CString(string(t))
- length = C.int(len(t))
- default:
- panic("not implemented")
- }
- defer C.free(unsafe.Pointer(buffer))
- C.curl_formadd_name_content_length(&head, &last, namestr, buffer, length)
- form.head, form.last = head, last
- return nil
-}
-
-func (form *Form) AddWithType(name string, content interface{}, content_type string) error {
- head, last := form.head, form.last
- namestr := C.CString(name)
- typestr := C.CString(content_type)
- defer C.free(unsafe.Pointer(namestr))
- defer C.free(unsafe.Pointer(typestr))
- var (
- buffer *C.char
- length C.int
- )
- switch t := content.(type) {
- case string:
- buffer = C.CString(t)
- length = C.int(len(t))
- case []byte:
- buffer = C.CString(string(t))
- length = C.int(len(t))
- default:
- panic("not implemented")
- }
- defer C.free(unsafe.Pointer(buffer))
- C.curl_formadd_name_content_length_type(&head, &last, namestr, buffer, length, typestr)
- form.head, form.last = head, last
- return nil
-}
-
-func (form *Form) AddFile(name, filename string) error {
- head, last := form.head, form.last
- namestr := C.CString(name)
- pathstr := C.CString(filename)
- typestr := C.CString(guessType(filename))
- defer C.free(unsafe.Pointer(namestr))
- defer C.free(unsafe.Pointer(pathstr))
- defer C.free(unsafe.Pointer(typestr))
- C.curl_formadd_name_file_type(&head, &last, namestr, pathstr, typestr)
- form.head, form.last = head, last
- return nil
-}
-
-func (form *Form) AddFromFile(name, filename string) {
-}
-
-func guessType(filename string) string {
- ext := path.Ext(filename)
- file_type := mime.TypeByExtension(ext)
- if file_type == "" {
- return "application/octet-stream"
- }
- return file_type
-}
diff --git a/vendor/github.com/andelf/go-curl/easy_test.go b/vendor/github.com/andelf/go-curl/easy_test.go
deleted file mode 100644
index 3a186ae..0000000
--- a/vendor/github.com/andelf/go-curl/easy_test.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package curl
-
-import (
- "fmt"
- "net/http"
- "net/http/httptest"
- "testing"
- "sync"
-)
-
-func setupTestServer(serverContent string) *httptest.Server {
- return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintln(w, serverContent)
- }))
-}
-
-func TestEasyInterface(t *testing.T) {
- ts := setupTestServer("")
- defer ts.Close()
-
- easy := EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(OPT_URL, ts.URL)
- if err := easy.Perform(); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestCallbackFunction(t *testing.T) {
- serverContent := "A random string"
- ts := setupTestServer(serverContent)
- defer ts.Close()
-
- easy := EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(OPT_URL, ts.URL)
- easy.Setopt(OPT_WRITEFUNCTION, func(buf []byte, userdata interface{}) bool {
- result := string(buf)
- expected := serverContent + "\n"
- if result != expected {
- t.Errorf("output should be %q and is %q.", expected, result)
- }
- return true
- })
- if err := easy.Perform(); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestEscape(t *testing.T) {
- easy := EasyInit()
- defer easy.Cleanup()
-
- payload := `payload={"msg": "First line\nSecond Line"}`
- expected := `payload%3D%7B%22msg%22%3A%20%22First%20line%5CnSecond%20Line%22%7D`
- result := easy.Escape(payload)
- if result != expected {
- t.Errorf("escaped output should be %q and is %q.", expected, result)
- }
-}
-
-func TestConcurrentInitAndCleanup(t *testing.T) {
- c := 2
- var wg sync.WaitGroup
- wg.Add(c)
- for i := 0; i < c; i++ {
- go func() {
- wg.Done()
- easy := EasyInit()
- defer easy.Cleanup()
- }()
- }
-
- wg.Wait()
-}
diff --git a/vendor/github.com/andelf/go-curl/logging.go b/vendor/github.com/andelf/go-curl/logging.go
deleted file mode 100644
index 8976233..0000000
--- a/vendor/github.com/andelf/go-curl/logging.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package curl
-
-import (
- "log"
-)
-
-const (
- _DEBUG = 10 * (iota + 1)
- _INFO
- _WARN
- _ERROR
-)
-
-const _DEFAULT_LOG_LEVEL = _WARN
-
-var log_level = _DEFAULT_LOG_LEVEL
-
-// SetLogLevel changes the log level which determines the granularity of the
-// messages that are logged. Available log levels are: "DEBUG", "INFO",
-// "WARN", "ERROR" and "DEFAULT_LOG_LEVEL".
-func SetLogLevel(levelName string) {
- switch levelName {
- case "DEBUG":
- log_level = _DEBUG
- case "INFO":
- log_level = _INFO
- case "WARN":
- log_level = _WARN
- case "ERROR":
- log_level = _ERROR
- case "DEFAULT_LOG_LEVEL":
- log_level = _DEFAULT_LOG_LEVEL
- }
-}
-
-func logf(limitLevel int, format string, args ...interface{}) {
- if log_level <= limitLevel {
- log.Printf(format, args...)
- }
-}
-
-func debugf(format string, args ...interface{}) {
- logf(_DEBUG, format, args...)
-}
-
-func infof(format string, args ...interface{}) {
- logf(_INFO, format, args...)
-}
-
-func warnf(format string, args ...interface{}) {
- logf(_WARN, format, args...)
-}
-
-func errorf(format string, args ...interface{}) {
- logf(_ERROR, format, args...)
-}
diff --git a/vendor/github.com/andelf/go-curl/logging_test.go b/vendor/github.com/andelf/go-curl/logging_test.go
deleted file mode 100644
index 387705a..0000000
--- a/vendor/github.com/andelf/go-curl/logging_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-
-package curl
-
-import (
- "testing"
- "bytes"
- "log"
- "os"
- "fmt"
- "regexp"
-)
-
-func TestDefaultLogLevel(t *testing.T) {
- if log_level != _DEFAULT_LOG_LEVEL {t.Error("Test failed, expected DEFAULT_LOG_LEVEL level.")}
-}
-
-func TestSetLogLevel(t *testing.T) {
- SetLogLevel("DEBUG")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
- if log_level != _DEBUG {t.Error("Test failed, expected DEBUG level.")}
- SetLogLevel("INFO")
- if log_level != _INFO {t.Error("Test failed, expected INFO level.")}
- SetLogLevel("WARN")
- if log_level != _WARN {t.Error("Test failed, expected WARN level.")}
- SetLogLevel("ERROR")
- if log_level != _ERROR {t.Error("Test failed, expected ERROR level.")}
-}
-
-var (
- testFormat = "test format %s"
- testArgument = "test string 1"
- expectedRegexp = regexp.MustCompile(".*" + fmt.Sprintf(testFormat, testArgument) + "\n$")
-)
-
-
-func TestLogf(t *testing.T) {
- buf := new(bytes.Buffer)
- log.SetOutput(buf)
- defer log.SetOutput(os.Stderr)
- SetLogLevel("DEBUG")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
-
- logf(_DEBUG, testFormat, testArgument)
- line := buf.String()
- matched := expectedRegexp.MatchString(line)
- if !matched {
- t.Errorf("log output should match %q and is %q.", expectedRegexp, line)
- }
-}
-
-func TestLogfUsesLogLevel(t *testing.T) {
- buf := new(bytes.Buffer)
- log.SetOutput(buf)
- defer log.SetOutput(os.Stderr)
- SetLogLevel("WARN")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
-
- logf(_DEBUG, testFormat, testArgument)
- line := buf.String()
- expectedLine := ""
- if line != expectedLine {
- t.Errorf("log output should match %q and is %q.", expectedLine, line)
- }
-}
diff --git a/vendor/github.com/andelf/go-curl/multi.go b/vendor/github.com/andelf/go-curl/multi.go
deleted file mode 100644
index 5794717..0000000
--- a/vendor/github.com/andelf/go-curl/multi.go
+++ /dev/null
@@ -1,160 +0,0 @@
-// This file depends on functionality not available on Windows, hence we
-// must skip it. https://github.com/andelf/go-curl/issues/48
-
-// +build !windows
-
-package curl
-
-/*
-#include
-#include
-
-static CURLMcode curl_multi_setopt_long(CURLM *handle, CURLMoption option, long parameter) {
- return curl_multi_setopt(handle, option, parameter);
-}
-static CURLMcode curl_multi_setopt_pointer(CURLM *handle, CURLMoption option, void *parameter) {
- return curl_multi_setopt(handle, option, parameter);
-}
-static CURLMcode curl_multi_fdset_pointer(CURLM *handle,
- void *read_fd_set,
- void *write_fd_set,
- void *exc_fd_set,
- int *max_fd)
-{
- return curl_multi_fdset(handle, read_fd_set, write_fd_set, exc_fd_set, max_fd);
-}
-static CURLMsg *curl_multi_info_read_pointer(CURLM *handle, int *msgs_in_queue)
-{
- return curl_multi_info_read(handle, msgs_in_queue);
-}
-*/
-import "C"
-
-import (
- "unsafe"
- "syscall"
-)
-
-type CurlMultiError C.CURLMcode
-type CurlMultiMsg C.CURLMSG
-
-func (e CurlMultiError) Error() string {
- // ret is const char*, no need to free
- ret := C.curl_multi_strerror(C.CURLMcode(e))
- return C.GoString(ret)
-}
-
-func newCurlMultiError(errno C.CURLMcode) error {
- // cannot use C.CURLM_OK here, cause multi.h use a undefined emum num
- if errno == 0 { // if nothing wrong
- return nil
- }
- return CurlMultiError(errno)
-}
-
-func newCURLMessage(message *C.CURLMsg) (msg *CURLMessage){
- if message == nil {
- return nil
- }
- msg = new(CURLMessage)
- msg.Msg = CurlMultiMsg(message.msg)
- msg.Easy_handle = &CURL{handle: message.easy_handle}
- msg.Data = message.data
- return msg
-}
-
-type CURLM struct {
- handle unsafe.Pointer
-}
-
-var dummy unsafe.Pointer
-type CURLMessage struct {
- Msg CurlMultiMsg
- Easy_handle *CURL
- Data [unsafe.Sizeof(dummy)]byte
-}
-
-// curl_multi_init - create a multi handle
-func MultiInit() *CURLM {
- p := C.curl_multi_init()
- return &CURLM{p}
-}
-
-// curl_multi_cleanup - close down a multi session
-func (mcurl *CURLM) Cleanup() error {
- p := mcurl.handle
- return newCurlMultiError(C.curl_multi_cleanup(p))
-}
-
-// curl_multi_perform - reads/writes available data from each easy handle
-func (mcurl *CURLM) Perform() (int, error) {
- p := mcurl.handle
- running_handles := C.int(-1)
- err := newCurlMultiError(C.curl_multi_perform(p, &running_handles))
- return int(running_handles), err
-}
-
-// curl_multi_add_handle - add an easy handle to a multi session
-func (mcurl *CURLM) AddHandle(easy *CURL) error {
- mp := mcurl.handle
- easy_handle := easy.handle
- return newCurlMultiError(C.curl_multi_add_handle(mp, easy_handle))
-}
-
-// curl_multi_remove_handle - remove an easy handle from a multi session
-func (mcurl *CURLM) RemoveHandle(easy *CURL) error {
- mp := mcurl.handle
- easy_handle := easy.handle
- return newCurlMultiError(C.curl_multi_remove_handle(mp, easy_handle))
-}
-
-func (mcurl *CURLM) Timeout() (int, error) {
- p := mcurl.handle
- timeout := C.long(-1)
- err := newCurlMultiError(C.curl_multi_timeout(p, &timeout))
- return int(timeout), err
-}
-
-func (mcurl *CURLM) Setopt(opt int, param interface{}) error {
- p := mcurl.handle
- if param == nil {
- return newCurlMultiError(C.curl_multi_setopt_pointer(p, C.CURLMoption(opt), nil))
- }
- switch {
- // currently cannot support these option
- // case MOPT_SOCKETFUNCTION, MOPT_SOCKETDATA, MOPT_TIMERFUNCTION, MOPT_TIMERDATA:
- // panic("not supported CURLM.Setopt opt")
- case opt >= C.CURLOPTTYPE_LONG:
- val := C.long(0)
- switch t := param.(type) {
- case int:
- val := C.long(t)
- return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
- case bool:
- val = C.long(0)
- if t {
- val = C.long(1)
- }
- return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
- }
- }
- panic("not supported CURLM.Setopt opt or param")
- return nil
-}
-
-func (mcurl *CURLM) Fdset(rset, wset, eset *syscall.FdSet) (int, error) {
- p := mcurl.handle
- read := unsafe.Pointer(rset)
- write := unsafe.Pointer(wset)
- exc := unsafe.Pointer(eset)
- maxfd := C.int(-1)
- err := newCurlMultiError(C.curl_multi_fdset_pointer(p, read, write,
- exc, &maxfd))
- return int(maxfd), err
-}
-
-func (mcurl *CURLM) Info_read() (*CURLMessage, int) {
- p := mcurl.handle
- left := C.int(0)
- return newCURLMessage(C.curl_multi_info_read_pointer(p, &left)), int(left)
-}
diff --git a/vendor/github.com/andelf/go-curl/share.go b/vendor/github.com/andelf/go-curl/share.go
deleted file mode 100644
index 8d1e16d..0000000
--- a/vendor/github.com/andelf/go-curl/share.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package curl
-
-/*
-#include
-
-static CURLSHcode curl_share_setopt_long(CURLSH *handle, CURLSHoption option, long parameter) {
- return curl_share_setopt(handle, option, parameter);
-}
-static CURLSHcode curl_share_setopt_pointer(CURLSH *handle, CURLSHoption option, void *parameter) {
- return curl_share_setopt(handle, option, parameter);
-}
-*/
-import "C"
-
-import "unsafe"
-
-// implement os.Error interface
-type CurlShareError C.CURLMcode
-
-func (e CurlShareError) Error() string {
- // ret is const char*, no need to free
- ret := C.curl_share_strerror(C.CURLSHcode(e))
- return C.GoString(ret)
-}
-
-func newCurlShareError(errno C.CURLSHcode) error {
- if errno == 0 { // if nothing wrong
- return nil
- }
- return CurlShareError(errno)
-}
-
-type CURLSH struct {
- handle unsafe.Pointer
-}
-
-func ShareInit() *CURLSH {
- p := C.curl_share_init()
- return &CURLSH{p}
-}
-
-func (shcurl *CURLSH) Cleanup() error {
- p := shcurl.handle
- return newCurlShareError(C.curl_share_cleanup(p))
-}
-
-func (shcurl *CURLSH) Setopt(opt int, param interface{}) error {
- p := shcurl.handle
- if param == nil {
- return newCurlShareError(C.curl_share_setopt_pointer(p, C.CURLSHoption(opt), nil))
- }
- switch opt {
- // case SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC, SHOPT_USERDATA:
- // panic("not supported")
- case SHOPT_SHARE, SHOPT_UNSHARE:
- if val, ok := param.(int); ok {
- return newCurlShareError(C.curl_share_setopt_long(p, C.CURLSHoption(opt), C.long(val)))
- }
- }
- panic("not supported CURLSH.Setopt opt or param")
- return nil
-}
diff --git a/vendor/github.com/davecgh/go-spew/.gitignore b/vendor/github.com/davecgh/go-spew/.gitignore
deleted file mode 100644
index 0026861..0000000
--- a/vendor/github.com/davecgh/go-spew/.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/vendor/github.com/davecgh/go-spew/.travis.yml b/vendor/github.com/davecgh/go-spew/.travis.yml
deleted file mode 100644
index 1f4cbf5..0000000
--- a/vendor/github.com/davecgh/go-spew/.travis.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-language: go
-go_import_path: github.com/davecgh/go-spew
-go:
- - 1.6.x
- - 1.7.x
- - 1.8.x
- - 1.9.x
- - 1.10.x
- - tip
-sudo: false
-install:
- - go get -v github.com/alecthomas/gometalinter
- - gometalinter --install
-script:
- - export PATH=$PATH:$HOME/gopath/bin
- - export GORACE="halt_on_error=1"
- - test -z "$(gometalinter --disable-all
- --enable=gofmt
- --enable=golint
- --enable=vet
- --enable=gosimple
- --enable=unconvert
- --deadline=4m ./spew | tee /dev/stderr)"
- - go test -v -race -tags safe ./spew
- - go test -v -race -tags testcgo ./spew -covermode=atomic -coverprofile=profile.cov
-after_success:
- - go get -v github.com/mattn/goveralls
- - goveralls -coverprofile=profile.cov -service=travis-ci
diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE
deleted file mode 100644
index bc52e96..0000000
--- a/vendor/github.com/davecgh/go-spew/LICENSE
+++ /dev/null
@@ -1,15 +0,0 @@
-ISC License
-
-Copyright (c) 2012-2016 Dave Collins
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/vendor/github.com/davecgh/go-spew/README.md b/vendor/github.com/davecgh/go-spew/README.md
deleted file mode 100644
index f6ed02c..0000000
--- a/vendor/github.com/davecgh/go-spew/README.md
+++ /dev/null
@@ -1,201 +0,0 @@
-go-spew
-=======
-
-[](https://travis-ci.org/davecgh/go-spew)
-[](http://copyfree.org)
-[](https://coveralls.io/r/davecgh/go-spew?branch=master)
-
-Go-spew implements a deep pretty printer for Go data structures to aid in
-debugging. A comprehensive suite of tests with 100% test coverage is provided
-to ensure proper functionality. See `test_coverage.txt` for the gocov coverage
-report. Go-spew is licensed under the liberal ISC license, so it may be used in
-open source or commercial projects.
-
-If you're interested in reading about how this package came to life and some
-of the challenges involved in providing a deep pretty printer, there is a blog
-post about it
-[here](https://web.archive.org/web/20160304013555/https://blog.cyphertite.com/go-spew-a-journey-into-dumping-go-data-structures/).
-
-## Documentation
-
-[](http://godoc.org/github.com/davecgh/go-spew/spew)
-
-Full `go doc` style documentation for the project can be viewed online without
-installing this package by using the excellent GoDoc site here:
-http://godoc.org/github.com/davecgh/go-spew/spew
-
-You can also view the documentation locally once the package is installed with
-the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to
-http://localhost:6060/pkg/github.com/davecgh/go-spew/spew
-
-## Installation
-
-```bash
-$ go get -u github.com/davecgh/go-spew/spew
-```
-
-## Quick Start
-
-Add this import line to the file you're working in:
-
-```Go
-import "github.com/davecgh/go-spew/spew"
-```
-
-To dump a variable with full newlines, indentation, type, and pointer
-information use Dump, Fdump, or Sdump:
-
-```Go
-spew.Dump(myVar1, myVar2, ...)
-spew.Fdump(someWriter, myVar1, myVar2, ...)
-str := spew.Sdump(myVar1, myVar2, ...)
-```
-
-Alternatively, if you would prefer to use format strings with a compacted inline
-printing style, use the convenience wrappers Printf, Fprintf, etc with %v (most
-compact), %+v (adds pointer addresses), %#v (adds types), or %#+v (adds types
-and pointer addresses):
-
-```Go
-spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
-spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
-spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
-spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
-```
-
-## Debugging a Web Application Example
-
-Here is an example of how you can use `spew.Sdump()` to help debug a web application. Please be sure to wrap your output using the `html.EscapeString()` function for safety reasons. You should also only use this debugging technique in a development environment, never in production.
-
-```Go
-package main
-
-import (
- "fmt"
- "html"
- "net/http"
-
- "github.com/davecgh/go-spew/spew"
-)
-
-func handler(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Content-Type", "text/html")
- fmt.Fprintf(w, "Hi there, %s!", r.URL.Path[1:])
- fmt.Fprintf(w, "")
-}
-
-func main() {
- http.HandleFunc("/", handler)
- http.ListenAndServe(":8080", nil)
-}
-```
-
-## Sample Dump Output
-
-```
-(main.Foo) {
- unexportedField: (*main.Bar)(0xf84002e210)({
- flag: (main.Flag) flagTwo,
- data: (uintptr)
- }),
- ExportedField: (map[interface {}]interface {}) {
- (string) "one": (bool) true
- }
-}
-([]uint8) {
- 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
- 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
- 00000020 31 32 |12|
-}
-```
-
-## Sample Formatter Output
-
-Double pointer to a uint8:
-```
- %v: <**>5
- %+v: <**>(0xf8400420d0->0xf8400420c8)5
- %#v: (**uint8)5
- %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5
-```
-
-Pointer to circular struct with a uint8 field and a pointer to itself:
-```
- %v: <*>{1 <*>}
- %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)}
- %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)}
- %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)}
-```
-
-## Configuration Options
-
-Configuration of spew is handled by fields in the ConfigState type. For
-convenience, all of the top-level functions use a global state available via the
-spew.Config global.
-
-It is also possible to create a ConfigState instance that provides methods
-equivalent to the top-level functions. This allows concurrent configuration
-options. See the ConfigState documentation for more details.
-
-```
-* Indent
- String to use for each indentation level for Dump functions.
- It is a single space by default. A popular alternative is "\t".
-
-* MaxDepth
- Maximum number of levels to descend into nested data structures.
- There is no limit by default.
-
-* DisableMethods
- Disables invocation of error and Stringer interface methods.
- Method invocation is enabled by default.
-
-* DisablePointerMethods
- Disables invocation of error and Stringer interface methods on types
- which only accept pointer receivers from non-pointer variables. This option
- relies on access to the unsafe package, so it will not have any effect when
- running in environments without access to the unsafe package such as Google
- App Engine or with the "safe" build tag specified.
- Pointer method invocation is enabled by default.
-
-* DisablePointerAddresses
- DisablePointerAddresses specifies whether to disable the printing of
- pointer addresses. This is useful when diffing data structures in tests.
-
-* DisableCapacities
- DisableCapacities specifies whether to disable the printing of capacities
- for arrays, slices, maps and channels. This is useful when diffing data
- structures in tests.
-
-* ContinueOnMethod
- Enables recursion into types after invoking error and Stringer interface
- methods. Recursion after method invocation is disabled by default.
-
-* SortKeys
- Specifies map keys should be sorted before being printed. Use
- this to have a more deterministic, diffable output. Note that
- only native types (bool, int, uint, floats, uintptr and string)
- and types which implement error or Stringer interfaces are supported,
- with other types sorted according to the reflect.Value.String() output
- which guarantees display stability. Natural map order is used by
- default.
-
-* SpewKeys
- SpewKeys specifies that, as a last resort attempt, map keys should be
- spewed to strings and sorted by those strings. This is only considered
- if SortKeys is true.
-
-```
-
-## Unsafe Package Dependency
-
-This package relies on the unsafe package to perform some of the more advanced
-features, however it also supports a "limited" mode which allows it to work in
-environments where the unsafe package is not available. By default, it will
-operate in this mode on Google App Engine and when compiled with GopherJS. The
-"safe" build tag may also be specified to force the package to build without
-using the unsafe package.
-
-## License
-
-Go-spew is licensed under the [copyfree](http://copyfree.org) ISC License.
diff --git a/vendor/github.com/davecgh/go-spew/cov_report.sh b/vendor/github.com/davecgh/go-spew/cov_report.sh
deleted file mode 100644
index 9579497..0000000
--- a/vendor/github.com/davecgh/go-spew/cov_report.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-# This script uses gocov to generate a test coverage report.
-# The gocov tool my be obtained with the following command:
-# go get github.com/axw/gocov/gocov
-#
-# It will be installed to $GOPATH/bin, so ensure that location is in your $PATH.
-
-# Check for gocov.
-if ! type gocov >/dev/null 2>&1; then
- echo >&2 "This script requires the gocov tool."
- echo >&2 "You may obtain it with the following command:"
- echo >&2 "go get github.com/axw/gocov/gocov"
- exit 1
-fi
-
-# Only run the cgo tests if gcc is installed.
-if type gcc >/dev/null 2>&1; then
- (cd spew && gocov test -tags testcgo | gocov report)
-else
- (cd spew && gocov test | gocov report)
-fi
diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go
deleted file mode 100644
index 7929947..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/bypass.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright (c) 2015-2016 Dave Collins
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-// NOTE: Due to the following build constraints, this file will only be compiled
-// when the code is not running on Google App Engine, compiled by GopherJS, and
-// "-tags safe" is not added to the go build command line. The "disableunsafe"
-// tag is deprecated and thus should not be used.
-// Go versions prior to 1.4 are disabled because they use a different layout
-// for interfaces which make the implementation of unsafeReflectValue more complex.
-// +build !js,!appengine,!safe,!disableunsafe,go1.4
-
-package spew
-
-import (
- "reflect"
- "unsafe"
-)
-
-const (
- // UnsafeDisabled is a build-time constant which specifies whether or
- // not access to the unsafe package is available.
- UnsafeDisabled = false
-
- // ptrSize is the size of a pointer on the current arch.
- ptrSize = unsafe.Sizeof((*byte)(nil))
-)
-
-type flag uintptr
-
-var (
- // flagRO indicates whether the value field of a reflect.Value
- // is read-only.
- flagRO flag
-
- // flagAddr indicates whether the address of the reflect.Value's
- // value may be taken.
- flagAddr flag
-)
-
-// flagKindMask holds the bits that make up the kind
-// part of the flags field. In all the supported versions,
-// it is in the lower 5 bits.
-const flagKindMask = flag(0x1f)
-
-// Different versions of Go have used different
-// bit layouts for the flags type. This table
-// records the known combinations.
-var okFlags = []struct {
- ro, addr flag
-}{{
- // From Go 1.4 to 1.5
- ro: 1 << 5,
- addr: 1 << 7,
-}, {
- // Up to Go tip.
- ro: 1<<5 | 1<<6,
- addr: 1 << 8,
-}}
-
-var flagValOffset = func() uintptr {
- field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag")
- if !ok {
- panic("reflect.Value has no flag field")
- }
- return field.Offset
-}()
-
-// flagField returns a pointer to the flag field of a reflect.Value.
-func flagField(v *reflect.Value) *flag {
- return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset))
-}
-
-// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
-// the typical safety restrictions preventing access to unaddressable and
-// unexported data. It works by digging the raw pointer to the underlying
-// value out of the protected value and generating a new unprotected (unsafe)
-// reflect.Value to it.
-//
-// This allows us to check for implementations of the Stringer and error
-// interfaces to be used for pretty printing ordinarily unaddressable and
-// inaccessible values such as unexported struct fields.
-func unsafeReflectValue(v reflect.Value) reflect.Value {
- if !v.IsValid() || (v.CanInterface() && v.CanAddr()) {
- return v
- }
- flagFieldPtr := flagField(&v)
- *flagFieldPtr &^= flagRO
- *flagFieldPtr |= flagAddr
- return v
-}
-
-// Sanity checks against future reflect package changes
-// to the type or semantics of the Value.flag field.
-func init() {
- field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag")
- if !ok {
- panic("reflect.Value has no flag field")
- }
- if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() {
- panic("reflect.Value flag field has changed kind")
- }
- type t0 int
- var t struct {
- A t0
- // t0 will have flagEmbedRO set.
- t0
- // a will have flagStickyRO set
- a t0
- }
- vA := reflect.ValueOf(t).FieldByName("A")
- va := reflect.ValueOf(t).FieldByName("a")
- vt0 := reflect.ValueOf(t).FieldByName("t0")
-
- // Infer flagRO from the difference between the flags
- // for the (otherwise identical) fields in t.
- flagPublic := *flagField(&vA)
- flagWithRO := *flagField(&va) | *flagField(&vt0)
- flagRO = flagPublic ^ flagWithRO
-
- // Infer flagAddr from the difference between a value
- // taken from a pointer and not.
- vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A")
- flagNoPtr := *flagField(&vA)
- flagPtr := *flagField(&vPtrA)
- flagAddr = flagNoPtr ^ flagPtr
-
- // Check that the inferred flags tally with one of the known versions.
- for _, f := range okFlags {
- if flagRO == f.ro && flagAddr == f.addr {
- return
- }
- }
- panic("reflect.Value read-only flag has changed semantics")
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
deleted file mode 100644
index 205c28d..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2015-2016 Dave Collins
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-// NOTE: Due to the following build constraints, this file will only be compiled
-// when the code is running on Google App Engine, compiled by GopherJS, or
-// "-tags safe" is added to the go build command line. The "disableunsafe"
-// tag is deprecated and thus should not be used.
-// +build js appengine safe disableunsafe !go1.4
-
-package spew
-
-import "reflect"
-
-const (
- // UnsafeDisabled is a build-time constant which specifies whether or
- // not access to the unsafe package is available.
- UnsafeDisabled = true
-)
-
-// unsafeReflectValue typically converts the passed reflect.Value into a one
-// that bypasses the typical safety restrictions preventing access to
-// unaddressable and unexported data. However, doing this relies on access to
-// the unsafe package. This is a stub version which simply returns the passed
-// reflect.Value when the unsafe package is not available.
-func unsafeReflectValue(v reflect.Value) reflect.Value {
- return v
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go
deleted file mode 100644
index 1be8ce9..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/common.go
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package spew
-
-import (
- "bytes"
- "fmt"
- "io"
- "reflect"
- "sort"
- "strconv"
-)
-
-// Some constants in the form of bytes to avoid string overhead. This mirrors
-// the technique used in the fmt package.
-var (
- panicBytes = []byte("(PANIC=")
- plusBytes = []byte("+")
- iBytes = []byte("i")
- trueBytes = []byte("true")
- falseBytes = []byte("false")
- interfaceBytes = []byte("(interface {})")
- commaNewlineBytes = []byte(",\n")
- newlineBytes = []byte("\n")
- openBraceBytes = []byte("{")
- openBraceNewlineBytes = []byte("{\n")
- closeBraceBytes = []byte("}")
- asteriskBytes = []byte("*")
- colonBytes = []byte(":")
- colonSpaceBytes = []byte(": ")
- openParenBytes = []byte("(")
- closeParenBytes = []byte(")")
- spaceBytes = []byte(" ")
- pointerChainBytes = []byte("->")
- nilAngleBytes = []byte("")
- maxNewlineBytes = []byte("\n")
- maxShortBytes = []byte("")
- circularBytes = []byte("")
- circularShortBytes = []byte("")
- invalidAngleBytes = []byte("")
- openBracketBytes = []byte("[")
- closeBracketBytes = []byte("]")
- percentBytes = []byte("%")
- precisionBytes = []byte(".")
- openAngleBytes = []byte("<")
- closeAngleBytes = []byte(">")
- openMapBytes = []byte("map[")
- closeMapBytes = []byte("]")
- lenEqualsBytes = []byte("len=")
- capEqualsBytes = []byte("cap=")
-)
-
-// hexDigits is used to map a decimal value to a hex digit.
-var hexDigits = "0123456789abcdef"
-
-// catchPanic handles any panics that might occur during the handleMethods
-// calls.
-func catchPanic(w io.Writer, v reflect.Value) {
- if err := recover(); err != nil {
- w.Write(panicBytes)
- fmt.Fprintf(w, "%v", err)
- w.Write(closeParenBytes)
- }
-}
-
-// handleMethods attempts to call the Error and String methods on the underlying
-// type the passed reflect.Value represents and outputes the result to Writer w.
-//
-// It handles panics in any called methods by catching and displaying the error
-// as the formatted value.
-func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) {
- // We need an interface to check if the type implements the error or
- // Stringer interface. However, the reflect package won't give us an
- // interface on certain things like unexported struct fields in order
- // to enforce visibility rules. We use unsafe, when it's available,
- // to bypass these restrictions since this package does not mutate the
- // values.
- if !v.CanInterface() {
- if UnsafeDisabled {
- return false
- }
-
- v = unsafeReflectValue(v)
- }
-
- // Choose whether or not to do error and Stringer interface lookups against
- // the base type or a pointer to the base type depending on settings.
- // Technically calling one of these methods with a pointer receiver can
- // mutate the value, however, types which choose to satisify an error or
- // Stringer interface with a pointer receiver should not be mutating their
- // state inside these interface methods.
- if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() {
- v = unsafeReflectValue(v)
- }
- if v.CanAddr() {
- v = v.Addr()
- }
-
- // Is it an error or Stringer?
- switch iface := v.Interface().(type) {
- case error:
- defer catchPanic(w, v)
- if cs.ContinueOnMethod {
- w.Write(openParenBytes)
- w.Write([]byte(iface.Error()))
- w.Write(closeParenBytes)
- w.Write(spaceBytes)
- return false
- }
-
- w.Write([]byte(iface.Error()))
- return true
-
- case fmt.Stringer:
- defer catchPanic(w, v)
- if cs.ContinueOnMethod {
- w.Write(openParenBytes)
- w.Write([]byte(iface.String()))
- w.Write(closeParenBytes)
- w.Write(spaceBytes)
- return false
- }
- w.Write([]byte(iface.String()))
- return true
- }
- return false
-}
-
-// printBool outputs a boolean value as true or false to Writer w.
-func printBool(w io.Writer, val bool) {
- if val {
- w.Write(trueBytes)
- } else {
- w.Write(falseBytes)
- }
-}
-
-// printInt outputs a signed integer value to Writer w.
-func printInt(w io.Writer, val int64, base int) {
- w.Write([]byte(strconv.FormatInt(val, base)))
-}
-
-// printUint outputs an unsigned integer value to Writer w.
-func printUint(w io.Writer, val uint64, base int) {
- w.Write([]byte(strconv.FormatUint(val, base)))
-}
-
-// printFloat outputs a floating point value using the specified precision,
-// which is expected to be 32 or 64bit, to Writer w.
-func printFloat(w io.Writer, val float64, precision int) {
- w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision)))
-}
-
-// printComplex outputs a complex value using the specified float precision
-// for the real and imaginary parts to Writer w.
-func printComplex(w io.Writer, c complex128, floatPrecision int) {
- r := real(c)
- w.Write(openParenBytes)
- w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision)))
- i := imag(c)
- if i >= 0 {
- w.Write(plusBytes)
- }
- w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision)))
- w.Write(iBytes)
- w.Write(closeParenBytes)
-}
-
-// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x'
-// prefix to Writer w.
-func printHexPtr(w io.Writer, p uintptr) {
- // Null pointer.
- num := uint64(p)
- if num == 0 {
- w.Write(nilAngleBytes)
- return
- }
-
- // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix
- buf := make([]byte, 18)
-
- // It's simpler to construct the hex string right to left.
- base := uint64(16)
- i := len(buf) - 1
- for num >= base {
- buf[i] = hexDigits[num%base]
- num /= base
- i--
- }
- buf[i] = hexDigits[num]
-
- // Add '0x' prefix.
- i--
- buf[i] = 'x'
- i--
- buf[i] = '0'
-
- // Strip unused leading bytes.
- buf = buf[i:]
- w.Write(buf)
-}
-
-// valuesSorter implements sort.Interface to allow a slice of reflect.Value
-// elements to be sorted.
-type valuesSorter struct {
- values []reflect.Value
- strings []string // either nil or same len and values
- cs *ConfigState
-}
-
-// newValuesSorter initializes a valuesSorter instance, which holds a set of
-// surrogate keys on which the data should be sorted. It uses flags in
-// ConfigState to decide if and how to populate those surrogate keys.
-func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface {
- vs := &valuesSorter{values: values, cs: cs}
- if canSortSimply(vs.values[0].Kind()) {
- return vs
- }
- if !cs.DisableMethods {
- vs.strings = make([]string, len(values))
- for i := range vs.values {
- b := bytes.Buffer{}
- if !handleMethods(cs, &b, vs.values[i]) {
- vs.strings = nil
- break
- }
- vs.strings[i] = b.String()
- }
- }
- if vs.strings == nil && cs.SpewKeys {
- vs.strings = make([]string, len(values))
- for i := range vs.values {
- vs.strings[i] = Sprintf("%#v", vs.values[i].Interface())
- }
- }
- return vs
-}
-
-// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted
-// directly, or whether it should be considered for sorting by surrogate keys
-// (if the ConfigState allows it).
-func canSortSimply(kind reflect.Kind) bool {
- // This switch parallels valueSortLess, except for the default case.
- switch kind {
- case reflect.Bool:
- return true
- case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
- return true
- case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
- return true
- case reflect.Float32, reflect.Float64:
- return true
- case reflect.String:
- return true
- case reflect.Uintptr:
- return true
- case reflect.Array:
- return true
- }
- return false
-}
-
-// Len returns the number of values in the slice. It is part of the
-// sort.Interface implementation.
-func (s *valuesSorter) Len() int {
- return len(s.values)
-}
-
-// Swap swaps the values at the passed indices. It is part of the
-// sort.Interface implementation.
-func (s *valuesSorter) Swap(i, j int) {
- s.values[i], s.values[j] = s.values[j], s.values[i]
- if s.strings != nil {
- s.strings[i], s.strings[j] = s.strings[j], s.strings[i]
- }
-}
-
-// valueSortLess returns whether the first value should sort before the second
-// value. It is used by valueSorter.Less as part of the sort.Interface
-// implementation.
-func valueSortLess(a, b reflect.Value) bool {
- switch a.Kind() {
- case reflect.Bool:
- return !a.Bool() && b.Bool()
- case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
- return a.Int() < b.Int()
- case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
- return a.Uint() < b.Uint()
- case reflect.Float32, reflect.Float64:
- return a.Float() < b.Float()
- case reflect.String:
- return a.String() < b.String()
- case reflect.Uintptr:
- return a.Uint() < b.Uint()
- case reflect.Array:
- // Compare the contents of both arrays.
- l := a.Len()
- for i := 0; i < l; i++ {
- av := a.Index(i)
- bv := b.Index(i)
- if av.Interface() == bv.Interface() {
- continue
- }
- return valueSortLess(av, bv)
- }
- }
- return a.String() < b.String()
-}
-
-// Less returns whether the value at index i should sort before the
-// value at index j. It is part of the sort.Interface implementation.
-func (s *valuesSorter) Less(i, j int) bool {
- if s.strings == nil {
- return valueSortLess(s.values[i], s.values[j])
- }
- return s.strings[i] < s.strings[j]
-}
-
-// sortValues is a sort function that handles both native types and any type that
-// can be converted to error or Stringer. Other inputs are sorted according to
-// their Value.String() value to ensure display stability.
-func sortValues(values []reflect.Value, cs *ConfigState) {
- if len(values) == 0 {
- return
- }
- sort.Sort(newValuesSorter(values, cs))
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/common_test.go b/vendor/github.com/davecgh/go-spew/spew/common_test.go
deleted file mode 100644
index 0f5ce47..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/common_test.go
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package spew_test
-
-import (
- "fmt"
- "reflect"
- "testing"
-
- "github.com/davecgh/go-spew/spew"
-)
-
-// custom type to test Stinger interface on non-pointer receiver.
-type stringer string
-
-// String implements the Stringer interface for testing invocation of custom
-// stringers on types with non-pointer receivers.
-func (s stringer) String() string {
- return "stringer " + string(s)
-}
-
-// custom type to test Stinger interface on pointer receiver.
-type pstringer string
-
-// String implements the Stringer interface for testing invocation of custom
-// stringers on types with only pointer receivers.
-func (s *pstringer) String() string {
- return "stringer " + string(*s)
-}
-
-// xref1 and xref2 are cross referencing structs for testing circular reference
-// detection.
-type xref1 struct {
- ps2 *xref2
-}
-type xref2 struct {
- ps1 *xref1
-}
-
-// indirCir1, indirCir2, and indirCir3 are used to generate an indirect circular
-// reference for testing detection.
-type indirCir1 struct {
- ps2 *indirCir2
-}
-type indirCir2 struct {
- ps3 *indirCir3
-}
-type indirCir3 struct {
- ps1 *indirCir1
-}
-
-// embed is used to test embedded structures.
-type embed struct {
- a string
-}
-
-// embedwrap is used to test embedded structures.
-type embedwrap struct {
- *embed
- e *embed
-}
-
-// panicer is used to intentionally cause a panic for testing spew properly
-// handles them
-type panicer int
-
-func (p panicer) String() string {
- panic("test panic")
-}
-
-// customError is used to test custom error interface invocation.
-type customError int
-
-func (e customError) Error() string {
- return fmt.Sprintf("error: %d", int(e))
-}
-
-// stringizeWants converts a slice of wanted test output into a format suitable
-// for a test error message.
-func stringizeWants(wants []string) string {
- s := ""
- for i, want := range wants {
- if i > 0 {
- s += fmt.Sprintf("want%d: %s", i+1, want)
- } else {
- s += "want: " + want
- }
- }
- return s
-}
-
-// testFailed returns whether or not a test failed by checking if the result
-// of the test is in the slice of wanted strings.
-func testFailed(result string, wants []string) bool {
- for _, want := range wants {
- if result == want {
- return false
- }
- }
- return true
-}
-
-type sortableStruct struct {
- x int
-}
-
-func (ss sortableStruct) String() string {
- return fmt.Sprintf("ss.%d", ss.x)
-}
-
-type unsortableStruct struct {
- x int
-}
-
-type sortTestCase struct {
- input []reflect.Value
- expected []reflect.Value
-}
-
-func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) {
- getInterfaces := func(values []reflect.Value) []interface{} {
- interfaces := []interface{}{}
- for _, v := range values {
- interfaces = append(interfaces, v.Interface())
- }
- return interfaces
- }
-
- for _, test := range tests {
- spew.SortValues(test.input, cs)
- // reflect.DeepEqual cannot really make sense of reflect.Value,
- // probably because of all the pointer tricks. For instance,
- // v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{}
- // instead.
- input := getInterfaces(test.input)
- expected := getInterfaces(test.expected)
- if !reflect.DeepEqual(input, expected) {
- t.Errorf("Sort mismatch:\n %v != %v", input, expected)
- }
- }
-}
-
-// TestSortValues ensures the sort functionality for relect.Value based sorting
-// works as intended.
-func TestSortValues(t *testing.T) {
- v := reflect.ValueOf
-
- a := v("a")
- b := v("b")
- c := v("c")
- embedA := v(embed{"a"})
- embedB := v(embed{"b"})
- embedC := v(embed{"c"})
- tests := []sortTestCase{
- // No values.
- {
- []reflect.Value{},
- []reflect.Value{},
- },
- // Bools.
- {
- []reflect.Value{v(false), v(true), v(false)},
- []reflect.Value{v(false), v(false), v(true)},
- },
- // Ints.
- {
- []reflect.Value{v(2), v(1), v(3)},
- []reflect.Value{v(1), v(2), v(3)},
- },
- // Uints.
- {
- []reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))},
- []reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))},
- },
- // Floats.
- {
- []reflect.Value{v(2.0), v(1.0), v(3.0)},
- []reflect.Value{v(1.0), v(2.0), v(3.0)},
- },
- // Strings.
- {
- []reflect.Value{b, a, c},
- []reflect.Value{a, b, c},
- },
- // Array
- {
- []reflect.Value{v([3]int{3, 2, 1}), v([3]int{1, 3, 2}), v([3]int{1, 2, 3})},
- []reflect.Value{v([3]int{1, 2, 3}), v([3]int{1, 3, 2}), v([3]int{3, 2, 1})},
- },
- // Uintptrs.
- {
- []reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))},
- []reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))},
- },
- // SortableStructs.
- {
- // Note: not sorted - DisableMethods is set.
- []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
- []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
- },
- // UnsortableStructs.
- {
- // Note: not sorted - SpewKeys is false.
- []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
- []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
- },
- // Invalid.
- {
- []reflect.Value{embedB, embedA, embedC},
- []reflect.Value{embedB, embedA, embedC},
- },
- }
- cs := spew.ConfigState{DisableMethods: true, SpewKeys: false}
- helpTestSortValues(tests, &cs, t)
-}
-
-// TestSortValuesWithMethods ensures the sort functionality for relect.Value
-// based sorting works as intended when using string methods.
-func TestSortValuesWithMethods(t *testing.T) {
- v := reflect.ValueOf
-
- a := v("a")
- b := v("b")
- c := v("c")
- tests := []sortTestCase{
- // Ints.
- {
- []reflect.Value{v(2), v(1), v(3)},
- []reflect.Value{v(1), v(2), v(3)},
- },
- // Strings.
- {
- []reflect.Value{b, a, c},
- []reflect.Value{a, b, c},
- },
- // SortableStructs.
- {
- []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
- []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
- },
- // UnsortableStructs.
- {
- // Note: not sorted - SpewKeys is false.
- []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
- []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
- },
- }
- cs := spew.ConfigState{DisableMethods: false, SpewKeys: false}
- helpTestSortValues(tests, &cs, t)
-}
-
-// TestSortValuesWithSpew ensures the sort functionality for relect.Value
-// based sorting works as intended when using spew to stringify keys.
-func TestSortValuesWithSpew(t *testing.T) {
- v := reflect.ValueOf
-
- a := v("a")
- b := v("b")
- c := v("c")
- tests := []sortTestCase{
- // Ints.
- {
- []reflect.Value{v(2), v(1), v(3)},
- []reflect.Value{v(1), v(2), v(3)},
- },
- // Strings.
- {
- []reflect.Value{b, a, c},
- []reflect.Value{a, b, c},
- },
- // SortableStructs.
- {
- []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
- []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
- },
- // UnsortableStructs.
- {
- []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
- []reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})},
- },
- }
- cs := spew.ConfigState{DisableMethods: true, SpewKeys: true}
- helpTestSortValues(tests, &cs, t)
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/config.go b/vendor/github.com/davecgh/go-spew/spew/config.go
deleted file mode 100644
index 2e3d22f..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/config.go
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package spew
-
-import (
- "bytes"
- "fmt"
- "io"
- "os"
-)
-
-// ConfigState houses the configuration options used by spew to format and
-// display values. There is a global instance, Config, that is used to control
-// all top-level Formatter and Dump functionality. Each ConfigState instance
-// provides methods equivalent to the top-level functions.
-//
-// The zero value for ConfigState provides no indentation. You would typically
-// want to set it to a space or a tab.
-//
-// Alternatively, you can use NewDefaultConfig to get a ConfigState instance
-// with default settings. See the documentation of NewDefaultConfig for default
-// values.
-type ConfigState struct {
- // Indent specifies the string to use for each indentation level. The
- // global config instance that all top-level functions use set this to a
- // single space by default. If you would like more indentation, you might
- // set this to a tab with "\t" or perhaps two spaces with " ".
- Indent string
-
- // MaxDepth controls the maximum number of levels to descend into nested
- // data structures. The default, 0, means there is no limit.
- //
- // NOTE: Circular data structures are properly detected, so it is not
- // necessary to set this value unless you specifically want to limit deeply
- // nested data structures.
- MaxDepth int
-
- // DisableMethods specifies whether or not error and Stringer interfaces are
- // invoked for types that implement them.
- DisableMethods bool
-
- // DisablePointerMethods specifies whether or not to check for and invoke
- // error and Stringer interfaces on types which only accept a pointer
- // receiver when the current type is not a pointer.
- //
- // NOTE: This might be an unsafe action since calling one of these methods
- // with a pointer receiver could technically mutate the value, however,
- // in practice, types which choose to satisify an error or Stringer
- // interface with a pointer receiver should not be mutating their state
- // inside these interface methods. As a result, this option relies on
- // access to the unsafe package, so it will not have any effect when
- // running in environments without access to the unsafe package such as
- // Google App Engine or with the "safe" build tag specified.
- DisablePointerMethods bool
-
- // DisablePointerAddresses specifies whether to disable the printing of
- // pointer addresses. This is useful when diffing data structures in tests.
- DisablePointerAddresses bool
-
- // DisableCapacities specifies whether to disable the printing of capacities
- // for arrays, slices, maps and channels. This is useful when diffing
- // data structures in tests.
- DisableCapacities bool
-
- // ContinueOnMethod specifies whether or not recursion should continue once
- // a custom error or Stringer interface is invoked. The default, false,
- // means it will print the results of invoking the custom error or Stringer
- // interface and return immediately instead of continuing to recurse into
- // the internals of the data type.
- //
- // NOTE: This flag does not have any effect if method invocation is disabled
- // via the DisableMethods or DisablePointerMethods options.
- ContinueOnMethod bool
-
- // SortKeys specifies map keys should be sorted before being printed. Use
- // this to have a more deterministic, diffable output. Note that only
- // native types (bool, int, uint, floats, uintptr and string) and types
- // that support the error or Stringer interfaces (if methods are
- // enabled) are supported, with other types sorted according to the
- // reflect.Value.String() output which guarantees display stability.
- SortKeys bool
-
- // SpewKeys specifies that, as a last resort attempt, map keys should
- // be spewed to strings and sorted by those strings. This is only
- // considered if SortKeys is true.
- SpewKeys bool
-}
-
-// Config is the active configuration of the top-level functions.
-// The configuration can be changed by modifying the contents of spew.Config.
-var Config = ConfigState{Indent: " "}
-
-// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
-// passed with a Formatter interface returned by c.NewFormatter. It returns
-// the formatted string as a value that satisfies error. See NewFormatter
-// for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) {
- return fmt.Errorf(format, c.convertArgs(a)...)
-}
-
-// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
-// passed with a Formatter interface returned by c.NewFormatter. It returns
-// the number of bytes written and any write error encountered. See
-// NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
- return fmt.Fprint(w, c.convertArgs(a)...)
-}
-
-// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
-// passed with a Formatter interface returned by c.NewFormatter. It returns
-// the number of bytes written and any write error encountered. See
-// NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
- return fmt.Fprintf(w, format, c.convertArgs(a)...)
-}
-
-// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
-// passed with a Formatter interface returned by c.NewFormatter. See
-// NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
- return fmt.Fprintln(w, c.convertArgs(a)...)
-}
-
-// Print is a wrapper for fmt.Print that treats each argument as if it were
-// passed with a Formatter interface returned by c.NewFormatter. It returns
-// the number of bytes written and any write error encountered. See
-// NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Print(c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Print(a ...interface{}) (n int, err error) {
- return fmt.Print(c.convertArgs(a)...)
-}
-
-// Printf is a wrapper for fmt.Printf that treats each argument as if it were
-// passed with a Formatter interface returned by c.NewFormatter. It returns
-// the number of bytes written and any write error encountered. See
-// NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) {
- return fmt.Printf(format, c.convertArgs(a)...)
-}
-
-// Println is a wrapper for fmt.Println that treats each argument as if it were
-// passed with a Formatter interface returned by c.NewFormatter. It returns
-// the number of bytes written and any write error encountered. See
-// NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Println(c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Println(a ...interface{}) (n int, err error) {
- return fmt.Println(c.convertArgs(a)...)
-}
-
-// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
-// passed with a Formatter interface returned by c.NewFormatter. It returns
-// the resulting string. See NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Sprint(a ...interface{}) string {
- return fmt.Sprint(c.convertArgs(a)...)
-}
-
-// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
-// passed with a Formatter interface returned by c.NewFormatter. It returns
-// the resulting string. See NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Sprintf(format string, a ...interface{}) string {
- return fmt.Sprintf(format, c.convertArgs(a)...)
-}
-
-// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
-// were passed with a Formatter interface returned by c.NewFormatter. It
-// returns the resulting string. See NewFormatter for formatting details.
-//
-// This function is shorthand for the following syntax:
-//
-// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b))
-func (c *ConfigState) Sprintln(a ...interface{}) string {
- return fmt.Sprintln(c.convertArgs(a)...)
-}
-
-/*
-NewFormatter returns a custom formatter that satisfies the fmt.Formatter
-interface. As a result, it integrates cleanly with standard fmt package
-printing functions. The formatter is useful for inline printing of smaller data
-types similar to the standard %v format specifier.
-
-The custom formatter only responds to the %v (most compact), %+v (adds pointer
-addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb
-combinations. Any other verbs such as %x and %q will be sent to the the
-standard fmt package for formatting. In addition, the custom formatter ignores
-the width and precision arguments (however they will still work on the format
-specifiers not handled by the custom formatter).
-
-Typically this function shouldn't be called directly. It is much easier to make
-use of the custom formatter by calling one of the convenience functions such as
-c.Printf, c.Println, or c.Printf.
-*/
-func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter {
- return newFormatter(c, v)
-}
-
-// Fdump formats and displays the passed arguments to io.Writer w. It formats
-// exactly the same as Dump.
-func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) {
- fdump(c, w, a...)
-}
-
-/*
-Dump displays the passed parameters to standard out with newlines, customizable
-indentation, and additional debug information such as complete types and all
-pointer addresses used to indirect to the final value. It provides the
-following features over the built-in printing facilities provided by the fmt
-package:
-
- * Pointers are dereferenced and followed
- * Circular data structures are detected and handled properly
- * Custom Stringer/error interfaces are optionally invoked, including
- on unexported types
- * Custom types which only implement the Stringer/error interfaces via
- a pointer receiver are optionally invoked when passing non-pointer
- variables
- * Byte arrays and slices are dumped like the hexdump -C command which
- includes offsets, byte values in hex, and ASCII output
-
-The configuration options are controlled by modifying the public members
-of c. See ConfigState for options documentation.
-
-See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
-get the formatted result as a string.
-*/
-func (c *ConfigState) Dump(a ...interface{}) {
- fdump(c, os.Stdout, a...)
-}
-
-// Sdump returns a string with the passed arguments formatted exactly the same
-// as Dump.
-func (c *ConfigState) Sdump(a ...interface{}) string {
- var buf bytes.Buffer
- fdump(c, &buf, a...)
- return buf.String()
-}
-
-// convertArgs accepts a slice of arguments and returns a slice of the same
-// length with each argument converted to a spew Formatter interface using
-// the ConfigState associated with s.
-func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) {
- formatters = make([]interface{}, len(args))
- for index, arg := range args {
- formatters[index] = newFormatter(c, arg)
- }
- return formatters
-}
-
-// NewDefaultConfig returns a ConfigState with the following default settings.
-//
-// Indent: " "
-// MaxDepth: 0
-// DisableMethods: false
-// DisablePointerMethods: false
-// ContinueOnMethod: false
-// SortKeys: false
-func NewDefaultConfig() *ConfigState {
- return &ConfigState{Indent: " "}
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/doc.go b/vendor/github.com/davecgh/go-spew/spew/doc.go
deleted file mode 100644
index aacaac6..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/doc.go
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
-Package spew implements a deep pretty printer for Go data structures to aid in
-debugging.
-
-A quick overview of the additional features spew provides over the built-in
-printing facilities for Go data types are as follows:
-
- * Pointers are dereferenced and followed
- * Circular data structures are detected and handled properly
- * Custom Stringer/error interfaces are optionally invoked, including
- on unexported types
- * Custom types which only implement the Stringer/error interfaces via
- a pointer receiver are optionally invoked when passing non-pointer
- variables
- * Byte arrays and slices are dumped like the hexdump -C command which
- includes offsets, byte values in hex, and ASCII output (only when using
- Dump style)
-
-There are two different approaches spew allows for dumping Go data structures:
-
- * Dump style which prints with newlines, customizable indentation,
- and additional debug information such as types and all pointer addresses
- used to indirect to the final value
- * A custom Formatter interface that integrates cleanly with the standard fmt
- package and replaces %v, %+v, %#v, and %#+v to provide inline printing
- similar to the default %v while providing the additional functionality
- outlined above and passing unsupported format verbs such as %x and %q
- along to fmt
-
-Quick Start
-
-This section demonstrates how to quickly get started with spew. See the
-sections below for further details on formatting and configuration options.
-
-To dump a variable with full newlines, indentation, type, and pointer
-information use Dump, Fdump, or Sdump:
- spew.Dump(myVar1, myVar2, ...)
- spew.Fdump(someWriter, myVar1, myVar2, ...)
- str := spew.Sdump(myVar1, myVar2, ...)
-
-Alternatively, if you would prefer to use format strings with a compacted inline
-printing style, use the convenience wrappers Printf, Fprintf, etc with
-%v (most compact), %+v (adds pointer addresses), %#v (adds types), or
-%#+v (adds types and pointer addresses):
- spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
- spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
- spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
- spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
-
-Configuration Options
-
-Configuration of spew is handled by fields in the ConfigState type. For
-convenience, all of the top-level functions use a global state available
-via the spew.Config global.
-
-It is also possible to create a ConfigState instance that provides methods
-equivalent to the top-level functions. This allows concurrent configuration
-options. See the ConfigState documentation for more details.
-
-The following configuration options are available:
- * Indent
- String to use for each indentation level for Dump functions.
- It is a single space by default. A popular alternative is "\t".
-
- * MaxDepth
- Maximum number of levels to descend into nested data structures.
- There is no limit by default.
-
- * DisableMethods
- Disables invocation of error and Stringer interface methods.
- Method invocation is enabled by default.
-
- * DisablePointerMethods
- Disables invocation of error and Stringer interface methods on types
- which only accept pointer receivers from non-pointer variables.
- Pointer method invocation is enabled by default.
-
- * DisablePointerAddresses
- DisablePointerAddresses specifies whether to disable the printing of
- pointer addresses. This is useful when diffing data structures in tests.
-
- * DisableCapacities
- DisableCapacities specifies whether to disable the printing of
- capacities for arrays, slices, maps and channels. This is useful when
- diffing data structures in tests.
-
- * ContinueOnMethod
- Enables recursion into types after invoking error and Stringer interface
- methods. Recursion after method invocation is disabled by default.
-
- * SortKeys
- Specifies map keys should be sorted before being printed. Use
- this to have a more deterministic, diffable output. Note that
- only native types (bool, int, uint, floats, uintptr and string)
- and types which implement error or Stringer interfaces are
- supported with other types sorted according to the
- reflect.Value.String() output which guarantees display
- stability. Natural map order is used by default.
-
- * SpewKeys
- Specifies that, as a last resort attempt, map keys should be
- spewed to strings and sorted by those strings. This is only
- considered if SortKeys is true.
-
-Dump Usage
-
-Simply call spew.Dump with a list of variables you want to dump:
-
- spew.Dump(myVar1, myVar2, ...)
-
-You may also call spew.Fdump if you would prefer to output to an arbitrary
-io.Writer. For example, to dump to standard error:
-
- spew.Fdump(os.Stderr, myVar1, myVar2, ...)
-
-A third option is to call spew.Sdump to get the formatted output as a string:
-
- str := spew.Sdump(myVar1, myVar2, ...)
-
-Sample Dump Output
-
-See the Dump example for details on the setup of the types and variables being
-shown here.
-
- (main.Foo) {
- unexportedField: (*main.Bar)(0xf84002e210)({
- flag: (main.Flag) flagTwo,
- data: (uintptr)
- }),
- ExportedField: (map[interface {}]interface {}) (len=1) {
- (string) (len=3) "one": (bool) true
- }
- }
-
-Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C
-command as shown.
- ([]uint8) (len=32 cap=32) {
- 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
- 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
- 00000020 31 32 |12|
- }
-
-Custom Formatter
-
-Spew provides a custom formatter that implements the fmt.Formatter interface
-so that it integrates cleanly with standard fmt package printing functions. The
-formatter is useful for inline printing of smaller data types similar to the
-standard %v format specifier.
-
-The custom formatter only responds to the %v (most compact), %+v (adds pointer
-addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb
-combinations. Any other verbs such as %x and %q will be sent to the the
-standard fmt package for formatting. In addition, the custom formatter ignores
-the width and precision arguments (however they will still work on the format
-specifiers not handled by the custom formatter).
-
-Custom Formatter Usage
-
-The simplest way to make use of the spew custom formatter is to call one of the
-convenience functions such as spew.Printf, spew.Println, or spew.Printf. The
-functions have syntax you are most likely already familiar with:
-
- spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
- spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
- spew.Println(myVar, myVar2)
- spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
- spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
-
-See the Index for the full list convenience functions.
-
-Sample Formatter Output
-
-Double pointer to a uint8:
- %v: <**>5
- %+v: <**>(0xf8400420d0->0xf8400420c8)5
- %#v: (**uint8)5
- %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5
-
-Pointer to circular struct with a uint8 field and a pointer to itself:
- %v: <*>{1 <*>}
- %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)}
- %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)}
- %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)}
-
-See the Printf example for details on the setup of variables being shown
-here.
-
-Errors
-
-Since it is possible for custom Stringer/error interfaces to panic, spew
-detects them and handles them internally by printing the panic information
-inline with the output. Since spew is intended to provide deep pretty printing
-capabilities on structures, it intentionally does not return any errors.
-*/
-package spew
diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go
deleted file mode 100644
index f78d89f..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/dump.go
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package spew
-
-import (
- "bytes"
- "encoding/hex"
- "fmt"
- "io"
- "os"
- "reflect"
- "regexp"
- "strconv"
- "strings"
-)
-
-var (
- // uint8Type is a reflect.Type representing a uint8. It is used to
- // convert cgo types to uint8 slices for hexdumping.
- uint8Type = reflect.TypeOf(uint8(0))
-
- // cCharRE is a regular expression that matches a cgo char.
- // It is used to detect character arrays to hexdump them.
- cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`)
-
- // cUnsignedCharRE is a regular expression that matches a cgo unsigned
- // char. It is used to detect unsigned character arrays to hexdump
- // them.
- cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`)
-
- // cUint8tCharRE is a regular expression that matches a cgo uint8_t.
- // It is used to detect uint8_t arrays to hexdump them.
- cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`)
-)
-
-// dumpState contains information about the state of a dump operation.
-type dumpState struct {
- w io.Writer
- depth int
- pointers map[uintptr]int
- ignoreNextType bool
- ignoreNextIndent bool
- cs *ConfigState
-}
-
-// indent performs indentation according to the depth level and cs.Indent
-// option.
-func (d *dumpState) indent() {
- if d.ignoreNextIndent {
- d.ignoreNextIndent = false
- return
- }
- d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth))
-}
-
-// unpackValue returns values inside of non-nil interfaces when possible.
-// This is useful for data types like structs, arrays, slices, and maps which
-// can contain varying types packed inside an interface.
-func (d *dumpState) unpackValue(v reflect.Value) reflect.Value {
- if v.Kind() == reflect.Interface && !v.IsNil() {
- v = v.Elem()
- }
- return v
-}
-
-// dumpPtr handles formatting of pointers by indirecting them as necessary.
-func (d *dumpState) dumpPtr(v reflect.Value) {
- // Remove pointers at or below the current depth from map used to detect
- // circular refs.
- for k, depth := range d.pointers {
- if depth >= d.depth {
- delete(d.pointers, k)
- }
- }
-
- // Keep list of all dereferenced pointers to show later.
- pointerChain := make([]uintptr, 0)
-
- // Figure out how many levels of indirection there are by dereferencing
- // pointers and unpacking interfaces down the chain while detecting circular
- // references.
- nilFound := false
- cycleFound := false
- indirects := 0
- ve := v
- for ve.Kind() == reflect.Ptr {
- if ve.IsNil() {
- nilFound = true
- break
- }
- indirects++
- addr := ve.Pointer()
- pointerChain = append(pointerChain, addr)
- if pd, ok := d.pointers[addr]; ok && pd < d.depth {
- cycleFound = true
- indirects--
- break
- }
- d.pointers[addr] = d.depth
-
- ve = ve.Elem()
- if ve.Kind() == reflect.Interface {
- if ve.IsNil() {
- nilFound = true
- break
- }
- ve = ve.Elem()
- }
- }
-
- // Display type information.
- d.w.Write(openParenBytes)
- d.w.Write(bytes.Repeat(asteriskBytes, indirects))
- d.w.Write([]byte(ve.Type().String()))
- d.w.Write(closeParenBytes)
-
- // Display pointer information.
- if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 {
- d.w.Write(openParenBytes)
- for i, addr := range pointerChain {
- if i > 0 {
- d.w.Write(pointerChainBytes)
- }
- printHexPtr(d.w, addr)
- }
- d.w.Write(closeParenBytes)
- }
-
- // Display dereferenced value.
- d.w.Write(openParenBytes)
- switch {
- case nilFound:
- d.w.Write(nilAngleBytes)
-
- case cycleFound:
- d.w.Write(circularBytes)
-
- default:
- d.ignoreNextType = true
- d.dump(ve)
- }
- d.w.Write(closeParenBytes)
-}
-
-// dumpSlice handles formatting of arrays and slices. Byte (uint8 under
-// reflection) arrays and slices are dumped in hexdump -C fashion.
-func (d *dumpState) dumpSlice(v reflect.Value) {
- // Determine whether this type should be hex dumped or not. Also,
- // for types which should be hexdumped, try to use the underlying data
- // first, then fall back to trying to convert them to a uint8 slice.
- var buf []uint8
- doConvert := false
- doHexDump := false
- numEntries := v.Len()
- if numEntries > 0 {
- vt := v.Index(0).Type()
- vts := vt.String()
- switch {
- // C types that need to be converted.
- case cCharRE.MatchString(vts):
- fallthrough
- case cUnsignedCharRE.MatchString(vts):
- fallthrough
- case cUint8tCharRE.MatchString(vts):
- doConvert = true
-
- // Try to use existing uint8 slices and fall back to converting
- // and copying if that fails.
- case vt.Kind() == reflect.Uint8:
- // We need an addressable interface to convert the type
- // to a byte slice. However, the reflect package won't
- // give us an interface on certain things like
- // unexported struct fields in order to enforce
- // visibility rules. We use unsafe, when available, to
- // bypass these restrictions since this package does not
- // mutate the values.
- vs := v
- if !vs.CanInterface() || !vs.CanAddr() {
- vs = unsafeReflectValue(vs)
- }
- if !UnsafeDisabled {
- vs = vs.Slice(0, numEntries)
-
- // Use the existing uint8 slice if it can be
- // type asserted.
- iface := vs.Interface()
- if slice, ok := iface.([]uint8); ok {
- buf = slice
- doHexDump = true
- break
- }
- }
-
- // The underlying data needs to be converted if it can't
- // be type asserted to a uint8 slice.
- doConvert = true
- }
-
- // Copy and convert the underlying type if needed.
- if doConvert && vt.ConvertibleTo(uint8Type) {
- // Convert and copy each element into a uint8 byte
- // slice.
- buf = make([]uint8, numEntries)
- for i := 0; i < numEntries; i++ {
- vv := v.Index(i)
- buf[i] = uint8(vv.Convert(uint8Type).Uint())
- }
- doHexDump = true
- }
- }
-
- // Hexdump the entire slice as needed.
- if doHexDump {
- indent := strings.Repeat(d.cs.Indent, d.depth)
- str := indent + hex.Dump(buf)
- str = strings.Replace(str, "\n", "\n"+indent, -1)
- str = strings.TrimRight(str, d.cs.Indent)
- d.w.Write([]byte(str))
- return
- }
-
- // Recursively call dump for each item.
- for i := 0; i < numEntries; i++ {
- d.dump(d.unpackValue(v.Index(i)))
- if i < (numEntries - 1) {
- d.w.Write(commaNewlineBytes)
- } else {
- d.w.Write(newlineBytes)
- }
- }
-}
-
-// dump is the main workhorse for dumping a value. It uses the passed reflect
-// value to figure out what kind of object we are dealing with and formats it
-// appropriately. It is a recursive function, however circular data structures
-// are detected and handled properly.
-func (d *dumpState) dump(v reflect.Value) {
- // Handle invalid reflect values immediately.
- kind := v.Kind()
- if kind == reflect.Invalid {
- d.w.Write(invalidAngleBytes)
- return
- }
-
- // Handle pointers specially.
- if kind == reflect.Ptr {
- d.indent()
- d.dumpPtr(v)
- return
- }
-
- // Print type information unless already handled elsewhere.
- if !d.ignoreNextType {
- d.indent()
- d.w.Write(openParenBytes)
- d.w.Write([]byte(v.Type().String()))
- d.w.Write(closeParenBytes)
- d.w.Write(spaceBytes)
- }
- d.ignoreNextType = false
-
- // Display length and capacity if the built-in len and cap functions
- // work with the value's kind and the len/cap itself is non-zero.
- valueLen, valueCap := 0, 0
- switch v.Kind() {
- case reflect.Array, reflect.Slice, reflect.Chan:
- valueLen, valueCap = v.Len(), v.Cap()
- case reflect.Map, reflect.String:
- valueLen = v.Len()
- }
- if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 {
- d.w.Write(openParenBytes)
- if valueLen != 0 {
- d.w.Write(lenEqualsBytes)
- printInt(d.w, int64(valueLen), 10)
- }
- if !d.cs.DisableCapacities && valueCap != 0 {
- if valueLen != 0 {
- d.w.Write(spaceBytes)
- }
- d.w.Write(capEqualsBytes)
- printInt(d.w, int64(valueCap), 10)
- }
- d.w.Write(closeParenBytes)
- d.w.Write(spaceBytes)
- }
-
- // Call Stringer/error interfaces if they exist and the handle methods flag
- // is enabled
- if !d.cs.DisableMethods {
- if (kind != reflect.Invalid) && (kind != reflect.Interface) {
- if handled := handleMethods(d.cs, d.w, v); handled {
- return
- }
- }
- }
-
- switch kind {
- case reflect.Invalid:
- // Do nothing. We should never get here since invalid has already
- // been handled above.
-
- case reflect.Bool:
- printBool(d.w, v.Bool())
-
- case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
- printInt(d.w, v.Int(), 10)
-
- case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
- printUint(d.w, v.Uint(), 10)
-
- case reflect.Float32:
- printFloat(d.w, v.Float(), 32)
-
- case reflect.Float64:
- printFloat(d.w, v.Float(), 64)
-
- case reflect.Complex64:
- printComplex(d.w, v.Complex(), 32)
-
- case reflect.Complex128:
- printComplex(d.w, v.Complex(), 64)
-
- case reflect.Slice:
- if v.IsNil() {
- d.w.Write(nilAngleBytes)
- break
- }
- fallthrough
-
- case reflect.Array:
- d.w.Write(openBraceNewlineBytes)
- d.depth++
- if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
- d.indent()
- d.w.Write(maxNewlineBytes)
- } else {
- d.dumpSlice(v)
- }
- d.depth--
- d.indent()
- d.w.Write(closeBraceBytes)
-
- case reflect.String:
- d.w.Write([]byte(strconv.Quote(v.String())))
-
- case reflect.Interface:
- // The only time we should get here is for nil interfaces due to
- // unpackValue calls.
- if v.IsNil() {
- d.w.Write(nilAngleBytes)
- }
-
- case reflect.Ptr:
- // Do nothing. We should never get here since pointers have already
- // been handled above.
-
- case reflect.Map:
- // nil maps should be indicated as different than empty maps
- if v.IsNil() {
- d.w.Write(nilAngleBytes)
- break
- }
-
- d.w.Write(openBraceNewlineBytes)
- d.depth++
- if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
- d.indent()
- d.w.Write(maxNewlineBytes)
- } else {
- numEntries := v.Len()
- keys := v.MapKeys()
- if d.cs.SortKeys {
- sortValues(keys, d.cs)
- }
- for i, key := range keys {
- d.dump(d.unpackValue(key))
- d.w.Write(colonSpaceBytes)
- d.ignoreNextIndent = true
- d.dump(d.unpackValue(v.MapIndex(key)))
- if i < (numEntries - 1) {
- d.w.Write(commaNewlineBytes)
- } else {
- d.w.Write(newlineBytes)
- }
- }
- }
- d.depth--
- d.indent()
- d.w.Write(closeBraceBytes)
-
- case reflect.Struct:
- d.w.Write(openBraceNewlineBytes)
- d.depth++
- if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
- d.indent()
- d.w.Write(maxNewlineBytes)
- } else {
- vt := v.Type()
- numFields := v.NumField()
- for i := 0; i < numFields; i++ {
- d.indent()
- vtf := vt.Field(i)
- d.w.Write([]byte(vtf.Name))
- d.w.Write(colonSpaceBytes)
- d.ignoreNextIndent = true
- d.dump(d.unpackValue(v.Field(i)))
- if i < (numFields - 1) {
- d.w.Write(commaNewlineBytes)
- } else {
- d.w.Write(newlineBytes)
- }
- }
- }
- d.depth--
- d.indent()
- d.w.Write(closeBraceBytes)
-
- case reflect.Uintptr:
- printHexPtr(d.w, uintptr(v.Uint()))
-
- case reflect.UnsafePointer, reflect.Chan, reflect.Func:
- printHexPtr(d.w, v.Pointer())
-
- // There were not any other types at the time this code was written, but
- // fall back to letting the default fmt package handle it in case any new
- // types are added.
- default:
- if v.CanInterface() {
- fmt.Fprintf(d.w, "%v", v.Interface())
- } else {
- fmt.Fprintf(d.w, "%v", v.String())
- }
- }
-}
-
-// fdump is a helper function to consolidate the logic from the various public
-// methods which take varying writers and config states.
-func fdump(cs *ConfigState, w io.Writer, a ...interface{}) {
- for _, arg := range a {
- if arg == nil {
- w.Write(interfaceBytes)
- w.Write(spaceBytes)
- w.Write(nilAngleBytes)
- w.Write(newlineBytes)
- continue
- }
-
- d := dumpState{w: w, cs: cs}
- d.pointers = make(map[uintptr]int)
- d.dump(reflect.ValueOf(arg))
- d.w.Write(newlineBytes)
- }
-}
-
-// Fdump formats and displays the passed arguments to io.Writer w. It formats
-// exactly the same as Dump.
-func Fdump(w io.Writer, a ...interface{}) {
- fdump(&Config, w, a...)
-}
-
-// Sdump returns a string with the passed arguments formatted exactly the same
-// as Dump.
-func Sdump(a ...interface{}) string {
- var buf bytes.Buffer
- fdump(&Config, &buf, a...)
- return buf.String()
-}
-
-/*
-Dump displays the passed parameters to standard out with newlines, customizable
-indentation, and additional debug information such as complete types and all
-pointer addresses used to indirect to the final value. It provides the
-following features over the built-in printing facilities provided by the fmt
-package:
-
- * Pointers are dereferenced and followed
- * Circular data structures are detected and handled properly
- * Custom Stringer/error interfaces are optionally invoked, including
- on unexported types
- * Custom types which only implement the Stringer/error interfaces via
- a pointer receiver are optionally invoked when passing non-pointer
- variables
- * Byte arrays and slices are dumped like the hexdump -C command which
- includes offsets, byte values in hex, and ASCII output
-
-The configuration options are controlled by an exported package global,
-spew.Config. See ConfigState for options documentation.
-
-See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
-get the formatted result as a string.
-*/
-func Dump(a ...interface{}) {
- fdump(&Config, os.Stdout, a...)
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/dump_test.go b/vendor/github.com/davecgh/go-spew/spew/dump_test.go
deleted file mode 100644
index 4a31a2e..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/dump_test.go
+++ /dev/null
@@ -1,1042 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
-Test Summary:
-NOTE: For each test, a nil pointer, a single pointer and double pointer to the
-base test element are also tested to ensure proper indirection across all types.
-
-- Max int8, int16, int32, int64, int
-- Max uint8, uint16, uint32, uint64, uint
-- Boolean true and false
-- Standard complex64 and complex128
-- Array containing standard ints
-- Array containing type with custom formatter on pointer receiver only
-- Array containing interfaces
-- Array containing bytes
-- Slice containing standard float32 values
-- Slice containing type with custom formatter on pointer receiver only
-- Slice containing interfaces
-- Slice containing bytes
-- Nil slice
-- Standard string
-- Nil interface
-- Sub-interface
-- Map with string keys and int vals
-- Map with custom formatter type on pointer receiver only keys and vals
-- Map with interface keys and values
-- Map with nil interface value
-- Struct with primitives
-- Struct that contains another struct
-- Struct that contains custom type with Stringer pointer interface via both
- exported and unexported fields
-- Struct that contains embedded struct and field to same struct
-- Uintptr to 0 (null pointer)
-- Uintptr address of real variable
-- Unsafe.Pointer to 0 (null pointer)
-- Unsafe.Pointer to address of real variable
-- Nil channel
-- Standard int channel
-- Function with no params and no returns
-- Function with param and no returns
-- Function with multiple params and multiple returns
-- Struct that is circular through self referencing
-- Structs that are circular through cross referencing
-- Structs that are indirectly circular
-- Type that panics in its Stringer interface
-*/
-
-package spew_test
-
-import (
- "bytes"
- "fmt"
- "testing"
- "unsafe"
-
- "github.com/davecgh/go-spew/spew"
-)
-
-// dumpTest is used to describe a test to be performed against the Dump method.
-type dumpTest struct {
- in interface{}
- wants []string
-}
-
-// dumpTests houses all of the tests to be performed against the Dump method.
-var dumpTests = make([]dumpTest, 0)
-
-// addDumpTest is a helper method to append the passed input and desired result
-// to dumpTests
-func addDumpTest(in interface{}, wants ...string) {
- test := dumpTest{in, wants}
- dumpTests = append(dumpTests, test)
-}
-
-func addIntDumpTests() {
- // Max int8.
- v := int8(127)
- nv := (*int8)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "int8"
- vs := "127"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Max int16.
- v2 := int16(32767)
- nv2 := (*int16)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "int16"
- v2s := "32767"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv2, "(*"+v2t+")()\n")
-
- // Max int32.
- v3 := int32(2147483647)
- nv3 := (*int32)(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "int32"
- v3s := "2147483647"
- addDumpTest(v3, "("+v3t+") "+v3s+"\n")
- addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n")
- addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n")
- addDumpTest(nv3, "(*"+v3t+")()\n")
-
- // Max int64.
- v4 := int64(9223372036854775807)
- nv4 := (*int64)(nil)
- pv4 := &v4
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "int64"
- v4s := "9223372036854775807"
- addDumpTest(v4, "("+v4t+") "+v4s+"\n")
- addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n")
- addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n")
- addDumpTest(nv4, "(*"+v4t+")()\n")
-
- // Max int.
- v5 := int(2147483647)
- nv5 := (*int)(nil)
- pv5 := &v5
- v5Addr := fmt.Sprintf("%p", pv5)
- pv5Addr := fmt.Sprintf("%p", &pv5)
- v5t := "int"
- v5s := "2147483647"
- addDumpTest(v5, "("+v5t+") "+v5s+"\n")
- addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n")
- addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n")
- addDumpTest(nv5, "(*"+v5t+")()\n")
-}
-
-func addUintDumpTests() {
- // Max uint8.
- v := uint8(255)
- nv := (*uint8)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "uint8"
- vs := "255"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Max uint16.
- v2 := uint16(65535)
- nv2 := (*uint16)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "uint16"
- v2s := "65535"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv2, "(*"+v2t+")()\n")
-
- // Max uint32.
- v3 := uint32(4294967295)
- nv3 := (*uint32)(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "uint32"
- v3s := "4294967295"
- addDumpTest(v3, "("+v3t+") "+v3s+"\n")
- addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n")
- addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n")
- addDumpTest(nv3, "(*"+v3t+")()\n")
-
- // Max uint64.
- v4 := uint64(18446744073709551615)
- nv4 := (*uint64)(nil)
- pv4 := &v4
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "uint64"
- v4s := "18446744073709551615"
- addDumpTest(v4, "("+v4t+") "+v4s+"\n")
- addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n")
- addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n")
- addDumpTest(nv4, "(*"+v4t+")()\n")
-
- // Max uint.
- v5 := uint(4294967295)
- nv5 := (*uint)(nil)
- pv5 := &v5
- v5Addr := fmt.Sprintf("%p", pv5)
- pv5Addr := fmt.Sprintf("%p", &pv5)
- v5t := "uint"
- v5s := "4294967295"
- addDumpTest(v5, "("+v5t+") "+v5s+"\n")
- addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n")
- addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n")
- addDumpTest(nv5, "(*"+v5t+")()\n")
-}
-
-func addBoolDumpTests() {
- // Boolean true.
- v := bool(true)
- nv := (*bool)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "bool"
- vs := "true"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Boolean false.
- v2 := bool(false)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "bool"
- v2s := "false"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
-}
-
-func addFloatDumpTests() {
- // Standard float32.
- v := float32(3.1415)
- nv := (*float32)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "float32"
- vs := "3.1415"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Standard float64.
- v2 := float64(3.1415926)
- nv2 := (*float64)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "float64"
- v2s := "3.1415926"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv2, "(*"+v2t+")()\n")
-}
-
-func addComplexDumpTests() {
- // Standard complex64.
- v := complex(float32(6), -2)
- nv := (*complex64)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "complex64"
- vs := "(6-2i)"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Standard complex128.
- v2 := complex(float64(-6), 2)
- nv2 := (*complex128)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "complex128"
- v2s := "(-6+2i)"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv2, "(*"+v2t+")()\n")
-}
-
-func addArrayDumpTests() {
- // Array containing standard ints.
- v := [3]int{1, 2, 3}
- vLen := fmt.Sprintf("%d", len(v))
- vCap := fmt.Sprintf("%d", cap(v))
- nv := (*[3]int)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "int"
- vs := "(len=" + vLen + " cap=" + vCap + ") {\n (" + vt + ") 1,\n (" +
- vt + ") 2,\n (" + vt + ") 3\n}"
- addDumpTest(v, "([3]"+vt+") "+vs+"\n")
- addDumpTest(pv, "(*[3]"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**[3]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*[3]"+vt+")()\n")
-
- // Array containing type with custom formatter on pointer receiver only.
- v2i0 := pstringer("1")
- v2i1 := pstringer("2")
- v2i2 := pstringer("3")
- v2 := [3]pstringer{v2i0, v2i1, v2i2}
- v2i0Len := fmt.Sprintf("%d", len(v2i0))
- v2i1Len := fmt.Sprintf("%d", len(v2i1))
- v2i2Len := fmt.Sprintf("%d", len(v2i2))
- v2Len := fmt.Sprintf("%d", len(v2))
- v2Cap := fmt.Sprintf("%d", cap(v2))
- nv2 := (*[3]pstringer)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "spew_test.pstringer"
- v2sp := "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t +
- ") (len=" + v2i0Len + ") stringer 1,\n (" + v2t +
- ") (len=" + v2i1Len + ") stringer 2,\n (" + v2t +
- ") (len=" + v2i2Len + ") " + "stringer 3\n}"
- v2s := v2sp
- if spew.UnsafeDisabled {
- v2s = "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t +
- ") (len=" + v2i0Len + ") \"1\",\n (" + v2t + ") (len=" +
- v2i1Len + ") \"2\",\n (" + v2t + ") (len=" + v2i2Len +
- ") " + "\"3\"\n}"
- }
- addDumpTest(v2, "([3]"+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*[3]"+v2t+")("+v2Addr+")("+v2sp+")\n")
- addDumpTest(&pv2, "(**[3]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2sp+")\n")
- addDumpTest(nv2, "(*[3]"+v2t+")()\n")
-
- // Array containing interfaces.
- v3i0 := "one"
- v3 := [3]interface{}{v3i0, int(2), uint(3)}
- v3i0Len := fmt.Sprintf("%d", len(v3i0))
- v3Len := fmt.Sprintf("%d", len(v3))
- v3Cap := fmt.Sprintf("%d", cap(v3))
- nv3 := (*[3]interface{})(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "[3]interface {}"
- v3t2 := "string"
- v3t3 := "int"
- v3t4 := "uint"
- v3s := "(len=" + v3Len + " cap=" + v3Cap + ") {\n (" + v3t2 + ") " +
- "(len=" + v3i0Len + ") \"one\",\n (" + v3t3 + ") 2,\n (" +
- v3t4 + ") 3\n}"
- addDumpTest(v3, "("+v3t+") "+v3s+"\n")
- addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n")
- addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n")
- addDumpTest(nv3, "(*"+v3t+")()\n")
-
- // Array containing bytes.
- v4 := [34]byte{
- 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
- 0x31, 0x32,
- }
- v4Len := fmt.Sprintf("%d", len(v4))
- v4Cap := fmt.Sprintf("%d", cap(v4))
- nv4 := (*[34]byte)(nil)
- pv4 := &v4
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "[34]uint8"
- v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " +
- "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" +
- " |............... |\n" +
- " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" +
- " |!\"#$%&'()*+,-./0|\n" +
- " 00000020 31 32 " +
- " |12|\n}"
- addDumpTest(v4, "("+v4t+") "+v4s+"\n")
- addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n")
- addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n")
- addDumpTest(nv4, "(*"+v4t+")()\n")
-}
-
-func addSliceDumpTests() {
- // Slice containing standard float32 values.
- v := []float32{3.14, 6.28, 12.56}
- vLen := fmt.Sprintf("%d", len(v))
- vCap := fmt.Sprintf("%d", cap(v))
- nv := (*[]float32)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "float32"
- vs := "(len=" + vLen + " cap=" + vCap + ") {\n (" + vt + ") 3.14,\n (" +
- vt + ") 6.28,\n (" + vt + ") 12.56\n}"
- addDumpTest(v, "([]"+vt+") "+vs+"\n")
- addDumpTest(pv, "(*[]"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**[]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*[]"+vt+")()\n")
-
- // Slice containing type with custom formatter on pointer receiver only.
- v2i0 := pstringer("1")
- v2i1 := pstringer("2")
- v2i2 := pstringer("3")
- v2 := []pstringer{v2i0, v2i1, v2i2}
- v2i0Len := fmt.Sprintf("%d", len(v2i0))
- v2i1Len := fmt.Sprintf("%d", len(v2i1))
- v2i2Len := fmt.Sprintf("%d", len(v2i2))
- v2Len := fmt.Sprintf("%d", len(v2))
- v2Cap := fmt.Sprintf("%d", cap(v2))
- nv2 := (*[]pstringer)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "spew_test.pstringer"
- v2s := "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + ") (len=" +
- v2i0Len + ") stringer 1,\n (" + v2t + ") (len=" + v2i1Len +
- ") stringer 2,\n (" + v2t + ") (len=" + v2i2Len + ") " +
- "stringer 3\n}"
- addDumpTest(v2, "([]"+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*[]"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**[]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv2, "(*[]"+v2t+")()\n")
-
- // Slice containing interfaces.
- v3i0 := "one"
- v3 := []interface{}{v3i0, int(2), uint(3), nil}
- v3i0Len := fmt.Sprintf("%d", len(v3i0))
- v3Len := fmt.Sprintf("%d", len(v3))
- v3Cap := fmt.Sprintf("%d", cap(v3))
- nv3 := (*[]interface{})(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "[]interface {}"
- v3t2 := "string"
- v3t3 := "int"
- v3t4 := "uint"
- v3t5 := "interface {}"
- v3s := "(len=" + v3Len + " cap=" + v3Cap + ") {\n (" + v3t2 + ") " +
- "(len=" + v3i0Len + ") \"one\",\n (" + v3t3 + ") 2,\n (" +
- v3t4 + ") 3,\n (" + v3t5 + ") \n}"
- addDumpTest(v3, "("+v3t+") "+v3s+"\n")
- addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n")
- addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n")
- addDumpTest(nv3, "(*"+v3t+")()\n")
-
- // Slice containing bytes.
- v4 := []byte{
- 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
- 0x31, 0x32,
- }
- v4Len := fmt.Sprintf("%d", len(v4))
- v4Cap := fmt.Sprintf("%d", cap(v4))
- nv4 := (*[]byte)(nil)
- pv4 := &v4
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "[]uint8"
- v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " +
- "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" +
- " |............... |\n" +
- " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" +
- " |!\"#$%&'()*+,-./0|\n" +
- " 00000020 31 32 " +
- " |12|\n}"
- addDumpTest(v4, "("+v4t+") "+v4s+"\n")
- addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n")
- addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n")
- addDumpTest(nv4, "(*"+v4t+")()\n")
-
- // Nil slice.
- v5 := []int(nil)
- nv5 := (*[]int)(nil)
- pv5 := &v5
- v5Addr := fmt.Sprintf("%p", pv5)
- pv5Addr := fmt.Sprintf("%p", &pv5)
- v5t := "[]int"
- v5s := ""
- addDumpTest(v5, "("+v5t+") "+v5s+"\n")
- addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n")
- addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n")
- addDumpTest(nv5, "(*"+v5t+")()\n")
-}
-
-func addStringDumpTests() {
- // Standard string.
- v := "test"
- vLen := fmt.Sprintf("%d", len(v))
- nv := (*string)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "string"
- vs := "(len=" + vLen + ") \"test\""
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-}
-
-func addInterfaceDumpTests() {
- // Nil interface.
- var v interface{}
- nv := (*interface{})(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "interface {}"
- vs := ""
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Sub-interface.
- v2 := interface{}(uint16(65535))
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "uint16"
- v2s := "65535"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
-}
-
-func addMapDumpTests() {
- // Map with string keys and int vals.
- k := "one"
- kk := "two"
- m := map[string]int{k: 1, kk: 2}
- klen := fmt.Sprintf("%d", len(k)) // not kLen to shut golint up
- kkLen := fmt.Sprintf("%d", len(kk))
- mLen := fmt.Sprintf("%d", len(m))
- nilMap := map[string]int(nil)
- nm := (*map[string]int)(nil)
- pm := &m
- mAddr := fmt.Sprintf("%p", pm)
- pmAddr := fmt.Sprintf("%p", &pm)
- mt := "map[string]int"
- mt1 := "string"
- mt2 := "int"
- ms := "(len=" + mLen + ") {\n (" + mt1 + ") (len=" + klen + ") " +
- "\"one\": (" + mt2 + ") 1,\n (" + mt1 + ") (len=" + kkLen +
- ") \"two\": (" + mt2 + ") 2\n}"
- ms2 := "(len=" + mLen + ") {\n (" + mt1 + ") (len=" + kkLen + ") " +
- "\"two\": (" + mt2 + ") 2,\n (" + mt1 + ") (len=" + klen +
- ") \"one\": (" + mt2 + ") 1\n}"
- addDumpTest(m, "("+mt+") "+ms+"\n", "("+mt+") "+ms2+"\n")
- addDumpTest(pm, "(*"+mt+")("+mAddr+")("+ms+")\n",
- "(*"+mt+")("+mAddr+")("+ms2+")\n")
- addDumpTest(&pm, "(**"+mt+")("+pmAddr+"->"+mAddr+")("+ms+")\n",
- "(**"+mt+")("+pmAddr+"->"+mAddr+")("+ms2+")\n")
- addDumpTest(nm, "(*"+mt+")()\n")
- addDumpTest(nilMap, "("+mt+") \n")
-
- // Map with custom formatter type on pointer receiver only keys and vals.
- k2 := pstringer("one")
- v2 := pstringer("1")
- m2 := map[pstringer]pstringer{k2: v2}
- k2Len := fmt.Sprintf("%d", len(k2))
- v2Len := fmt.Sprintf("%d", len(v2))
- m2Len := fmt.Sprintf("%d", len(m2))
- nilMap2 := map[pstringer]pstringer(nil)
- nm2 := (*map[pstringer]pstringer)(nil)
- pm2 := &m2
- m2Addr := fmt.Sprintf("%p", pm2)
- pm2Addr := fmt.Sprintf("%p", &pm2)
- m2t := "map[spew_test.pstringer]spew_test.pstringer"
- m2t1 := "spew_test.pstringer"
- m2t2 := "spew_test.pstringer"
- m2s := "(len=" + m2Len + ") {\n (" + m2t1 + ") (len=" + k2Len + ") " +
- "stringer one: (" + m2t2 + ") (len=" + v2Len + ") stringer 1\n}"
- if spew.UnsafeDisabled {
- m2s = "(len=" + m2Len + ") {\n (" + m2t1 + ") (len=" + k2Len +
- ") " + "\"one\": (" + m2t2 + ") (len=" + v2Len +
- ") \"1\"\n}"
- }
- addDumpTest(m2, "("+m2t+") "+m2s+"\n")
- addDumpTest(pm2, "(*"+m2t+")("+m2Addr+")("+m2s+")\n")
- addDumpTest(&pm2, "(**"+m2t+")("+pm2Addr+"->"+m2Addr+")("+m2s+")\n")
- addDumpTest(nm2, "(*"+m2t+")()\n")
- addDumpTest(nilMap2, "("+m2t+") \n")
-
- // Map with interface keys and values.
- k3 := "one"
- k3Len := fmt.Sprintf("%d", len(k3))
- m3 := map[interface{}]interface{}{k3: 1}
- m3Len := fmt.Sprintf("%d", len(m3))
- nilMap3 := map[interface{}]interface{}(nil)
- nm3 := (*map[interface{}]interface{})(nil)
- pm3 := &m3
- m3Addr := fmt.Sprintf("%p", pm3)
- pm3Addr := fmt.Sprintf("%p", &pm3)
- m3t := "map[interface {}]interface {}"
- m3t1 := "string"
- m3t2 := "int"
- m3s := "(len=" + m3Len + ") {\n (" + m3t1 + ") (len=" + k3Len + ") " +
- "\"one\": (" + m3t2 + ") 1\n}"
- addDumpTest(m3, "("+m3t+") "+m3s+"\n")
- addDumpTest(pm3, "(*"+m3t+")("+m3Addr+")("+m3s+")\n")
- addDumpTest(&pm3, "(**"+m3t+")("+pm3Addr+"->"+m3Addr+")("+m3s+")\n")
- addDumpTest(nm3, "(*"+m3t+")()\n")
- addDumpTest(nilMap3, "("+m3t+") \n")
-
- // Map with nil interface value.
- k4 := "nil"
- k4Len := fmt.Sprintf("%d", len(k4))
- m4 := map[string]interface{}{k4: nil}
- m4Len := fmt.Sprintf("%d", len(m4))
- nilMap4 := map[string]interface{}(nil)
- nm4 := (*map[string]interface{})(nil)
- pm4 := &m4
- m4Addr := fmt.Sprintf("%p", pm4)
- pm4Addr := fmt.Sprintf("%p", &pm4)
- m4t := "map[string]interface {}"
- m4t1 := "string"
- m4t2 := "interface {}"
- m4s := "(len=" + m4Len + ") {\n (" + m4t1 + ") (len=" + k4Len + ")" +
- " \"nil\": (" + m4t2 + ") \n}"
- addDumpTest(m4, "("+m4t+") "+m4s+"\n")
- addDumpTest(pm4, "(*"+m4t+")("+m4Addr+")("+m4s+")\n")
- addDumpTest(&pm4, "(**"+m4t+")("+pm4Addr+"->"+m4Addr+")("+m4s+")\n")
- addDumpTest(nm4, "(*"+m4t+")()\n")
- addDumpTest(nilMap4, "("+m4t+") \n")
-}
-
-func addStructDumpTests() {
- // Struct with primitives.
- type s1 struct {
- a int8
- b uint8
- }
- v := s1{127, 255}
- nv := (*s1)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "spew_test.s1"
- vt2 := "int8"
- vt3 := "uint8"
- vs := "{\n a: (" + vt2 + ") 127,\n b: (" + vt3 + ") 255\n}"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Struct that contains another struct.
- type s2 struct {
- s1 s1
- b bool
- }
- v2 := s2{s1{127, 255}, true}
- nv2 := (*s2)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "spew_test.s2"
- v2t2 := "spew_test.s1"
- v2t3 := "int8"
- v2t4 := "uint8"
- v2t5 := "bool"
- v2s := "{\n s1: (" + v2t2 + ") {\n a: (" + v2t3 + ") 127,\n b: (" +
- v2t4 + ") 255\n },\n b: (" + v2t5 + ") true\n}"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv2, "(*"+v2t+")()\n")
-
- // Struct that contains custom type with Stringer pointer interface via both
- // exported and unexported fields.
- type s3 struct {
- s pstringer
- S pstringer
- }
- v3 := s3{"test", "test2"}
- nv3 := (*s3)(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "spew_test.s3"
- v3t2 := "spew_test.pstringer"
- v3s := "{\n s: (" + v3t2 + ") (len=4) stringer test,\n S: (" + v3t2 +
- ") (len=5) stringer test2\n}"
- v3sp := v3s
- if spew.UnsafeDisabled {
- v3s = "{\n s: (" + v3t2 + ") (len=4) \"test\",\n S: (" +
- v3t2 + ") (len=5) \"test2\"\n}"
- v3sp = "{\n s: (" + v3t2 + ") (len=4) \"test\",\n S: (" +
- v3t2 + ") (len=5) stringer test2\n}"
- }
- addDumpTest(v3, "("+v3t+") "+v3s+"\n")
- addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3sp+")\n")
- addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3sp+")\n")
- addDumpTest(nv3, "(*"+v3t+")()\n")
-
- // Struct that contains embedded struct and field to same struct.
- e := embed{"embedstr"}
- eLen := fmt.Sprintf("%d", len("embedstr"))
- v4 := embedwrap{embed: &e, e: &e}
- nv4 := (*embedwrap)(nil)
- pv4 := &v4
- eAddr := fmt.Sprintf("%p", &e)
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "spew_test.embedwrap"
- v4t2 := "spew_test.embed"
- v4t3 := "string"
- v4s := "{\n embed: (*" + v4t2 + ")(" + eAddr + ")({\n a: (" + v4t3 +
- ") (len=" + eLen + ") \"embedstr\"\n }),\n e: (*" + v4t2 +
- ")(" + eAddr + ")({\n a: (" + v4t3 + ") (len=" + eLen + ")" +
- " \"embedstr\"\n })\n}"
- addDumpTest(v4, "("+v4t+") "+v4s+"\n")
- addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n")
- addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n")
- addDumpTest(nv4, "(*"+v4t+")()\n")
-}
-
-func addUintptrDumpTests() {
- // Null pointer.
- v := uintptr(0)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "uintptr"
- vs := ""
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
-
- // Address of real variable.
- i := 1
- v2 := uintptr(unsafe.Pointer(&i))
- nv2 := (*uintptr)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "uintptr"
- v2s := fmt.Sprintf("%p", &i)
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv2, "(*"+v2t+")()\n")
-}
-
-func addUnsafePointerDumpTests() {
- // Null pointer.
- v := unsafe.Pointer(nil)
- nv := (*unsafe.Pointer)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "unsafe.Pointer"
- vs := ""
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Address of real variable.
- i := 1
- v2 := unsafe.Pointer(&i)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "unsafe.Pointer"
- v2s := fmt.Sprintf("%p", &i)
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-}
-
-func addChanDumpTests() {
- // Nil channel.
- var v chan int
- pv := &v
- nv := (*chan int)(nil)
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "chan int"
- vs := ""
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Real channel.
- v2 := make(chan int)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "chan int"
- v2s := fmt.Sprintf("%p", v2)
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
-}
-
-func addFuncDumpTests() {
- // Function with no params and no returns.
- v := addIntDumpTests
- nv := (*func())(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "func()"
- vs := fmt.Sprintf("%p", v)
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-
- // Function with param and no returns.
- v2 := TestDump
- nv2 := (*func(*testing.T))(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "func(*testing.T)"
- v2s := fmt.Sprintf("%p", v2)
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n")
- addDumpTest(nv2, "(*"+v2t+")()\n")
-
- // Function with multiple params and multiple returns.
- var v3 = func(i int, s string) (b bool, err error) {
- return true, nil
- }
- nv3 := (*func(int, string) (bool, error))(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "func(int, string) (bool, error)"
- v3s := fmt.Sprintf("%p", v3)
- addDumpTest(v3, "("+v3t+") "+v3s+"\n")
- addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n")
- addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n")
- addDumpTest(nv3, "(*"+v3t+")()\n")
-}
-
-func addCircularDumpTests() {
- // Struct that is circular through self referencing.
- type circular struct {
- c *circular
- }
- v := circular{nil}
- v.c = &v
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "spew_test.circular"
- vs := "{\n c: (*" + vt + ")(" + vAddr + ")({\n c: (*" + vt + ")(" +
- vAddr + ")()\n })\n}"
- vs2 := "{\n c: (*" + vt + ")(" + vAddr + ")()\n}"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs2+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs2+")\n")
-
- // Structs that are circular through cross referencing.
- v2 := xref1{nil}
- ts2 := xref2{&v2}
- v2.ps2 = &ts2
- pv2 := &v2
- ts2Addr := fmt.Sprintf("%p", &ts2)
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "spew_test.xref1"
- v2t2 := "spew_test.xref2"
- v2s := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t +
- ")(" + v2Addr + ")({\n ps2: (*" + v2t2 + ")(" + ts2Addr +
- ")()\n })\n })\n}"
- v2s2 := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t +
- ")(" + v2Addr + ")()\n })\n}"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
- addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s2+")\n")
- addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s2+")\n")
-
- // Structs that are indirectly circular.
- v3 := indirCir1{nil}
- tic2 := indirCir2{nil}
- tic3 := indirCir3{&v3}
- tic2.ps3 = &tic3
- v3.ps2 = &tic2
- pv3 := &v3
- tic2Addr := fmt.Sprintf("%p", &tic2)
- tic3Addr := fmt.Sprintf("%p", &tic3)
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "spew_test.indirCir1"
- v3t2 := "spew_test.indirCir2"
- v3t3 := "spew_test.indirCir3"
- v3s := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 +
- ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr +
- ")({\n ps2: (*" + v3t2 + ")(" + tic2Addr +
- ")()\n })\n })\n })\n}"
- v3s2 := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 +
- ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr +
- ")()\n })\n })\n}"
- addDumpTest(v3, "("+v3t+") "+v3s+"\n")
- addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s2+")\n")
- addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s2+")\n")
-}
-
-func addPanicDumpTests() {
- // Type that panics in its Stringer interface.
- v := panicer(127)
- nv := (*panicer)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "spew_test.panicer"
- vs := "(PANIC=test panic)127"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-}
-
-func addErrorDumpTests() {
- // Type that has a custom Error interface.
- v := customError(127)
- nv := (*customError)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "spew_test.customError"
- vs := "error: 127"
- addDumpTest(v, "("+vt+") "+vs+"\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n")
- addDumpTest(nv, "(*"+vt+")()\n")
-}
-
-// TestDump executes all of the tests described by dumpTests.
-func TestDump(t *testing.T) {
- // Setup tests.
- addIntDumpTests()
- addUintDumpTests()
- addBoolDumpTests()
- addFloatDumpTests()
- addComplexDumpTests()
- addArrayDumpTests()
- addSliceDumpTests()
- addStringDumpTests()
- addInterfaceDumpTests()
- addMapDumpTests()
- addStructDumpTests()
- addUintptrDumpTests()
- addUnsafePointerDumpTests()
- addChanDumpTests()
- addFuncDumpTests()
- addCircularDumpTests()
- addPanicDumpTests()
- addErrorDumpTests()
- addCgoDumpTests()
-
- t.Logf("Running %d tests", len(dumpTests))
- for i, test := range dumpTests {
- buf := new(bytes.Buffer)
- spew.Fdump(buf, test.in)
- s := buf.String()
- if testFailed(s, test.wants) {
- t.Errorf("Dump #%d\n got: %s %s", i, s, stringizeWants(test.wants))
- continue
- }
- }
-}
-
-func TestDumpSortedKeys(t *testing.T) {
- cfg := spew.ConfigState{SortKeys: true}
- s := cfg.Sdump(map[int]string{1: "1", 3: "3", 2: "2"})
- expected := "(map[int]string) (len=3) {\n(int) 1: (string) (len=1) " +
- "\"1\",\n(int) 2: (string) (len=1) \"2\",\n(int) 3: (string) " +
- "(len=1) \"3\"\n" +
- "}\n"
- if s != expected {
- t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
- }
-
- s = cfg.Sdump(map[stringer]int{"1": 1, "3": 3, "2": 2})
- expected = "(map[spew_test.stringer]int) (len=3) {\n" +
- "(spew_test.stringer) (len=1) stringer 1: (int) 1,\n" +
- "(spew_test.stringer) (len=1) stringer 2: (int) 2,\n" +
- "(spew_test.stringer) (len=1) stringer 3: (int) 3\n" +
- "}\n"
- if s != expected {
- t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
- }
-
- s = cfg.Sdump(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2})
- expected = "(map[spew_test.pstringer]int) (len=3) {\n" +
- "(spew_test.pstringer) (len=1) stringer 1: (int) 1,\n" +
- "(spew_test.pstringer) (len=1) stringer 2: (int) 2,\n" +
- "(spew_test.pstringer) (len=1) stringer 3: (int) 3\n" +
- "}\n"
- if spew.UnsafeDisabled {
- expected = "(map[spew_test.pstringer]int) (len=3) {\n" +
- "(spew_test.pstringer) (len=1) \"1\": (int) 1,\n" +
- "(spew_test.pstringer) (len=1) \"2\": (int) 2,\n" +
- "(spew_test.pstringer) (len=1) \"3\": (int) 3\n" +
- "}\n"
- }
- if s != expected {
- t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
- }
-
- s = cfg.Sdump(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2})
- expected = "(map[spew_test.customError]int) (len=3) {\n" +
- "(spew_test.customError) error: 1: (int) 1,\n" +
- "(spew_test.customError) error: 2: (int) 2,\n" +
- "(spew_test.customError) error: 3: (int) 3\n" +
- "}\n"
- if s != expected {
- t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
- }
-
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go
deleted file mode 100644
index 108baa5..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (c) 2013-2016 Dave Collins
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-// NOTE: Due to the following build constraints, this file will only be compiled
-// when both cgo is supported and "-tags testcgo" is added to the go test
-// command line. This means the cgo tests are only added (and hence run) when
-// specifially requested. This configuration is used because spew itself
-// does not require cgo to run even though it does handle certain cgo types
-// specially. Rather than forcing all clients to require cgo and an external
-// C compiler just to run the tests, this scheme makes them optional.
-// +build cgo,testcgo
-
-package spew_test
-
-import (
- "fmt"
-
- "github.com/davecgh/go-spew/spew/testdata"
-)
-
-func addCgoDumpTests() {
- // C char pointer.
- v := testdata.GetCgoCharPointer()
- nv := testdata.GetCgoNullCharPointer()
- pv := &v
- vcAddr := fmt.Sprintf("%p", v)
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "*testdata._Ctype_char"
- vs := "116"
- addDumpTest(v, "("+vt+")("+vcAddr+")("+vs+")\n")
- addDumpTest(pv, "(*"+vt+")("+vAddr+"->"+vcAddr+")("+vs+")\n")
- addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+"->"+vcAddr+")("+vs+")\n")
- addDumpTest(nv, "("+vt+")()\n")
-
- // C char array.
- v2, v2l, v2c := testdata.GetCgoCharArray()
- v2Len := fmt.Sprintf("%d", v2l)
- v2Cap := fmt.Sprintf("%d", v2c)
- v2t := "[6]testdata._Ctype_char"
- v2s := "(len=" + v2Len + " cap=" + v2Cap + ") " +
- "{\n 00000000 74 65 73 74 32 00 " +
- " |test2.|\n}"
- addDumpTest(v2, "("+v2t+") "+v2s+"\n")
-
- // C unsigned char array.
- v3, v3l, v3c := testdata.GetCgoUnsignedCharArray()
- v3Len := fmt.Sprintf("%d", v3l)
- v3Cap := fmt.Sprintf("%d", v3c)
- v3t := "[6]testdata._Ctype_unsignedchar"
- v3t2 := "[6]testdata._Ctype_uchar"
- v3s := "(len=" + v3Len + " cap=" + v3Cap + ") " +
- "{\n 00000000 74 65 73 74 33 00 " +
- " |test3.|\n}"
- addDumpTest(v3, "("+v3t+") "+v3s+"\n", "("+v3t2+") "+v3s+"\n")
-
- // C signed char array.
- v4, v4l, v4c := testdata.GetCgoSignedCharArray()
- v4Len := fmt.Sprintf("%d", v4l)
- v4Cap := fmt.Sprintf("%d", v4c)
- v4t := "[6]testdata._Ctype_schar"
- v4t2 := "testdata._Ctype_schar"
- v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " +
- "{\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 101,\n (" + v4t2 +
- ") 115,\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 52,\n (" + v4t2 +
- ") 0\n}"
- addDumpTest(v4, "("+v4t+") "+v4s+"\n")
-
- // C uint8_t array.
- v5, v5l, v5c := testdata.GetCgoUint8tArray()
- v5Len := fmt.Sprintf("%d", v5l)
- v5Cap := fmt.Sprintf("%d", v5c)
- v5t := "[6]testdata._Ctype_uint8_t"
- v5t2 := "[6]testdata._Ctype_uchar"
- v5s := "(len=" + v5Len + " cap=" + v5Cap + ") " +
- "{\n 00000000 74 65 73 74 35 00 " +
- " |test5.|\n}"
- addDumpTest(v5, "("+v5t+") "+v5s+"\n", "("+v5t2+") "+v5s+"\n")
-
- // C typedefed unsigned char array.
- v6, v6l, v6c := testdata.GetCgoTypdefedUnsignedCharArray()
- v6Len := fmt.Sprintf("%d", v6l)
- v6Cap := fmt.Sprintf("%d", v6c)
- v6t := "[6]testdata._Ctype_custom_uchar_t"
- v6t2 := "[6]testdata._Ctype_uchar"
- v6s := "(len=" + v6Len + " cap=" + v6Cap + ") " +
- "{\n 00000000 74 65 73 74 36 00 " +
- " |test6.|\n}"
- addDumpTest(v6, "("+v6t+") "+v6s+"\n", "("+v6t2+") "+v6s+"\n")
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go
deleted file mode 100644
index 52a0971..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2013 Dave Collins
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-// NOTE: Due to the following build constraints, this file will only be compiled
-// when either cgo is not supported or "-tags testcgo" is not added to the go
-// test command line. This file intentionally does not setup any cgo tests in
-// this scenario.
-// +build !cgo !testcgo
-
-package spew_test
-
-func addCgoDumpTests() {
- // Don't add any tests for cgo since this file is only compiled when
- // there should not be any cgo tests.
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/example_test.go b/vendor/github.com/davecgh/go-spew/spew/example_test.go
deleted file mode 100644
index c6ec8c6..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/example_test.go
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package spew_test
-
-import (
- "fmt"
-
- "github.com/davecgh/go-spew/spew"
-)
-
-type Flag int
-
-const (
- flagOne Flag = iota
- flagTwo
-)
-
-var flagStrings = map[Flag]string{
- flagOne: "flagOne",
- flagTwo: "flagTwo",
-}
-
-func (f Flag) String() string {
- if s, ok := flagStrings[f]; ok {
- return s
- }
- return fmt.Sprintf("Unknown flag (%d)", int(f))
-}
-
-type Bar struct {
- data uintptr
-}
-
-type Foo struct {
- unexportedField Bar
- ExportedField map[interface{}]interface{}
-}
-
-// This example demonstrates how to use Dump to dump variables to stdout.
-func ExampleDump() {
- // The following package level declarations are assumed for this example:
- /*
- type Flag int
-
- const (
- flagOne Flag = iota
- flagTwo
- )
-
- var flagStrings = map[Flag]string{
- flagOne: "flagOne",
- flagTwo: "flagTwo",
- }
-
- func (f Flag) String() string {
- if s, ok := flagStrings[f]; ok {
- return s
- }
- return fmt.Sprintf("Unknown flag (%d)", int(f))
- }
-
- type Bar struct {
- data uintptr
- }
-
- type Foo struct {
- unexportedField Bar
- ExportedField map[interface{}]interface{}
- }
- */
-
- // Setup some sample data structures for the example.
- bar := Bar{uintptr(0)}
- s1 := Foo{bar, map[interface{}]interface{}{"one": true}}
- f := Flag(5)
- b := []byte{
- 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
- 0x31, 0x32,
- }
-
- // Dump!
- spew.Dump(s1, f, b)
-
- // Output:
- // (spew_test.Foo) {
- // unexportedField: (spew_test.Bar) {
- // data: (uintptr)
- // },
- // ExportedField: (map[interface {}]interface {}) (len=1) {
- // (string) (len=3) "one": (bool) true
- // }
- // }
- // (spew_test.Flag) Unknown flag (5)
- // ([]uint8) (len=34 cap=34) {
- // 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
- // 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
- // 00000020 31 32 |12|
- // }
- //
-}
-
-// This example demonstrates how to use Printf to display a variable with a
-// format string and inline formatting.
-func ExamplePrintf() {
- // Create a double pointer to a uint 8.
- ui8 := uint8(5)
- pui8 := &ui8
- ppui8 := &pui8
-
- // Create a circular data type.
- type circular struct {
- ui8 uint8
- c *circular
- }
- c := circular{ui8: 1}
- c.c = &c
-
- // Print!
- spew.Printf("ppui8: %v\n", ppui8)
- spew.Printf("circular: %v\n", c)
-
- // Output:
- // ppui8: <**>5
- // circular: {1 <*>{1 <*>}}
-}
-
-// This example demonstrates how to use a ConfigState.
-func ExampleConfigState() {
- // Modify the indent level of the ConfigState only. The global
- // configuration is not modified.
- scs := spew.ConfigState{Indent: "\t"}
-
- // Output using the ConfigState instance.
- v := map[string]int{"one": 1}
- scs.Printf("v: %v\n", v)
- scs.Dump(v)
-
- // Output:
- // v: map[one:1]
- // (map[string]int) (len=1) {
- // (string) (len=3) "one": (int) 1
- // }
-}
-
-// This example demonstrates how to use ConfigState.Dump to dump variables to
-// stdout
-func ExampleConfigState_Dump() {
- // See the top-level Dump example for details on the types used in this
- // example.
-
- // Create two ConfigState instances with different indentation.
- scs := spew.ConfigState{Indent: "\t"}
- scs2 := spew.ConfigState{Indent: " "}
-
- // Setup some sample data structures for the example.
- bar := Bar{uintptr(0)}
- s1 := Foo{bar, map[interface{}]interface{}{"one": true}}
-
- // Dump using the ConfigState instances.
- scs.Dump(s1)
- scs2.Dump(s1)
-
- // Output:
- // (spew_test.Foo) {
- // unexportedField: (spew_test.Bar) {
- // data: (uintptr)
- // },
- // ExportedField: (map[interface {}]interface {}) (len=1) {
- // (string) (len=3) "one": (bool) true
- // }
- // }
- // (spew_test.Foo) {
- // unexportedField: (spew_test.Bar) {
- // data: (uintptr)
- // },
- // ExportedField: (map[interface {}]interface {}) (len=1) {
- // (string) (len=3) "one": (bool) true
- // }
- // }
- //
-}
-
-// This example demonstrates how to use ConfigState.Printf to display a variable
-// with a format string and inline formatting.
-func ExampleConfigState_Printf() {
- // See the top-level Dump example for details on the types used in this
- // example.
-
- // Create two ConfigState instances and modify the method handling of the
- // first ConfigState only.
- scs := spew.NewDefaultConfig()
- scs2 := spew.NewDefaultConfig()
- scs.DisableMethods = true
-
- // Alternatively
- // scs := spew.ConfigState{Indent: " ", DisableMethods: true}
- // scs2 := spew.ConfigState{Indent: " "}
-
- // This is of type Flag which implements a Stringer and has raw value 1.
- f := flagTwo
-
- // Dump using the ConfigState instances.
- scs.Printf("f: %v\n", f)
- scs2.Printf("f: %v\n", f)
-
- // Output:
- // f: 1
- // f: flagTwo
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go
deleted file mode 100644
index b04edb7..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/format.go
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package spew
-
-import (
- "bytes"
- "fmt"
- "reflect"
- "strconv"
- "strings"
-)
-
-// supportedFlags is a list of all the character flags supported by fmt package.
-const supportedFlags = "0-+# "
-
-// formatState implements the fmt.Formatter interface and contains information
-// about the state of a formatting operation. The NewFormatter function can
-// be used to get a new Formatter which can be used directly as arguments
-// in standard fmt package printing calls.
-type formatState struct {
- value interface{}
- fs fmt.State
- depth int
- pointers map[uintptr]int
- ignoreNextType bool
- cs *ConfigState
-}
-
-// buildDefaultFormat recreates the original format string without precision
-// and width information to pass in to fmt.Sprintf in the case of an
-// unrecognized type. Unless new types are added to the language, this
-// function won't ever be called.
-func (f *formatState) buildDefaultFormat() (format string) {
- buf := bytes.NewBuffer(percentBytes)
-
- for _, flag := range supportedFlags {
- if f.fs.Flag(int(flag)) {
- buf.WriteRune(flag)
- }
- }
-
- buf.WriteRune('v')
-
- format = buf.String()
- return format
-}
-
-// constructOrigFormat recreates the original format string including precision
-// and width information to pass along to the standard fmt package. This allows
-// automatic deferral of all format strings this package doesn't support.
-func (f *formatState) constructOrigFormat(verb rune) (format string) {
- buf := bytes.NewBuffer(percentBytes)
-
- for _, flag := range supportedFlags {
- if f.fs.Flag(int(flag)) {
- buf.WriteRune(flag)
- }
- }
-
- if width, ok := f.fs.Width(); ok {
- buf.WriteString(strconv.Itoa(width))
- }
-
- if precision, ok := f.fs.Precision(); ok {
- buf.Write(precisionBytes)
- buf.WriteString(strconv.Itoa(precision))
- }
-
- buf.WriteRune(verb)
-
- format = buf.String()
- return format
-}
-
-// unpackValue returns values inside of non-nil interfaces when possible and
-// ensures that types for values which have been unpacked from an interface
-// are displayed when the show types flag is also set.
-// This is useful for data types like structs, arrays, slices, and maps which
-// can contain varying types packed inside an interface.
-func (f *formatState) unpackValue(v reflect.Value) reflect.Value {
- if v.Kind() == reflect.Interface {
- f.ignoreNextType = false
- if !v.IsNil() {
- v = v.Elem()
- }
- }
- return v
-}
-
-// formatPtr handles formatting of pointers by indirecting them as necessary.
-func (f *formatState) formatPtr(v reflect.Value) {
- // Display nil if top level pointer is nil.
- showTypes := f.fs.Flag('#')
- if v.IsNil() && (!showTypes || f.ignoreNextType) {
- f.fs.Write(nilAngleBytes)
- return
- }
-
- // Remove pointers at or below the current depth from map used to detect
- // circular refs.
- for k, depth := range f.pointers {
- if depth >= f.depth {
- delete(f.pointers, k)
- }
- }
-
- // Keep list of all dereferenced pointers to possibly show later.
- pointerChain := make([]uintptr, 0)
-
- // Figure out how many levels of indirection there are by derferencing
- // pointers and unpacking interfaces down the chain while detecting circular
- // references.
- nilFound := false
- cycleFound := false
- indirects := 0
- ve := v
- for ve.Kind() == reflect.Ptr {
- if ve.IsNil() {
- nilFound = true
- break
- }
- indirects++
- addr := ve.Pointer()
- pointerChain = append(pointerChain, addr)
- if pd, ok := f.pointers[addr]; ok && pd < f.depth {
- cycleFound = true
- indirects--
- break
- }
- f.pointers[addr] = f.depth
-
- ve = ve.Elem()
- if ve.Kind() == reflect.Interface {
- if ve.IsNil() {
- nilFound = true
- break
- }
- ve = ve.Elem()
- }
- }
-
- // Display type or indirection level depending on flags.
- if showTypes && !f.ignoreNextType {
- f.fs.Write(openParenBytes)
- f.fs.Write(bytes.Repeat(asteriskBytes, indirects))
- f.fs.Write([]byte(ve.Type().String()))
- f.fs.Write(closeParenBytes)
- } else {
- if nilFound || cycleFound {
- indirects += strings.Count(ve.Type().String(), "*")
- }
- f.fs.Write(openAngleBytes)
- f.fs.Write([]byte(strings.Repeat("*", indirects)))
- f.fs.Write(closeAngleBytes)
- }
-
- // Display pointer information depending on flags.
- if f.fs.Flag('+') && (len(pointerChain) > 0) {
- f.fs.Write(openParenBytes)
- for i, addr := range pointerChain {
- if i > 0 {
- f.fs.Write(pointerChainBytes)
- }
- printHexPtr(f.fs, addr)
- }
- f.fs.Write(closeParenBytes)
- }
-
- // Display dereferenced value.
- switch {
- case nilFound:
- f.fs.Write(nilAngleBytes)
-
- case cycleFound:
- f.fs.Write(circularShortBytes)
-
- default:
- f.ignoreNextType = true
- f.format(ve)
- }
-}
-
-// format is the main workhorse for providing the Formatter interface. It
-// uses the passed reflect value to figure out what kind of object we are
-// dealing with and formats it appropriately. It is a recursive function,
-// however circular data structures are detected and handled properly.
-func (f *formatState) format(v reflect.Value) {
- // Handle invalid reflect values immediately.
- kind := v.Kind()
- if kind == reflect.Invalid {
- f.fs.Write(invalidAngleBytes)
- return
- }
-
- // Handle pointers specially.
- if kind == reflect.Ptr {
- f.formatPtr(v)
- return
- }
-
- // Print type information unless already handled elsewhere.
- if !f.ignoreNextType && f.fs.Flag('#') {
- f.fs.Write(openParenBytes)
- f.fs.Write([]byte(v.Type().String()))
- f.fs.Write(closeParenBytes)
- }
- f.ignoreNextType = false
-
- // Call Stringer/error interfaces if they exist and the handle methods
- // flag is enabled.
- if !f.cs.DisableMethods {
- if (kind != reflect.Invalid) && (kind != reflect.Interface) {
- if handled := handleMethods(f.cs, f.fs, v); handled {
- return
- }
- }
- }
-
- switch kind {
- case reflect.Invalid:
- // Do nothing. We should never get here since invalid has already
- // been handled above.
-
- case reflect.Bool:
- printBool(f.fs, v.Bool())
-
- case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
- printInt(f.fs, v.Int(), 10)
-
- case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
- printUint(f.fs, v.Uint(), 10)
-
- case reflect.Float32:
- printFloat(f.fs, v.Float(), 32)
-
- case reflect.Float64:
- printFloat(f.fs, v.Float(), 64)
-
- case reflect.Complex64:
- printComplex(f.fs, v.Complex(), 32)
-
- case reflect.Complex128:
- printComplex(f.fs, v.Complex(), 64)
-
- case reflect.Slice:
- if v.IsNil() {
- f.fs.Write(nilAngleBytes)
- break
- }
- fallthrough
-
- case reflect.Array:
- f.fs.Write(openBracketBytes)
- f.depth++
- if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
- f.fs.Write(maxShortBytes)
- } else {
- numEntries := v.Len()
- for i := 0; i < numEntries; i++ {
- if i > 0 {
- f.fs.Write(spaceBytes)
- }
- f.ignoreNextType = true
- f.format(f.unpackValue(v.Index(i)))
- }
- }
- f.depth--
- f.fs.Write(closeBracketBytes)
-
- case reflect.String:
- f.fs.Write([]byte(v.String()))
-
- case reflect.Interface:
- // The only time we should get here is for nil interfaces due to
- // unpackValue calls.
- if v.IsNil() {
- f.fs.Write(nilAngleBytes)
- }
-
- case reflect.Ptr:
- // Do nothing. We should never get here since pointers have already
- // been handled above.
-
- case reflect.Map:
- // nil maps should be indicated as different than empty maps
- if v.IsNil() {
- f.fs.Write(nilAngleBytes)
- break
- }
-
- f.fs.Write(openMapBytes)
- f.depth++
- if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
- f.fs.Write(maxShortBytes)
- } else {
- keys := v.MapKeys()
- if f.cs.SortKeys {
- sortValues(keys, f.cs)
- }
- for i, key := range keys {
- if i > 0 {
- f.fs.Write(spaceBytes)
- }
- f.ignoreNextType = true
- f.format(f.unpackValue(key))
- f.fs.Write(colonBytes)
- f.ignoreNextType = true
- f.format(f.unpackValue(v.MapIndex(key)))
- }
- }
- f.depth--
- f.fs.Write(closeMapBytes)
-
- case reflect.Struct:
- numFields := v.NumField()
- f.fs.Write(openBraceBytes)
- f.depth++
- if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
- f.fs.Write(maxShortBytes)
- } else {
- vt := v.Type()
- for i := 0; i < numFields; i++ {
- if i > 0 {
- f.fs.Write(spaceBytes)
- }
- vtf := vt.Field(i)
- if f.fs.Flag('+') || f.fs.Flag('#') {
- f.fs.Write([]byte(vtf.Name))
- f.fs.Write(colonBytes)
- }
- f.format(f.unpackValue(v.Field(i)))
- }
- }
- f.depth--
- f.fs.Write(closeBraceBytes)
-
- case reflect.Uintptr:
- printHexPtr(f.fs, uintptr(v.Uint()))
-
- case reflect.UnsafePointer, reflect.Chan, reflect.Func:
- printHexPtr(f.fs, v.Pointer())
-
- // There were not any other types at the time this code was written, but
- // fall back to letting the default fmt package handle it if any get added.
- default:
- format := f.buildDefaultFormat()
- if v.CanInterface() {
- fmt.Fprintf(f.fs, format, v.Interface())
- } else {
- fmt.Fprintf(f.fs, format, v.String())
- }
- }
-}
-
-// Format satisfies the fmt.Formatter interface. See NewFormatter for usage
-// details.
-func (f *formatState) Format(fs fmt.State, verb rune) {
- f.fs = fs
-
- // Use standard formatting for verbs that are not v.
- if verb != 'v' {
- format := f.constructOrigFormat(verb)
- fmt.Fprintf(fs, format, f.value)
- return
- }
-
- if f.value == nil {
- if fs.Flag('#') {
- fs.Write(interfaceBytes)
- }
- fs.Write(nilAngleBytes)
- return
- }
-
- f.format(reflect.ValueOf(f.value))
-}
-
-// newFormatter is a helper function to consolidate the logic from the various
-// public methods which take varying config states.
-func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter {
- fs := &formatState{value: v, cs: cs}
- fs.pointers = make(map[uintptr]int)
- return fs
-}
-
-/*
-NewFormatter returns a custom formatter that satisfies the fmt.Formatter
-interface. As a result, it integrates cleanly with standard fmt package
-printing functions. The formatter is useful for inline printing of smaller data
-types similar to the standard %v format specifier.
-
-The custom formatter only responds to the %v (most compact), %+v (adds pointer
-addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb
-combinations. Any other verbs such as %x and %q will be sent to the the
-standard fmt package for formatting. In addition, the custom formatter ignores
-the width and precision arguments (however they will still work on the format
-specifiers not handled by the custom formatter).
-
-Typically this function shouldn't be called directly. It is much easier to make
-use of the custom formatter by calling one of the convenience functions such as
-Printf, Println, or Fprintf.
-*/
-func NewFormatter(v interface{}) fmt.Formatter {
- return newFormatter(&Config, v)
-}
diff --git a/vendor/github.com/davecgh/go-spew/spew/format_test.go b/vendor/github.com/davecgh/go-spew/spew/format_test.go
deleted file mode 100644
index 87ee965..0000000
--- a/vendor/github.com/davecgh/go-spew/spew/format_test.go
+++ /dev/null
@@ -1,1558 +0,0 @@
-/*
- * Copyright (c) 2013-2016 Dave Collins
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
-Test Summary:
-NOTE: For each test, a nil pointer, a single pointer and double pointer to the
-base test element are also tested to ensure proper indirection across all types.
-
-- Max int8, int16, int32, int64, int
-- Max uint8, uint16, uint32, uint64, uint
-- Boolean true and false
-- Standard complex64 and complex128
-- Array containing standard ints
-- Array containing type with custom formatter on pointer receiver only
-- Array containing interfaces
-- Slice containing standard float32 values
-- Slice containing type with custom formatter on pointer receiver only
-- Slice containing interfaces
-- Nil slice
-- Standard string
-- Nil interface
-- Sub-interface
-- Map with string keys and int vals
-- Map with custom formatter type on pointer receiver only keys and vals
-- Map with interface keys and values
-- Map with nil interface value
-- Struct with primitives
-- Struct that contains another struct
-- Struct that contains custom type with Stringer pointer interface via both
- exported and unexported fields
-- Struct that contains embedded struct and field to same struct
-- Uintptr to 0 (null pointer)
-- Uintptr address of real variable
-- Unsafe.Pointer to 0 (null pointer)
-- Unsafe.Pointer to address of real variable
-- Nil channel
-- Standard int channel
-- Function with no params and no returns
-- Function with param and no returns
-- Function with multiple params and multiple returns
-- Struct that is circular through self referencing
-- Structs that are circular through cross referencing
-- Structs that are indirectly circular
-- Type that panics in its Stringer interface
-- Type that has a custom Error interface
-- %x passthrough with uint
-- %#x passthrough with uint
-- %f passthrough with precision
-- %f passthrough with width and precision
-- %d passthrough with width
-- %q passthrough with string
-*/
-
-package spew_test
-
-import (
- "bytes"
- "fmt"
- "testing"
- "unsafe"
-
- "github.com/davecgh/go-spew/spew"
-)
-
-// formatterTest is used to describe a test to be performed against NewFormatter.
-type formatterTest struct {
- format string
- in interface{}
- wants []string
-}
-
-// formatterTests houses all of the tests to be performed against NewFormatter.
-var formatterTests = make([]formatterTest, 0)
-
-// addFormatterTest is a helper method to append the passed input and desired
-// result to formatterTests.
-func addFormatterTest(format string, in interface{}, wants ...string) {
- test := formatterTest{format, in, wants}
- formatterTests = append(formatterTests, test)
-}
-
-func addIntFormatterTests() {
- // Max int8.
- v := int8(127)
- nv := (*int8)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "int8"
- vs := "127"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Max int16.
- v2 := int16(32767)
- nv2 := (*int16)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "int16"
- v2s := "32767"
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%v", nv2, "")
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
- addFormatterTest("%#v", nv2, "(*"+v2t+")"+"")
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"")
-
- // Max int32.
- v3 := int32(2147483647)
- nv3 := (*int32)(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "int32"
- v3s := "2147483647"
- addFormatterTest("%v", v3, v3s)
- addFormatterTest("%v", pv3, "<*>"+v3s)
- addFormatterTest("%v", &pv3, "<**>"+v3s)
- addFormatterTest("%v", nv3, "")
- addFormatterTest("%+v", v3, v3s)
- addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s)
- addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%#v", v3, "("+v3t+")"+v3s)
- addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s)
- addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s)
- addFormatterTest("%#v", nv3, "(*"+v3t+")"+"")
- addFormatterTest("%#+v", v3, "("+v3t+")"+v3s)
- addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s)
- addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s)
- addFormatterTest("%#v", nv3, "(*"+v3t+")"+"")
-
- // Max int64.
- v4 := int64(9223372036854775807)
- nv4 := (*int64)(nil)
- pv4 := &v4
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "int64"
- v4s := "9223372036854775807"
- addFormatterTest("%v", v4, v4s)
- addFormatterTest("%v", pv4, "<*>"+v4s)
- addFormatterTest("%v", &pv4, "<**>"+v4s)
- addFormatterTest("%v", nv4, "")
- addFormatterTest("%+v", v4, v4s)
- addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s)
- addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s)
- addFormatterTest("%+v", nv4, "")
- addFormatterTest("%#v", v4, "("+v4t+")"+v4s)
- addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s)
- addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s)
- addFormatterTest("%#v", nv4, "(*"+v4t+")"+"")
- addFormatterTest("%#+v", v4, "("+v4t+")"+v4s)
- addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s)
- addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s)
- addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"")
-
- // Max int.
- v5 := int(2147483647)
- nv5 := (*int)(nil)
- pv5 := &v5
- v5Addr := fmt.Sprintf("%p", pv5)
- pv5Addr := fmt.Sprintf("%p", &pv5)
- v5t := "int"
- v5s := "2147483647"
- addFormatterTest("%v", v5, v5s)
- addFormatterTest("%v", pv5, "<*>"+v5s)
- addFormatterTest("%v", &pv5, "<**>"+v5s)
- addFormatterTest("%v", nv5, "")
- addFormatterTest("%+v", v5, v5s)
- addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s)
- addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s)
- addFormatterTest("%+v", nv5, "")
- addFormatterTest("%#v", v5, "("+v5t+")"+v5s)
- addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s)
- addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s)
- addFormatterTest("%#v", nv5, "(*"+v5t+")"+"")
- addFormatterTest("%#+v", v5, "("+v5t+")"+v5s)
- addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s)
- addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s)
- addFormatterTest("%#+v", nv5, "(*"+v5t+")"+"")
-}
-
-func addUintFormatterTests() {
- // Max uint8.
- v := uint8(255)
- nv := (*uint8)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "uint8"
- vs := "255"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Max uint16.
- v2 := uint16(65535)
- nv2 := (*uint16)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "uint16"
- v2s := "65535"
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%v", nv2, "")
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
- addFormatterTest("%#v", nv2, "(*"+v2t+")"+"")
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"")
-
- // Max uint32.
- v3 := uint32(4294967295)
- nv3 := (*uint32)(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "uint32"
- v3s := "4294967295"
- addFormatterTest("%v", v3, v3s)
- addFormatterTest("%v", pv3, "<*>"+v3s)
- addFormatterTest("%v", &pv3, "<**>"+v3s)
- addFormatterTest("%v", nv3, "")
- addFormatterTest("%+v", v3, v3s)
- addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s)
- addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%#v", v3, "("+v3t+")"+v3s)
- addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s)
- addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s)
- addFormatterTest("%#v", nv3, "(*"+v3t+")"+"")
- addFormatterTest("%#+v", v3, "("+v3t+")"+v3s)
- addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s)
- addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s)
- addFormatterTest("%#v", nv3, "(*"+v3t+")"+"")
-
- // Max uint64.
- v4 := uint64(18446744073709551615)
- nv4 := (*uint64)(nil)
- pv4 := &v4
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "uint64"
- v4s := "18446744073709551615"
- addFormatterTest("%v", v4, v4s)
- addFormatterTest("%v", pv4, "<*>"+v4s)
- addFormatterTest("%v", &pv4, "<**>"+v4s)
- addFormatterTest("%v", nv4, "")
- addFormatterTest("%+v", v4, v4s)
- addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s)
- addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s)
- addFormatterTest("%+v", nv4, "")
- addFormatterTest("%#v", v4, "("+v4t+")"+v4s)
- addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s)
- addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s)
- addFormatterTest("%#v", nv4, "(*"+v4t+")"+"")
- addFormatterTest("%#+v", v4, "("+v4t+")"+v4s)
- addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s)
- addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s)
- addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"")
-
- // Max uint.
- v5 := uint(4294967295)
- nv5 := (*uint)(nil)
- pv5 := &v5
- v5Addr := fmt.Sprintf("%p", pv5)
- pv5Addr := fmt.Sprintf("%p", &pv5)
- v5t := "uint"
- v5s := "4294967295"
- addFormatterTest("%v", v5, v5s)
- addFormatterTest("%v", pv5, "<*>"+v5s)
- addFormatterTest("%v", &pv5, "<**>"+v5s)
- addFormatterTest("%v", nv5, "")
- addFormatterTest("%+v", v5, v5s)
- addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s)
- addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s)
- addFormatterTest("%+v", nv5, "")
- addFormatterTest("%#v", v5, "("+v5t+")"+v5s)
- addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s)
- addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s)
- addFormatterTest("%#v", nv5, "(*"+v5t+")"+"")
- addFormatterTest("%#+v", v5, "("+v5t+")"+v5s)
- addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s)
- addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s)
- addFormatterTest("%#v", nv5, "(*"+v5t+")"+"")
-}
-
-func addBoolFormatterTests() {
- // Boolean true.
- v := bool(true)
- nv := (*bool)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "bool"
- vs := "true"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Boolean false.
- v2 := bool(false)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "bool"
- v2s := "false"
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
-}
-
-func addFloatFormatterTests() {
- // Standard float32.
- v := float32(3.1415)
- nv := (*float32)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "float32"
- vs := "3.1415"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Standard float64.
- v2 := float64(3.1415926)
- nv2 := (*float64)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "float64"
- v2s := "3.1415926"
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
- addFormatterTest("%#v", nv2, "(*"+v2t+")"+"")
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"")
-}
-
-func addComplexFormatterTests() {
- // Standard complex64.
- v := complex(float32(6), -2)
- nv := (*complex64)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "complex64"
- vs := "(6-2i)"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Standard complex128.
- v2 := complex(float64(-6), 2)
- nv2 := (*complex128)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "complex128"
- v2s := "(-6+2i)"
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
- addFormatterTest("%#v", nv2, "(*"+v2t+")"+"")
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"")
-}
-
-func addArrayFormatterTests() {
- // Array containing standard ints.
- v := [3]int{1, 2, 3}
- nv := (*[3]int)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "[3]int"
- vs := "[1 2 3]"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Array containing type with custom formatter on pointer receiver only.
- v2 := [3]pstringer{"1", "2", "3"}
- nv2 := (*[3]pstringer)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "[3]spew_test.pstringer"
- v2sp := "[stringer 1 stringer 2 stringer 3]"
- v2s := v2sp
- if spew.UnsafeDisabled {
- v2s = "[1 2 3]"
- }
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2sp)
- addFormatterTest("%v", &pv2, "<**>"+v2sp)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2sp)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2sp)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2sp)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2sp)
- addFormatterTest("%#v", nv2, "(*"+v2t+")"+"")
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2sp)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2sp)
- addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"")
-
- // Array containing interfaces.
- v3 := [3]interface{}{"one", int(2), uint(3)}
- nv3 := (*[3]interface{})(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "[3]interface {}"
- v3t2 := "string"
- v3t3 := "int"
- v3t4 := "uint"
- v3s := "[one 2 3]"
- v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3]"
- addFormatterTest("%v", v3, v3s)
- addFormatterTest("%v", pv3, "<*>"+v3s)
- addFormatterTest("%v", &pv3, "<**>"+v3s)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%+v", v3, v3s)
- addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s)
- addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%#v", v3, "("+v3t+")"+v3s2)
- addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2)
- addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2)
- addFormatterTest("%#v", nv3, "(*"+v3t+")"+"")
- addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2)
- addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2)
- addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2)
- addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"")
-}
-
-func addSliceFormatterTests() {
- // Slice containing standard float32 values.
- v := []float32{3.14, 6.28, 12.56}
- nv := (*[]float32)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "[]float32"
- vs := "[3.14 6.28 12.56]"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Slice containing type with custom formatter on pointer receiver only.
- v2 := []pstringer{"1", "2", "3"}
- nv2 := (*[]pstringer)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "[]spew_test.pstringer"
- v2s := "[stringer 1 stringer 2 stringer 3]"
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
- addFormatterTest("%#v", nv2, "(*"+v2t+")"+"")
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"")
-
- // Slice containing interfaces.
- v3 := []interface{}{"one", int(2), uint(3), nil}
- nv3 := (*[]interface{})(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "[]interface {}"
- v3t2 := "string"
- v3t3 := "int"
- v3t4 := "uint"
- v3t5 := "interface {}"
- v3s := "[one 2 3 ]"
- v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3 (" + v3t5 +
- ")]"
- addFormatterTest("%v", v3, v3s)
- addFormatterTest("%v", pv3, "<*>"+v3s)
- addFormatterTest("%v", &pv3, "<**>"+v3s)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%+v", v3, v3s)
- addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s)
- addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%#v", v3, "("+v3t+")"+v3s2)
- addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2)
- addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2)
- addFormatterTest("%#v", nv3, "(*"+v3t+")"+"")
- addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2)
- addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2)
- addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2)
- addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"")
-
- // Nil slice.
- var v4 []int
- nv4 := (*[]int)(nil)
- pv4 := &v4
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "[]int"
- v4s := ""
- addFormatterTest("%v", v4, v4s)
- addFormatterTest("%v", pv4, "<*>"+v4s)
- addFormatterTest("%v", &pv4, "<**>"+v4s)
- addFormatterTest("%+v", nv4, "")
- addFormatterTest("%+v", v4, v4s)
- addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s)
- addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s)
- addFormatterTest("%+v", nv4, "")
- addFormatterTest("%#v", v4, "("+v4t+")"+v4s)
- addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s)
- addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s)
- addFormatterTest("%#v", nv4, "(*"+v4t+")"+"")
- addFormatterTest("%#+v", v4, "("+v4t+")"+v4s)
- addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s)
- addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s)
- addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"")
-}
-
-func addStringFormatterTests() {
- // Standard string.
- v := "test"
- nv := (*string)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "string"
- vs := "test"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-}
-
-func addInterfaceFormatterTests() {
- // Nil interface.
- var v interface{}
- nv := (*interface{})(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "interface {}"
- vs := ""
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%+v", v, vs)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Sub-interface.
- v2 := interface{}(uint16(65535))
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "uint16"
- v2s := "65535"
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
-}
-
-func addMapFormatterTests() {
- // Map with string keys and int vals.
- v := map[string]int{"one": 1, "two": 2}
- nilMap := map[string]int(nil)
- nv := (*map[string]int)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "map[string]int"
- vs := "map[one:1 two:2]"
- vs2 := "map[two:2 one:1]"
- addFormatterTest("%v", v, vs, vs2)
- addFormatterTest("%v", pv, "<*>"+vs, "<*>"+vs2)
- addFormatterTest("%v", &pv, "<**>"+vs, "<**>"+vs2)
- addFormatterTest("%+v", nilMap, "")
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%+v", v, vs, vs2)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs, "<*>("+vAddr+")"+vs2)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs,
- "<**>("+pvAddr+"->"+vAddr+")"+vs2)
- addFormatterTest("%+v", nilMap, "")
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs, "("+vt+")"+vs2)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs, "(*"+vt+")"+vs2)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs, "(**"+vt+")"+vs2)
- addFormatterTest("%#v", nilMap, "("+vt+")"+"")
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs, "("+vt+")"+vs2)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs,
- "(*"+vt+")("+vAddr+")"+vs2)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs,
- "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs2)
- addFormatterTest("%#+v", nilMap, "("+vt+")"+"")
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Map with custom formatter type on pointer receiver only keys and vals.
- v2 := map[pstringer]pstringer{"one": "1"}
- nv2 := (*map[pstringer]pstringer)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "map[spew_test.pstringer]spew_test.pstringer"
- v2s := "map[stringer one:stringer 1]"
- if spew.UnsafeDisabled {
- v2s = "map[one:1]"
- }
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%+v", v2, v2s)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
- addFormatterTest("%#v", nv2, "(*"+v2t+")"+"")
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
- addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"")
-
- // Map with interface keys and values.
- v3 := map[interface{}]interface{}{"one": 1}
- nv3 := (*map[interface{}]interface{})(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "map[interface {}]interface {}"
- v3t1 := "string"
- v3t2 := "int"
- v3s := "map[one:1]"
- v3s2 := "map[(" + v3t1 + ")one:(" + v3t2 + ")1]"
- addFormatterTest("%v", v3, v3s)
- addFormatterTest("%v", pv3, "<*>"+v3s)
- addFormatterTest("%v", &pv3, "<**>"+v3s)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%+v", v3, v3s)
- addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s)
- addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%#v", v3, "("+v3t+")"+v3s2)
- addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2)
- addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2)
- addFormatterTest("%#v", nv3, "(*"+v3t+")"+"")
- addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2)
- addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2)
- addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2)
- addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"")
-
- // Map with nil interface value
- v4 := map[string]interface{}{"nil": nil}
- nv4 := (*map[string]interface{})(nil)
- pv4 := &v4
- v4Addr := fmt.Sprintf("%p", pv4)
- pv4Addr := fmt.Sprintf("%p", &pv4)
- v4t := "map[string]interface {}"
- v4t1 := "interface {}"
- v4s := "map[nil:]"
- v4s2 := "map[nil:(" + v4t1 + ")]"
- addFormatterTest("%v", v4, v4s)
- addFormatterTest("%v", pv4, "<*>"+v4s)
- addFormatterTest("%v", &pv4, "<**>"+v4s)
- addFormatterTest("%+v", nv4, "")
- addFormatterTest("%+v", v4, v4s)
- addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s)
- addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s)
- addFormatterTest("%+v", nv4, "")
- addFormatterTest("%#v", v4, "("+v4t+")"+v4s2)
- addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s2)
- addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s2)
- addFormatterTest("%#v", nv4, "(*"+v4t+")"+"")
- addFormatterTest("%#+v", v4, "("+v4t+")"+v4s2)
- addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s2)
- addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s2)
- addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"")
-}
-
-func addStructFormatterTests() {
- // Struct with primitives.
- type s1 struct {
- a int8
- b uint8
- }
- v := s1{127, 255}
- nv := (*s1)(nil)
- pv := &v
- vAddr := fmt.Sprintf("%p", pv)
- pvAddr := fmt.Sprintf("%p", &pv)
- vt := "spew_test.s1"
- vt2 := "int8"
- vt3 := "uint8"
- vs := "{127 255}"
- vs2 := "{a:127 b:255}"
- vs3 := "{a:(" + vt2 + ")127 b:(" + vt3 + ")255}"
- addFormatterTest("%v", v, vs)
- addFormatterTest("%v", pv, "<*>"+vs)
- addFormatterTest("%v", &pv, "<**>"+vs)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%+v", v, vs2)
- addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs2)
- addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs2)
- addFormatterTest("%+v", nv, "")
- addFormatterTest("%#v", v, "("+vt+")"+vs3)
- addFormatterTest("%#v", pv, "(*"+vt+")"+vs3)
- addFormatterTest("%#v", &pv, "(**"+vt+")"+vs3)
- addFormatterTest("%#v", nv, "(*"+vt+")"+"")
- addFormatterTest("%#+v", v, "("+vt+")"+vs3)
- addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs3)
- addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs3)
- addFormatterTest("%#+v", nv, "(*"+vt+")"+"")
-
- // Struct that contains another struct.
- type s2 struct {
- s1 s1
- b bool
- }
- v2 := s2{s1{127, 255}, true}
- nv2 := (*s2)(nil)
- pv2 := &v2
- v2Addr := fmt.Sprintf("%p", pv2)
- pv2Addr := fmt.Sprintf("%p", &pv2)
- v2t := "spew_test.s2"
- v2t2 := "spew_test.s1"
- v2t3 := "int8"
- v2t4 := "uint8"
- v2t5 := "bool"
- v2s := "{{127 255} true}"
- v2s2 := "{s1:{a:127 b:255} b:true}"
- v2s3 := "{s1:(" + v2t2 + "){a:(" + v2t3 + ")127 b:(" + v2t4 + ")255} b:(" +
- v2t5 + ")true}"
- addFormatterTest("%v", v2, v2s)
- addFormatterTest("%v", pv2, "<*>"+v2s)
- addFormatterTest("%v", &pv2, "<**>"+v2s)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%+v", v2, v2s2)
- addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s2)
- addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s2)
- addFormatterTest("%+v", nv2, "")
- addFormatterTest("%#v", v2, "("+v2t+")"+v2s3)
- addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s3)
- addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s3)
- addFormatterTest("%#v", nv2, "(*"+v2t+")"+"")
- addFormatterTest("%#+v", v2, "("+v2t+")"+v2s3)
- addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s3)
- addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s3)
- addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"")
-
- // Struct that contains custom type with Stringer pointer interface via both
- // exported and unexported fields.
- type s3 struct {
- s pstringer
- S pstringer
- }
- v3 := s3{"test", "test2"}
- nv3 := (*s3)(nil)
- pv3 := &v3
- v3Addr := fmt.Sprintf("%p", pv3)
- pv3Addr := fmt.Sprintf("%p", &pv3)
- v3t := "spew_test.s3"
- v3t2 := "spew_test.pstringer"
- v3s := "{stringer test stringer test2}"
- v3sp := v3s
- v3s2 := "{s:stringer test S:stringer test2}"
- v3s2p := v3s2
- v3s3 := "{s:(" + v3t2 + ")stringer test S:(" + v3t2 + ")stringer test2}"
- v3s3p := v3s3
- if spew.UnsafeDisabled {
- v3s = "{test test2}"
- v3sp = "{test stringer test2}"
- v3s2 = "{s:test S:test2}"
- v3s2p = "{s:test S:stringer test2}"
- v3s3 = "{s:(" + v3t2 + ")test S:(" + v3t2 + ")test2}"
- v3s3p = "{s:(" + v3t2 + ")test S:(" + v3t2 + ")stringer test2}"
- }
- addFormatterTest("%v", v3, v3s)
- addFormatterTest("%v", pv3, "<*>"+v3sp)
- addFormatterTest("%v", &pv3, "<**>"+v3sp)
- addFormatterTest("%+v", nv3, "")
- addFormatterTest("%+v", v3, v3s2)
- addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s2p)
- addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s2p)
- addFormatterTest("%+v", nv3, "