├── .dockerignore ├── Procfile ├── .gitignore ├── vendor ├── github.com │ ├── rs │ │ ├── cors │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ └── utils.go │ │ └── xhandler │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── xhandler.go │ │ │ ├── middleware.go │ │ │ └── chain.go │ ├── PuerkitoBio │ │ └── goquery │ │ │ ├── .gitattributes │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── iteration.go │ │ │ ├── LICENSE │ │ │ ├── expand.go │ │ │ ├── query.go │ │ │ └── array.go │ ├── smartystreets │ │ ├── assertions │ │ │ ├── .gitignore │ │ │ ├── internal │ │ │ │ └── oglematchers │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── .travis.yml │ │ │ │ │ ├── any.go │ │ │ │ │ ├── has_same_type_as.go │ │ │ │ │ ├── transform_description.go │ │ │ │ │ ├── has_substr.go │ │ │ │ │ ├── greater_than.go │ │ │ │ │ ├── greater_or_equal.go │ │ │ │ │ ├── new_matcher.go │ │ │ │ │ ├── less_or_equal.go │ │ │ │ │ ├── not.go │ │ │ │ │ ├── error.go │ │ │ │ │ ├── contains.go │ │ │ │ │ ├── pointee.go │ │ │ │ │ ├── matches_regexp.go │ │ │ │ │ ├── README.md │ │ │ │ │ ├── all_of.go │ │ │ │ │ ├── panics.go │ │ │ │ │ ├── deep_equals.go │ │ │ │ │ ├── elements_are.go │ │ │ │ │ ├── any_of.go │ │ │ │ │ └── matcher.go │ │ │ ├── assertions.goconvey │ │ │ ├── .travis.yml │ │ │ ├── filter.go │ │ │ ├── LICENSE.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── serializer.go │ │ │ ├── panic.go │ │ │ └── type.go │ │ └── goconvey │ │ │ ├── convey │ │ │ ├── reporting │ │ │ │ ├── reporting.goconvey │ │ │ │ ├── doc.go │ │ │ │ ├── console.go │ │ │ │ ├── gotest.go │ │ │ │ ├── dot.go │ │ │ │ ├── reporter.go │ │ │ │ ├── printer.go │ │ │ │ ├── story.go │ │ │ │ ├── problems.go │ │ │ │ ├── json.go │ │ │ │ ├── init.go │ │ │ │ └── statistics.go │ │ │ ├── convey.goconvey │ │ │ ├── nilReporter.go │ │ │ ├── gotest │ │ │ │ └── utils.go │ │ │ ├── init.go │ │ │ ├── discovery.go │ │ │ └── assertions.go │ │ │ └── LICENSE.md │ ├── jarcoal │ │ └── httpmock │ │ │ ├── .travis.yml │ │ │ ├── env.go │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── doc.go │ │ │ └── README.md │ ├── andybalholm │ │ └── cascadia │ │ │ ├── .travis.yml │ │ │ ├── README.md │ │ │ └── LICENSE │ ├── unrolled │ │ └── render │ │ │ ├── .travis.yml │ │ │ ├── .gitignore │ │ │ ├── helpers.go │ │ │ ├── helpers_pre16.go │ │ │ ├── LICENSE │ │ │ ├── buffer.go │ │ │ └── doc.go │ ├── gorilla │ │ ├── context │ │ │ ├── README.md │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ └── doc.go │ │ └── mux │ │ │ ├── .travis.yml │ │ │ └── LICENSE │ ├── jtolds │ │ └── gls │ │ │ ├── gen_sym.go │ │ │ ├── id_pool.go │ │ │ ├── LICENSE │ │ │ ├── stack_tags.go │ │ │ ├── stack_tags_main.go │ │ │ ├── stack_tags_js.go │ │ │ └── README.md │ ├── danryan │ │ └── env │ │ │ ├── .gitignore │ │ │ └── env.go │ ├── codegangsta │ │ └── negroni │ │ │ ├── doc.go │ │ │ ├── logger.go │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── recovery.go │ │ │ ├── static.go │ │ │ └── response_writer.go │ └── gopherjs │ │ └── gopherjs │ │ └── LICENSE └── golang.org │ └── x │ ├── net │ ├── PATENTS │ ├── LICENSE │ ├── html │ │ ├── atom │ │ │ └── atom.go │ │ ├── const.go │ │ └── doc.go │ └── context │ │ └── go17.go │ └── text │ ├── PATENTS │ ├── LICENSE │ └── encoding │ └── internal │ ├── internal.go │ └── identifier │ └── identifier.go ├── doc.go ├── Document └── img │ └── delibird.logo.png ├── couriers ├── testhtml │ ├── cj_start.html │ ├── cj_invalid.html │ ├── cj_complete.html │ ├── logen_invalid.html │ ├── logen_complete.html │ ├── kg_invalid2.html │ ├── kg_invalid.html │ └── kg_complete.html ├── courier.go ├── courier_test.go ├── kg_test.go ├── cj_test.go ├── logen_test.go ├── kpost_test.go └── kg.go ├── Godeps └── Readme ├── Dockerfile ├── CHANGELOG.md ├── app.json ├── server ├── main_test.go └── main.go ├── constants.go ├── LICENSE ├── model.go └── .travis.yml /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: server 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | bin 4 | server/server 5 | *.coverprofile 6 | -------------------------------------------------------------------------------- /vendor/github.com/rs/cors/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.3 4 | - 1.4 5 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/.gitattributes: -------------------------------------------------------------------------------- 1 | testdata/* linguist-vendored 2 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | // Package delibird is opensource shipment tracking library 2 | package delibird 3 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | /.idea 4 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -------------------------------------------------------------------------------- /vendor/github.com/jarcoal/httpmock/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: tip 3 | notifications: 4 | email: false -------------------------------------------------------------------------------- /Document/img/delibird.logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/purpleworks/delibird/HEAD/Document/img/delibird.logo.png -------------------------------------------------------------------------------- /couriers/testhtml/cj_start.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/purpleworks/delibird/HEAD/couriers/testhtml/cj_start.html -------------------------------------------------------------------------------- /couriers/testhtml/cj_invalid.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/purpleworks/delibird/HEAD/couriers/testhtml/cj_invalid.html -------------------------------------------------------------------------------- /couriers/testhtml/cj_complete.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/purpleworks/delibird/HEAD/couriers/testhtml/cj_complete.html -------------------------------------------------------------------------------- /couriers/testhtml/logen_invalid.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/purpleworks/delibird/HEAD/couriers/testhtml/logen_invalid.html -------------------------------------------------------------------------------- /couriers/testhtml/logen_complete.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/purpleworks/delibird/HEAD/couriers/testhtml/logen_complete.html -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/.gitignore: -------------------------------------------------------------------------------- 1 | *.sublime-* 2 | .DS_Store 3 | *.swp 4 | #*.*# 5 | tags 6 | goquery.test 7 | 8 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/.gitignore: -------------------------------------------------------------------------------- 1 | *.6 2 | 6.out 3 | _obj/ 4 | _test/ 5 | _testmain.go 6 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - tip 8 | -------------------------------------------------------------------------------- /vendor/github.com/rs/xhandler/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.5 4 | - tip 5 | matrix: 6 | allow_failures: 7 | - go: tip 8 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/assertions.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -coverpkg=github.com/smartystreets/assertions,github.com/smartystreets/assertions/internal/oglematchers -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml: -------------------------------------------------------------------------------- 1 | # Cf. http://docs.travis-ci.com/user/getting-started/ 2 | # Cf. http://docs.travis-ci.com/user/languages/go/ 3 | 4 | language: go 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | MAINTAINER chungsub.kim@purpleworks.co.kr 3 | 4 | RUN apk add --update ca-certificates 5 | ADD bin/delibird_server /delibird_server 6 | EXPOSE 9000 7 | 8 | ENTRYPOINT ["/delibird_server"] 9 | -------------------------------------------------------------------------------- /vendor/github.com/jarcoal/httpmock/env.go: -------------------------------------------------------------------------------- 1 | package httpmock 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | var envVarName = "GONOMOCKS" 8 | 9 | func Disabled() bool { 10 | return os.Getenv(envVarName) != "" 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.2 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | 9 | install: 10 | - go get -t ./... 11 | 12 | script: go test -v 13 | 14 | sudo: false 15 | -------------------------------------------------------------------------------- /vendor/github.com/andybalholm/cascadia/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.3 5 | - 1.4 6 | 7 | install: 8 | - go get github.com/andybalholm/cascadia 9 | 10 | script: 11 | - go test -v 12 | 13 | notifications: 14 | email: false 15 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/convey.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | #-covermode=count 4 | #-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.1.3 (2017-04-14) 2 | 3 | Add Logen 4 | 5 | # 0.1.2 (2017-04-14) 6 | 7 | Fix KG Logis date parse error 8 | 9 | # 0.1.1 (2016-06-21) 10 | 11 | Add KG Logis by @serendip811 12 | 13 | # 0.1.0 (2016-06-12) 14 | 15 | First public release 16 | -------------------------------------------------------------------------------- /vendor/github.com/unrolled/render/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.3 5 | - 1.4 6 | - 1.5 7 | - 1.6 8 | - tip 9 | 10 | install: 11 | - go get github.com/eknkc/amber 12 | 13 | script: 14 | - go test -v -race -tags=integration 15 | 16 | -------------------------------------------------------------------------------- /vendor/github.com/andybalholm/cascadia/README.md: -------------------------------------------------------------------------------- 1 | # cascadia 2 | 3 | [![](https://travis-ci.org/andybalholm/cascadia.svg)](https://travis-ci.org/andybalholm/cascadia) 4 | 5 | The Cascadia package implements CSS selectors for use with the parse trees produced by the html package. 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go: -------------------------------------------------------------------------------- 1 | // Package reporting contains internal functionality related 2 | // to console reporting and output. Although this package has 3 | // exported names is not intended for public consumption. See the 4 | // examples package for how to use this project. 5 | package reporting 6 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 8 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/console.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | type console struct{} 9 | 10 | func (self *console) Write(p []byte) (n int, err error) { 11 | return fmt.Print(string(p)) 12 | } 13 | 14 | func NewConsole() io.Writer { 15 | return new(console) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.2 7 | - go: 1.3 8 | - go: 1.4 9 | - go: 1.5 10 | - go: 1.6 11 | - go: tip 12 | 13 | script: 14 | - go get -t -v ./... 15 | - diff -u <(echo -n) <(gofmt -d .) 16 | - go tool vet . 17 | - go test -v -race ./... 18 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/gen_sym.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | var ( 4 | symPool = &idPool{} 5 | ) 6 | 7 | // ContextKey is a throwaway value you can use as a key to a ContextManager 8 | type ContextKey struct{ id uint } 9 | 10 | // GenSym will return a brand new, never-before-used ContextKey 11 | func GenSym() ContextKey { 12 | return ContextKey{id: symPool.Acquire()} 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/jarcoal/httpmock/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/danryan/env/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | .env 25 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.3 7 | - go: 1.4 8 | - go: 1.5 9 | - go: 1.6 10 | - go: tip 11 | allow_failures: 12 | - go: tip 13 | 14 | script: 15 | - go get -t -v ./... 16 | - diff -u <(echo -n) <(gofmt -d .) 17 | - go vet $(go list ./... | grep -v /vendor/) 18 | - go test -v -race ./... 19 | -------------------------------------------------------------------------------- /vendor/github.com/unrolled/render/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | 25 | 26 | *.pem 27 | .DS_Store 28 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Delibird API Server", 3 | "description": "Shipment tracking api server", 4 | "repository": "https://github.com/purpleworks/delibird", 5 | "keywords": ["go", "shipment", "tracking", "courier"], 6 | "env": { 7 | "ENVIRONMENT": { 8 | "description": "server environment (development or production)", 9 | "value": "production" 10 | }, 11 | "ENABLE_CORS": { 12 | "description": "enable cors (true or false)", 13 | "value": "true" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/unrolled/render/helpers.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package render 4 | 5 | import ( 6 | "fmt" 7 | "html/template" 8 | ) 9 | 10 | // Included helper functions for use when rendering HTML. 11 | var helperFuncs = template.FuncMap{ 12 | "yield": func() (string, error) { 13 | return "", fmt.Errorf("yield called with no layout defined") 14 | }, 15 | "partial": func() (string, error) { 16 | return "", fmt.Errorf("block called with no layout defined") 17 | }, 18 | "current": func() (string, error) { 19 | return "", nil 20 | }, 21 | } 22 | -------------------------------------------------------------------------------- /server/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | 8 | . "github.com/smartystreets/goconvey/convey" 9 | ) 10 | 11 | func TestMain(t *testing.T) { 12 | ts := httptest.NewServer(App()) 13 | defer ts.Close() 14 | 15 | Convey("HTTP Request E2E test", t, func() { 16 | Convey("#tracking", func() { 17 | Convey("Response has 404(not found) status code when invalid path", func() { 18 | res, err := http.Get(ts.URL + "/track") 19 | if err != nil { 20 | t.Fatal(err) 21 | } 22 | So(res.StatusCode, ShouldEqual, http.StatusNotFound) 23 | }) 24 | }) 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/filter.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "fmt" 4 | 5 | const ( 6 | success = "" 7 | needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." 8 | needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." 9 | ) 10 | 11 | func need(needed int, expected []interface{}) string { 12 | if len(expected) != needed { 13 | return fmt.Sprintf(needExactValues, needed, len(expected)) 14 | } 15 | return success 16 | } 17 | 18 | func atLeast(minimum int, expected []interface{}) string { 19 | if len(expected) < 1 { 20 | return needNonEmptyCollection 21 | } 22 | return success 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/nilReporter.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "github.com/smartystreets/goconvey/convey/reporting" 5 | ) 6 | 7 | type nilReporter struct{} 8 | 9 | func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} 10 | func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} 11 | func (self *nilReporter) Report(report *reporting.AssertionResult) {} 12 | func (self *nilReporter) Exit() {} 13 | func (self *nilReporter) EndStory() {} 14 | func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } 15 | func newNilReporter() *nilReporter { return &nilReporter{} } 16 | -------------------------------------------------------------------------------- /constants.go: -------------------------------------------------------------------------------- 1 | package delibird 2 | 3 | type TrackingStatus int 4 | 5 | const ( 6 | // 알수 없음 7 | UnknownStatus TrackingStatus = -1 8 | // 접수 대기 9 | Pending TrackingStatus = 1 10 | // 영업점 접수 (SM입고) 11 | Ready TrackingStatus = 2 12 | // 집화처리 13 | PickupComplete TrackingStatus = 3 14 | // 간선상차 / 물건 실음 / 중간 집화지 출발 15 | Loading TrackingStatus = 4 16 | // 간선하차 / 분류 / 중간 집화지 도착 17 | Unloading TrackingStatus = 5 18 | // 배송출발 19 | DeleveryStart TrackingStatus = 51 20 | // 배송완료 21 | DeleveryComplete TrackingStatus = 91 22 | // 미배달 23 | DoNotDelevery TrackingStatus = 99 24 | ) 25 | 26 | const ( 27 | NoCode string = "NO_CODE_AVAILABLE" 28 | NoTrackingInfo string = "NO_TRACKING_INFO" 29 | ParseError string = "PARSE_ERROR" 30 | RequestPageError string = "REQUEST_PAGE_ERROR" 31 | ) 32 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/id_pool.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | // though this could probably be better at keeping ids smaller, the goal of 4 | // this class is to keep a registry of the smallest unique integer ids 5 | // per-process possible 6 | 7 | import ( 8 | "sync" 9 | ) 10 | 11 | type idPool struct { 12 | mtx sync.Mutex 13 | released []uint 14 | max_id uint 15 | } 16 | 17 | func (p *idPool) Acquire() (id uint) { 18 | p.mtx.Lock() 19 | defer p.mtx.Unlock() 20 | if len(p.released) > 0 { 21 | id = p.released[len(p.released)-1] 22 | p.released = p.released[:len(p.released)-1] 23 | return id 24 | } 25 | id = p.max_id 26 | p.max_id++ 27 | return id 28 | } 29 | 30 | func (p *idPool) Release(id uint) { 31 | p.mtx.Lock() 32 | defer p.mtx.Unlock() 33 | p.released = append(p.released, id) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/unrolled/render/helpers_pre16.go: -------------------------------------------------------------------------------- 1 | // +build !go1.6 2 | 3 | package render 4 | 5 | import ( 6 | "fmt" 7 | "html/template" 8 | ) 9 | 10 | // Included helper functions for use when rendering HTML. 11 | var helperFuncs = template.FuncMap{ 12 | "yield": func() (string, error) { 13 | return "", fmt.Errorf("yield called with no layout defined") 14 | }, 15 | // `block` is deprecated! Use the `partial` below if you need this functionality still. 16 | // Otherwise, checkout Go's `block` implementation introduced in 1.6 17 | "block": func() (string, error) { 18 | return "", fmt.Errorf("block called with no layout defined") 19 | }, 20 | "partial": func() (string, error) { 21 | return "", fmt.Errorf("block called with no layout defined") 22 | }, 23 | "current": func() (string, error) { 24 | return "", nil 25 | }, 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/negroni/doc.go: -------------------------------------------------------------------------------- 1 | // Package negroni is an idiomatic approach to web middleware in Go. It is tiny, non-intrusive, and encourages use of net/http Handlers. 2 | // 3 | // If you like the idea of Martini, but you think it contains too much magic, then Negroni is a great fit. 4 | // 5 | // For a full guide visit http://github.com/codegangsta/negroni 6 | // 7 | // package main 8 | // 9 | // import ( 10 | // "github.com/codegangsta/negroni" 11 | // "net/http" 12 | // "fmt" 13 | // ) 14 | // 15 | // func main() { 16 | // mux := http.NewServeMux() 17 | // mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { 18 | // fmt.Fprintf(w, "Welcome to the home page!") 19 | // }) 20 | // 21 | // n := negroni.Classic() 22 | // n.UseHandler(mux) 23 | // n.Run(":3000") 24 | // } 25 | package negroni 26 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | type gotestReporter struct{ test T } 4 | 5 | func (self *gotestReporter) BeginStory(story *StoryReport) { 6 | self.test = story.Test 7 | } 8 | 9 | func (self *gotestReporter) Enter(scope *ScopeReport) {} 10 | 11 | func (self *gotestReporter) Report(r *AssertionResult) { 12 | if !passed(r) { 13 | self.test.Fail() 14 | } 15 | } 16 | 17 | func (self *gotestReporter) Exit() {} 18 | 19 | func (self *gotestReporter) EndStory() { 20 | self.test = nil 21 | } 22 | 23 | func (self *gotestReporter) Write(content []byte) (written int, err error) { 24 | return len(content), nil // no-op 25 | } 26 | 27 | func NewGoTestReporter() *gotestReporter { 28 | return new(gotestReporter) 29 | } 30 | 31 | func passed(r *AssertionResult) bool { 32 | return r.Error == nil && r.Failure == "" 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/negroni/logger.go: -------------------------------------------------------------------------------- 1 | package negroni 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "os" 7 | "time" 8 | ) 9 | 10 | // Logger is a middleware handler that logs the request as it goes in and the response as it goes out. 11 | type Logger struct { 12 | // Logger inherits from log.Logger used to log messages with the Logger middleware 13 | *log.Logger 14 | } 15 | 16 | // NewLogger returns a new Logger instance 17 | func NewLogger() *Logger { 18 | return &Logger{log.New(os.Stdout, "[negroni] ", 0)} 19 | } 20 | 21 | func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) { 22 | start := time.Now() 23 | l.Printf("Started %s %s", r.Method, r.URL.Path) 24 | 25 | next(rw, r) 26 | 27 | res := rw.(ResponseWriter) 28 | l.Printf("Completed %v %s in %v", res.Status(), http.StatusText(res.Status()), time.Since(start)) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/negroni/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | **ATTN**: This project uses [semantic versioning](http://semver.org/). 4 | 5 | ## [Unreleased] 6 | 7 | ## [0.2.0] - 2016-05-10 8 | ### Added 9 | - Support for variadic handlers in `New()` 10 | - Added `Negroni.Handlers()` to fetch all of the handlers for a given chain 11 | - Allowed size in `Recovery` handler was bumped to 8k 12 | - `Negroni.UseFunc` to push another handler onto the chain 13 | 14 | ### Changed 15 | - Set the status before calling `beforeFuncs` so the information is available to them 16 | - Set default status to `200` in the case that no handler writes status -- was previously `0` 17 | - Panic if `nil` handler is given to `negroni.Use` 18 | 19 | ## 0.1.0 - 2013-07-22 20 | ### Added 21 | - Initial implementation. 22 | 23 | [Unreleased]: https://github.com/codegangsta/negroni/compare/v0.2.0...HEAD 24 | [0.2.0]: https://github.com/codegangsta/negroni/compare/v0.1.0...v0.2.0 25 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go: -------------------------------------------------------------------------------- 1 | // Package gotest contains internal functionality. Although this package 2 | // contains one or more exported names it is not intended for public 3 | // consumption. See the examples package for how to use this project. 4 | package gotest 5 | 6 | import ( 7 | "runtime" 8 | "strings" 9 | ) 10 | 11 | func ResolveExternalCaller() (file string, line int, name string) { 12 | var caller_id uintptr 13 | callers := runtime.Callers(0, callStack) 14 | 15 | for x := 0; x < callers; x++ { 16 | caller_id, file, line, _ = runtime.Caller(x) 17 | if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { 18 | name = runtime.FuncForPC(caller_id).Name() 19 | return 20 | } 21 | } 22 | file, line, name = "", -1, "" 23 | return // panic? 24 | } 25 | 26 | const maxStackDepth = 100 // This had better be enough... 27 | 28 | var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) 29 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type dot struct{ out *Printer } 6 | 7 | func (self *dot) BeginStory(story *StoryReport) {} 8 | 9 | func (self *dot) Enter(scope *ScopeReport) {} 10 | 11 | func (self *dot) Report(report *AssertionResult) { 12 | if report.Error != nil { 13 | fmt.Print(redColor) 14 | self.out.Insert(dotError) 15 | } else if report.Failure != "" { 16 | fmt.Print(yellowColor) 17 | self.out.Insert(dotFailure) 18 | } else if report.Skipped { 19 | fmt.Print(yellowColor) 20 | self.out.Insert(dotSkip) 21 | } else { 22 | fmt.Print(greenColor) 23 | self.out.Insert(dotSuccess) 24 | } 25 | fmt.Print(resetColor) 26 | } 27 | 28 | func (self *dot) Exit() {} 29 | 30 | func (self *dot) EndStory() {} 31 | 32 | func (self *dot) Write(content []byte) (written int, err error) { 33 | return len(content), nil // no-op 34 | } 35 | 36 | func NewDotReporter(out *Printer) *dot { 37 | self := new(dot) 38 | self.out = out 39 | return self 40 | } 41 | -------------------------------------------------------------------------------- /couriers/courier.go: -------------------------------------------------------------------------------- 1 | package couriers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/purpleworks/delibird" 6 | "reflect" 7 | ) 8 | 9 | // Courier is the interface representing the standardized methods to 10 | // parse shipment tracking html 11 | type Courier interface { 12 | // Parse html to tracking object 13 | Parse(invoice string) (delibird.Track, *delibird.ApiError) 14 | // Courier code 15 | Code() string 16 | // Courier name 17 | Name() string 18 | } 19 | 20 | var courierMap = map[string]Courier{} 21 | 22 | // NewCourier creates courier object by courier company code 23 | func New(name string) (Courier, *delibird.ApiError) { 24 | if value, ok := courierMap[name]; ok { 25 | courier := reflect.New(reflect.TypeOf(value).Elem()).Interface().(Courier) 26 | return courier, nil 27 | } 28 | 29 | return nil, delibird.NewApiError(delibird.NoCode, fmt.Sprintf("%v is not supported.", name)) 30 | } 31 | 32 | // RegisterCourier register new courier 33 | func RegisterCourier(name string, courier Courier) { 34 | courierMap[name] = courier 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // Any returns a matcher that matches any value. 19 | func Any() Matcher { 20 | return &anyMatcher{} 21 | } 22 | 23 | type anyMatcher struct { 24 | } 25 | 26 | func (m *anyMatcher) Description() string { 27 | return "is anything" 28 | } 29 | 30 | func (m *anyMatcher) Matches(c interface{}) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Purpleworks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Space Monkey, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /vendor/github.com/rs/cors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Olivier Poitrey 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/rs/xhandler/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Olivier Poitrey 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/jarcoal/httpmock/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Jared Morse 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/unrolled/render/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Cory Jacobsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/negroni/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Jeremy Saenz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/unrolled/render/buffer.go: -------------------------------------------------------------------------------- 1 | package render 2 | 3 | import "bytes" 4 | 5 | // bufPool represents a reusable buffer pool for executing templates into. 6 | var bufPool *BufferPool 7 | 8 | // BufferPool implements a pool of bytes.Buffers in the form of a bounded channel. 9 | // Pulled from the github.com/oxtoacart/bpool package (Apache licensed). 10 | type BufferPool struct { 11 | c chan *bytes.Buffer 12 | } 13 | 14 | // NewBufferPool creates a new BufferPool bounded to the given size. 15 | func NewBufferPool(size int) (bp *BufferPool) { 16 | return &BufferPool{ 17 | c: make(chan *bytes.Buffer, size), 18 | } 19 | } 20 | 21 | // Get gets a Buffer from the BufferPool, or creates a new one if none are 22 | // available in the pool. 23 | func (bp *BufferPool) Get() (b *bytes.Buffer) { 24 | select { 25 | case b = <-bp.c: 26 | // reuse existing buffer 27 | default: 28 | // create new buffer 29 | b = bytes.NewBuffer([]byte{}) 30 | } 31 | return 32 | } 33 | 34 | // Put returns the given Buffer to the BufferPool. 35 | func (bp *BufferPool) Put(b *bytes.Buffer) { 36 | b.Reset() 37 | select { 38 | case bp.c <- b: 39 | default: // Discard the buffer if the pool is full. 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/iteration.go: -------------------------------------------------------------------------------- 1 | package goquery 2 | 3 | // Each iterates over a Selection object, executing a function for each 4 | // matched element. It returns the current Selection object. 5 | func (s *Selection) Each(f func(int, *Selection)) *Selection { 6 | for i, n := range s.Nodes { 7 | f(i, newSingleSelection(n, s.document)) 8 | } 9 | return s 10 | } 11 | 12 | // EachWithBreak iterates over a Selection object, executing a function for each 13 | // matched element. It is identical to Each except that it is possible to break 14 | // out of the loop by returning false in the callback function. It returns the 15 | // current Selection object. 16 | func (s *Selection) EachWithBreak(f func(int, *Selection) bool) *Selection { 17 | for i, n := range s.Nodes { 18 | if !f(i, newSingleSelection(n, s.document)) { 19 | return s 20 | } 21 | } 22 | return s 23 | } 24 | 25 | // Map passes each element in the current matched set through a function, 26 | // producing a slice of string holding the returned values. 27 | func (s *Selection) Map(f func(int, *Selection) string) (result []string) { 28 | for i, n := range s.Nodes { 29 | result = append(result, f(i, newSingleSelection(n, s.document))) 30 | } 31 | 32 | return result 33 | } 34 | -------------------------------------------------------------------------------- /model.go: -------------------------------------------------------------------------------- 1 | package delibird 2 | 3 | import "fmt" 4 | 5 | // Error json model 6 | type ApiError struct { 7 | Code string 8 | Message string 9 | } 10 | 11 | // String() implement 12 | func (e ApiError) String() string { 13 | return fmt.Sprintf("[%s] %s", e.Code, e.Message) 14 | } 15 | 16 | // NewApiError creates ApiError object 17 | func NewApiError(code, message string) *ApiError { 18 | return &ApiError{code, message} 19 | } 20 | 21 | type Track struct { 22 | TrackingNumber string `json:"tracking_number"` 23 | CompanyCode string `json:"company_code"` 24 | CompanyName string `json:"company_name"` 25 | Sender string `json:"sender"` 26 | Receiver string `json:"receiver"` 27 | Signer string `json:"signer"` 28 | StatusCode TrackingStatus `json:"status_code"` 29 | StatusText string `json:"status_text"` 30 | History []History `json:"history"` 31 | } 32 | 33 | type History struct { 34 | Area string `json:"area"` 35 | Tel string `json:"tel,omitempty"` 36 | Date int64 `json:"date"` 37 | DateText string `json:"date_text"` 38 | StatusCode TrackingStatus `json:"status_code"` 39 | StatusText string `json:"status_text"` 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/negroni/recovery.go: -------------------------------------------------------------------------------- 1 | package negroni 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "os" 8 | "runtime" 9 | ) 10 | 11 | // Recovery is a Negroni middleware that recovers from any panics and writes a 500 if there was one. 12 | type Recovery struct { 13 | Logger *log.Logger 14 | PrintStack bool 15 | StackAll bool 16 | StackSize int 17 | } 18 | 19 | // NewRecovery returns a new instance of Recovery 20 | func NewRecovery() *Recovery { 21 | return &Recovery{ 22 | Logger: log.New(os.Stdout, "[negroni] ", 0), 23 | PrintStack: true, 24 | StackAll: false, 25 | StackSize: 1024 * 8, 26 | } 27 | } 28 | 29 | func (rec *Recovery) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) { 30 | defer func() { 31 | if err := recover(); err != nil { 32 | if rw.Header().Get("Content-Type") == "" { 33 | rw.Header().Set("Content-Type", "text/plain; charset=utf-8") 34 | } 35 | 36 | rw.WriteHeader(http.StatusInternalServerError) 37 | stack := make([]byte, rec.StackSize) 38 | stack = stack[:runtime.Stack(stack, rec.StackAll)] 39 | 40 | f := "PANIC: %s\n%s" 41 | rec.Logger.Printf(f, err, stack) 42 | 43 | if rec.PrintStack { 44 | fmt.Fprintf(rw, f, err, stack) 45 | } 46 | } 47 | }() 48 | 49 | next(rw, r) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // HasSameTypeAs returns a matcher that matches values with exactly the same 24 | // type as the supplied prototype. 25 | func HasSameTypeAs(p interface{}) Matcher { 26 | expected := reflect.TypeOf(p) 27 | pred := func(c interface{}) error { 28 | actual := reflect.TypeOf(c) 29 | if actual != expected { 30 | return fmt.Errorf("which has type %v", actual) 31 | } 32 | 33 | return nil 34 | } 35 | 36 | return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "io" 4 | 5 | type Reporter interface { 6 | BeginStory(story *StoryReport) 7 | Enter(scope *ScopeReport) 8 | Report(r *AssertionResult) 9 | Exit() 10 | EndStory() 11 | io.Writer 12 | } 13 | 14 | type reporters struct{ collection []Reporter } 15 | 16 | func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } 17 | func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } 18 | func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } 19 | func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } 20 | func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } 21 | 22 | func (self *reporters) Write(contents []byte) (written int, err error) { 23 | self.foreach(func(r Reporter) { 24 | written, err = r.Write(contents) 25 | }) 26 | return written, err 27 | } 28 | 29 | func (self *reporters) foreach(action func(Reporter)) { 30 | for _, r := range self.collection { 31 | action(r) 32 | } 33 | } 34 | 35 | func NewReporters(collection ...Reporter) *reporters { 36 | self := new(reporters) 37 | self.collection = collection 38 | return self 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.6 4 | - 1.7 5 | - 1.8 6 | - tip 7 | env: 8 | global: 9 | - secure: m1NUJe8noNWaA+LihzI/AnmM9jNPayt0PKd/vhkPrwIbadkY0ThfDjOo1Iv9X6PYdRtYh8B0U6S0eJ3dldb8400bYFcDAHKbWrgWdW2wQ6DJwrxyX2pC92p4aqdjTvIABNAlbeLfM+Zxl9ah8KoGHOuuiF9uVtuCCtva11LJahQm699YRM4kYGcLUj2kAhFA1Fmi+szoj1ZncffKjCxkP+Z7EyWog47WKcN7jNlTWqFmqev6doNBTbLik8EM4ti+WswAX9NL5wa7F74yqFbAqXabqgBvvoi/IQahMa/YQzcA9Wg1muuGwIS2RIyEjlDGtLkywmCHdGLbbZIpVDHh5KBevAWTiMRc3aAb8P8f/MQ5qqf/P9OYufqKottKL0pGEk/oYkhynFHQzR+ifpMUnauAxMikfN1aeErDkyp/4EFt5xXGvYkvXMXkB1fMvYZrli/gLOJu5sutIlpglUrbyaFqcqtHr7hRmb8uTyf6/BJyiaX0Uy1cQRQnedba4fso03AKVADsSCnE3A8UrHz15ls6bv5vDjtY3GWeO0QVzqw5tyR77ydxudnuxA+lRZY4NfTpalXeVuLhrAeRYLfLED21ZqnPw6vh44mzev6iu5QjYVGuCcNg5gkKkgt0YntQY8FRc9OdTl3Bd6bFh5hIbBxltu5p1eVQHbChS4sF4jI= 10 | before_install: 11 | - go get github.com/modocache/gover 12 | - go get github.com/smartystreets/goconvey 13 | - go get github.com/mattn/goveralls 14 | - go get golang.org/x/tools/cmd/cover 15 | script: 16 | - go test -v -coverprofile=delibird.coverprofile 17 | - go test -v -coverprofile=server.coverprofile ./server 18 | - go test -v -coverprofile=couriers.coverprofile ./couriers 19 | - $HOME/gopath/bin/gover 20 | - $HOME/gopath/bin/goveralls -coverprofile=gover.coverprofile -service=travis-ci 21 | after_success: 22 | - GOPATH=`pwd`:$GOPATH $HOME/gopath/bin/goveralls -coverprofile=profile.cov -service=travis-ci 23 | -------------------------------------------------------------------------------- /vendor/github.com/andybalholm/cascadia/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Andy Balholm. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Richard Musiol. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /couriers/courier_test.go: -------------------------------------------------------------------------------- 1 | package couriers 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "path/filepath" 7 | "runtime" 8 | "testing" 9 | 10 | "github.com/purpleworks/delibird" 11 | . "github.com/smartystreets/goconvey/convey" 12 | ) 13 | 14 | type SampleCourier struct{} 15 | 16 | func (t SampleCourier) Code() string { 17 | return "SampleCourier" 18 | } 19 | func (t SampleCourier) Name() string { 20 | return "SampleCourier" 21 | } 22 | func (t SampleCourier) Parse(invoice string) (delibird.Track, *delibird.ApiError) { 23 | return delibird.Track{}, nil 24 | } 25 | 26 | // test html mock file 27 | func readTestResponseFile(filename string) string { 28 | prefix := "." 29 | 30 | if _, currentPath, _, ok := runtime.Caller(0); ok { 31 | prefix = filepath.Dir(currentPath) 32 | } 33 | 34 | b, _ := ioutil.ReadFile(fmt.Sprintf("%s/testhtml/%s", prefix, filename)) 35 | 36 | return string(b) 37 | } 38 | 39 | func TestCourier(t *testing.T) { 40 | Convey("Courier create test", t, func() { 41 | Convey("Return error when invalid code", func() { 42 | _, err := New("TEST") 43 | So(err, ShouldNotBeNil) 44 | }) 45 | 46 | Convey("Return Courier object when valid code", func() { 47 | RegisterCourier("SampleCourier", &SampleCourier{}) 48 | 49 | courier, err := New("SampleCourier") 50 | So(courier.Code(), ShouldEqual, "SampleCourier") 51 | So(courier.Name(), ShouldEqual, "SampleCourier") 52 | So(err, ShouldBeNil) 53 | }) 54 | }) 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // transformDescription returns a matcher that is equivalent to the supplied 19 | // one, except that it has the supplied description instead of the one attached 20 | // to the existing matcher. 21 | func transformDescription(m Matcher, newDesc string) Matcher { 22 | return &transformDescriptionMatcher{newDesc, m} 23 | } 24 | 25 | type transformDescriptionMatcher struct { 26 | desc string 27 | wrappedMatcher Matcher 28 | } 29 | 30 | func (m *transformDescriptionMatcher) Description() string { 31 | return m.desc 32 | } 33 | 34 | func (m *transformDescriptionMatcher) Matches(c interface{}) error { 35 | return m.wrappedMatcher.Matches(c) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | // so, basically, we're going to encode integer tags in base-16 on the stack 4 | 5 | const ( 6 | bitWidth = 4 7 | ) 8 | 9 | func addStackTag(tag uint, context_call func()) { 10 | if context_call == nil { 11 | return 12 | } 13 | markS(tag, context_call) 14 | } 15 | 16 | func markS(tag uint, cb func()) { _m(tag, cb) } 17 | func mark0(tag uint, cb func()) { _m(tag, cb) } 18 | func mark1(tag uint, cb func()) { _m(tag, cb) } 19 | func mark2(tag uint, cb func()) { _m(tag, cb) } 20 | func mark3(tag uint, cb func()) { _m(tag, cb) } 21 | func mark4(tag uint, cb func()) { _m(tag, cb) } 22 | func mark5(tag uint, cb func()) { _m(tag, cb) } 23 | func mark6(tag uint, cb func()) { _m(tag, cb) } 24 | func mark7(tag uint, cb func()) { _m(tag, cb) } 25 | func mark8(tag uint, cb func()) { _m(tag, cb) } 26 | func mark9(tag uint, cb func()) { _m(tag, cb) } 27 | func markA(tag uint, cb func()) { _m(tag, cb) } 28 | func markB(tag uint, cb func()) { _m(tag, cb) } 29 | func markC(tag uint, cb func()) { _m(tag, cb) } 30 | func markD(tag uint, cb func()) { _m(tag, cb) } 31 | func markE(tag uint, cb func()) { _m(tag, cb) } 32 | func markF(tag uint, cb func()) { _m(tag, cb) } 33 | 34 | var pc_lookup = make(map[uintptr]int8, 17) 35 | var mark_lookup [16]func(uint, func()) 36 | 37 | func _m(tag_remainder uint, cb func()) { 38 | if tag_remainder == 0 { 39 | cb() 40 | } else { 41 | mark_lookup[tag_remainder&0xf](tag_remainder>>bitWidth, cb) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "strings" 7 | ) 8 | 9 | type Printer struct { 10 | out io.Writer 11 | prefix string 12 | } 13 | 14 | func (self *Printer) Println(message string, values ...interface{}) { 15 | formatted := self.format(message, values...) + newline 16 | self.out.Write([]byte(formatted)) 17 | } 18 | 19 | func (self *Printer) Print(message string, values ...interface{}) { 20 | formatted := self.format(message, values...) 21 | self.out.Write([]byte(formatted)) 22 | } 23 | 24 | func (self *Printer) Insert(text string) { 25 | self.out.Write([]byte(text)) 26 | } 27 | 28 | func (self *Printer) format(message string, values ...interface{}) string { 29 | var formatted string 30 | if len(values) == 0 { 31 | formatted = self.prefix + message 32 | } else { 33 | formatted = self.prefix + fmt.Sprintf(message, values...) 34 | } 35 | indented := strings.Replace(formatted, newline, newline+self.prefix, -1) 36 | return strings.TrimRight(indented, space) 37 | } 38 | 39 | func (self *Printer) Indent() { 40 | self.prefix += pad 41 | } 42 | 43 | func (self *Printer) Dedent() { 44 | if len(self.prefix) >= padLength { 45 | self.prefix = self.prefix[:len(self.prefix)-padLength] 46 | } 47 | } 48 | 49 | func NewPrinter(out io.Writer) *Printer { 50 | self := new(Printer) 51 | self.out = out 52 | return self 53 | } 54 | 55 | const space = " " 56 | const pad = space + space 57 | const padLength = len(pad) 58 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags_main.go: -------------------------------------------------------------------------------- 1 | // +build !js 2 | 3 | package gls 4 | 5 | // This file is used for standard Go builds, which have the expected runtime support 6 | 7 | import ( 8 | "reflect" 9 | "runtime" 10 | ) 11 | 12 | func init() { 13 | setEntries := func(f func(uint, func()), v int8) { 14 | pc_lookup[reflect.ValueOf(f).Pointer()] = v 15 | if v >= 0 { 16 | mark_lookup[v] = f 17 | } 18 | } 19 | setEntries(markS, -0x1) 20 | setEntries(mark0, 0x0) 21 | setEntries(mark1, 0x1) 22 | setEntries(mark2, 0x2) 23 | setEntries(mark3, 0x3) 24 | setEntries(mark4, 0x4) 25 | setEntries(mark5, 0x5) 26 | setEntries(mark6, 0x6) 27 | setEntries(mark7, 0x7) 28 | setEntries(mark8, 0x8) 29 | setEntries(mark9, 0x9) 30 | setEntries(markA, 0xa) 31 | setEntries(markB, 0xb) 32 | setEntries(markC, 0xc) 33 | setEntries(markD, 0xd) 34 | setEntries(markE, 0xe) 35 | setEntries(markF, 0xf) 36 | } 37 | 38 | func currentStack(skip int) []uintptr { 39 | stack := make([]uintptr, maxCallers) 40 | return stack[:runtime.Callers(3+skip, stack)] 41 | } 42 | 43 | func readStackTags(skip int) (tags []uint) { 44 | stack := currentStack(skip) 45 | var current_tag uint 46 | for _, pc := range stack { 47 | pc = runtime.FuncForPC(pc).Entry() 48 | val, ok := pc_lookup[pc] 49 | if !ok { 50 | continue 51 | } 52 | if val < 0 { 53 | tags = append(tags, current_tag) 54 | current_tag = 0 55 | continue 56 | } 57 | current_tag <<= bitWidth 58 | current_tag += uint(val) 59 | } 60 | return 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "strings" 23 | ) 24 | 25 | // HasSubstr returns a matcher that matches strings containing s as a 26 | // substring. 27 | func HasSubstr(s string) Matcher { 28 | return NewMatcher( 29 | func(c interface{}) error { return hasSubstr(s, c) }, 30 | fmt.Sprintf("has substring \"%s\"", s)) 31 | } 32 | 33 | func hasSubstr(needle string, c interface{}) error { 34 | v := reflect.ValueOf(c) 35 | if v.Kind() != reflect.String { 36 | return NewFatalError("which is not a string") 37 | } 38 | 39 | // Perform the substring search. 40 | haystack := v.String() 41 | if strings.Contains(haystack, needle) { 42 | return nil 43 | } 44 | 45 | return errors.New("") 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2014, Martin Angers & Contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterThan returns a matcher that matches integer, floating point, or 24 | // strings values v such that v > x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterThan will panic. 30 | func GreaterThan(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessOrEqual(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v >= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterOrEqual will panic. 30 | func GreaterOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than or equal to \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessThan(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // Create a matcher with the given description and predicate function, which 19 | // will be invoked to handle calls to Matchers. 20 | // 21 | // Using this constructor may be a convenience over defining your own type that 22 | // implements Matcher if you do not need any logic in your Description method. 23 | func NewMatcher( 24 | predicate func(interface{}) error, 25 | description string) Matcher { 26 | return &predicateMatcher{ 27 | predicate: predicate, 28 | description: description, 29 | } 30 | } 31 | 32 | type predicateMatcher struct { 33 | predicate func(interface{}) error 34 | description string 35 | } 36 | 37 | func (pm *predicateMatcher) Matches(c interface{}) error { 38 | return pm.predicate(c) 39 | } 40 | 41 | func (pm *predicateMatcher) Description() string { 42 | return pm.description 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // LessOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v <= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // LessOrEqual will panic. 30 | func LessOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("less than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("less than or equal to \"%s\"", x) 36 | } 37 | 38 | // Put LessThan last so that its error messages will be used in the event of 39 | // failure. 40 | return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/not.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | ) 22 | 23 | // Not returns a matcher that inverts the set of values matched by the wrapped 24 | // matcher. It does not transform the result for values for which the wrapped 25 | // matcher returns a fatal error. 26 | func Not(m Matcher) Matcher { 27 | return ¬Matcher{m} 28 | } 29 | 30 | type notMatcher struct { 31 | wrapped Matcher 32 | } 33 | 34 | func (m *notMatcher) Matches(c interface{}) (err error) { 35 | err = m.wrapped.Matches(c) 36 | 37 | // Did the wrapped matcher say yes? 38 | if err == nil { 39 | return errors.New("") 40 | } 41 | 42 | // Did the wrapped matcher return a fatal error? 43 | if _, isFatal := err.(*FatalError); isFatal { 44 | return err 45 | } 46 | 47 | // The wrapped matcher returned a non-fatal error. 48 | return nil 49 | } 50 | 51 | func (m *notMatcher) Description() string { 52 | return fmt.Sprintf("not(%s)", m.wrapped.Description()) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/rs/xhandler/xhandler.go: -------------------------------------------------------------------------------- 1 | // Package xhandler provides a bridge between http.Handler and net/context. 2 | // 3 | // xhandler enforces net/context in your handlers without sacrificing 4 | // compatibility with existing http.Handlers nor imposing a specific router. 5 | // 6 | // Thanks to net/context deadline management, xhandler is able to enforce 7 | // a per request deadline and will cancel the context in when the client close 8 | // the connection unexpectedly. 9 | // 10 | // You may create net/context aware middlewares pretty much the same way as 11 | // you would do with http.Handler. 12 | package xhandler 13 | 14 | import ( 15 | "net/http" 16 | 17 | "golang.org/x/net/context" 18 | ) 19 | 20 | // HandlerC is a net/context aware http.Handler 21 | type HandlerC interface { 22 | ServeHTTPC(context.Context, http.ResponseWriter, *http.Request) 23 | } 24 | 25 | // HandlerFuncC type is an adapter to allow the use of ordinary functions 26 | // as a xhandler.Handler. If f is a function with the appropriate signature, 27 | // xhandler.HandlerFuncC(f) is a xhandler.Handler object that calls f. 28 | type HandlerFuncC func(context.Context, http.ResponseWriter, *http.Request) 29 | 30 | // ServeHTTPC calls f(ctx, w, r). 31 | func (f HandlerFuncC) ServeHTTPC(ctx context.Context, w http.ResponseWriter, r *http.Request) { 32 | f(ctx, w, r) 33 | } 34 | 35 | // New creates a conventional http.Handler injecting the provided root 36 | // context to sub handlers. This handler is used as a bridge between conventional 37 | // http.Handler and context aware handlers. 38 | func New(ctx context.Context, h HandlerC) http.Handler { 39 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 40 | h.ServeHTTPC(ctx, w, r) 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/jarcoal/httpmock/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | HTTPmock provides tools for mocking HTTP responses. 3 | 4 | Simple Example: 5 | func TestFetchArticles(t *testing.T) { 6 | httpmock.Activate() 7 | defer httpmock.DeactivateAndReset() 8 | 9 | httpmock.RegisterResponder("GET", "https://api.mybiz.com/articles.json", 10 | httpmock.NewStringResponder(200, `[{"id": 1, "name": "My Great Article"}]`)) 11 | 12 | // do stuff that makes a request to articles.json 13 | } 14 | 15 | Advanced Example: 16 | func TestFetchArticles(t *testing.T) { 17 | httpmock.Activate() 18 | defer httpmock.DeactivateAndReset() 19 | 20 | // our database of articles 21 | articles := make([]map[string]interface{}, 0) 22 | 23 | // mock to list out the articles 24 | httpmock.RegisterResponder("GET", "https://api.mybiz.com/articles.json", 25 | func(req *http.Request) (*http.Response, error) { 26 | resp, err := httpmock.NewJsonResponse(200, articles) 27 | if err != nil { 28 | return httpmock.NewStringResponse(500, ""), nil 29 | } 30 | return resp 31 | }, 32 | ) 33 | 34 | // mock to add a new article 35 | httpmock.RegisterResponder("POST", "https://api.mybiz.com/articles.json", 36 | func(req *http.Request) (*http.Response, error) { 37 | article := make(map[string]interface{}) 38 | if err := json.NewDecoder(req.Body).Decode(&article); err != nil { 39 | return httpmock.NewStringResponse(400, ""), nil 40 | } 41 | 42 | articles = append(articles, article) 43 | 44 | resp, err := httpmock.NewJsonResponse(200, article) 45 | if err != nil { 46 | return httpmock.NewStringResponse(500, ""), nil 47 | } 48 | return resp, nil 49 | }, 50 | ) 51 | 52 | // do stuff that adds and checks articles 53 | } 54 | 55 | */ 56 | package httpmock 57 | -------------------------------------------------------------------------------- /couriers/kg_test.go: -------------------------------------------------------------------------------- 1 | package couriers 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/jarcoal/httpmock" 8 | "github.com/purpleworks/delibird" 9 | . "github.com/smartystreets/goconvey/convey" 10 | ) 11 | 12 | func TestKGCourier(t *testing.T) { 13 | // create kg courier 14 | courier, _ := New("KG") 15 | 16 | // create http mock 17 | httpmock.Activate() 18 | defer httpmock.DeactivateAndReset() 19 | 20 | invalidTrackingNumber := "kg_invalid" 21 | invalidTrackingNumber2 := "kg_invalid2" 22 | completeTrackingNumber := "kg_complete" 23 | 24 | httpmock.RegisterResponder("GET", fmt.Sprintf(Kg{}.TrackingUrl(), invalidTrackingNumber), 25 | httpmock.NewStringResponder(200, readTestResponseFile(invalidTrackingNumber+".html"))) 26 | httpmock.RegisterResponder("GET", fmt.Sprintf(Kg{}.TrackingUrl(), invalidTrackingNumber2), 27 | httpmock.NewStringResponder(200, readTestResponseFile(invalidTrackingNumber2+".html"))) 28 | httpmock.RegisterResponder("GET", fmt.Sprintf(Kg{}.TrackingUrl(), completeTrackingNumber), 29 | httpmock.NewStringResponder(200, readTestResponseFile(completeTrackingNumber+".html"))) 30 | 31 | Convey("KG test", t, func() { 32 | Convey("Invalid tracking number test", func() { 33 | _, err := courier.Parse(invalidTrackingNumber) 34 | 35 | So(err, ShouldNotBeNil) 36 | }) 37 | Convey("Invalid tracking number test2", func() { 38 | _, err := courier.Parse(invalidTrackingNumber2) 39 | 40 | So(err, ShouldNotBeNil) 41 | }) 42 | 43 | Convey("Complete courier test", func() { 44 | data, _ := courier.Parse(completeTrackingNumber) 45 | 46 | So(data.StatusCode, ShouldEqual, delibird.DeleveryComplete) 47 | So(data.Sender, ShouldEqual, "웨일런샵") 48 | So(data.Receiver, ShouldEqual, "김예준") 49 | So(data.CompanyCode, ShouldEqual, "KG") 50 | }) 51 | }) 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/rs/cors/utils.go: -------------------------------------------------------------------------------- 1 | package cors 2 | 3 | import "strings" 4 | 5 | const toLower = 'a' - 'A' 6 | 7 | type converter func(string) string 8 | 9 | type wildcard struct { 10 | prefix string 11 | suffix string 12 | } 13 | 14 | func (w wildcard) match(s string) bool { 15 | return len(s) >= len(w.prefix+w.suffix) && strings.HasPrefix(s, w.prefix) && strings.HasSuffix(s, w.suffix) 16 | } 17 | 18 | // convert converts a list of string using the passed converter function 19 | func convert(s []string, c converter) []string { 20 | out := []string{} 21 | for _, i := range s { 22 | out = append(out, c(i)) 23 | } 24 | return out 25 | } 26 | 27 | // parseHeaderList tokenize + normalize a string containing a list of headers 28 | func parseHeaderList(headerList string) []string { 29 | l := len(headerList) 30 | h := make([]byte, 0, l) 31 | upper := true 32 | // Estimate the number headers in order to allocate the right splice size 33 | t := 0 34 | for i := 0; i < l; i++ { 35 | if headerList[i] == ',' { 36 | t++ 37 | } 38 | } 39 | headers := make([]string, 0, t) 40 | for i := 0; i < l; i++ { 41 | b := headerList[i] 42 | if b >= 'a' && b <= 'z' { 43 | if upper { 44 | h = append(h, b-toLower) 45 | } else { 46 | h = append(h, b) 47 | } 48 | } else if b >= 'A' && b <= 'Z' { 49 | if !upper { 50 | h = append(h, b+toLower) 51 | } else { 52 | h = append(h, b) 53 | } 54 | } else if b == '-' || b == '_' || (b >= '0' && b <= '9') { 55 | h = append(h, b) 56 | } 57 | 58 | if b == ' ' || b == ',' || i == l-1 { 59 | if len(h) > 0 { 60 | // Flush the found header 61 | headers = append(headers, string(h)) 62 | h = h[:0] 63 | upper = true 64 | } 65 | } else { 66 | upper = b == '-' || b == '_' 67 | } 68 | } 69 | return headers 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/jarcoal/httpmock/README.md: -------------------------------------------------------------------------------- 1 | httpmock [![Build Status](https://travis-ci.org/jarcoal/httpmock.png?branch=master)](https://travis-ci.org/jarcoal/httpmock) 2 | ===== 3 | 4 | ### Simple Example: 5 | ```go 6 | func TestFetchArticles(t *testing.T) { 7 | httpmock.Activate() 8 | defer httpmock.DeactivateAndReset() 9 | 10 | httpmock.RegisterResponder("GET", "https://api.mybiz.com/articles.json", 11 | httpmock.NewStringResponder(200, `[{"id": 1, "name": "My Great Article"}]`)) 12 | 13 | // do stuff that makes a request to articles.json 14 | } 15 | ``` 16 | 17 | ### Advanced Example: 18 | ```go 19 | func TestFetchArticles(t *testing.T) { 20 | httpmock.Activate() 21 | defer httpmock.DeactivateAndReset() 22 | 23 | // our database of articles 24 | articles := make([]map[string]interface{}, 0) 25 | 26 | // mock to list out the articles 27 | httpmock.RegisterResponder("GET", "https://api.mybiz.com/articles.json", 28 | func(req *http.Request) (*http.Response, error) { 29 | resp, err := httpmock.NewJsonResponse(200, articles) 30 | if err != nil { 31 | return httpmock.NewStringResponse(500, ""), nil 32 | } 33 | return resp, nil 34 | }, 35 | ) 36 | 37 | // mock to add a new article 38 | httpmock.RegisterResponder("POST", "https://api.mybiz.com/articles.json", 39 | func(req *http.Request) (*http.Response, error) { 40 | article := make(map[string]interface{}) 41 | if err := json.NewDecoder(req.Body).Decode(&article); err != nil { 42 | return httpmock.NewStringResponse(400, ""), nil 43 | } 44 | 45 | articles = append(articles, article) 46 | 47 | resp, err := httpmock.NewJsonResponse(200, article) 48 | if err != nil { 49 | return httpmock.NewStringResponse(500, ""), nil 50 | } 51 | return resp, nil 52 | }, 53 | ) 54 | 55 | // do stuff that adds and checks articles 56 | } 57 | ``` -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // Error returns a matcher that matches non-nil values implementing the 19 | // built-in error interface for whom the return value of Error() matches the 20 | // supplied matcher. 21 | // 22 | // For example: 23 | // 24 | // err := errors.New("taco burrito") 25 | // 26 | // Error(Equals("taco burrito")) // matches err 27 | // Error(HasSubstr("taco")) // matches err 28 | // Error(HasSubstr("enchilada")) // doesn't match err 29 | // 30 | func Error(m Matcher) Matcher { 31 | return &errorMatcher{m} 32 | } 33 | 34 | type errorMatcher struct { 35 | wrappedMatcher Matcher 36 | } 37 | 38 | func (m *errorMatcher) Description() string { 39 | return "error " + m.wrappedMatcher.Description() 40 | } 41 | 42 | func (m *errorMatcher) Matches(c interface{}) error { 43 | // Make sure that c is an error. 44 | e, ok := c.(error) 45 | if !ok { 46 | return NewFatalError("which is not an error") 47 | } 48 | 49 | // Pass on the error text to the wrapped matcher. 50 | return m.wrappedMatcher.Matches(e.Error()) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/expand.go: -------------------------------------------------------------------------------- 1 | package goquery 2 | 3 | import ( 4 | "github.com/andybalholm/cascadia" 5 | "golang.org/x/net/html" 6 | ) 7 | 8 | // Add adds the selector string's matching nodes to those in the current 9 | // selection and returns a new Selection object. 10 | // The selector string is run in the context of the document of the current 11 | // Selection object. 12 | func (s *Selection) Add(selector string) *Selection { 13 | return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, cascadia.MustCompile(selector))...) 14 | } 15 | 16 | // AddMatcher adds the matcher's matching nodes to those in the current 17 | // selection and returns a new Selection object. 18 | // The matcher is run in the context of the document of the current 19 | // Selection object. 20 | func (s *Selection) AddMatcher(m Matcher) *Selection { 21 | return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, m)...) 22 | } 23 | 24 | // AddSelection adds the specified Selection object's nodes to those in the 25 | // current selection and returns a new Selection object. 26 | func (s *Selection) AddSelection(sel *Selection) *Selection { 27 | if sel == nil { 28 | return s.AddNodes() 29 | } 30 | return s.AddNodes(sel.Nodes...) 31 | } 32 | 33 | // Union is an alias for AddSelection. 34 | func (s *Selection) Union(sel *Selection) *Selection { 35 | return s.AddSelection(sel) 36 | } 37 | 38 | // AddNodes adds the specified nodes to those in the 39 | // current selection and returns a new Selection object. 40 | func (s *Selection) AddNodes(nodes ...*html.Node) *Selection { 41 | return pushStack(s, appendWithoutDuplicates(s.Nodes, nodes)) 42 | } 43 | 44 | // AndSelf adds the previous set of elements on the stack to the current set. 45 | // It returns a new Selection object containing the current Selection combined 46 | // with the previous one. 47 | func (s *Selection) AndSelf() *Selection { 48 | return s.AddSelection(s.prevSel) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/rs/xhandler/middleware.go: -------------------------------------------------------------------------------- 1 | package xhandler 2 | 3 | import ( 4 | "net/http" 5 | "time" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // CloseHandler returns a Handler cancelling the context when the client 11 | // connection close unexpectedly. 12 | func CloseHandler(next HandlerC) HandlerC { 13 | return HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { 14 | // Cancel the context if the client closes the connection 15 | if wcn, ok := w.(http.CloseNotifier); ok { 16 | var cancel context.CancelFunc 17 | ctx, cancel = context.WithCancel(ctx) 18 | defer cancel() 19 | 20 | notify := wcn.CloseNotify() 21 | go func() { 22 | select { 23 | case <-notify: 24 | cancel() 25 | case <-ctx.Done(): 26 | } 27 | }() 28 | } 29 | 30 | next.ServeHTTPC(ctx, w, r) 31 | }) 32 | } 33 | 34 | // TimeoutHandler returns a Handler which adds a timeout to the context. 35 | // 36 | // Child handlers have the responsability to obey the context deadline and to return 37 | // an appropriate error (or not) response in case of timeout. 38 | func TimeoutHandler(timeout time.Duration) func(next HandlerC) HandlerC { 39 | return func(next HandlerC) HandlerC { 40 | return HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { 41 | ctx, _ = context.WithTimeout(ctx, timeout) 42 | next.ServeHTTPC(ctx, w, r) 43 | }) 44 | } 45 | } 46 | 47 | // If is a special handler that will skip insert the condNext handler only if a condition 48 | // applies at runtime. 49 | func If(cond func(ctx context.Context, w http.ResponseWriter, r *http.Request) bool, condNext func(next HandlerC) HandlerC) func(next HandlerC) HandlerC { 50 | return func(next HandlerC) HandlerC { 51 | return HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { 52 | if cond(ctx, w, r) { 53 | condNext(next).ServeHTTPC(ctx, w, r) 54 | } else { 55 | next.ServeHTTPC(ctx, w, r) 56 | } 57 | }) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. 4 | 5 | Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: 6 | 7 | - _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. 8 | - _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. 9 | - _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. 10 | - _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. 11 | - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... 12 | - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... 13 | -------------------------------------------------------------------------------- /couriers/cj_test.go: -------------------------------------------------------------------------------- 1 | package couriers 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/jarcoal/httpmock" 8 | "github.com/purpleworks/delibird" 9 | . "github.com/smartystreets/goconvey/convey" 10 | ) 11 | 12 | func TestCJCourier(t *testing.T) { 13 | // create cj courier 14 | courier, _ := New("CJ") 15 | 16 | // create http mock 17 | httpmock.Activate() 18 | defer httpmock.DeactivateAndReset() 19 | 20 | invalidTrackingNumber := "cj_invalid" 21 | startTrackingNumber := "cj_start" 22 | completeTrackingNumber := "cj_complete" 23 | 24 | httpmock.RegisterResponder("GET", fmt.Sprintf(Cj{}.TrackingUrl(), invalidTrackingNumber), 25 | httpmock.NewStringResponder(200, readTestResponseFile(invalidTrackingNumber+".html"))) 26 | httpmock.RegisterResponder("GET", fmt.Sprintf(Cj{}.TrackingUrl(), startTrackingNumber), 27 | httpmock.NewStringResponder(200, readTestResponseFile(startTrackingNumber+".html"))) 28 | httpmock.RegisterResponder("GET", fmt.Sprintf(Cj{}.TrackingUrl(), completeTrackingNumber), 29 | httpmock.NewStringResponder(200, readTestResponseFile(completeTrackingNumber+".html"))) 30 | 31 | Convey("CJ test", t, func() { 32 | Convey("Invalid tracking number test", func() { 33 | _, err := courier.Parse(invalidTrackingNumber) 34 | 35 | So(err, ShouldNotBeNil) 36 | }) 37 | 38 | Convey("Start courier test", func() { 39 | data, _ := courier.Parse(startTrackingNumber) 40 | 41 | So(data.StatusCode, ShouldEqual, delibird.DeleveryStart) 42 | So(data.Sender, ShouldEqual, "홈*럼") 43 | So(data.Receiver, ShouldEqual, "테*트") 44 | So(data.Signer, ShouldEqual, "") 45 | So(data.CompanyCode, ShouldEqual, "CJ") 46 | }) 47 | 48 | Convey("Complete courier test", func() { 49 | data, _ := courier.Parse(completeTrackingNumber) 50 | 51 | So(data.StatusCode, ShouldEqual, delibird.DeleveryComplete) 52 | So(data.Sender, ShouldEqual, "홈*럼") 53 | So(data.Receiver, ShouldEqual, "테*트") 54 | So(data.Signer, ShouldEqual, "본인") 55 | So(data.CompanyCode, ShouldEqual, "CJ") 56 | }) 57 | }) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/story.go: -------------------------------------------------------------------------------- 1 | // TODO: in order for this reporter to be completely honest 2 | // we need to retrofit to be more like the json reporter such that: 3 | // 1. it maintains ScopeResult collections, which count assertions 4 | // 2. it reports only after EndStory(), so that all tick marks 5 | // are placed near the appropriate title. 6 | // 3. Under unit test 7 | 8 | package reporting 9 | 10 | import ( 11 | "fmt" 12 | "strings" 13 | ) 14 | 15 | type story struct { 16 | out *Printer 17 | titlesById map[string]string 18 | currentKey []string 19 | } 20 | 21 | func (self *story) BeginStory(story *StoryReport) {} 22 | 23 | func (self *story) Enter(scope *ScopeReport) { 24 | self.out.Indent() 25 | 26 | self.currentKey = append(self.currentKey, scope.Title) 27 | ID := strings.Join(self.currentKey, "|") 28 | 29 | if _, found := self.titlesById[ID]; !found { 30 | self.out.Println("") 31 | self.out.Print(scope.Title) 32 | self.out.Insert(" ") 33 | self.titlesById[ID] = scope.Title 34 | } 35 | } 36 | 37 | func (self *story) Report(report *AssertionResult) { 38 | if report.Error != nil { 39 | fmt.Print(redColor) 40 | self.out.Insert(error_) 41 | } else if report.Failure != "" { 42 | fmt.Print(yellowColor) 43 | self.out.Insert(failure) 44 | } else if report.Skipped { 45 | fmt.Print(yellowColor) 46 | self.out.Insert(skip) 47 | } else { 48 | fmt.Print(greenColor) 49 | self.out.Insert(success) 50 | } 51 | fmt.Print(resetColor) 52 | } 53 | 54 | func (self *story) Exit() { 55 | self.out.Dedent() 56 | self.currentKey = self.currentKey[:len(self.currentKey)-1] 57 | } 58 | 59 | func (self *story) EndStory() { 60 | self.titlesById = make(map[string]string) 61 | self.out.Println("\n") 62 | } 63 | 64 | func (self *story) Write(content []byte) (written int, err error) { 65 | return len(content), nil // no-op 66 | } 67 | 68 | func NewStoryReporter(out *Printer) *story { 69 | self := new(story) 70 | self.out = out 71 | self.titlesById = make(map[string]string) 72 | return self 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // Return a matcher that matches arrays slices with at least one element that 24 | // matches the supplied argument. If the argument x is not itself a Matcher, 25 | // this is equivalent to Contains(Equals(x)). 26 | func Contains(x interface{}) Matcher { 27 | var result containsMatcher 28 | var ok bool 29 | 30 | if result.elementMatcher, ok = x.(Matcher); !ok { 31 | result.elementMatcher = DeepEquals(x) 32 | } 33 | 34 | return &result 35 | } 36 | 37 | type containsMatcher struct { 38 | elementMatcher Matcher 39 | } 40 | 41 | func (m *containsMatcher) Description() string { 42 | return fmt.Sprintf("contains: %s", m.elementMatcher.Description()) 43 | } 44 | 45 | func (m *containsMatcher) Matches(candidate interface{}) error { 46 | // The candidate must be a slice or an array. 47 | v := reflect.ValueOf(candidate) 48 | if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { 49 | return NewFatalError("which is not a slice or array") 50 | } 51 | 52 | // Check each element. 53 | for i := 0; i < v.Len(); i++ { 54 | elem := v.Index(i) 55 | if matchErr := m.elementMatcher.Matches(elem.Interface()); matchErr == nil { 56 | return nil 57 | } 58 | } 59 | 60 | return fmt.Errorf("") 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/unrolled/render/doc.go: -------------------------------------------------------------------------------- 1 | /*Package render is a package that provides functionality for easily rendering JSON, XML, binary data, and HTML templates. 2 | 3 | package main 4 | 5 | import ( 6 | "encoding/xml" 7 | "net/http" 8 | 9 | "github.com/unrolled/render" // or "gopkg.in/unrolled/render.v1" 10 | ) 11 | 12 | type ExampleXml struct { 13 | XMLName xml.Name `xml:"example"` 14 | One string `xml:"one,attr"` 15 | Two string `xml:"two,attr"` 16 | } 17 | 18 | func main() { 19 | r := render.New() 20 | mux := http.NewServeMux() 21 | 22 | mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { 23 | w.Write([]byte("Welcome, visit sub pages now.")) 24 | }) 25 | 26 | mux.HandleFunc("/data", func(w http.ResponseWriter, req *http.Request) { 27 | r.Data(w, http.StatusOK, []byte("Some binary data here.")) 28 | }) 29 | 30 | mux.HandleFunc("/text", func(w http.ResponseWriter, req *http.Request) { 31 | r.Text(w, http.StatusOK, "Plain text here") 32 | }) 33 | 34 | mux.HandleFunc("/json", func(w http.ResponseWriter, req *http.Request) { 35 | r.JSON(w, http.StatusOK, map[string]string{"hello": "json"}) 36 | }) 37 | 38 | mux.HandleFunc("/jsonp", func(w http.ResponseWriter, req *http.Request) { 39 | r.JSONP(w, http.StatusOK, "callbackName", map[string]string{"hello": "jsonp"}) 40 | }) 41 | 42 | mux.HandleFunc("/xml", func(w http.ResponseWriter, req *http.Request) { 43 | r.XML(w, http.StatusOK, ExampleXml{One: "hello", Two: "xml"}) 44 | }) 45 | 46 | mux.HandleFunc("/html", func(w http.ResponseWriter, req *http.Request) { 47 | // Assumes you have a template in ./templates called "example.tmpl". 48 | // $ mkdir -p templates && echo "

Hello HTML world.

" > templates/example.tmpl 49 | r.HTML(w, http.StatusOK, "example", nil) 50 | }) 51 | 52 | http.ListenAndServe("0.0.0.0:3000", mux) 53 | } 54 | */ 55 | package render 56 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/query.go: -------------------------------------------------------------------------------- 1 | package goquery 2 | 3 | import ( 4 | "github.com/andybalholm/cascadia" 5 | "golang.org/x/net/html" 6 | ) 7 | 8 | // Is checks the current matched set of elements against a selector and 9 | // returns true if at least one of these elements matches. 10 | func (s *Selection) Is(selector string) bool { 11 | if len(s.Nodes) > 0 { 12 | return s.IsMatcher(cascadia.MustCompile(selector)) 13 | } 14 | 15 | return false 16 | } 17 | 18 | // IsMatcher checks the current matched set of elements against a matcher and 19 | // returns true if at least one of these elements matches. 20 | func (s *Selection) IsMatcher(m Matcher) bool { 21 | if len(s.Nodes) > 0 { 22 | if len(s.Nodes) == 1 { 23 | return m.Match(s.Nodes[0]) 24 | } 25 | return len(m.Filter(s.Nodes)) > 0 26 | } 27 | 28 | return false 29 | } 30 | 31 | // IsFunction checks the current matched set of elements against a predicate and 32 | // returns true if at least one of these elements matches. 33 | func (s *Selection) IsFunction(f func(int, *Selection) bool) bool { 34 | return s.FilterFunction(f).Length() > 0 35 | } 36 | 37 | // IsSelection checks the current matched set of elements against a Selection object 38 | // and returns true if at least one of these elements matches. 39 | func (s *Selection) IsSelection(sel *Selection) bool { 40 | return s.FilterSelection(sel).Length() > 0 41 | } 42 | 43 | // IsNodes checks the current matched set of elements against the specified nodes 44 | // and returns true if at least one of these elements matches. 45 | func (s *Selection) IsNodes(nodes ...*html.Node) bool { 46 | return s.FilterNodes(nodes...).Length() > 0 47 | } 48 | 49 | // Contains returns true if the specified Node is within, 50 | // at any depth, one of the nodes in the Selection object. 51 | // It is NOT inclusive, to behave like jQuery's implementation, and 52 | // unlike Javascript's .contains, so if the contained 53 | // node is itself in the selection, it returns false. 54 | func (s *Selection) Contains(n *html.Node) bool { 55 | return sliceContains(s.Nodes, n) 56 | } 57 | -------------------------------------------------------------------------------- /couriers/logen_test.go: -------------------------------------------------------------------------------- 1 | package couriers 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/jarcoal/httpmock" 8 | "github.com/purpleworks/delibird" 9 | . "github.com/smartystreets/goconvey/convey" 10 | ) 11 | 12 | func TestLogenCourier(t *testing.T) { 13 | // create logen courier 14 | courier, _ := New("LOGEN") 15 | 16 | // create http mock 17 | httpmock.Activate() 18 | defer httpmock.DeactivateAndReset() 19 | 20 | invalidTrackingNumber := "logen_invalid" 21 | //startTrackingNumber := "logen_start" 22 | completeTrackingNumber := "logen_complete" 23 | 24 | httpmock.RegisterResponder("GET", fmt.Sprintf(Logen{}.TrackingUrl(), invalidTrackingNumber), 25 | httpmock.NewStringResponder(200, readTestResponseFile(invalidTrackingNumber+".html"))) 26 | //httpmock.RegisterResponder("GET", fmt.Sprintf(Logen{}.TrackingUrl(), startTrackingNumber), 27 | // httpmock.NewStringResponder(200, readTestResponseFile(startTrackingNumber+".html"))) 28 | httpmock.RegisterResponder("GET", fmt.Sprintf(Logen{}.TrackingUrl(), completeTrackingNumber), 29 | httpmock.NewStringResponder(200, readTestResponseFile(completeTrackingNumber+".html"))) 30 | 31 | Convey("LOGEN test", t, func() { 32 | Convey("Invalid tracking number test", func() { 33 | _, err := courier.Parse(invalidTrackingNumber) 34 | 35 | So(err, ShouldNotBeNil) 36 | }) 37 | 38 | //Convey("Start courier test", func() { 39 | // data, _ := courier.Parse(startTrackingNumber) 40 | // 41 | // So(data.StatusCode, ShouldEqual, delibird.DeleveryStart) 42 | // So(data.Sender, ShouldEqual, "홈*럼") 43 | // So(data.Receiver, ShouldEqual, "테*트") 44 | // So(data.Signer, ShouldEqual, "") 45 | // So(data.CompanyCode, ShouldEqual, "CJ") 46 | //}) 47 | 48 | Convey("Complete courier test", func() { 49 | data, _ := courier.Parse(completeTrackingNumber) 50 | 51 | So(data.StatusCode, ShouldEqual, delibird.DeleveryComplete) 52 | So(data.Sender, ShouldEqual, "홈*럼") 53 | So(data.Receiver, ShouldEqual, "테*트") 54 | So(data.Signer, ShouldEqual, "본인") 55 | So(data.CompanyCode, ShouldEqual, "LOGEN") 56 | }) 57 | }) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | ) 23 | 24 | // Return a matcher that matches non-nil pointers whose pointee matches the 25 | // wrapped matcher. 26 | func Pointee(m Matcher) Matcher { 27 | return &pointeeMatcher{m} 28 | } 29 | 30 | type pointeeMatcher struct { 31 | wrapped Matcher 32 | } 33 | 34 | func (m *pointeeMatcher) Matches(c interface{}) (err error) { 35 | // Make sure the candidate is of the appropriate type. 36 | cv := reflect.ValueOf(c) 37 | if !cv.IsValid() || cv.Kind() != reflect.Ptr { 38 | return NewFatalError("which is not a pointer") 39 | } 40 | 41 | // Make sure the candidate is non-nil. 42 | if cv.IsNil() { 43 | return NewFatalError("") 44 | } 45 | 46 | // Defer to the wrapped matcher. Fix up empty errors so that failure messages 47 | // are more helpful than just printing a pointer for "Actual". 48 | pointee := cv.Elem().Interface() 49 | err = m.wrapped.Matches(pointee) 50 | if err != nil && err.Error() == "" { 51 | s := fmt.Sprintf("whose pointee is %v", pointee) 52 | 53 | if _, ok := err.(*FatalError); ok { 54 | err = NewFatalError(s) 55 | } else { 56 | err = errors.New(s) 57 | } 58 | } 59 | 60 | return err 61 | } 62 | 63 | func (m *pointeeMatcher) Description() string { 64 | return fmt.Sprintf("pointee(%s)", m.wrapped.Description()) 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type problem struct { 6 | silent bool 7 | out *Printer 8 | errors []*AssertionResult 9 | failures []*AssertionResult 10 | } 11 | 12 | func (self *problem) BeginStory(story *StoryReport) {} 13 | 14 | func (self *problem) Enter(scope *ScopeReport) {} 15 | 16 | func (self *problem) Report(report *AssertionResult) { 17 | if report.Error != nil { 18 | self.errors = append(self.errors, report) 19 | } else if report.Failure != "" { 20 | self.failures = append(self.failures, report) 21 | } 22 | } 23 | 24 | func (self *problem) Exit() {} 25 | 26 | func (self *problem) EndStory() { 27 | self.show(self.showErrors, redColor) 28 | self.show(self.showFailures, yellowColor) 29 | self.prepareForNextStory() 30 | } 31 | func (self *problem) show(display func(), color string) { 32 | if !self.silent { 33 | fmt.Print(color) 34 | } 35 | display() 36 | if !self.silent { 37 | fmt.Print(resetColor) 38 | } 39 | self.out.Dedent() 40 | } 41 | func (self *problem) showErrors() { 42 | for i, e := range self.errors { 43 | if i == 0 { 44 | self.out.Println("\nErrors:\n") 45 | self.out.Indent() 46 | } 47 | self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) 48 | } 49 | } 50 | func (self *problem) showFailures() { 51 | for i, f := range self.failures { 52 | if i == 0 { 53 | self.out.Println("\nFailures:\n") 54 | self.out.Indent() 55 | } 56 | self.out.Println(failureTemplate, f.File, f.Line, f.Failure) 57 | } 58 | } 59 | 60 | func (self *problem) Write(content []byte) (written int, err error) { 61 | return len(content), nil // no-op 62 | } 63 | 64 | func NewProblemReporter(out *Printer) *problem { 65 | self := new(problem) 66 | self.out = out 67 | self.prepareForNextStory() 68 | return self 69 | } 70 | 71 | func NewSilentProblemReporter(out *Printer) *problem { 72 | self := NewProblemReporter(out) 73 | self.silent = true 74 | return self 75 | } 76 | 77 | func (self *problem) prepareForNextStory() { 78 | self.errors = []*AssertionResult{} 79 | self.failures = []*AssertionResult{} 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "regexp" 23 | ) 24 | 25 | // MatchesRegexp returns a matcher that matches strings and byte slices whose 26 | // contents match the supplied regular expression. The semantics are those of 27 | // regexp.Match. In particular, that means the match is not implicitly anchored 28 | // to the ends of the string: MatchesRegexp("bar") will match "foo bar baz". 29 | func MatchesRegexp(pattern string) Matcher { 30 | re, err := regexp.Compile(pattern) 31 | if err != nil { 32 | panic("MatchesRegexp: " + err.Error()) 33 | } 34 | 35 | return &matchesRegexpMatcher{re} 36 | } 37 | 38 | type matchesRegexpMatcher struct { 39 | re *regexp.Regexp 40 | } 41 | 42 | func (m *matchesRegexpMatcher) Description() string { 43 | return fmt.Sprintf("matches regexp \"%s\"", m.re.String()) 44 | } 45 | 46 | func (m *matchesRegexpMatcher) Matches(c interface{}) (err error) { 47 | v := reflect.ValueOf(c) 48 | isString := v.Kind() == reflect.String 49 | isByteSlice := v.Kind() == reflect.Slice && v.Elem().Kind() == reflect.Uint8 50 | 51 | err = errors.New("") 52 | 53 | switch { 54 | case isString: 55 | if m.re.MatchString(v.String()) { 56 | err = nil 57 | } 58 | 59 | case isByteSlice: 60 | if m.re.Match(v.Bytes()) { 61 | err = nil 62 | } 63 | 64 | default: 65 | err = NewFatalError("which is not a string or []byte") 66 | } 67 | 68 | return 69 | } 70 | -------------------------------------------------------------------------------- /couriers/testhtml/kg_invalid2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | KG로지스 배송조회 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 30 |
31 |

01 주문정보

32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
주문정보
운송장번호1490-2212-4654
보내시는분()
받으시는분()
상품명>수량
63 |

02 상품이동현황

64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 |
상품이동현황 리스트
일자시간지사/대리점 연락처이동상태
물품 이동경로정보가 없습니다.
85 |
86 | 창닫기 87 |
88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/serializer.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/smartystreets/assertions/internal/go-render/render" 8 | ) 9 | 10 | type Serializer interface { 11 | serialize(expected, actual interface{}, message string) string 12 | serializeDetailed(expected, actual interface{}, message string) string 13 | } 14 | 15 | type failureSerializer struct{} 16 | 17 | func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { 18 | view := FailureView{ 19 | Message: message, 20 | Expected: render.Render(expected), 21 | Actual: render.Render(actual), 22 | } 23 | serialized, err := json.Marshal(view) 24 | if err != nil { 25 | return message 26 | } 27 | return string(serialized) 28 | } 29 | 30 | func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { 31 | view := FailureView{ 32 | Message: message, 33 | Expected: fmt.Sprintf("%+v", expected), 34 | Actual: fmt.Sprintf("%+v", actual), 35 | } 36 | serialized, err := json.Marshal(view) 37 | if err != nil { 38 | return message 39 | } 40 | return string(serialized) 41 | } 42 | 43 | func newSerializer() *failureSerializer { 44 | return &failureSerializer{} 45 | } 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | 49 | // This struct is also declared in github.com/smartystreets/goconvey/convey/reporting. 50 | // The json struct tags should be equal in both declarations. 51 | type FailureView struct { 52 | Message string `json:"Message"` 53 | Expected string `json:"Expected"` 54 | Actual string `json:"Actual"` 55 | } 56 | 57 | /////////////////////////////////////////////////////// 58 | 59 | // noopSerializer just gives back the original message. This is useful when we are using 60 | // the assertions from a context other than the web UI, that requires the JSON structure 61 | // provided by the failureSerializer. 62 | type noopSerializer struct{} 63 | 64 | func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { 65 | return message 66 | } 67 | func (self *noopSerializer) serializeDetailed(expected, actual interface{}, message string) string { 68 | return message 69 | } 70 | -------------------------------------------------------------------------------- /server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "strings" 7 | 8 | "github.com/codegangsta/negroni" 9 | "github.com/danryan/env" 10 | "github.com/gorilla/mux" 11 | "github.com/purpleworks/delibird" 12 | "github.com/purpleworks/delibird/couriers" 13 | "github.com/rs/cors" 14 | "github.com/unrolled/render" 15 | ) 16 | 17 | type Config struct { 18 | Environment string `env:"key=ENVIRONMENT default=development"` 19 | Port string `env:"key=PORT default=9000"` 20 | EnableCors string `env:"key=ENABLE_CORS default=false"` 21 | } 22 | 23 | var ( 24 | renderer *render.Render 25 | config *Config 26 | ) 27 | 28 | func init() { 29 | var option render.Options 30 | config = &Config{} 31 | if err := env.Process(config); err != nil { 32 | fmt.Println(err) 33 | } 34 | if config.Environment == "development" { 35 | option.IndentJSON = true 36 | } 37 | renderer = render.New(option) 38 | } 39 | 40 | func renderErrorJson(w http.ResponseWriter, err *delibird.ApiError, status int) { 41 | if status < 100 { 42 | status = http.StatusBadRequest 43 | } 44 | 45 | renderer.JSON(w, status, map[string]string{"code": err.Code, "message": err.Message}) 46 | } 47 | 48 | func App() http.Handler { 49 | // router 50 | r := mux.NewRouter() 51 | r.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) { 52 | renderer.Text(w, http.StatusOK, "pong") 53 | }) 54 | 55 | r.HandleFunc("/tracking/{code}/{trackingNumber}", func(w http.ResponseWriter, r *http.Request) { 56 | vars := mux.Vars(r) 57 | 58 | courier, err := couriers.New(vars["code"]) 59 | if err != nil { 60 | fmt.Println(err) 61 | renderErrorJson(w, err, 400) 62 | return 63 | } 64 | 65 | trackingNumber := strings.Replace(vars["trackingNumber"], "-", "", -1) 66 | data, err := courier.Parse(trackingNumber) 67 | if err != nil { 68 | renderErrorJson(w, err, 400) 69 | return 70 | } 71 | 72 | renderer.JSON(w, http.StatusOK, data) 73 | }) 74 | 75 | // middleware 76 | n := negroni.Classic() 77 | 78 | // enable CORS 79 | if config.EnableCors == "true" { 80 | c := cors.New(cors.Options{}) 81 | n.Use(c) 82 | } 83 | 84 | // add handler 85 | n.UseHandler(r) 86 | 87 | return n 88 | } 89 | 90 | func main() { 91 | // listen 92 | http.ListenAndServe(fmt.Sprintf(":%s", config.Port), App()) 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers) 2 | 3 | `oglematchers` is a package for the Go programming language containing a set of 4 | matchers, useful in a testing or mocking framework, inspired by and mostly 5 | compatible with [Google Test][googletest] for C++ and 6 | [Google JS Test][google-js-test]. The package is used by the 7 | [ogletest][ogletest] testing framework and [oglemock][oglemock] mocking 8 | framework, which may be more directly useful to you, but can be generically used 9 | elsewhere as well. 10 | 11 | A "matcher" is simply an object with a `Matches` method defining a set of golang 12 | values matched by the matcher, and a `Description` method describing that set. 13 | For example, here are some matchers: 14 | 15 | ```go 16 | // Numbers 17 | Equals(17.13) 18 | LessThan(19) 19 | 20 | // Strings 21 | Equals("taco") 22 | HasSubstr("burrito") 23 | MatchesRegex("t.*o") 24 | 25 | // Combining matchers 26 | AnyOf(LessThan(17), GreaterThan(19)) 27 | ``` 28 | 29 | There are lots more; see [here][reference] for a reference. You can also add 30 | your own simply by implementing the `oglematchers.Matcher` interface. 31 | 32 | 33 | Installation 34 | ------------ 35 | 36 | First, make sure you have installed Go 1.0.2 or newer. See 37 | [here][golang-install] for instructions. 38 | 39 | Use the following command to install `oglematchers` and keep it up to date: 40 | 41 | go get -u github.com/smartystreets/assertions/internal/oglematchers 42 | 43 | 44 | Documentation 45 | ------------- 46 | 47 | See [here][reference] for documentation. Alternatively, you can install the 48 | package and then use `godoc`: 49 | 50 | godoc github.com/smartystreets/assertions/internal/oglematchers 51 | 52 | 53 | [reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers 54 | [golang-install]: http://golang.org/doc/install.html 55 | [googletest]: http://code.google.com/p/googletest/ 56 | [google-js-test]: http://code.google.com/p/google-js-test/ 57 | [ogletest]: http://github.com/smartystreets/assertions/internal/ogletest 58 | [oglemock]: http://github.com/smartystreets/assertions/internal/oglemock 59 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/negroni/static.go: -------------------------------------------------------------------------------- 1 | package negroni 2 | 3 | import ( 4 | "net/http" 5 | "path" 6 | "strings" 7 | ) 8 | 9 | // Static is a middleware handler that serves static files in the given 10 | // directory/filesystem. If the file does not exist on the filesystem, it 11 | // passes along to the next middleware in the chain. If you desire "fileserver" 12 | // type behavior where it returns a 404 for unfound files, you should consider 13 | // using http.FileServer from the Go stdlib. 14 | type Static struct { 15 | // Dir is the directory to serve static files from 16 | Dir http.FileSystem 17 | // Prefix is the optional prefix used to serve the static directory content 18 | Prefix string 19 | // IndexFile defines which file to serve as index if it exists. 20 | IndexFile string 21 | } 22 | 23 | // NewStatic returns a new instance of Static 24 | func NewStatic(directory http.FileSystem) *Static { 25 | return &Static{ 26 | Dir: directory, 27 | Prefix: "", 28 | IndexFile: "index.html", 29 | } 30 | } 31 | 32 | func (s *Static) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) { 33 | if r.Method != "GET" && r.Method != "HEAD" { 34 | next(rw, r) 35 | return 36 | } 37 | file := r.URL.Path 38 | // if we have a prefix, filter requests by stripping the prefix 39 | if s.Prefix != "" { 40 | if !strings.HasPrefix(file, s.Prefix) { 41 | next(rw, r) 42 | return 43 | } 44 | file = file[len(s.Prefix):] 45 | if file != "" && file[0] != '/' { 46 | next(rw, r) 47 | return 48 | } 49 | } 50 | f, err := s.Dir.Open(file) 51 | if err != nil { 52 | // discard the error? 53 | next(rw, r) 54 | return 55 | } 56 | defer f.Close() 57 | 58 | fi, err := f.Stat() 59 | if err != nil { 60 | next(rw, r) 61 | return 62 | } 63 | 64 | // try to serve index file 65 | if fi.IsDir() { 66 | // redirect if missing trailing slash 67 | if !strings.HasSuffix(r.URL.Path, "/") { 68 | http.Redirect(rw, r, r.URL.Path+"/", http.StatusFound) 69 | return 70 | } 71 | 72 | file = path.Join(file, s.IndexFile) 73 | f, err = s.Dir.Open(file) 74 | if err != nil { 75 | next(rw, r) 76 | return 77 | } 78 | defer f.Close() 79 | 80 | fi, err = f.Stat() 81 | if err != nil || fi.IsDir() { 82 | next(rw, r) 83 | return 84 | } 85 | } 86 | 87 | http.ServeContent(rw, r, file, fi.ModTime(), f) 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/init.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | 7 | "github.com/jtolds/gls" 8 | "github.com/smartystreets/assertions" 9 | "github.com/smartystreets/goconvey/convey/reporting" 10 | ) 11 | 12 | func init() { 13 | assertions.GoConveyMode(true) 14 | 15 | declareFlags() 16 | 17 | ctxMgr = gls.NewContextManager() 18 | } 19 | 20 | func declareFlags() { 21 | flag.BoolVar(&json, "convey-json", false, "When true, emits results in JSON blocks. Default: 'false'") 22 | flag.BoolVar(&silent, "convey-silent", false, "When true, all output from GoConvey is suppressed.") 23 | flag.BoolVar(&story, "convey-story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") 24 | 25 | if noStoryFlagProvided() { 26 | story = verboseEnabled 27 | } 28 | 29 | // FYI: flag.Parse() is called from the testing package. 30 | } 31 | 32 | func noStoryFlagProvided() bool { 33 | return !story && !storyDisabled 34 | } 35 | 36 | func buildReporter() reporting.Reporter { 37 | selectReporter := os.Getenv("GOCONVEY_REPORTER") 38 | 39 | switch { 40 | case testReporter != nil: 41 | return testReporter 42 | case json || selectReporter == "json": 43 | return reporting.BuildJsonReporter() 44 | case silent || selectReporter == "silent": 45 | return reporting.BuildSilentReporter() 46 | case selectReporter == "dot": 47 | // Story is turned on when verbose is set, so we need to check for dot reporter first. 48 | return reporting.BuildDotReporter() 49 | case story || selectReporter == "story": 50 | return reporting.BuildStoryReporter() 51 | default: 52 | return reporting.BuildDotReporter() 53 | } 54 | } 55 | 56 | var ( 57 | ctxMgr *gls.ContextManager 58 | 59 | // only set by internal tests 60 | testReporter reporting.Reporter 61 | ) 62 | 63 | var ( 64 | json bool 65 | silent bool 66 | story bool 67 | 68 | verboseEnabled = flagFound("-test.v=true") 69 | storyDisabled = flagFound("-story=false") 70 | ) 71 | 72 | // flagFound parses the command line args manually for flags defined in other 73 | // packages. Like the '-v' flag from the "testing" package, for instance. 74 | func flagFound(flagValue string) bool { 75 | for _, arg := range os.Args { 76 | if arg == flagValue { 77 | return true 78 | } 79 | } 80 | return false 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "strings" 20 | ) 21 | 22 | // AllOf accepts a set of matchers S and returns a matcher that follows the 23 | // algorithm below when considering a candidate c: 24 | // 25 | // 1. Return true if for every Matcher m in S, m matches c. 26 | // 27 | // 2. Otherwise, if there is a matcher m in S such that m returns a fatal 28 | // error for c, return that matcher's error message. 29 | // 30 | // 3. Otherwise, return false with the error from some wrapped matcher. 31 | // 32 | // This is akin to a logical AND operation for matchers. 33 | func AllOf(matchers ...Matcher) Matcher { 34 | return &allOfMatcher{matchers} 35 | } 36 | 37 | type allOfMatcher struct { 38 | wrappedMatchers []Matcher 39 | } 40 | 41 | func (m *allOfMatcher) Description() string { 42 | // Special case: the empty set. 43 | if len(m.wrappedMatchers) == 0 { 44 | return "is anything" 45 | } 46 | 47 | // Join the descriptions for the wrapped matchers. 48 | wrappedDescs := make([]string, len(m.wrappedMatchers)) 49 | for i, wrappedMatcher := range m.wrappedMatchers { 50 | wrappedDescs[i] = wrappedMatcher.Description() 51 | } 52 | 53 | return strings.Join(wrappedDescs, ", and ") 54 | } 55 | 56 | func (m *allOfMatcher) Matches(c interface{}) (err error) { 57 | for _, wrappedMatcher := range m.wrappedMatchers { 58 | if wrappedErr := wrappedMatcher.Matches(c); wrappedErr != nil { 59 | err = wrappedErr 60 | 61 | // If the error is fatal, return immediately with this error. 62 | _, ok := wrappedErr.(*FatalError) 63 | if ok { 64 | return 65 | } 66 | } 67 | } 68 | 69 | return 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | ) 23 | 24 | // Panics matches zero-arg functions which, when invoked, panic with an error 25 | // that matches the supplied matcher. 26 | // 27 | // NOTE(jacobsa): This matcher cannot detect the case where the function panics 28 | // using panic(nil), by design of the language. See here for more info: 29 | // 30 | // http://goo.gl/9aIQL 31 | // 32 | func Panics(m Matcher) Matcher { 33 | return &panicsMatcher{m} 34 | } 35 | 36 | type panicsMatcher struct { 37 | wrappedMatcher Matcher 38 | } 39 | 40 | func (m *panicsMatcher) Description() string { 41 | return "panics with: " + m.wrappedMatcher.Description() 42 | } 43 | 44 | func (m *panicsMatcher) Matches(c interface{}) (err error) { 45 | // Make sure c is a zero-arg function. 46 | v := reflect.ValueOf(c) 47 | if v.Kind() != reflect.Func || v.Type().NumIn() != 0 { 48 | err = NewFatalError("which is not a zero-arg function") 49 | return 50 | } 51 | 52 | // Call the function and check its panic error. 53 | defer func() { 54 | if e := recover(); e != nil { 55 | err = m.wrappedMatcher.Matches(e) 56 | 57 | // Set a clearer error message if the matcher said no. 58 | if err != nil { 59 | wrappedClause := "" 60 | if err.Error() != "" { 61 | wrappedClause = ", " + err.Error() 62 | } 63 | 64 | err = errors.New(fmt.Sprintf("which panicked with: %v%s", e, wrappedClause)) 65 | } 66 | } 67 | }() 68 | 69 | v.Call([]reflect.Value{}) 70 | 71 | // If we get here, the function didn't panic. 72 | err = errors.New("which didn't panic") 73 | return 74 | } 75 | -------------------------------------------------------------------------------- /couriers/kpost_test.go: -------------------------------------------------------------------------------- 1 | package couriers 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/jarcoal/httpmock" 8 | "github.com/purpleworks/delibird" 9 | . "github.com/smartystreets/goconvey/convey" 10 | ) 11 | 12 | func TestKpostCourier(t *testing.T) { 13 | // create epost courier 14 | courier, _ := New("KPOST") 15 | 16 | // create http mock 17 | httpmock.Activate() 18 | defer httpmock.DeactivateAndReset() 19 | 20 | invalidTrackingNumber := "kpost_invalid" 21 | invalidTrackingNumber2 := "kpost_invalid_2" 22 | startTrackingNumber := "kpost_start" 23 | completeTrackingNumber := "kpost_complete" 24 | 25 | httpmock.RegisterResponder("GET", fmt.Sprintf(Kpost{}.TrackingUrl(), invalidTrackingNumber), 26 | httpmock.NewStringResponder(200, readTestResponseFile(invalidTrackingNumber+".html"))) 27 | httpmock.RegisterResponder("GET", fmt.Sprintf(Kpost{}.TrackingUrl(), invalidTrackingNumber2), 28 | httpmock.NewStringResponder(200, readTestResponseFile(invalidTrackingNumber2+".html"))) 29 | httpmock.RegisterResponder("GET", fmt.Sprintf(Kpost{}.TrackingUrl(), startTrackingNumber), 30 | httpmock.NewStringResponder(200, readTestResponseFile(startTrackingNumber+".html"))) 31 | httpmock.RegisterResponder("GET", fmt.Sprintf(Kpost{}.TrackingUrl(), completeTrackingNumber), 32 | httpmock.NewStringResponder(200, readTestResponseFile(completeTrackingNumber+".html"))) 33 | 34 | Convey("KPOST test", t, func() { 35 | Convey("Invalid tracking number test", func() { 36 | _, err := courier.Parse(invalidTrackingNumber) 37 | 38 | So(err, ShouldNotBeNil) 39 | }) 40 | 41 | Convey("Invalid tracking number test2", func() { 42 | _, err := courier.Parse(invalidTrackingNumber2) 43 | 44 | So(err, ShouldNotBeNil) 45 | }) 46 | 47 | Convey("Start courier test", func() { 48 | data, _ := courier.Parse(startTrackingNumber) 49 | 50 | So(data.StatusCode, ShouldEqual, delibird.Unloading) 51 | So(data.Sender, ShouldEqual, "홈*럼") 52 | So(data.Receiver, ShouldEqual, "테*트") 53 | So(data.CompanyCode, ShouldEqual, "KPOST") 54 | }) 55 | 56 | Convey("Complete courier test", func() { 57 | data, _ := courier.Parse(completeTrackingNumber) 58 | 59 | So(data.StatusCode, ShouldEqual, delibird.DeleveryComplete) 60 | So(data.Sender, ShouldEqual, "홈*럼") 61 | So(data.Receiver, ShouldEqual, "테*트") 62 | So(data.Signer, ShouldEqual, "테*트님 - 본인") 63 | So(data.CompanyCode, ShouldEqual, "KPOST") 64 | }) 65 | }) 66 | } 67 | -------------------------------------------------------------------------------- /couriers/testhtml/kg_invalid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | KG로지스 배송조회 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | 34 |
35 |

01 주문정보

36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
주문정보
운송장번호null
보내시는분null(null)
받으시는분null(null)
상품명>null수량null
67 |

02 상품이동현황

68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 |
상품이동현황 리스트
일자시간지사/대리점 연락처이동상태
물품 이동경로정보가 없습니다.
89 |
90 | 창닫기 91 |
92 |
93 |
94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/encoding/internal/internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package internal contains code that is shared among encoding implementations. 6 | package internal 7 | 8 | import ( 9 | "golang.org/x/text/encoding" 10 | "golang.org/x/text/encoding/internal/identifier" 11 | "golang.org/x/text/transform" 12 | ) 13 | 14 | // Encoding is an implementation of the Encoding interface that adds the String 15 | // and ID methods to an existing encoding. 16 | type Encoding struct { 17 | encoding.Encoding 18 | Name string 19 | MIB identifier.MIB 20 | } 21 | 22 | // _ verifies that Encoding implements identifier.Interface. 23 | var _ identifier.Interface = (*Encoding)(nil) 24 | 25 | func (e *Encoding) String() string { 26 | return e.Name 27 | } 28 | 29 | func (e *Encoding) ID() (mib identifier.MIB, other string) { 30 | return e.MIB, "" 31 | } 32 | 33 | // SimpleEncoding is an Encoding that combines two Transformers. 34 | type SimpleEncoding struct { 35 | Decoder transform.Transformer 36 | Encoder transform.Transformer 37 | } 38 | 39 | func (e *SimpleEncoding) NewDecoder() *encoding.Decoder { 40 | return &encoding.Decoder{Transformer: e.Decoder} 41 | } 42 | 43 | func (e *SimpleEncoding) NewEncoder() *encoding.Encoder { 44 | return &encoding.Encoder{Transformer: e.Encoder} 45 | } 46 | 47 | // FuncEncoding is an Encoding that combines two functions returning a new 48 | // Transformer. 49 | type FuncEncoding struct { 50 | Decoder func() transform.Transformer 51 | Encoder func() transform.Transformer 52 | } 53 | 54 | func (e FuncEncoding) NewDecoder() *encoding.Decoder { 55 | return &encoding.Decoder{Transformer: e.Decoder()} 56 | } 57 | 58 | func (e FuncEncoding) NewEncoder() *encoding.Encoder { 59 | return &encoding.Encoder{Transformer: e.Encoder()} 60 | } 61 | 62 | // A RepertoireError indicates a rune is not in the repertoire of a destination 63 | // encoding. It is associated with an encoding-specific suggested replacement 64 | // byte. 65 | type RepertoireError byte 66 | 67 | // Error implements the error interrface. 68 | func (r RepertoireError) Error() string { 69 | return "encoding: rune not supported by encoding." 70 | } 71 | 72 | // Replacement returns the replacement string associated with this error. 73 | func (r RepertoireError) Replacement() byte { return byte(r) } 74 | 75 | var ErrASCIIReplacement = RepertoireError(encoding.ASCIISub) 76 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/html/atom/atom.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package atom provides integer codes (also known as atoms) for a fixed set of 6 | // frequently occurring HTML strings: tag names and attribute keys such as "p" 7 | // and "id". 8 | // 9 | // Sharing an atom's name between all elements with the same tag can result in 10 | // fewer string allocations when tokenizing and parsing HTML. Integer 11 | // comparisons are also generally faster than string comparisons. 12 | // 13 | // The value of an atom's particular code is not guaranteed to stay the same 14 | // between versions of this package. Neither is any ordering guaranteed: 15 | // whether atom.H1 < atom.H2 may also change. The codes are not guaranteed to 16 | // be dense. The only guarantees are that e.g. looking up "div" will yield 17 | // atom.Div, calling atom.Div.String will return "div", and atom.Div != 0. 18 | package atom 19 | 20 | // Atom is an integer code for a string. The zero value maps to "". 21 | type Atom uint32 22 | 23 | // String returns the atom's name. 24 | func (a Atom) String() string { 25 | start := uint32(a >> 8) 26 | n := uint32(a & 0xff) 27 | if start+n > uint32(len(atomText)) { 28 | return "" 29 | } 30 | return atomText[start : start+n] 31 | } 32 | 33 | func (a Atom) string() string { 34 | return atomText[a>>8 : a>>8+a&0xff] 35 | } 36 | 37 | // fnv computes the FNV hash with an arbitrary starting value h. 38 | func fnv(h uint32, s []byte) uint32 { 39 | for i := range s { 40 | h ^= uint32(s[i]) 41 | h *= 16777619 42 | } 43 | return h 44 | } 45 | 46 | func match(s string, t []byte) bool { 47 | for i, c := range t { 48 | if s[i] != c { 49 | return false 50 | } 51 | } 52 | return true 53 | } 54 | 55 | // Lookup returns the atom whose name is s. It returns zero if there is no 56 | // such atom. The lookup is case sensitive. 57 | func Lookup(s []byte) Atom { 58 | if len(s) == 0 || len(s) > maxAtomLen { 59 | return 0 60 | } 61 | h := fnv(hash0, s) 62 | if a := table[h&uint32(len(table)-1)]; int(a&0xff) == len(s) && match(a.string(), s) { 63 | return a 64 | } 65 | if a := table[(h>>16)&uint32(len(table)-1)]; int(a&0xff) == len(s) && match(a.string(), s) { 66 | return a 67 | } 68 | return 0 69 | } 70 | 71 | // String returns a string whose contents are equal to s. In that sense, it is 72 | // equivalent to string(s) but may be more efficient. 73 | func String(s []byte) string { 74 | if a := Lookup(s); a != 0 { 75 | return a.String() 76 | } 77 | return string(s) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/json.go: -------------------------------------------------------------------------------- 1 | // TODO: under unit test 2 | 3 | package reporting 4 | 5 | import ( 6 | "bytes" 7 | "encoding/json" 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | type JsonReporter struct { 13 | out *Printer 14 | currentKey []string 15 | current *ScopeResult 16 | index map[string]*ScopeResult 17 | scopes []*ScopeResult 18 | } 19 | 20 | func (self *JsonReporter) depth() int { return len(self.currentKey) } 21 | 22 | func (self *JsonReporter) BeginStory(story *StoryReport) {} 23 | 24 | func (self *JsonReporter) Enter(scope *ScopeReport) { 25 | self.currentKey = append(self.currentKey, scope.Title) 26 | ID := strings.Join(self.currentKey, "|") 27 | if _, found := self.index[ID]; !found { 28 | next := newScopeResult(scope.Title, self.depth(), scope.File, scope.Line) 29 | self.scopes = append(self.scopes, next) 30 | self.index[ID] = next 31 | } 32 | self.current = self.index[ID] 33 | } 34 | 35 | func (self *JsonReporter) Report(report *AssertionResult) { 36 | self.current.Assertions = append(self.current.Assertions, report) 37 | } 38 | 39 | func (self *JsonReporter) Exit() { 40 | self.currentKey = self.currentKey[:len(self.currentKey)-1] 41 | } 42 | 43 | func (self *JsonReporter) EndStory() { 44 | self.report() 45 | self.reset() 46 | } 47 | func (self *JsonReporter) report() { 48 | scopes := []string{} 49 | for _, scope := range self.scopes { 50 | serialized, err := json.Marshal(scope) 51 | if err != nil { 52 | self.out.Println(jsonMarshalFailure) 53 | panic(err) 54 | } 55 | var buffer bytes.Buffer 56 | json.Indent(&buffer, serialized, "", " ") 57 | scopes = append(scopes, buffer.String()) 58 | } 59 | self.out.Print(fmt.Sprintf("%s\n%s,\n%s\n", OpenJson, strings.Join(scopes, ","), CloseJson)) 60 | } 61 | func (self *JsonReporter) reset() { 62 | self.scopes = []*ScopeResult{} 63 | self.index = map[string]*ScopeResult{} 64 | self.currentKey = nil 65 | } 66 | 67 | func (self *JsonReporter) Write(content []byte) (written int, err error) { 68 | self.current.Output += string(content) 69 | return len(content), nil 70 | } 71 | 72 | func NewJsonReporter(out *Printer) *JsonReporter { 73 | self := new(JsonReporter) 74 | self.out = out 75 | self.reset() 76 | return self 77 | } 78 | 79 | const OpenJson = ">->->OPEN-JSON->->->" // "⌦" 80 | const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫" 81 | const jsonMarshalFailure = ` 82 | 83 | GOCONVEY_JSON_MARSHALL_FAILURE: There was an error when attempting to convert test results to JSON. 84 | Please file a bug report and reference the code that caused this failure if possible. 85 | 86 | Here's the panic: 87 | 88 | ` 89 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/init.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "os" 5 | "runtime" 6 | "strings" 7 | ) 8 | 9 | func init() { 10 | if !isColorableTerminal() { 11 | monochrome() 12 | } 13 | 14 | if runtime.GOOS == "windows" { 15 | success, failure, error_ = dotSuccess, dotFailure, dotError 16 | } 17 | } 18 | 19 | func BuildJsonReporter() Reporter { 20 | out := NewPrinter(NewConsole()) 21 | return NewReporters( 22 | NewGoTestReporter(), 23 | NewJsonReporter(out)) 24 | } 25 | func BuildDotReporter() Reporter { 26 | out := NewPrinter(NewConsole()) 27 | return NewReporters( 28 | NewGoTestReporter(), 29 | NewDotReporter(out), 30 | NewProblemReporter(out), 31 | consoleStatistics) 32 | } 33 | func BuildStoryReporter() Reporter { 34 | out := NewPrinter(NewConsole()) 35 | return NewReporters( 36 | NewGoTestReporter(), 37 | NewStoryReporter(out), 38 | NewProblemReporter(out), 39 | consoleStatistics) 40 | } 41 | func BuildSilentReporter() Reporter { 42 | out := NewPrinter(NewConsole()) 43 | return NewReporters( 44 | NewGoTestReporter(), 45 | NewSilentProblemReporter(out)) 46 | } 47 | 48 | var ( 49 | newline = "\n" 50 | success = "✔" 51 | failure = "✘" 52 | error_ = "🔥" 53 | skip = "⚠" 54 | dotSuccess = "." 55 | dotFailure = "x" 56 | dotError = "E" 57 | dotSkip = "S" 58 | errorTemplate = "* %s \nLine %d: - %v \n%s\n" 59 | failureTemplate = "* %s \nLine %d:\n%s\n" 60 | ) 61 | 62 | var ( 63 | greenColor = "\033[32m" 64 | yellowColor = "\033[33m" 65 | redColor = "\033[31m" 66 | resetColor = "\033[0m" 67 | ) 68 | 69 | var consoleStatistics = NewStatisticsReporter(NewPrinter(NewConsole())) 70 | 71 | func SuppressConsoleStatistics() { consoleStatistics.Suppress() } 72 | func PrintConsoleStatistics() { consoleStatistics.PrintSummary() } 73 | 74 | // QuiteMode disables all console output symbols. This is only meant to be used 75 | // for tests that are internal to goconvey where the output is distracting or 76 | // otherwise not needed in the test output. 77 | func QuietMode() { 78 | success, failure, error_, skip, dotSuccess, dotFailure, dotError, dotSkip = "", "", "", "", "", "", "", "" 79 | } 80 | 81 | func monochrome() { 82 | greenColor, yellowColor, redColor, resetColor = "", "", "", "" 83 | } 84 | 85 | func isColorableTerminal() bool { 86 | return strings.Contains(os.Getenv("TERM"), "color") 87 | } 88 | 89 | // This interface allows us to pass the *testing.T struct 90 | // throughout the internals of this tool without ever 91 | // having to import the "testing" package. 92 | type T interface { 93 | Fail() 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | func (self *statistics) BeginStory(story *StoryReport) {} 9 | 10 | func (self *statistics) Enter(scope *ScopeReport) {} 11 | 12 | func (self *statistics) Report(report *AssertionResult) { 13 | self.Lock() 14 | defer self.Unlock() 15 | 16 | if !self.failing && report.Failure != "" { 17 | self.failing = true 18 | } 19 | if !self.erroring && report.Error != nil { 20 | self.erroring = true 21 | } 22 | if report.Skipped { 23 | self.skipped += 1 24 | } else { 25 | self.total++ 26 | } 27 | } 28 | 29 | func (self *statistics) Exit() {} 30 | 31 | func (self *statistics) EndStory() { 32 | self.Lock() 33 | defer self.Unlock() 34 | 35 | if !self.suppressed { 36 | self.printSummaryLocked() 37 | } 38 | } 39 | 40 | func (self *statistics) Suppress() { 41 | self.Lock() 42 | defer self.Unlock() 43 | self.suppressed = true 44 | } 45 | 46 | func (self *statistics) PrintSummary() { 47 | self.Lock() 48 | defer self.Unlock() 49 | self.printSummaryLocked() 50 | } 51 | 52 | func (self *statistics) printSummaryLocked() { 53 | self.reportAssertionsLocked() 54 | self.reportSkippedSectionsLocked() 55 | self.completeReportLocked() 56 | } 57 | func (self *statistics) reportAssertionsLocked() { 58 | self.decideColorLocked() 59 | self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) 60 | } 61 | func (self *statistics) decideColorLocked() { 62 | if self.failing && !self.erroring { 63 | fmt.Print(yellowColor) 64 | } else if self.erroring { 65 | fmt.Print(redColor) 66 | } else { 67 | fmt.Print(greenColor) 68 | } 69 | } 70 | func (self *statistics) reportSkippedSectionsLocked() { 71 | if self.skipped > 0 { 72 | fmt.Print(yellowColor) 73 | self.out.Print(" (one or more sections skipped)") 74 | } 75 | } 76 | func (self *statistics) completeReportLocked() { 77 | fmt.Print(resetColor) 78 | self.out.Print("\n") 79 | self.out.Print("\n") 80 | } 81 | 82 | func (self *statistics) Write(content []byte) (written int, err error) { 83 | return len(content), nil // no-op 84 | } 85 | 86 | func NewStatisticsReporter(out *Printer) *statistics { 87 | self := statistics{} 88 | self.out = out 89 | return &self 90 | } 91 | 92 | type statistics struct { 93 | sync.Mutex 94 | 95 | out *Printer 96 | total int 97 | failing bool 98 | erroring bool 99 | skipped int 100 | suppressed bool 101 | } 102 | 103 | func plural(word string, count int) string { 104 | if count == 1 { 105 | return word 106 | } 107 | return word + "s" 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package gls 4 | 5 | // This file is used for GopherJS builds, which don't have normal runtime support 6 | 7 | import ( 8 | "regexp" 9 | "strconv" 10 | "strings" 11 | 12 | "github.com/gopherjs/gopherjs/js" 13 | ) 14 | 15 | var stackRE = regexp.MustCompile("\\s+at (\\S*) \\([^:]+:(\\d+):(\\d+)") 16 | 17 | func findPtr() uintptr { 18 | jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n") 19 | for i := 1; i < jsStack.Get("length").Int(); i++ { 20 | item := jsStack.Index(i).String() 21 | matches := stackRE.FindAllStringSubmatch(item, -1) 22 | if matches == nil { 23 | return 0 24 | } 25 | pkgPath := matches[0][1] 26 | if strings.HasPrefix(pkgPath, "$packages.github.com/jtolds/gls.mark") { 27 | line, _ := strconv.Atoi(matches[0][2]) 28 | char, _ := strconv.Atoi(matches[0][3]) 29 | x := (uintptr(line) << 16) | uintptr(char) 30 | return x 31 | } 32 | } 33 | 34 | return 0 35 | } 36 | 37 | func init() { 38 | setEntries := func(f func(uint, func()), v int8) { 39 | var ptr uintptr 40 | f(0, func() { 41 | ptr = findPtr() 42 | }) 43 | pc_lookup[ptr] = v 44 | if v >= 0 { 45 | mark_lookup[v] = f 46 | } 47 | } 48 | setEntries(markS, -0x1) 49 | setEntries(mark0, 0x0) 50 | setEntries(mark1, 0x1) 51 | setEntries(mark2, 0x2) 52 | setEntries(mark3, 0x3) 53 | setEntries(mark4, 0x4) 54 | setEntries(mark5, 0x5) 55 | setEntries(mark6, 0x6) 56 | setEntries(mark7, 0x7) 57 | setEntries(mark8, 0x8) 58 | setEntries(mark9, 0x9) 59 | setEntries(markA, 0xa) 60 | setEntries(markB, 0xb) 61 | setEntries(markC, 0xc) 62 | setEntries(markD, 0xd) 63 | setEntries(markE, 0xe) 64 | setEntries(markF, 0xf) 65 | } 66 | 67 | func currentStack(skip int) (stack []uintptr) { 68 | jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n") 69 | for i := skip + 2; i < jsStack.Get("length").Int(); i++ { 70 | item := jsStack.Index(i).String() 71 | matches := stackRE.FindAllStringSubmatch(item, -1) 72 | if matches == nil { 73 | return stack 74 | } 75 | line, _ := strconv.Atoi(matches[0][2]) 76 | char, _ := strconv.Atoi(matches[0][3]) 77 | x := (uintptr(line) << 16) | uintptr(char)&0xffff 78 | stack = append(stack, x) 79 | } 80 | 81 | return stack 82 | } 83 | 84 | func readStackTags(skip int) (tags []uint) { 85 | stack := currentStack(skip) 86 | var current_tag uint 87 | for _, pc := range stack { 88 | val, ok := pc_lookup[pc] 89 | if !ok { 90 | continue 91 | } 92 | if val < 0 { 93 | tags = append(tags, current_tag) 94 | current_tag = 0 95 | continue 96 | } 97 | current_tag <<= bitWidth 98 | current_tag += uint(val) 99 | } 100 | return 101 | } 102 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "bytes" 20 | "errors" 21 | "fmt" 22 | "reflect" 23 | ) 24 | 25 | var byteSliceType reflect.Type = reflect.TypeOf([]byte{}) 26 | 27 | // DeepEquals returns a matcher that matches based on 'deep equality', as 28 | // defined by the reflect package. This matcher requires that values have 29 | // identical types to x. 30 | func DeepEquals(x interface{}) Matcher { 31 | return &deepEqualsMatcher{x} 32 | } 33 | 34 | type deepEqualsMatcher struct { 35 | x interface{} 36 | } 37 | 38 | func (m *deepEqualsMatcher) Description() string { 39 | xDesc := fmt.Sprintf("%v", m.x) 40 | xValue := reflect.ValueOf(m.x) 41 | 42 | // Special case: fmt.Sprintf presents nil slices as "[]", but 43 | // reflect.DeepEqual makes a distinction between nil and empty slices. Make 44 | // this less confusing. 45 | if xValue.Kind() == reflect.Slice && xValue.IsNil() { 46 | xDesc = "" 47 | } 48 | 49 | return fmt.Sprintf("deep equals: %s", xDesc) 50 | } 51 | 52 | func (m *deepEqualsMatcher) Matches(c interface{}) error { 53 | // Make sure the types match. 54 | ct := reflect.TypeOf(c) 55 | xt := reflect.TypeOf(m.x) 56 | 57 | if ct != xt { 58 | return NewFatalError(fmt.Sprintf("which is of type %v", ct)) 59 | } 60 | 61 | // Special case: handle byte slices more efficiently. 62 | cValue := reflect.ValueOf(c) 63 | xValue := reflect.ValueOf(m.x) 64 | 65 | if ct == byteSliceType && !cValue.IsNil() && !xValue.IsNil() { 66 | xBytes := m.x.([]byte) 67 | cBytes := c.([]byte) 68 | 69 | if bytes.Equal(cBytes, xBytes) { 70 | return nil 71 | } 72 | 73 | return errors.New("") 74 | } 75 | 76 | // Defer to the reflect package. 77 | if reflect.DeepEqual(m.x, c) { 78 | return nil 79 | } 80 | 81 | // Special case: if the comparison failed because c is the nil slice, given 82 | // an indication of this (since its value is printed as "[]"). 83 | if cValue.Kind() == reflect.Slice && cValue.IsNil() { 84 | return errors.New("which is nil") 85 | } 86 | 87 | return errors.New("") 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/danryan/env/env.go: -------------------------------------------------------------------------------- 1 | package env 2 | 3 | // package main 4 | 5 | import ( 6 | "errors" 7 | "reflect" 8 | ) 9 | 10 | // Env struct 11 | type Env struct { 12 | Value reflect.Value // Value is the value of an interface or pointer 13 | Prefix string 14 | Vars []*Var 15 | } 16 | 17 | // Process takes a struct, and maps environment variables to its fields. 18 | // Errors returned from underlying functions will bubble up to the surface. 19 | func Process(v interface{}) error { 20 | _, err := NewEnv(v) 21 | if err != nil { 22 | return err 23 | } 24 | 25 | return nil 26 | } 27 | 28 | // MustProcess maps environment variables to the fields of struct v. 29 | // If any errors are returned, this function will panic. 30 | func MustProcess(v interface{}) { 31 | _, err := NewEnv(v) 32 | if err != nil { 33 | panic(err) 34 | } 35 | } 36 | 37 | // FieldNames returns the name of all struct fields as aa slice of strings 38 | func (e *Env) FieldNames() []string { 39 | fieldType := e.Type() 40 | 41 | var fieldNames []string 42 | for i := 0; i < fieldType.NumField(); i++ { 43 | field := fieldType.Field(i) 44 | fieldNames = append(fieldNames, field.Name) 45 | } 46 | return fieldNames 47 | } 48 | 49 | // Type returns the type of e.Value 50 | func (e *Env) Type() reflect.Type { 51 | return e.Value.Type() 52 | } 53 | 54 | var errInvalidValue = errors.New("expected value must be a pointer to a struct") 55 | 56 | // New is a shortcut wrapper around NewEnv 57 | func New(v interface{}) (*Env, error) { 58 | return NewEnv(v) 59 | } 60 | 61 | // NewEnv returns a new Env 62 | func NewEnv(v interface{}) (*Env, error) { 63 | e := &Env{} 64 | 65 | if reflect.TypeOf(v).Kind() != reflect.Ptr { 66 | return nil, errInvalidValue 67 | } 68 | if reflect.ValueOf(v).Elem().Kind() != reflect.Struct { 69 | return nil, errInvalidValue 70 | } 71 | 72 | e.SetValue(v) 73 | 74 | if err := e.Parse(); err != nil { 75 | return e, err 76 | } 77 | 78 | return e, nil 79 | } 80 | 81 | // SetValue sets Value of Env e 82 | func (e *Env) SetValue(v interface{}) { 83 | if reflect.TypeOf(v).Kind() == reflect.Ptr { 84 | e.Value = reflect.ValueOf(v).Elem() 85 | } else { 86 | e.Value = reflect.ValueOf(v) 87 | } 88 | } 89 | 90 | // SetPrefix sets prefix of Env e 91 | func (e *Env) SetPrefix(prefix string) { 92 | e.Prefix = prefix 93 | } 94 | 95 | // Parse parses the config struct into valid Vars 96 | func (e *Env) Parse() error { 97 | for _, name := range e.FieldNames() { 98 | field, _ := e.Value.Type().FieldByName(name) 99 | v, err := NewVar(field) 100 | 101 | if err != nil { 102 | return err 103 | } 104 | e.Value.FieldByName(name).Set(v.Value) 105 | e.Vars = append(e.Vars, v) 106 | } 107 | 108 | return nil 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package context stores values shared during a request lifetime. 7 | 8 | For example, a router can set variables extracted from the URL and later 9 | application handlers can access those values, or it can be used to store 10 | sessions values to be saved at the end of a request. There are several 11 | others common uses. 12 | 13 | The idea was posted by Brad Fitzpatrick to the go-nuts mailing list: 14 | 15 | http://groups.google.com/group/golang-nuts/msg/e2d679d303aa5d53 16 | 17 | Here's the basic usage: first define the keys that you will need. The key 18 | type is interface{} so a key can be of any type that supports equality. 19 | Here we define a key using a custom int type to avoid name collisions: 20 | 21 | package foo 22 | 23 | import ( 24 | "github.com/gorilla/context" 25 | ) 26 | 27 | type key int 28 | 29 | const MyKey key = 0 30 | 31 | Then set a variable. Variables are bound to an http.Request object, so you 32 | need a request instance to set a value: 33 | 34 | context.Set(r, MyKey, "bar") 35 | 36 | The application can later access the variable using the same key you provided: 37 | 38 | func MyHandler(w http.ResponseWriter, r *http.Request) { 39 | // val is "bar". 40 | val := context.Get(r, foo.MyKey) 41 | 42 | // returns ("bar", true) 43 | val, ok := context.GetOk(r, foo.MyKey) 44 | // ... 45 | } 46 | 47 | And that's all about the basic usage. We discuss some other ideas below. 48 | 49 | Any type can be stored in the context. To enforce a given type, make the key 50 | private and wrap Get() and Set() to accept and return values of a specific 51 | type: 52 | 53 | type key int 54 | 55 | const mykey key = 0 56 | 57 | // GetMyKey returns a value for this package from the request values. 58 | func GetMyKey(r *http.Request) SomeType { 59 | if rv := context.Get(r, mykey); rv != nil { 60 | return rv.(SomeType) 61 | } 62 | return nil 63 | } 64 | 65 | // SetMyKey sets a value for this package in the request values. 66 | func SetMyKey(r *http.Request, val SomeType) { 67 | context.Set(r, mykey, val) 68 | } 69 | 70 | Variables must be cleared at the end of a request, to remove all values 71 | that were stored. This can be done in an http.Handler, after a request was 72 | served. Just call Clear() passing the request: 73 | 74 | context.Clear(r) 75 | 76 | ...or use ClearHandler(), which conveniently wraps an http.Handler to clear 77 | variables at the end of a request lifetime. 78 | 79 | The Routers from the packages gorilla/mux and gorilla/pat call Clear() 80 | so if you are using either of them you don't need to clear the context manually. 81 | */ 82 | package context 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/html/const.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package html 6 | 7 | // Section 12.2.3.2 of the HTML5 specification says "The following elements 8 | // have varying levels of special parsing rules". 9 | // https://html.spec.whatwg.org/multipage/syntax.html#the-stack-of-open-elements 10 | var isSpecialElementMap = map[string]bool{ 11 | "address": true, 12 | "applet": true, 13 | "area": true, 14 | "article": true, 15 | "aside": true, 16 | "base": true, 17 | "basefont": true, 18 | "bgsound": true, 19 | "blockquote": true, 20 | "body": true, 21 | "br": true, 22 | "button": true, 23 | "caption": true, 24 | "center": true, 25 | "col": true, 26 | "colgroup": true, 27 | "dd": true, 28 | "details": true, 29 | "dir": true, 30 | "div": true, 31 | "dl": true, 32 | "dt": true, 33 | "embed": true, 34 | "fieldset": true, 35 | "figcaption": true, 36 | "figure": true, 37 | "footer": true, 38 | "form": true, 39 | "frame": true, 40 | "frameset": true, 41 | "h1": true, 42 | "h2": true, 43 | "h3": true, 44 | "h4": true, 45 | "h5": true, 46 | "h6": true, 47 | "head": true, 48 | "header": true, 49 | "hgroup": true, 50 | "hr": true, 51 | "html": true, 52 | "iframe": true, 53 | "img": true, 54 | "input": true, 55 | "isindex": true, 56 | "li": true, 57 | "link": true, 58 | "listing": true, 59 | "marquee": true, 60 | "menu": true, 61 | "meta": true, 62 | "nav": true, 63 | "noembed": true, 64 | "noframes": true, 65 | "noscript": true, 66 | "object": true, 67 | "ol": true, 68 | "p": true, 69 | "param": true, 70 | "plaintext": true, 71 | "pre": true, 72 | "script": true, 73 | "section": true, 74 | "select": true, 75 | "source": true, 76 | "style": true, 77 | "summary": true, 78 | "table": true, 79 | "tbody": true, 80 | "td": true, 81 | "template": true, 82 | "textarea": true, 83 | "tfoot": true, 84 | "th": true, 85 | "thead": true, 86 | "title": true, 87 | "tr": true, 88 | "track": true, 89 | "ul": true, 90 | "wbr": true, 91 | "xmp": true, 92 | } 93 | 94 | func isSpecialElement(element *Node) bool { 95 | switch element.Namespace { 96 | case "", "html": 97 | return isSpecialElementMap[element.Data] 98 | case "svg": 99 | return element.Data == "foreignObject" 100 | } 101 | return false 102 | } 103 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/discovery.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | type actionSpecifier uint8 4 | 5 | const ( 6 | noSpecifier actionSpecifier = iota 7 | skipConvey 8 | focusConvey 9 | ) 10 | 11 | type suite struct { 12 | Situation string 13 | Test t 14 | Focus bool 15 | Func func(C) // nil means skipped 16 | FailMode FailureMode 17 | } 18 | 19 | func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { 20 | ret := &suite{ 21 | Situation: situation, 22 | Test: test, 23 | Func: f, 24 | FailMode: failureMode, 25 | } 26 | switch specifier { 27 | case skipConvey: 28 | ret.Func = nil 29 | case focusConvey: 30 | ret.Focus = true 31 | } 32 | return ret 33 | } 34 | 35 | func discover(items []interface{}) *suite { 36 | name, items := parseName(items) 37 | test, items := parseGoTest(items) 38 | failure, items := parseFailureMode(items) 39 | action, items := parseAction(items) 40 | specifier, items := parseSpecifier(items) 41 | 42 | if len(items) != 0 { 43 | conveyPanic(parseError) 44 | } 45 | 46 | return newSuite(name, failure, action, test, specifier) 47 | } 48 | func item(items []interface{}) interface{} { 49 | if len(items) == 0 { 50 | conveyPanic(parseError) 51 | } 52 | return items[0] 53 | } 54 | func parseName(items []interface{}) (string, []interface{}) { 55 | if name, parsed := item(items).(string); parsed { 56 | return name, items[1:] 57 | } 58 | conveyPanic(parseError) 59 | panic("never get here") 60 | } 61 | func parseGoTest(items []interface{}) (t, []interface{}) { 62 | if test, parsed := item(items).(t); parsed { 63 | return test, items[1:] 64 | } 65 | return nil, items 66 | } 67 | func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { 68 | if mode, parsed := item(items).(FailureMode); parsed { 69 | return mode, items[1:] 70 | } 71 | return FailureInherits, items 72 | } 73 | func parseAction(items []interface{}) (func(C), []interface{}) { 74 | switch x := item(items).(type) { 75 | case nil: 76 | return nil, items[1:] 77 | case func(C): 78 | return x, items[1:] 79 | case func(): 80 | return func(C) { x() }, items[1:] 81 | } 82 | conveyPanic(parseError) 83 | panic("never get here") 84 | } 85 | func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) { 86 | if len(items) == 0 { 87 | return noSpecifier, items 88 | } 89 | if spec, ok := items[0].(actionSpecifier); ok { 90 | return spec, items[1:] 91 | } 92 | conveyPanic(parseError) 93 | panic("never get here") 94 | } 95 | 96 | // This interface allows us to pass the *testing.T struct 97 | // throughout the internals of this package without ever 98 | // having to import the "testing" package. 99 | type t interface { 100 | Fail() 101 | } 102 | 103 | const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." 104 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "strings" 23 | ) 24 | 25 | // Given a list of arguments M, ElementsAre returns a matcher that matches 26 | // arrays and slices A where all of the following hold: 27 | // 28 | // * A is the same length as M. 29 | // 30 | // * For each i < len(A) where M[i] is a matcher, A[i] matches M[i]. 31 | // 32 | // * For each i < len(A) where M[i] is not a matcher, A[i] matches 33 | // Equals(M[i]). 34 | // 35 | func ElementsAre(M ...interface{}) Matcher { 36 | // Copy over matchers, or convert to Equals(x) for non-matcher x. 37 | subMatchers := make([]Matcher, len(M)) 38 | for i, x := range M { 39 | if matcher, ok := x.(Matcher); ok { 40 | subMatchers[i] = matcher 41 | continue 42 | } 43 | 44 | subMatchers[i] = Equals(x) 45 | } 46 | 47 | return &elementsAreMatcher{subMatchers} 48 | } 49 | 50 | type elementsAreMatcher struct { 51 | subMatchers []Matcher 52 | } 53 | 54 | func (m *elementsAreMatcher) Description() string { 55 | subDescs := make([]string, len(m.subMatchers)) 56 | for i, sm := range m.subMatchers { 57 | subDescs[i] = sm.Description() 58 | } 59 | 60 | return fmt.Sprintf("elements are: [%s]", strings.Join(subDescs, ", ")) 61 | } 62 | 63 | func (m *elementsAreMatcher) Matches(candidates interface{}) error { 64 | // The candidate must be a slice or an array. 65 | v := reflect.ValueOf(candidates) 66 | if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { 67 | return NewFatalError("which is not a slice or array") 68 | } 69 | 70 | // The length must be correct. 71 | if v.Len() != len(m.subMatchers) { 72 | return errors.New(fmt.Sprintf("which is of length %d", v.Len())) 73 | } 74 | 75 | // Check each element. 76 | for i, subMatcher := range m.subMatchers { 77 | c := v.Index(i) 78 | if matchErr := subMatcher.Matches(c.Interface()); matchErr != nil { 79 | // Return an errors indicating which element doesn't match. If the 80 | // matcher error was fatal, make this one fatal too. 81 | err := errors.New(fmt.Sprintf("whose element %d doesn't match", i)) 82 | if _, isFatal := matchErr.(*FatalError); isFatal { 83 | err = NewFatalError(err.Error()) 84 | } 85 | 86 | return err 87 | } 88 | } 89 | 90 | return nil 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "strings" 23 | ) 24 | 25 | // AnyOf accepts a set of values S and returns a matcher that follows the 26 | // algorithm below when considering a candidate c: 27 | // 28 | // 1. If there exists a value m in S such that m implements the Matcher 29 | // interface and m matches c, return true. 30 | // 31 | // 2. Otherwise, if there exists a value v in S such that v does not implement 32 | // the Matcher interface and the matcher Equals(v) matches c, return true. 33 | // 34 | // 3. Otherwise, if there is a value m in S such that m implements the Matcher 35 | // interface and m returns a fatal error for c, return that fatal error. 36 | // 37 | // 4. Otherwise, return false. 38 | // 39 | // This is akin to a logical OR operation for matchers, with non-matchers x 40 | // being treated as Equals(x). 41 | func AnyOf(vals ...interface{}) Matcher { 42 | // Get ahold of a type variable for the Matcher interface. 43 | var dummy *Matcher 44 | matcherType := reflect.TypeOf(dummy).Elem() 45 | 46 | // Create a matcher for each value, or use the value itself if it's already a 47 | // matcher. 48 | wrapped := make([]Matcher, len(vals)) 49 | for i, v := range vals { 50 | t := reflect.TypeOf(v) 51 | if t != nil && t.Implements(matcherType) { 52 | wrapped[i] = v.(Matcher) 53 | } else { 54 | wrapped[i] = Equals(v) 55 | } 56 | } 57 | 58 | return &anyOfMatcher{wrapped} 59 | } 60 | 61 | type anyOfMatcher struct { 62 | wrapped []Matcher 63 | } 64 | 65 | func (m *anyOfMatcher) Description() string { 66 | wrappedDescs := make([]string, len(m.wrapped)) 67 | for i, matcher := range m.wrapped { 68 | wrappedDescs[i] = matcher.Description() 69 | } 70 | 71 | return fmt.Sprintf("or(%s)", strings.Join(wrappedDescs, ", ")) 72 | } 73 | 74 | func (m *anyOfMatcher) Matches(c interface{}) (err error) { 75 | err = errors.New("") 76 | 77 | // Try each matcher in turn. 78 | for _, matcher := range m.wrapped { 79 | wrappedErr := matcher.Matches(c) 80 | 81 | // Return immediately if there's a match. 82 | if wrappedErr == nil { 83 | err = nil 84 | return 85 | } 86 | 87 | // Note the fatal error, if any. 88 | if _, isFatal := wrappedErr.(*FatalError); isFatal { 89 | err = wrappedErr 90 | } 91 | } 92 | 93 | return 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/negroni/response_writer.go: -------------------------------------------------------------------------------- 1 | package negroni 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "net" 7 | "net/http" 8 | ) 9 | 10 | // ResponseWriter is a wrapper around http.ResponseWriter that provides extra information about 11 | // the response. It is recommended that middleware handlers use this construct to wrap a responsewriter 12 | // if the functionality calls for it. 13 | type ResponseWriter interface { 14 | http.ResponseWriter 15 | http.Flusher 16 | // Status returns the status code of the response or 0 if the response has not been written. 17 | Status() int 18 | // Written returns whether or not the ResponseWriter has been written. 19 | Written() bool 20 | // Size returns the size of the response body. 21 | Size() int 22 | // Before allows for a function to be called before the ResponseWriter has been written to. This is 23 | // useful for setting headers or any other operations that must happen before a response has been written. 24 | Before(func(ResponseWriter)) 25 | } 26 | 27 | type beforeFunc func(ResponseWriter) 28 | 29 | // NewResponseWriter creates a ResponseWriter that wraps an http.ResponseWriter 30 | func NewResponseWriter(rw http.ResponseWriter) ResponseWriter { 31 | return &responseWriter{ 32 | ResponseWriter: rw, 33 | status: http.StatusOK, 34 | size: 0, 35 | beforeFuncs: nil} 36 | } 37 | 38 | type responseWriter struct { 39 | http.ResponseWriter 40 | status int 41 | size int 42 | beforeFuncs []beforeFunc 43 | } 44 | 45 | func (rw *responseWriter) WriteHeader(s int) { 46 | rw.status = s 47 | rw.callBefore() 48 | rw.ResponseWriter.WriteHeader(s) 49 | } 50 | 51 | func (rw *responseWriter) Write(b []byte) (int, error) { 52 | if !rw.Written() { 53 | // The status will be StatusOK if WriteHeader has not been called yet 54 | rw.WriteHeader(http.StatusOK) 55 | } 56 | size, err := rw.ResponseWriter.Write(b) 57 | rw.size += size 58 | return size, err 59 | } 60 | 61 | func (rw *responseWriter) Status() int { 62 | return rw.status 63 | } 64 | 65 | func (rw *responseWriter) Size() int { 66 | return rw.size 67 | } 68 | 69 | func (rw *responseWriter) Written() bool { 70 | return rw.status != 0 71 | } 72 | 73 | func (rw *responseWriter) Before(before func(ResponseWriter)) { 74 | rw.beforeFuncs = append(rw.beforeFuncs, before) 75 | } 76 | 77 | func (rw *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { 78 | hijacker, ok := rw.ResponseWriter.(http.Hijacker) 79 | if !ok { 80 | return nil, nil, fmt.Errorf("the ResponseWriter doesn't support the Hijacker interface") 81 | } 82 | return hijacker.Hijack() 83 | } 84 | 85 | func (rw *responseWriter) CloseNotify() <-chan bool { 86 | return rw.ResponseWriter.(http.CloseNotifier).CloseNotify() 87 | } 88 | 89 | func (rw *responseWriter) callBefore() { 90 | for i := len(rw.beforeFuncs) - 1; i >= 0; i-- { 91 | rw.beforeFuncs[i](rw) 92 | } 93 | } 94 | 95 | func (rw *responseWriter) Flush() { 96 | flusher, ok := rw.ResponseWriter.(http.Flusher) 97 | if ok { 98 | flusher.Flush() 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package context 8 | 9 | import ( 10 | "context" // standard library's context, as of Go 1.7 11 | "time" 12 | ) 13 | 14 | var ( 15 | todo = context.TODO() 16 | background = context.Background() 17 | ) 18 | 19 | // Canceled is the error returned by Context.Err when the context is canceled. 20 | var Canceled = context.Canceled 21 | 22 | // DeadlineExceeded is the error returned by Context.Err when the context's 23 | // deadline passes. 24 | var DeadlineExceeded = context.DeadlineExceeded 25 | 26 | // WithCancel returns a copy of parent with a new Done channel. The returned 27 | // context's Done channel is closed when the returned cancel function is called 28 | // or when the parent context's Done channel is closed, whichever happens first. 29 | // 30 | // Canceling this context releases resources associated with it, so code should 31 | // call cancel as soon as the operations running in this Context complete. 32 | func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { 33 | ctx, f := context.WithCancel(parent) 34 | return ctx, CancelFunc(f) 35 | } 36 | 37 | // WithDeadline returns a copy of the parent context with the deadline adjusted 38 | // to be no later than d. If the parent's deadline is already earlier than d, 39 | // WithDeadline(parent, d) is semantically equivalent to parent. The returned 40 | // context's Done channel is closed when the deadline expires, when the returned 41 | // cancel function is called, or when the parent context's Done channel is 42 | // closed, whichever happens first. 43 | // 44 | // Canceling this context releases resources associated with it, so code should 45 | // call cancel as soon as the operations running in this Context complete. 46 | func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { 47 | ctx, f := context.WithDeadline(parent, deadline) 48 | return ctx, CancelFunc(f) 49 | } 50 | 51 | // WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). 52 | // 53 | // Canceling this context releases resources associated with it, so code should 54 | // call cancel as soon as the operations running in this Context complete: 55 | // 56 | // func slowOperationWithTimeout(ctx context.Context) (Result, error) { 57 | // ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) 58 | // defer cancel() // releases resources if slowOperation completes before timeout elapses 59 | // return slowOperation(ctx) 60 | // } 61 | func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { 62 | return WithDeadline(parent, time.Now().Add(timeout)) 63 | } 64 | 65 | // WithValue returns a copy of parent in which the value associated with key is 66 | // val. 67 | // 68 | // Use context Values only for request-scoped data that transits processes and 69 | // APIs, not for passing optional parameters to functions. 70 | func WithValue(parent Context, key interface{}, val interface{}) Context { 71 | return context.WithValue(parent, key, val) 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/panic.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "fmt" 4 | 5 | // ShouldPanic receives a void, niladic function and expects to recover a panic. 6 | func ShouldPanic(actual interface{}, expected ...interface{}) (message string) { 7 | if fail := need(0, expected); fail != success { 8 | return fail 9 | } 10 | 11 | action, _ := actual.(func()) 12 | 13 | if action == nil { 14 | message = shouldUseVoidNiladicFunction 15 | return 16 | } 17 | 18 | defer func() { 19 | recovered := recover() 20 | if recovered == nil { 21 | message = shouldHavePanicked 22 | } else { 23 | message = success 24 | } 25 | }() 26 | action() 27 | 28 | return 29 | } 30 | 31 | // ShouldNotPanic receives a void, niladic function and expects to execute the function without any panic. 32 | func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) { 33 | if fail := need(0, expected); fail != success { 34 | return fail 35 | } 36 | 37 | action, _ := actual.(func()) 38 | 39 | if action == nil { 40 | message = shouldUseVoidNiladicFunction 41 | return 42 | } 43 | 44 | defer func() { 45 | recovered := recover() 46 | if recovered != nil { 47 | message = fmt.Sprintf(shouldNotHavePanicked, recovered) 48 | } else { 49 | message = success 50 | } 51 | }() 52 | action() 53 | 54 | return 55 | } 56 | 57 | // ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content. 58 | func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) { 59 | if fail := need(1, expected); fail != success { 60 | return fail 61 | } 62 | 63 | action, _ := actual.(func()) 64 | 65 | if action == nil { 66 | message = shouldUseVoidNiladicFunction 67 | return 68 | } 69 | 70 | defer func() { 71 | recovered := recover() 72 | if recovered == nil { 73 | message = shouldHavePanicked 74 | } else { 75 | if equal := ShouldEqual(recovered, expected[0]); equal != success { 76 | message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered)) 77 | } else { 78 | message = success 79 | } 80 | } 81 | }() 82 | action() 83 | 84 | return 85 | } 86 | 87 | // ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument. 88 | func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) { 89 | if fail := need(1, expected); fail != success { 90 | return fail 91 | } 92 | 93 | action, _ := actual.(func()) 94 | 95 | if action == nil { 96 | message = shouldUseVoidNiladicFunction 97 | return 98 | } 99 | 100 | defer func() { 101 | recovered := recover() 102 | if recovered == nil { 103 | message = success 104 | } else { 105 | if equal := ShouldEqual(recovered, expected[0]); equal == success { 106 | message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) 107 | } else { 108 | message = success 109 | } 110 | } 111 | }() 112 | action() 113 | 114 | return 115 | } 116 | -------------------------------------------------------------------------------- /couriers/testhtml/kg_complete.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | KG로지스 배송조회 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 29 |
30 |

01 주문정보

31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
주문정보
운송장번호1490-2212-4650
보내시는분웨일런샵 님(서울 중구 명동2가)
받으시는분김예준 님(서울 강남구 청담동)
상품명>.수량1
62 |

02 상품이동현황

63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 |
상품이동현황 리스트
일자시간지사/대리점 연락처이동상태
2016.06.0108:43중구방산 / 02-2299-6969집하
2016.06.0123:05이천터미널 / 05053500106간선입고
2016.06.0123:05이천터미널 / 05053500106간선출고
2016.06.0207:42강동 / 02-3013-1102간선입고
2016.06.0207:58강남압구정 / 010-3930-9419배송출발
2016.06.0219:16강남압구정 / 010-3930-9419배송완료
122 |
123 | 창닫기 124 |
125 |
126 |
127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/assertions.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import "github.com/smartystreets/assertions" 4 | 5 | var ( 6 | ShouldEqual = assertions.ShouldEqual 7 | ShouldNotEqual = assertions.ShouldNotEqual 8 | ShouldAlmostEqual = assertions.ShouldAlmostEqual 9 | ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual 10 | ShouldResemble = assertions.ShouldResemble 11 | ShouldNotResemble = assertions.ShouldNotResemble 12 | ShouldPointTo = assertions.ShouldPointTo 13 | ShouldNotPointTo = assertions.ShouldNotPointTo 14 | ShouldBeNil = assertions.ShouldBeNil 15 | ShouldNotBeNil = assertions.ShouldNotBeNil 16 | ShouldBeTrue = assertions.ShouldBeTrue 17 | ShouldBeFalse = assertions.ShouldBeFalse 18 | ShouldBeZeroValue = assertions.ShouldBeZeroValue 19 | 20 | ShouldBeGreaterThan = assertions.ShouldBeGreaterThan 21 | ShouldBeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo 22 | ShouldBeLessThan = assertions.ShouldBeLessThan 23 | ShouldBeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo 24 | ShouldBeBetween = assertions.ShouldBeBetween 25 | ShouldNotBeBetween = assertions.ShouldNotBeBetween 26 | ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual 27 | ShouldNotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual 28 | 29 | ShouldContain = assertions.ShouldContain 30 | ShouldNotContain = assertions.ShouldNotContain 31 | ShouldContainKey = assertions.ShouldContainKey 32 | ShouldNotContainKey = assertions.ShouldNotContainKey 33 | ShouldBeIn = assertions.ShouldBeIn 34 | ShouldNotBeIn = assertions.ShouldNotBeIn 35 | ShouldBeEmpty = assertions.ShouldBeEmpty 36 | ShouldNotBeEmpty = assertions.ShouldNotBeEmpty 37 | ShouldHaveLength = assertions.ShouldHaveLength 38 | 39 | ShouldStartWith = assertions.ShouldStartWith 40 | ShouldNotStartWith = assertions.ShouldNotStartWith 41 | ShouldEndWith = assertions.ShouldEndWith 42 | ShouldNotEndWith = assertions.ShouldNotEndWith 43 | ShouldBeBlank = assertions.ShouldBeBlank 44 | ShouldNotBeBlank = assertions.ShouldNotBeBlank 45 | ShouldContainSubstring = assertions.ShouldContainSubstring 46 | ShouldNotContainSubstring = assertions.ShouldNotContainSubstring 47 | 48 | ShouldPanic = assertions.ShouldPanic 49 | ShouldNotPanic = assertions.ShouldNotPanic 50 | ShouldPanicWith = assertions.ShouldPanicWith 51 | ShouldNotPanicWith = assertions.ShouldNotPanicWith 52 | 53 | ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs 54 | ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs 55 | ShouldImplement = assertions.ShouldImplement 56 | ShouldNotImplement = assertions.ShouldNotImplement 57 | 58 | ShouldHappenBefore = assertions.ShouldHappenBefore 59 | ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore 60 | ShouldHappenAfter = assertions.ShouldHappenAfter 61 | ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter 62 | ShouldHappenBetween = assertions.ShouldHappenBetween 63 | ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween 64 | ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween 65 | ShouldHappenWithin = assertions.ShouldHappenWithin 66 | ShouldNotHappenWithin = assertions.ShouldNotHappenWithin 67 | ShouldBeChronological = assertions.ShouldBeChronological 68 | ) 69 | -------------------------------------------------------------------------------- /vendor/github.com/rs/xhandler/chain.go: -------------------------------------------------------------------------------- 1 | package xhandler 2 | 3 | import ( 4 | "net/http" 5 | 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // Chain is an helper to chain middleware handlers together for an easier 10 | // management. 11 | type Chain []func(next HandlerC) HandlerC 12 | 13 | // UseC appends a context-aware handler to the middleware chain. 14 | func (c *Chain) UseC(f func(next HandlerC) HandlerC) { 15 | *c = append(*c, f) 16 | } 17 | 18 | // Use appends a standard http.Handler to the middleware chain without 19 | // lossing track of the context when inserted between two context aware handlers. 20 | // 21 | // Caveat: the f function will be called on each request so you are better to put 22 | // any initialization sequence outside of this function. 23 | func (c *Chain) Use(f func(next http.Handler) http.Handler) { 24 | xf := func(next HandlerC) HandlerC { 25 | return HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { 26 | n := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 27 | next.ServeHTTPC(ctx, w, r) 28 | }) 29 | f(n).ServeHTTP(w, r) 30 | }) 31 | } 32 | *c = append(*c, xf) 33 | } 34 | 35 | // Handler wraps the provided final handler with all the middleware appended to 36 | // the chain and return a new standard http.Handler instance. 37 | // The context.Background() context is injected automatically. 38 | func (c Chain) Handler(xh HandlerC) http.Handler { 39 | ctx := context.Background() 40 | return c.HandlerCtx(ctx, xh) 41 | } 42 | 43 | // HandlerFC is an helper to provide a function (HandlerFuncC) to Handler(). 44 | // 45 | // HandlerFC is equivalent to: 46 | // c.Handler(xhandler.HandlerFuncC(xhc)) 47 | func (c Chain) HandlerFC(xhf HandlerFuncC) http.Handler { 48 | ctx := context.Background() 49 | return c.HandlerCtx(ctx, HandlerFuncC(xhf)) 50 | } 51 | 52 | // HandlerH is an helper to provide a standard http handler (http.HandlerFunc) 53 | // to Handler(). Your final handler won't have access the context though. 54 | func (c Chain) HandlerH(h http.Handler) http.Handler { 55 | ctx := context.Background() 56 | return c.HandlerCtx(ctx, HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { 57 | h.ServeHTTP(w, r) 58 | })) 59 | } 60 | 61 | // HandlerF is an helper to provide a standard http handler function 62 | // (http.HandlerFunc) to Handler(). Your final handler won't have access 63 | // the context though. 64 | func (c Chain) HandlerF(hf http.HandlerFunc) http.Handler { 65 | ctx := context.Background() 66 | return c.HandlerCtx(ctx, HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { 67 | hf(w, r) 68 | })) 69 | } 70 | 71 | // HandlerCtx wraps the provided final handler with all the middleware appended to 72 | // the chain and return a new standard http.Handler instance. 73 | func (c Chain) HandlerCtx(ctx context.Context, xh HandlerC) http.Handler { 74 | return New(ctx, c.HandlerC(xh)) 75 | } 76 | 77 | // HandlerC wraps the provided final handler with all the middleware appended to 78 | // the chain and returns a HandlerC instance. 79 | func (c Chain) HandlerC(xh HandlerC) HandlerC { 80 | for i := len(c) - 1; i >= 0; i-- { 81 | xh = c[i](xh) 82 | } 83 | return xh 84 | } 85 | 86 | // HandlerCF wraps the provided final handler func with all the middleware appended to 87 | // the chain and returns a HandlerC instance. 88 | // 89 | // HandlerCF is equivalent to: 90 | // c.HandlerC(xhandler.HandlerFuncC(xhc)) 91 | func (c Chain) HandlerCF(xhc HandlerFuncC) HandlerC { 92 | return c.HandlerC(HandlerFuncC(xhc)) 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/array.go: -------------------------------------------------------------------------------- 1 | package goquery 2 | 3 | import ( 4 | "golang.org/x/net/html" 5 | ) 6 | 7 | // First reduces the set of matched elements to the first in the set. 8 | // It returns a new Selection object, and an empty Selection object if the 9 | // the selection is empty. 10 | func (s *Selection) First() *Selection { 11 | return s.Eq(0) 12 | } 13 | 14 | // Last reduces the set of matched elements to the last in the set. 15 | // It returns a new Selection object, and an empty Selection object if 16 | // the selection is empty. 17 | func (s *Selection) Last() *Selection { 18 | return s.Eq(-1) 19 | } 20 | 21 | // Eq reduces the set of matched elements to the one at the specified index. 22 | // If a negative index is given, it counts backwards starting at the end of the 23 | // set. It returns a new Selection object, and an empty Selection object if the 24 | // index is invalid. 25 | func (s *Selection) Eq(index int) *Selection { 26 | if index < 0 { 27 | index += len(s.Nodes) 28 | } 29 | 30 | if index >= len(s.Nodes) || index < 0 { 31 | return newEmptySelection(s.document) 32 | } 33 | 34 | return s.Slice(index, index+1) 35 | } 36 | 37 | // Slice reduces the set of matched elements to a subset specified by a range 38 | // of indices. 39 | func (s *Selection) Slice(start, end int) *Selection { 40 | if start < 0 { 41 | start += len(s.Nodes) 42 | } 43 | if end < 0 { 44 | end += len(s.Nodes) 45 | } 46 | return pushStack(s, s.Nodes[start:end]) 47 | } 48 | 49 | // Get retrieves the underlying node at the specified index. 50 | // Get without parameter is not implemented, since the node array is available 51 | // on the Selection object. 52 | func (s *Selection) Get(index int) *html.Node { 53 | if index < 0 { 54 | index += len(s.Nodes) // Negative index gets from the end 55 | } 56 | return s.Nodes[index] 57 | } 58 | 59 | // Index returns the position of the first element within the Selection object 60 | // relative to its sibling elements. 61 | func (s *Selection) Index() int { 62 | if len(s.Nodes) > 0 { 63 | return newSingleSelection(s.Nodes[0], s.document).PrevAll().Length() 64 | } 65 | return -1 66 | } 67 | 68 | // IndexSelector returns the position of the first element within the 69 | // Selection object relative to the elements matched by the selector, or -1 if 70 | // not found. 71 | func (s *Selection) IndexSelector(selector string) int { 72 | if len(s.Nodes) > 0 { 73 | sel := s.document.Find(selector) 74 | return indexInSlice(sel.Nodes, s.Nodes[0]) 75 | } 76 | return -1 77 | } 78 | 79 | // IndexMatcher returns the position of the first element within the 80 | // Selection object relative to the elements matched by the matcher, or -1 if 81 | // not found. 82 | func (s *Selection) IndexMatcher(m Matcher) int { 83 | if len(s.Nodes) > 0 { 84 | sel := s.document.FindMatcher(m) 85 | return indexInSlice(sel.Nodes, s.Nodes[0]) 86 | } 87 | return -1 88 | } 89 | 90 | // IndexOfNode returns the position of the specified node within the Selection 91 | // object, or -1 if not found. 92 | func (s *Selection) IndexOfNode(node *html.Node) int { 93 | return indexInSlice(s.Nodes, node) 94 | } 95 | 96 | // IndexOfSelection returns the position of the first node in the specified 97 | // Selection object within this Selection object, or -1 if not found. 98 | func (s *Selection) IndexOfSelection(sel *Selection) int { 99 | if sel != nil && len(sel.Nodes) > 0 { 100 | return indexInSlice(s.Nodes, sel.Nodes[0]) 101 | } 102 | return -1 103 | } 104 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/encoding/internal/identifier/identifier.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:generate go run gen.go 6 | 7 | // Package identifier defines the contract between implementations of Encoding 8 | // and Index by defining identifiers that uniquely identify standardized coded 9 | // character sets (CCS) and character encoding schemes (CES), which we will 10 | // together refer to as encodings, for which Encoding implementations provide 11 | // converters to and from UTF-8. This package is typically only of concern to 12 | // implementers of Indexes and Encodings. 13 | // 14 | // One part of the identifier is the MIB code, which is defined by IANA and 15 | // uniquely identifies a CCS or CES. Each code is associated with data that 16 | // references authorities, official documentation as well as aliases and MIME 17 | // names. 18 | // 19 | // Not all CESs are covered by the IANA registry. The "other" string that is 20 | // returned by ID can be used to identify other character sets or versions of 21 | // existing ones. 22 | // 23 | // It is recommended that each package that provides a set of Encodings provide 24 | // the All and Common variables to reference all supported encodings and 25 | // commonly used subset. This allows Index implementations to include all 26 | // available encodings without explicitly referencing or knowing about them. 27 | package identifier 28 | 29 | // Note: this package is internal, but could be made public if there is a need 30 | // for writing third-party Indexes and Encodings. 31 | 32 | // References: 33 | // - http://source.icu-project.org/repos/icu/icu/trunk/source/data/mappings/convrtrs.txt 34 | // - http://www.iana.org/assignments/character-sets/character-sets.xhtml 35 | // - http://www.iana.org/assignments/ianacharset-mib/ianacharset-mib 36 | // - http://www.ietf.org/rfc/rfc2978.txt 37 | // - http://www.unicode.org/reports/tr22/ 38 | // - http://www.w3.org/TR/encoding/ 39 | // - http://www.w3.org/TR/encoding/indexes/encodings.json 40 | // - https://encoding.spec.whatwg.org/ 41 | // - https://tools.ietf.org/html/rfc6657#section-5 42 | 43 | // Interface can be implemented by Encodings to define the CCS or CES for which 44 | // it implements conversions. 45 | type Interface interface { 46 | // ID returns an encoding identifier. Exactly one of the mib and other 47 | // values should be non-zero. 48 | // 49 | // In the usual case it is only necessary to indicate the MIB code. The 50 | // other string can be used to specify encodings for which there is no MIB, 51 | // such as "x-mac-dingbat". 52 | // 53 | // The other string may only contain the characters a-z, A-Z, 0-9, - and _. 54 | ID() (mib MIB, other string) 55 | 56 | // NOTE: the restrictions on the encoding are to allow extending the syntax 57 | // with additional information such as versions, vendors and other variants. 58 | } 59 | 60 | // A MIB identifies an encoding. It is derived from the IANA MIB codes and adds 61 | // some identifiers for some encodings that are not covered by the IANA 62 | // standard. 63 | // 64 | // See http://www.iana.org/assignments/ianacharset-mib. 65 | type MIB uint16 66 | 67 | // These additional MIB types are not defined in IANA. They are added because 68 | // they are common and defined within the text repo. 69 | const ( 70 | // Unofficial marks the start of encodings not registered by IANA. 71 | Unofficial MIB = 10000 + iota 72 | 73 | // Replacement is the WhatWG replacement encoding. 74 | Replacement 75 | 76 | // XUserDefined is the code for x-user-defined. 77 | XUserDefined 78 | 79 | // MacintoshCyrillic is the code for x-mac-cyrillic. 80 | MacintoshCyrillic 81 | ) 82 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/type.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | // ShouldHaveSameTypeAs receives exactly two parameters and compares their underlying types for equality. 9 | func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string { 10 | if fail := need(1, expected); fail != success { 11 | return fail 12 | } 13 | 14 | first := reflect.TypeOf(actual) 15 | second := reflect.TypeOf(expected[0]) 16 | 17 | if equal := ShouldEqual(first, second); equal != success { 18 | return serializer.serialize(second, first, fmt.Sprintf(shouldHaveBeenA, actual, second, first)) 19 | } 20 | return success 21 | } 22 | 23 | // ShouldNotHaveSameTypeAs receives exactly two parameters and compares their underlying types for inequality. 24 | func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string { 25 | if fail := need(1, expected); fail != success { 26 | return fail 27 | } 28 | 29 | first := reflect.TypeOf(actual) 30 | second := reflect.TypeOf(expected[0]) 31 | 32 | if equal := ShouldEqual(first, second); equal == success { 33 | return fmt.Sprintf(shouldNotHaveBeenA, actual, second) 34 | } 35 | return success 36 | } 37 | 38 | // ShouldImplement receives exactly two parameters and ensures 39 | // that the first implements the interface type of the second. 40 | func ShouldImplement(actual interface{}, expectedList ...interface{}) string { 41 | if fail := need(1, expectedList); fail != success { 42 | return fail 43 | } 44 | 45 | expected := expectedList[0] 46 | if fail := ShouldBeNil(expected); fail != success { 47 | return shouldCompareWithInterfacePointer 48 | } 49 | 50 | if fail := ShouldNotBeNil(actual); fail != success { 51 | return shouldNotBeNilActual 52 | } 53 | 54 | var actualType reflect.Type 55 | if reflect.TypeOf(actual).Kind() != reflect.Ptr { 56 | actualType = reflect.PtrTo(reflect.TypeOf(actual)) 57 | } else { 58 | actualType = reflect.TypeOf(actual) 59 | } 60 | 61 | expectedType := reflect.TypeOf(expected) 62 | if fail := ShouldNotBeNil(expectedType); fail != success { 63 | return shouldCompareWithInterfacePointer 64 | } 65 | 66 | expectedInterface := expectedType.Elem() 67 | 68 | if actualType == nil { 69 | return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actual) 70 | } 71 | 72 | if !actualType.Implements(expectedInterface) { 73 | return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actualType) 74 | } 75 | return success 76 | } 77 | 78 | // ShouldNotImplement receives exactly two parameters and ensures 79 | // that the first does NOT implement the interface type of the second. 80 | func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string { 81 | if fail := need(1, expectedList); fail != success { 82 | return fail 83 | } 84 | 85 | expected := expectedList[0] 86 | if fail := ShouldBeNil(expected); fail != success { 87 | return shouldCompareWithInterfacePointer 88 | } 89 | 90 | if fail := ShouldNotBeNil(actual); fail != success { 91 | return shouldNotBeNilActual 92 | } 93 | 94 | var actualType reflect.Type 95 | if reflect.TypeOf(actual).Kind() != reflect.Ptr { 96 | actualType = reflect.PtrTo(reflect.TypeOf(actual)) 97 | } else { 98 | actualType = reflect.TypeOf(actual) 99 | } 100 | 101 | expectedType := reflect.TypeOf(expected) 102 | if fail := ShouldNotBeNil(expectedType); fail != success { 103 | return shouldCompareWithInterfacePointer 104 | } 105 | 106 | expectedInterface := expectedType.Elem() 107 | 108 | if actualType.Implements(expectedInterface) { 109 | return fmt.Sprintf(shouldNotHaveImplemented, actualType, expectedInterface) 110 | } 111 | return success 112 | } 113 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/html/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package html implements an HTML5-compliant tokenizer and parser. 7 | 8 | Tokenization is done by creating a Tokenizer for an io.Reader r. It is the 9 | caller's responsibility to ensure that r provides UTF-8 encoded HTML. 10 | 11 | z := html.NewTokenizer(r) 12 | 13 | Given a Tokenizer z, the HTML is tokenized by repeatedly calling z.Next(), 14 | which parses the next token and returns its type, or an error: 15 | 16 | for { 17 | tt := z.Next() 18 | if tt == html.ErrorToken { 19 | // ... 20 | return ... 21 | } 22 | // Process the current token. 23 | } 24 | 25 | There are two APIs for retrieving the current token. The high-level API is to 26 | call Token; the low-level API is to call Text or TagName / TagAttr. Both APIs 27 | allow optionally calling Raw after Next but before Token, Text, TagName, or 28 | TagAttr. In EBNF notation, the valid call sequence per token is: 29 | 30 | Next {Raw} [ Token | Text | TagName {TagAttr} ] 31 | 32 | Token returns an independent data structure that completely describes a token. 33 | Entities (such as "<") are unescaped, tag names and attribute keys are 34 | lower-cased, and attributes are collected into a []Attribute. For example: 35 | 36 | for { 37 | if z.Next() == html.ErrorToken { 38 | // Returning io.EOF indicates success. 39 | return z.Err() 40 | } 41 | emitToken(z.Token()) 42 | } 43 | 44 | The low-level API performs fewer allocations and copies, but the contents of 45 | the []byte values returned by Text, TagName and TagAttr may change on the next 46 | call to Next. For example, to extract an HTML page's anchor text: 47 | 48 | depth := 0 49 | for { 50 | tt := z.Next() 51 | switch tt { 52 | case ErrorToken: 53 | return z.Err() 54 | case TextToken: 55 | if depth > 0 { 56 | // emitBytes should copy the []byte it receives, 57 | // if it doesn't process it immediately. 58 | emitBytes(z.Text()) 59 | } 60 | case StartTagToken, EndTagToken: 61 | tn, _ := z.TagName() 62 | if len(tn) == 1 && tn[0] == 'a' { 63 | if tt == StartTagToken { 64 | depth++ 65 | } else { 66 | depth-- 67 | } 68 | } 69 | } 70 | } 71 | 72 | Parsing is done by calling Parse with an io.Reader, which returns the root of 73 | the parse tree (the document element) as a *Node. It is the caller's 74 | responsibility to ensure that the Reader provides UTF-8 encoded HTML. For 75 | example, to process each anchor node in depth-first order: 76 | 77 | doc, err := html.Parse(r) 78 | if err != nil { 79 | // ... 80 | } 81 | var f func(*html.Node) 82 | f = func(n *html.Node) { 83 | if n.Type == html.ElementNode && n.Data == "a" { 84 | // Do something with n... 85 | } 86 | for c := n.FirstChild; c != nil; c = c.NextSibling { 87 | f(c) 88 | } 89 | } 90 | f(doc) 91 | 92 | The relevant specifications include: 93 | https://html.spec.whatwg.org/multipage/syntax.html and 94 | https://html.spec.whatwg.org/multipage/syntax.html#tokenization 95 | */ 96 | package html 97 | 98 | // The tokenization algorithm implemented by this package is not a line-by-line 99 | // transliteration of the relatively verbose state-machine in the WHATWG 100 | // specification. A more direct approach is used instead, where the program 101 | // counter implies the state, such as whether it is tokenizing a tag or a text 102 | // node. Specification compliance is verified by checking expected and actual 103 | // outputs over a test suite rather than aiming for algorithmic fidelity. 104 | 105 | // TODO(nigeltao): Does a DOM API belong in this package or a separate one? 106 | // TODO(nigeltao): How does parsing interact with a JavaScript engine? 107 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/README.md: -------------------------------------------------------------------------------- 1 | gls 2 | === 3 | 4 | Goroutine local storage 5 | 6 | ### IMPORTANT NOTE ### 7 | 8 | It is my duty to point you to https://blog.golang.org/context, which is how 9 | Google solves all of the problems you'd perhaps consider using this package 10 | for at scale. 11 | 12 | One downside to Google's approach is that *all* of your functions must have 13 | a new first argument, but after clearing that hurdle everything else is much 14 | better. 15 | 16 | If you aren't interested in this warning, read on. 17 | 18 | ### Huhwaht? Why? ### 19 | 20 | Every so often, a thread shows up on the 21 | [golang-nuts](https://groups.google.com/d/forum/golang-nuts) asking for some 22 | form of goroutine-local-storage, or some kind of goroutine id, or some kind of 23 | context. There are a few valid use cases for goroutine-local-storage, one of 24 | the most prominent being log line context. One poster was interested in being 25 | able to log an HTTP request context id in every log line in the same goroutine 26 | as the incoming HTTP request, without having to change every library and 27 | function call he was interested in logging. 28 | 29 | This would be pretty useful. Provided that you could get some kind of 30 | goroutine-local-storage, you could call 31 | [log.SetOutput](http://golang.org/pkg/log/#SetOutput) with your own logging 32 | writer that checks goroutine-local-storage for some context information and 33 | adds that context to your log lines. 34 | 35 | But alas, Andrew Gerrand's typically diplomatic answer to the question of 36 | goroutine-local variables was: 37 | 38 | > We wouldn't even be having this discussion if thread local storage wasn't 39 | > useful. But every feature comes at a cost, and in my opinion the cost of 40 | > threadlocals far outweighs their benefits. They're just not a good fit for 41 | > Go. 42 | 43 | So, yeah, that makes sense. That's a pretty good reason for why the language 44 | won't support a specific and (relatively) unuseful feature that requires some 45 | runtime changes, just for the sake of a little bit of log improvement. 46 | 47 | But does Go require runtime changes? 48 | 49 | ### How it works ### 50 | 51 | Go has pretty fantastic introspective and reflective features, but one thing Go 52 | doesn't give you is any kind of access to the stack pointer, or frame pointer, 53 | or goroutine id, or anything contextual about your current stack. It gives you 54 | access to your list of callers, but only along with program counters, which are 55 | fixed at compile time. 56 | 57 | But it does give you the stack. 58 | 59 | So, we define 16 special functions and embed base-16 tags into the stack using 60 | the call order of those 16 functions. Then, we can read our tags back out of 61 | the stack looking at the callers list. 62 | 63 | We then use these tags as an index into a traditional map for implementing 64 | this library. 65 | 66 | ### What are people saying? ### 67 | 68 | "Wow, that's horrifying." 69 | 70 | "This is the most terrible thing I have seen in a very long time." 71 | 72 | "Where is it getting a context from? Is this serializing all the requests? 73 | What the heck is the client being bound to? What are these tags? Why does he 74 | need callers? Oh god no. No no no." 75 | 76 | ### Docs ### 77 | 78 | Please see the docs at http://godoc.org/github.com/jtolds/gls 79 | 80 | ### Related ### 81 | 82 | If you're okay relying on the string format of the current runtime stacktrace 83 | including a unique goroutine id (not guaranteed by the spec or anything, but 84 | very unlikely to change within a Go release), you might be able to squeeze 85 | out a bit more performance by using this similar library, inspired by some 86 | code Brad Fitzpatrick wrote for debugging his HTTP/2 library: 87 | https://github.com/tylerb/gls (in contrast, jtolds/gls doesn't require 88 | any knowledge of the string format of the runtime stacktrace, which 89 | probably adds unnecessary overhead). 90 | -------------------------------------------------------------------------------- /couriers/kg.go: -------------------------------------------------------------------------------- 1 | package couriers 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "io/ioutil" 8 | "log" 9 | "net/http" 10 | "regexp" 11 | "strings" 12 | "time" 13 | 14 | "github.com/PuerkitoBio/goquery" 15 | "github.com/purpleworks/delibird" 16 | ) 17 | 18 | type Kg struct{} 19 | 20 | func init() { 21 | RegisterCourier("KG", &Kg{}) 22 | } 23 | 24 | func (t Kg) Code() string { 25 | return "KG" 26 | } 27 | 28 | func (t Kg) Name() string { 29 | return "KG로지스" 30 | } 31 | 32 | func (t Kg) TrackingUrl() string { 33 | return "http://www.kglogis.co.kr/contents/waybill.jsp?item_no=%s" 34 | } 35 | 36 | func (t Kg) Parse(trackingNumber string) (delibird.Track, *delibird.ApiError) { 37 | track := delibird.Track{} 38 | 39 | body, err := t.getHtml(trackingNumber) 40 | 41 | if err != nil { 42 | return track, delibird.NewApiError(delibird.RequestPageError, err.Error()) 43 | } 44 | 45 | doc, err := goquery.NewDocumentFromReader(body) 46 | if err != nil { 47 | return track, delibird.NewApiError(delibird.ParseError, err.Error()) 48 | } 49 | 50 | if strings.HasPrefix(strings.TrimSpace(doc.Text()), "alert") { 51 | return track, delibird.NewApiError(delibird.NoTrackingInfo, "등록되지 않은 운송장이거나 배송준비중입니다.") 52 | } 53 | 54 | if strings.TrimSpace(doc.Find("table").Eq(1).Find("tbody tr td").Eq(0).Text()) == "물품 이동경로정보가 없습니다." { 55 | return track, delibird.NewApiError(delibird.NoTrackingInfo, "등록되지 않은 운송장이거나 배송준비중입니다.") 56 | } 57 | 58 | track = delibird.Track{ 59 | TrackingNumber: trackingNumber, 60 | CompanyCode: t.Code(), 61 | CompanyName: t.Name(), 62 | Sender: strings.TrimRight(doc.Find("table").Eq(0).Find("tbody tr").Eq(1).Find("td span").Eq(0).Text(), "님 "), 63 | Receiver: strings.TrimRight(doc.Find("table").Eq(0).Find("tbody tr").Eq(2).Find("td span").Eq(0).Text(), "님 "), 64 | Signer: "", 65 | } 66 | 67 | history := []delibird.History{} 68 | 69 | numberReg, _ := regexp.Compile("[^0-9-]") 70 | 71 | //배송정보 72 | doc.Find("table").Eq(1).Find("tbody tr").Each(func(i int, s *goquery.Selection) { 73 | dateText := strings.TrimSpace(s.Find("td").Eq(0).Text()) + " " + strings.TrimSpace(s.Find("td").Eq(1).Text()) 74 | date, err := time.Parse("2006.01.02 15:04", dateText) 75 | if err != nil { 76 | log.Print(err) 77 | } else { 78 | statusText := strings.TrimSpace(s.Find("td span").Eq(3).Text()) 79 | 80 | track.StatusCode = t.getStatus(statusText) 81 | track.StatusText = statusText 82 | 83 | area_tel := strings.Split(strings.TrimSpace(s.Find("td span").Eq(2).Text()), "/") 84 | tel := numberReg.ReplaceAllString(area_tel[1], "") 85 | if tel == "--" { 86 | tel = "" 87 | } 88 | history = append(history, 89 | delibird.History{ 90 | Date: date.Add(-time.Hour * 9).Unix(), 91 | DateText: date.Format("2006-01-02 15:04"), 92 | Area: strings.TrimSpace(area_tel[0]), 93 | Tel: tel, 94 | StatusCode: t.getStatus(statusText), 95 | StatusText: statusText, 96 | }) 97 | 98 | } 99 | }) 100 | track.History = history 101 | 102 | return track, nil 103 | } 104 | 105 | func (t Kg) getHtml(trackingNumber string) (io.Reader, error) { 106 | url := fmt.Sprintf(t.TrackingUrl(), trackingNumber) 107 | res, err := http.Get(url) 108 | if err != nil { 109 | return nil, err 110 | } 111 | defer res.Body.Close() 112 | 113 | body, err := ioutil.ReadAll(res.Body) 114 | if err != nil { 115 | return nil, err 116 | } 117 | 118 | return bytes.NewBuffer(body), nil 119 | } 120 | 121 | func (t Kg) getStatus(status_text string) delibird.TrackingStatus { 122 | switch status_text { 123 | case "집하": 124 | return delibird.PickupComplete 125 | case "간선입고": 126 | return delibird.Loading 127 | case "간선출고": 128 | return delibird.Unloading 129 | case "배송출발": 130 | return delibird.DeleveryStart 131 | case "배송완료": 132 | return delibird.DeleveryComplete 133 | case "미배달": 134 | return delibird.DoNotDelevery 135 | } 136 | 137 | return delibird.UnknownStatus 138 | } 139 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/matcher.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package oglematchers provides a set of matchers useful in a testing or 17 | // mocking framework. These matchers are inspired by and mostly compatible with 18 | // Google Test for C++ and Google JS Test. 19 | // 20 | // This package is used by github.com/smartystreets/assertions/internal/ogletest and 21 | // github.com/smartystreets/assertions/internal/oglemock, which may be more directly useful if you're not 22 | // writing your own testing package or defining your own matchers. 23 | package oglematchers 24 | 25 | // A Matcher is some predicate implicitly defining a set of values that it 26 | // matches. For example, GreaterThan(17) matches all numeric values greater 27 | // than 17, and HasSubstr("taco") matches all strings with the substring 28 | // "taco". 29 | // 30 | // Matchers are typically exposed to tests via constructor functions like 31 | // HasSubstr. In order to implement such a function you can either define your 32 | // own matcher type or use NewMatcher. 33 | type Matcher interface { 34 | // Check whether the supplied value belongs to the the set defined by the 35 | // matcher. Return a non-nil error if and only if it does not. 36 | // 37 | // The error describes why the value doesn't match. The error text is a 38 | // relative clause that is suitable for being placed after the value. For 39 | // example, a predicate that matches strings with a particular substring may, 40 | // when presented with a numerical value, return the following error text: 41 | // 42 | // "which is not a string" 43 | // 44 | // Then the failure message may look like: 45 | // 46 | // Expected: has substring "taco" 47 | // Actual: 17, which is not a string 48 | // 49 | // If the error is self-apparent based on the description of the matcher, the 50 | // error text may be empty (but the error still non-nil). For example: 51 | // 52 | // Expected: 17 53 | // Actual: 19 54 | // 55 | // If you are implementing a new matcher, see also the documentation on 56 | // FatalError. 57 | Matches(candidate interface{}) error 58 | 59 | // Description returns a string describing the property that values matching 60 | // this matcher have, as a verb phrase where the subject is the value. For 61 | // example, "is greather than 17" or "has substring "taco"". 62 | Description() string 63 | } 64 | 65 | // FatalError is an implementation of the error interface that may be returned 66 | // from matchers, indicating the error should be propagated. Returning a 67 | // *FatalError indicates that the matcher doesn't process values of the 68 | // supplied type, or otherwise doesn't know how to handle the value. 69 | // 70 | // For example, if GreaterThan(17) returned false for the value "taco" without 71 | // a fatal error, then Not(GreaterThan(17)) would return true. This is 72 | // technically correct, but is surprising and may mask failures where the wrong 73 | // sort of matcher is accidentally used. Instead, GreaterThan(17) can return a 74 | // fatal error, which will be propagated by Not(). 75 | type FatalError struct { 76 | errorText string 77 | } 78 | 79 | // NewFatalError creates a FatalError struct with the supplied error text. 80 | func NewFatalError(s string) *FatalError { 81 | return &FatalError{s} 82 | } 83 | 84 | func (e *FatalError) Error() string { 85 | return e.errorText 86 | } 87 | --------------------------------------------------------------------------------