├── .gitignore ├── vendor ├── github.com │ ├── gin-gonic │ │ └── gin │ │ │ ├── wercker.yml │ │ │ ├── logo.jpg │ │ │ ├── codecov.yml │ │ │ ├── binding │ │ │ ├── example │ │ │ │ ├── test.proto │ │ │ │ └── test.pb.go │ │ │ ├── xml.go │ │ │ ├── json.go │ │ │ ├── protobuf.go │ │ │ ├── default_validator.go │ │ │ ├── form.go │ │ │ └── binding.go │ │ │ ├── helpers_test.go │ │ │ ├── deprecated.go │ │ │ ├── render │ │ │ ├── data.go │ │ │ ├── xml.go │ │ │ ├── redirect.go │ │ │ ├── yaml.go │ │ │ ├── text.go │ │ │ ├── render.go │ │ │ ├── json.go │ │ │ └── html.go │ │ │ ├── mode_test.go │ │ │ ├── fs.go │ │ │ ├── LICENSE │ │ │ ├── recovery_test.go │ │ │ ├── mode.go │ │ │ ├── debug_test.go │ │ │ ├── debug.go │ │ │ ├── path_test.go │ │ │ ├── response_writer.go │ │ │ ├── auth.go │ │ │ ├── path.go │ │ │ ├── errors_test.go │ │ │ ├── recovery.go │ │ │ └── response_writer_test.go │ ├── mattn │ │ └── go-isatty │ │ │ ├── doc.go │ │ │ ├── isatty_others.go │ │ │ ├── isatty_others_test.go │ │ │ ├── example_test.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_solaris.go │ │ │ ├── isatty_appengine.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_windows_test.go │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── isatty_windows.go │ ├── manucorporat │ │ └── sse │ │ │ ├── writer.go │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── sse-encoder.go │ │ │ └── sse-decoder_test.go │ └── golang │ │ └── protobuf │ │ ├── LICENSE │ │ └── proto │ │ ├── Makefile │ │ ├── testdata │ │ ├── Makefile │ │ └── golden_test.go │ │ ├── size2_test.go │ │ ├── proto3_proto │ │ └── proto3.proto │ │ └── message_set_test.go ├── gopkg.in │ ├── go-playground │ │ └── validator.v8 │ │ │ ├── logo.png │ │ │ ├── LICENSE │ │ │ └── examples_test.go │ └── yaml.v2 │ │ ├── suite_test.go │ │ ├── LICENSE │ │ ├── LICENSE.libyaml │ │ ├── writerc.go │ │ ├── sorter.go │ │ └── README.md ├── golang.org │ └── x │ │ ├── sys │ │ ├── unix │ │ │ ├── endian_big.go │ │ │ ├── export_test.go │ │ │ ├── endian_little.go │ │ │ ├── constants.go │ │ │ ├── syscall_no_getwd.go │ │ │ ├── zsysnum_solaris_amd64.go │ │ │ ├── env_unset.go │ │ │ ├── syscall_linux_amd64_gc.go │ │ │ ├── flock_linux_32bit.go │ │ │ ├── syscall_freebsd_test.go │ │ │ ├── asm_solaris_amd64.s │ │ │ ├── gccgo_linux_sparc64.go │ │ │ ├── gccgo_linux_amd64.go │ │ │ ├── race0.go │ │ │ ├── mmap_unix_test.go │ │ │ ├── env_unix.go │ │ │ ├── syscall_unix_gc.go │ │ │ ├── asm_linux_arm64.s │ │ │ ├── str.go │ │ │ ├── race.go │ │ │ ├── asm_linux_s390x.s │ │ │ ├── asm_linux_ppc64x.s │ │ │ ├── asm_linux_arm.s │ │ │ ├── asm_linux_mips64x.s │ │ │ ├── asm_freebsd_arm.s │ │ │ ├── asm_netbsd_arm.s │ │ │ ├── asm_darwin_386.s │ │ │ ├── asm_freebsd_386.s │ │ │ ├── asm_netbsd_386.s │ │ │ ├── asm_openbsd_386.s │ │ │ ├── asm_darwin_amd64.s │ │ │ ├── asm_freebsd_amd64.s │ │ │ ├── asm_linux_amd64.s │ │ │ ├── asm_netbsd_amd64.s │ │ │ ├── asm_openbsd_amd64.s │ │ │ ├── asm_dragonfly_amd64.s │ │ │ ├── asm_darwin_arm.s │ │ │ ├── bluetooth_linux.go │ │ │ ├── asm_darwin_arm64.s │ │ │ ├── asm_linux_mipsx.s │ │ │ ├── flock.go │ │ │ ├── syscall_solaris_test.go │ │ │ ├── mksysnum_darwin.pl │ │ │ ├── asm_linux_386.s │ │ │ ├── syscall_solaris_amd64.go │ │ │ ├── openbsd_pledge.go │ │ │ ├── syscall_openbsd_amd64.go │ │ │ ├── syscall_netbsd_386.go │ │ │ ├── syscall_netbsd_arm.go │ │ │ ├── syscall_netbsd_amd64.go │ │ │ ├── syscall_openbsd_386.go │ │ │ ├── gccgo_c.c │ │ │ ├── sockcmsg_linux.go │ │ │ ├── mksysnum_dragonfly.pl │ │ │ ├── mksysnum_openbsd.pl │ │ │ ├── syscall_test.go │ │ │ ├── mksysnum_netbsd.pl │ │ │ ├── syscall_bsd_test.go │ │ │ ├── syscall_dragonfly_amd64.go │ │ │ ├── syscall_freebsd_amd64.go │ │ │ ├── syscall_freebsd_arm.go │ │ │ ├── syscall_freebsd_386.go │ │ │ ├── gccgo.go │ │ │ ├── mksysnum_freebsd.pl │ │ │ ├── syscall_darwin_arm.go │ │ │ ├── syscall_darwin_arm64.go │ │ │ ├── syscall_darwin_386.go │ │ │ ├── syscall_darwin_amd64.go │ │ │ ├── syscall.go │ │ │ ├── mkpost.go │ │ │ └── openbsd_test.go │ │ ├── PATENTS │ │ └── LICENSE │ │ └── net │ │ ├── context │ │ ├── withtimeout_test.go │ │ └── go17.go │ │ ├── PATENTS │ │ └── LICENSE └── vendor.json ├── refguides ├── 2016-april │ └── refguide.pdf └── 2017-april │ └── refguide.pdf ├── .travis.yml ├── static └── js │ ├── ie8-html5.js │ ├── search.js │ └── main.js ├── templates ├── search.tmpl ├── footer.tmpl ├── resources.js.tmpl ├── head.tmpl ├── index.tmpl ├── resource.tmpl └── header.tmpl ├── main.go ├── LICENSE ├── README.md ├── resource.go └── routes.go /.gitignore: -------------------------------------------------------------------------------- 1 | gin-bin 2 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/wercker.yml: -------------------------------------------------------------------------------- 1 | box: wercker/default -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /refguides/2016-april/refguide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfbrigade/sfsbook/HEAD/refguides/2016-april/refguide.pdf -------------------------------------------------------------------------------- /refguides/2017-april/refguide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfbrigade/sfsbook/HEAD/refguides/2017-april/refguide.pdf -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfbrigade/sfsbook/HEAD/vendor/github.com/gin-gonic/gin/logo.jpg -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - master 5 | 6 | install: 7 | go get github.com/codegangsta/gin 8 | 9 | script: go test 10 | -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sfbrigade/sfsbook/HEAD/vendor/gopkg.in/go-playground/validator.v8/logo.png -------------------------------------------------------------------------------- /static/js/ie8-html5.js: -------------------------------------------------------------------------------- 1 | document.createElement('header'); 2 | document.createElement('nav'); 3 | document.createElement('section'); 4 | document.createElement('footer'); 5 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | notify: 3 | gitter: 4 | default: 5 | url: https://webhooks.gitter.im/e/d90dcdeeab2f1e357165 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/suite_test.go: -------------------------------------------------------------------------------- 1 | package yaml_test 2 | 3 | import ( 4 | . "gopkg.in/check.v1" 5 | "testing" 6 | ) 7 | 8 | func Test(t *testing.T) { TestingT(t) } 9 | 10 | type S struct{} 11 | 12 | var _ = Suite(&S{}) 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.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 ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/export_test.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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | var Itoa = itoa 10 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/example/test.proto: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | enum FOO {X=17;}; 4 | 5 | message Test { 6 | required string label = 1; 7 | optional int32 type = 2[default=77]; 8 | repeated int64 reps = 3; 9 | optional group OptionalGroup = 4{ 10 | required string RequiredField = 5; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/helpers_test.go: -------------------------------------------------------------------------------- 1 | package gin 2 | 3 | import ( 4 | "net/http/httptest" 5 | ) 6 | 7 | func CreateTestContext() (c *Context, w *httptest.ResponseRecorder, r *Engine) { 8 | w = httptest.NewRecorder() 9 | r = New() 10 | c = r.allocateContext() 11 | c.reset() 12 | c.writermem.reset(w) 13 | return 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 7 | // terminal. This is also always false on this environment. 8 | func IsCygwinTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.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 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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 dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.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 amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others_test.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package isatty 4 | 5 | import ( 6 | "os" 7 | "testing" 8 | ) 9 | 10 | func TestTerminal(t *testing.T) { 11 | // test for non-panic 12 | IsTerminal(os.Stdout.Fd()) 13 | } 14 | 15 | func TestCygwinPipeName(t *testing.T) { 16 | if IsCygwinTerminal(os.Stdout.Fd()) { 17 | t.Fatal("should be false always") 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/example_test.go: -------------------------------------------------------------------------------- 1 | package isatty_test 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/mattn/go-isatty" 8 | ) 9 | 10 | func Example() { 11 | if isatty.IsTerminal(os.Stdout.Fd()) { 12 | fmt.Println("Is Terminal") 13 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { 14 | fmt.Println("Is Cygwin/MSYS2 Terminal") 15 | } else { 16 | fmt.Println("Is Not Terminal") 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/deprecated.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import "log" 8 | 9 | func (c *Context) GetCookie(name string) (string, error) { 10 | log.Println("GetCookie() method is deprecated. Use Cookie() instead.") 11 | return c.Cookie(name) 12 | } 13 | -------------------------------------------------------------------------------- /templates/search.tmpl: -------------------------------------------------------------------------------- 1 | 2 | {{template "head"}} 3 | 4 |
5 | {{template "header" .}} 6 | {{template "searchbar" .}} 7 |
    8 |

    Results for: {{.Query}}

    9 |
10 | {{template "footer"}} 11 |
12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /templates/footer.tmpl: -------------------------------------------------------------------------------- 1 | {{define "footer"}} 2 |
3 |
About
4 |
Activities
5 |
Get Involved
6 |
Donate
7 |
8 | {{end}} 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 freebsd 6 | 7 | package unix_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/sys/unix" 13 | ) 14 | 15 | func TestSysctlUint64(t *testing.T) { 16 | _, err := unix.SysctlUint64("security.mac.labeled") 17 | if err != nil { 18 | t.Fatal(err) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/gin-gonic/gin" 4 | 5 | func main() { 6 | router := gin.Default() 7 | router.LoadHTMLGlob("templates/*") 8 | router.Static("/static", "./static") 9 | 10 | router.GET("/", IndexHandler) 11 | router.GET("/search", SearchHandler) 12 | router.GET("/resources", ResourcesIndexHandler) 13 | router.GET("/resources/:slug", ResourceShowHandler) 14 | router.GET("/resources.js", ResourcesJsIndexHandler) 15 | 16 | router.Run() // listen and serve on 0.0.0.0:8080 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/writer.go: -------------------------------------------------------------------------------- 1 | package sse 2 | 3 | import "io" 4 | 5 | type stringWriter interface { 6 | io.Writer 7 | WriteString(string) (int, error) 8 | } 9 | 10 | type stringWrapper struct { 11 | io.Writer 12 | } 13 | 14 | func (w stringWrapper) WriteString(str string) (int, error) { 15 | return w.Writer.Write([]byte(str)) 16 | } 17 | 18 | func checkWriter(writer io.Writer) stringWriter { 19 | if w, ok := writer.(stringWriter); ok { 20 | return w 21 | } else { 22 | return stringWrapper{writer} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.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 gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/data.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import "net/http" 8 | 9 | type Data struct { 10 | ContentType string 11 | Data []byte 12 | } 13 | 14 | func (r Data) Render(w http.ResponseWriter) error { 15 | if len(r.ContentType) > 0 { 16 | w.Header()["Content-Type"] = []string{r.ContentType} 17 | } 18 | w.Write(r.Data) 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.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 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/xml.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "encoding/xml" 9 | "net/http" 10 | ) 11 | 12 | type XML struct { 13 | Data interface{} 14 | } 15 | 16 | var xmlContentType = []string{"application/xml; charset=utf-8"} 17 | 18 | func (r XML) Render(w http.ResponseWriter) error { 19 | writeContentType(w, xmlContentType) 20 | return xml.NewEncoder(w).Encode(r.Data) 21 | } 22 | -------------------------------------------------------------------------------- /static/js/search.js: -------------------------------------------------------------------------------- 1 | var index = elasticlunr(function () { 2 | this.addField('name'); 3 | this.addField('categories'); 4 | this.addField('description'); 5 | this.addField('services'); 6 | this.addField('email'); 7 | this.addField('address'); 8 | this.addField('languages'); 9 | this.addField('population_served'); 10 | this.addField('website'); 11 | this.addField('business_line'); 12 | this.addField('crisis_line'); 13 | this.addField('fax'); 14 | }); 15 | 16 | for (var i = 0; i < resources.length; i++) { 17 | resources[i].id = i; 18 | index.addDoc(resources[i]); 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/xml.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import ( 8 | "encoding/xml" 9 | "net/http" 10 | ) 11 | 12 | type xmlBinding struct{} 13 | 14 | func (xmlBinding) Name() string { 15 | return "xml" 16 | } 17 | 18 | func (xmlBinding) Bind(req *http.Request, obj interface{}) error { 19 | decoder := xml.NewDecoder(req.Body) 20 | if err := decoder.Decode(obj); err != nil { 21 | return err 22 | } 23 | return validate(obj) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import ( 8 | "encoding/json" 9 | 10 | "net/http" 11 | ) 12 | 13 | type jsonBinding struct{} 14 | 15 | func (jsonBinding) Name() string { 16 | return "json" 17 | } 18 | 19 | func (jsonBinding) Bind(req *http.Request, obj interface{}) error { 20 | decoder := json.NewDecoder(req.Body) 21 | if err := decoder.Decode(obj); err != nil { 22 | return err 23 | } 24 | return validate(obj) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.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 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mmap_unix_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/sys/unix" 13 | ) 14 | 15 | func TestMmap(t *testing.T) { 16 | b, err := unix.Mmap(-1, 0, unix.Getpagesize(), unix.PROT_NONE, unix.MAP_ANON|unix.MAP_PRIVATE) 17 | if err != nil { 18 | t.Fatalf("Mmap: %v", err) 19 | } 20 | if err := unix.Munmap(b); err != nil { 21 | t.Fatalf("Munmap: %v", err) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/redirect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "fmt" 9 | "net/http" 10 | ) 11 | 12 | type Redirect struct { 13 | Code int 14 | Request *http.Request 15 | Location string 16 | } 17 | 18 | func (r Redirect) Render(w http.ResponseWriter) error { 19 | if (r.Code < 300 || r.Code > 308) && r.Code != 201 { 20 | panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code)) 21 | } 22 | http.Redirect(w, r.Request, r.Location, r.Code) 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/yaml.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "net/http" 9 | 10 | "gopkg.in/yaml.v2" 11 | ) 12 | 13 | type YAML struct { 14 | Data interface{} 15 | } 16 | 17 | var yamlContentType = []string{"application/x-yaml; charset=utf-8"} 18 | 19 | func (r YAML) Render(w http.ResponseWriter) error { 20 | writeContentType(w, yamlContentType) 21 | 22 | bytes, err := yaml.Marshal(r.Data) 23 | if err != nil { 24 | return err 25 | } 26 | 27 | w.Write(bytes) 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /templates/resources.js.tmpl: -------------------------------------------------------------------------------- 1 | var resources = []; 2 | {{range $index, $element := .Resources}} 3 | resources[{{$index}}] = { 4 | name: "{{$element.Name}}", 5 | categories: "{{$element.Categories}}", 6 | description: "{{$element.Description}}", 7 | services: "{{$element.Services}}", 8 | email: "{{$element.Email}}", 9 | address: "{{$element.Address}}", 10 | languages: "{{$element.Languages}}", 11 | population_served: "{{$element.PopsServed}}", 12 | website: "{{$element.Website}}", 13 | business_line: "{{$element.BusinessLine}}", 14 | crisis_line: "{{$element.CrisisLine}}", 15 | fax: "{{$element.Fax}}", 16 | slug: "{{$element.Slug}}" 17 | }; 18 | {{end}} 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 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 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.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 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 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 s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 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 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/mode_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func init() { 14 | SetMode(TestMode) 15 | } 16 | 17 | func TestSetMode(t *testing.T) { 18 | SetMode(DebugMode) 19 | assert.Equal(t, ginMode, debugCode) 20 | assert.Equal(t, Mode(), DebugMode) 21 | 22 | SetMode(ReleaseMode) 23 | assert.Equal(t, ginMode, releaseCode) 24 | assert.Equal(t, Mode(), ReleaseMode) 25 | 26 | SetMode(TestMode) 27 | assert.Equal(t, ginMode, testCode) 28 | assert.Equal(t, Mode(), TestMode) 29 | 30 | assert.Panics(t, func() { SetMode("unknown") }) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/withtimeout_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 context_test 6 | 7 | import ( 8 | "fmt" 9 | "time" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | func ExampleWithTimeout() { 15 | // Pass a context with a timeout to tell a blocking function that it 16 | // should abandon its work after the timeout elapses. 17 | ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond) 18 | select { 19 | case <-time.After(200 * time.Millisecond): 20 | fmt.Println("overslept") 21 | case <-ctx.Done(): 22 | fmt.Println(ctx.Err()) // prints "context deadline exceeded" 23 | } 24 | // Output: 25 | // context deadline exceeded 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/text.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "net/http" 11 | ) 12 | 13 | type String struct { 14 | Format string 15 | Data []interface{} 16 | } 17 | 18 | var plainContentType = []string{"text/plain; charset=utf-8"} 19 | 20 | func (r String) Render(w http.ResponseWriter) error { 21 | WriteString(w, r.Format, r.Data) 22 | return nil 23 | } 24 | 25 | func WriteString(w http.ResponseWriter, format string, data []interface{}) { 26 | writeContentType(w, plainContentType) 27 | 28 | if len(data) > 0 { 29 | fmt.Fprintf(w, format, data...) 30 | } else { 31 | io.WriteString(w, format) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.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 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /templates/head.tmpl: -------------------------------------------------------------------------------- 1 | {{define "head"}} 2 | 3 | 4 | SFWAR Resource Guide 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | {{end}} 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 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 linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/render.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import "net/http" 8 | 9 | type Render interface { 10 | Render(http.ResponseWriter) error 11 | } 12 | 13 | var ( 14 | _ Render = JSON{} 15 | _ Render = IndentedJSON{} 16 | _ Render = XML{} 17 | _ Render = String{} 18 | _ Render = Redirect{} 19 | _ Render = Data{} 20 | _ Render = HTML{} 21 | _ HTMLRender = HTMLDebug{} 22 | _ HTMLRender = HTMLProduction{} 23 | _ Render = YAML{} 24 | ) 25 | 26 | func writeContentType(w http.ResponseWriter, value []string) { 27 | header := w.Header() 28 | if val := header["Content-Type"]; len(val) == 0 { 29 | header["Content-Type"] = value 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 solaris 6 | 7 | package unix_test 8 | 9 | import ( 10 | "os/exec" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestStatvfs(t *testing.T) { 17 | if err := unix.Statvfs("", nil); err == nil { 18 | t.Fatal(`Statvfs("") expected failure`) 19 | } 20 | 21 | statvfs := unix.Statvfs_t{} 22 | if err := unix.Statvfs("/", &statvfs); err != nil { 23 | t.Errorf(`Statvfs("/") failed: %v`, err) 24 | } 25 | 26 | if t.Failed() { 27 | mount, err := exec.Command("mount").CombinedOutput() 28 | if err != nil { 29 | t.Logf("mount: %v\n%s", err, mount) 30 | } else { 31 | t.Logf("mount: %s", mount) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/protobuf.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import ( 8 | "github.com/golang/protobuf/proto" 9 | 10 | "io/ioutil" 11 | "net/http" 12 | ) 13 | 14 | type protobufBinding struct{} 15 | 16 | func (protobufBinding) Name() string { 17 | return "protobuf" 18 | } 19 | 20 | func (protobufBinding) Bind(req *http.Request, obj interface{}) error { 21 | 22 | buf, err := ioutil.ReadAll(req.Body) 23 | if err != nil { 24 | return err 25 | } 26 | 27 | if err = proto.Unmarshal(buf, obj.(proto.Message)); err != nil { 28 | return err 29 | } 30 | 31 | //Here it's same to return validate(obj), but util now we cann't add `binding:""` to the struct 32 | //which automatically generate by gen-proto 33 | return nil 34 | //return validate(obj) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print < 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Senthil Arivudainambi 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/gin-gonic/gin/fs.go: -------------------------------------------------------------------------------- 1 | package gin 2 | 3 | import ( 4 | "net/http" 5 | "os" 6 | ) 7 | 8 | type ( 9 | onlyfilesFS struct { 10 | fs http.FileSystem 11 | } 12 | neuteredReaddirFile struct { 13 | http.File 14 | } 15 | ) 16 | 17 | // Dir returns a http.Filesystem that can be used by http.FileServer(). It is used interally 18 | // in router.Static(). 19 | // if listDirectory == true, then it works the same as http.Dir() otherwise it returns 20 | // a filesystem that prevents http.FileServer() to list the directory files. 21 | func Dir(root string, listDirectory bool) http.FileSystem { 22 | fs := http.Dir(root) 23 | if listDirectory { 24 | return fs 25 | } 26 | return &onlyfilesFS{fs} 27 | } 28 | 29 | // Conforms to http.Filesystem 30 | func (fs onlyfilesFS) Open(name string) (http.File, error) { 31 | f, err := fs.fs.Open(name) 32 | if err != nil { 33 | return nil, err 34 | } 35 | return neuteredReaddirFile{f}, nil 36 | } 37 | 38 | // Overrides the http.File default implementation 39 | func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) { 40 | // this disables directory listing 41 | return nil, nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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 arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Manuel Martínez-Almeida 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Manuel Martínez-Almeida 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dean Karn 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 | 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 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 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /templates/index.tmpl: -------------------------------------------------------------------------------- 1 | 2 | {{template "head"}} 3 | 4 |
5 | {{template "header" . }} 6 | {{template "searchbar" . }} 7 |
8 |

Find Local Support

9 |

SFWAR's referral guide has over 350 resources for survivors, significant others and service providers. Covering areas such as Child Sexual Abuse, Counseling, Body Work, and Employment, this guide has been invaluable to us. We hope that you will find it helpful as well. If you come across any resources that need to be updated, please email Teresa Martyny.

10 |

24-hour Rape Crisis Line

11 |

Rape crisis counselors are available 24 hours/day to offer support, information and resources for survivors of rape and sexual assault, friends, family members and others. Counselors are also trained in areas such as sexual harassment, incest, child sexual assault, same-sex sexual assault, domestic violence, ritual abuse, suicide prevention, male survivors and stalking. SFWAR's crisis hotline is (415) 647-RAPE.

12 |
13 | {{template "footer"}} 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.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 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for DragonFly from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV); 17 | 18 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <= 0 { 43 | t.Fatal("bad math") 44 | } 45 | s := unix.Itoa(i) 46 | f := fmt.Sprint(i) 47 | if s != f { 48 | t.Fatalf("itoa(%d) = %s, want %s", i, s, f) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sfsbook 2 | 3 | STOP VIOLENCE! 4 | 5 | ## Structure 6 | 7 | We use [Gin http framework](https://github.com/gin-gonic/gin) for routing and 8 | rendering of paths. 9 | 10 | main.go - contains the Gin initializer and sets up various routes and runs the 11 | server. 12 | 13 | routes.go - contains various handlers; will be moved to own package once this 14 | file becomes too big. 15 | 16 | templates/ - contains various Go templates. 17 | 18 | static/ - contains js and css files; this folder is server to the public, so 19 | BEWARE! 20 | 21 | refguides/ - contains the resources in various formats; nested by date pdf was 22 | added. 23 | 24 | vendor/ - contains vendored dependencies; 25 | 26 | ## Development 27 | 28 | Install [gin](github.com/gin-gonic/gin) which is a live reload 29 | utility. 30 | 31 | go get github.com/gin-gonic/gin 32 | 33 | Run server with: 34 | 35 | gin run main.go 36 | 37 | If you add a new dep, be sure to add it to vendor/ with: 38 | 39 | govendor add +external 40 | go get -u github.com/kardianos/govendor 41 | 42 | You can access the server at: http://localhost:3000. 43 | 44 | ## Credits 45 | 46 | This repo's frontend and javascript code is original from 47 | https://github.com/sfbrigade/sfsbook. All credit goes to @rjkroege 48 | and @cehsu and many other contributors seen 49 | [here](https://github.com/sfbrigade/sfsbook/graphs/contributors). 50 | -------------------------------------------------------------------------------- /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/sys/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/gin-gonic/gin/recovery_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "bytes" 9 | "testing" 10 | 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | // TestPanicInHandler assert that panic has been recovered. 15 | func TestPanicInHandler(t *testing.T) { 16 | buffer := new(bytes.Buffer) 17 | router := New() 18 | router.Use(RecoveryWithWriter(buffer)) 19 | router.GET("/recovery", func(_ *Context) { 20 | panic("Oupps, Houston, we have a problem") 21 | }) 22 | // RUN 23 | w := performRequest(router, "GET", "/recovery") 24 | // TEST 25 | assert.Equal(t, w.Code, 500) 26 | assert.Contains(t, buffer.String(), "GET /recovery") 27 | assert.Contains(t, buffer.String(), "Oupps, Houston, we have a problem") 28 | assert.Contains(t, buffer.String(), "TestPanicInHandler") 29 | } 30 | 31 | // TestPanicWithAbort assert that panic has been recovered even if context.Abort was used. 32 | func TestPanicWithAbort(t *testing.T) { 33 | router := New() 34 | router.Use(RecoveryWithWriter(nil)) 35 | router.GET("/recovery", func(c *Context) { 36 | c.AbortWithStatus(400) 37 | panic("Oupps, Houston, we have a problem") 38 | }) 39 | // RUN 40 | w := performRequest(router, "GET", "/recovery") 41 | // TEST 42 | assert.Equal(t, w.Code, 400) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/form.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import "net/http" 8 | 9 | type formBinding struct{} 10 | type formPostBinding struct{} 11 | type formMultipartBinding struct{} 12 | 13 | func (formBinding) Name() string { 14 | return "form" 15 | } 16 | 17 | func (formBinding) Bind(req *http.Request, obj interface{}) error { 18 | if err := req.ParseForm(); err != nil { 19 | return err 20 | } 21 | req.ParseMultipartForm(32 << 10) // 32 MB 22 | if err := mapForm(obj, req.Form); err != nil { 23 | return err 24 | } 25 | return validate(obj) 26 | } 27 | 28 | func (formPostBinding) Name() string { 29 | return "form-urlencoded" 30 | } 31 | 32 | func (formPostBinding) Bind(req *http.Request, obj interface{}) error { 33 | if err := req.ParseForm(); err != nil { 34 | return err 35 | } 36 | if err := mapForm(obj, req.PostForm); err != nil { 37 | return err 38 | } 39 | return validate(obj) 40 | } 41 | 42 | func (formMultipartBinding) Name() string { 43 | return "multipart/form-data" 44 | } 45 | 46 | func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error { 47 | if err := req.ParseMultipartForm(32 << 10); err != nil { 48 | return err 49 | } 50 | if err := mapForm(obj, req.MultipartForm.Value); err != nil { 51 | return err 52 | } 53 | return validate(obj) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for OpenBSD from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV); 17 | 18 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print < 0 { 52 | return template.Must(template.ParseFiles(r.Files...)) 53 | } 54 | if len(r.Glob) > 0 { 55 | return template.Must(template.ParseGlob(r.Glob)) 56 | } 57 | panic("the HTML debug render was created without files or glob pattern") 58 | } 59 | 60 | func (r HTML) Render(w http.ResponseWriter) error { 61 | writeContentType(w, htmlContentType) 62 | if len(r.Name) == 0 { 63 | return r.Template.Execute(w, r.Data) 64 | } 65 | return r.Template.ExecuteTemplate(w, r.Name, r.Data) 66 | } 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "io" 9 | "os" 10 | 11 | "github.com/gin-gonic/gin/binding" 12 | ) 13 | 14 | const ENV_GIN_MODE = "GIN_MODE" 15 | 16 | const ( 17 | DebugMode string = "debug" 18 | ReleaseMode string = "release" 19 | TestMode string = "test" 20 | ) 21 | const ( 22 | debugCode = iota 23 | releaseCode 24 | testCode 25 | ) 26 | 27 | // DefaultWriter is the default io.Writer used the Gin for debug output and 28 | // middleware output like Logger() or Recovery(). 29 | // Note that both Logger and Recovery provides custom ways to configure their 30 | // output io.Writer. 31 | // To support coloring in Windows use: 32 | // import "github.com/mattn/go-colorable" 33 | // gin.DefaultWriter = colorable.NewColorableStdout() 34 | var DefaultWriter io.Writer = os.Stdout 35 | var DefaultErrorWriter io.Writer = os.Stderr 36 | 37 | var ginMode = debugCode 38 | var modeName = DebugMode 39 | 40 | func init() { 41 | mode := os.Getenv(ENV_GIN_MODE) 42 | if len(mode) == 0 { 43 | SetMode(DebugMode) 44 | } else { 45 | SetMode(mode) 46 | } 47 | } 48 | 49 | func SetMode(value string) { 50 | switch value { 51 | case DebugMode: 52 | ginMode = debugCode 53 | case ReleaseMode: 54 | ginMode = releaseCode 55 | case TestMode: 56 | ginMode = testCode 57 | default: 58 | panic("gin mode unknown: " + value) 59 | } 60 | modeName = value 61 | } 62 | 63 | func DisableBindValidation() { 64 | binding.Validator = nil 65 | } 66 | 67 | func Mode() string { 68 | return modeName 69 | } 70 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.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 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.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 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/README.md: -------------------------------------------------------------------------------- 1 | #Server-Sent Events [![GoDoc](https://godoc.org/github.com/manucorporat/sse?status.svg)](https://godoc.org/github.com/manucorporat/sse) [![Build Status](https://travis-ci.org/manucorporat/sse.svg)](https://travis-ci.org/manucorporat/sse) 2 | 3 | Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is [standardized as part of HTML5[1] by the W3C](http://www.w3.org/TR/2009/WD-eventsource-20091029/). 4 | 5 | - [Real world demostration using Gin](http://sse.getgin.io/) 6 | - [Read this great SSE introduction by the HTML5Rocks guys](http://www.html5rocks.com/en/tutorials/eventsource/basics/) 7 | - [Browser support](http://caniuse.com/#feat=eventsource) 8 | 9 | ##Sample code 10 | 11 | ```go 12 | import "github.com/manucorporat/sse" 13 | 14 | func httpHandler(w http.ResponseWriter, req *http.Request) { 15 | // data can be a primitive like a string, an integer or a float 16 | sse.Encode(w, sse.Event{ 17 | Event: "message", 18 | Data: "some data\nmore data", 19 | }) 20 | 21 | // also a complex type, like a map, a struct or a slice 22 | sse.Encode(w, sse.Event{ 23 | Id: "124", 24 | Event: "message", 25 | Data: map[string]interface{}{ 26 | "user": "manu", 27 | "date": time.Now().Unix(), 28 | "content": "hi!", 29 | }, 30 | }) 31 | } 32 | ``` 33 | ``` 34 | event: message 35 | data: some data\\nmore data 36 | 37 | id: 124 38 | event: message 39 | data: {"content":"hi!","date":1431540810,"user":"manu"} 40 | 41 | ``` 42 | 43 | ##Content-Type 44 | 45 | ```go 46 | fmt.Println(sse.ContentType) 47 | ``` 48 | ``` 49 | text/event-stream 50 | ``` 51 | 52 | ##Decoding support 53 | 54 | There is a client-side implementation of SSE coming soon. -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for FreeBSD from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_freebsd.pl " . join(' ', @ARGV); 17 | 18 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 2 | {{template "head"}} 3 | 4 |
5 | {{template "header" .}} 6 | {{template "searchbar" .}} 7 | 8 |
9 |

Resource Details

10 |
11 | 12 | {{range .Resources}} 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 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 | 62 | 63 |
Name{{.Name}}
Categories{{.Categories}}
Description{{.Description}}
Services{{.Services}}
Email{{.Email}}
Address{{.Address}}
Languages{{.Languages}}
Populations Served{{.PopsServed}}
Website{{.Website}}
Business Line{{.BusinessLine}}
Crisis Line{{.CrisisLine}}
Fax{{.Fax}}
64 |
65 | {{end}} {{/* with .Resources*/}} 66 | 67 | {{template "footer" .}} 68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /templates/header.tmpl: -------------------------------------------------------------------------------- 1 | {{define "header"}} 2 |
3 |
4 | 5 |

SFWAR Resource Guide

6 |
7 |
8 |
9 |
10 |
    11 |
  • 12 | 13 | ESCAPE 14 | Leave this Site 15 | 16 |
  • 17 |
  • 18 | 19 | 415-647-7273 20 | Get Help Now 21 | 22 |
  • 23 | 38 |
39 |
40 |
41 |
42 | {{end}} 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.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 unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /resource.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "html/template" 7 | "io/ioutil" 8 | "log" 9 | "regexp" 10 | "strings" 11 | ) 12 | 13 | var ( 14 | ErrResourceNotFound = errors.New("Resource not found.") 15 | ) 16 | 17 | type Resource struct { 18 | Name string 19 | Slug string 20 | Categories string 21 | Description string 22 | Services string 23 | Email string 24 | Address string 25 | Languages string 26 | PopsServed string 27 | Website string 28 | BusinessLine string 29 | CrisisLine string 30 | Fax string 31 | } 32 | 33 | type escapedResources struct { 34 | Name template.HTML 35 | Slug template.HTML 36 | Categories template.HTML 37 | Description template.HTML 38 | Services template.HTML 39 | Email template.HTML 40 | Address template.HTML 41 | Languages template.HTML 42 | PopsServed template.HTML 43 | Website template.HTML 44 | BusinessLine template.HTML 45 | CrisisLine template.HTML 46 | Fax template.HTML 47 | } 48 | 49 | var ResourceFile = "refguides/2016-april/refguide.json" 50 | 51 | func GetResources() (resources []*Resource, err error) { 52 | file, err := ioutil.ReadFile(ResourceFile) 53 | if err != nil { 54 | return nil, err 55 | } 56 | 57 | if err := json.Unmarshal(file, &resources); err != nil { 58 | return nil, err 59 | } 60 | 61 | reg, err := regexp.Compile("[^a-zA-Z0-9]+") 62 | if err != nil { 63 | log.Fatal(err) 64 | } 65 | 66 | for _, r := range resources { 67 | r.Slug = reg.ReplaceAllString(strings.ToLower(r.Name), "-") 68 | r.Description = strings.Replace(r.Description, `"`, `\"`, -1) 69 | r.Services = strings.Replace(r.Services, `"`, `\"`, -1) 70 | } 71 | 72 | return resources, nil 73 | } 74 | 75 | func GetResourceBySlug(slug string) (*Resource, error) { 76 | resources, err := GetResources() 77 | if err != nil { 78 | return nil, err 79 | } 80 | 81 | for _, r := range resources { 82 | if r.Slug == slug { 83 | return r, nil 84 | } 85 | } 86 | 87 | return nil, ErrResourceNotFound 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/debug_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "bytes" 9 | "errors" 10 | "io" 11 | "log" 12 | "os" 13 | "testing" 14 | 15 | "github.com/stretchr/testify/assert" 16 | ) 17 | 18 | // TODO 19 | // func debugRoute(httpMethod, absolutePath string, handlers HandlersChain) { 20 | // func debugPrint(format string, values ...interface{}) { 21 | 22 | func TestIsDebugging(t *testing.T) { 23 | SetMode(DebugMode) 24 | assert.True(t, IsDebugging()) 25 | SetMode(ReleaseMode) 26 | assert.False(t, IsDebugging()) 27 | SetMode(TestMode) 28 | assert.False(t, IsDebugging()) 29 | } 30 | 31 | func TestDebugPrint(t *testing.T) { 32 | var w bytes.Buffer 33 | setup(&w) 34 | defer teardown() 35 | 36 | SetMode(ReleaseMode) 37 | debugPrint("DEBUG this!") 38 | SetMode(TestMode) 39 | debugPrint("DEBUG this!") 40 | assert.Empty(t, w.String()) 41 | 42 | SetMode(DebugMode) 43 | debugPrint("these are %d %s\n", 2, "error messages") 44 | assert.Equal(t, w.String(), "[GIN-debug] these are 2 error messages\n") 45 | } 46 | 47 | func TestDebugPrintError(t *testing.T) { 48 | var w bytes.Buffer 49 | setup(&w) 50 | defer teardown() 51 | 52 | SetMode(DebugMode) 53 | debugPrintError(nil) 54 | assert.Empty(t, w.String()) 55 | 56 | debugPrintError(errors.New("this is an error")) 57 | assert.Equal(t, w.String(), "[GIN-debug] [ERROR] this is an error\n") 58 | } 59 | 60 | func TestDebugPrintRoutes(t *testing.T) { 61 | var w bytes.Buffer 62 | setup(&w) 63 | defer teardown() 64 | 65 | debugPrintRoute("GET", "/path/to/route/:param", HandlersChain{func(c *Context) {}, handlerNameTest}) 66 | assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(2 handlers\)\n$`, w.String()) 67 | } 68 | 69 | func setup(w io.Writer) { 70 | SetMode(DebugMode) 71 | log.SetOutput(w) 72 | } 73 | 74 | func teardown() { 75 | SetMode(TestMode) 76 | log.SetOutput(os.Stdout) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "bytes" 9 | "html/template" 10 | "log" 11 | ) 12 | 13 | func init() { 14 | log.SetFlags(0) 15 | } 16 | 17 | // IsDebugging returns true if the framework is running in debug mode. 18 | // Use SetMode(gin.Release) to switch to disable the debug mode. 19 | func IsDebugging() bool { 20 | return ginMode == debugCode 21 | } 22 | 23 | func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) { 24 | if IsDebugging() { 25 | nuHandlers := len(handlers) 26 | handlerName := nameOfFunction(handlers.Last()) 27 | debugPrint("%-6s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers) 28 | } 29 | } 30 | 31 | func debugPrintLoadTemplate(tmpl *template.Template) { 32 | if IsDebugging() { 33 | var buf bytes.Buffer 34 | for _, tmpl := range tmpl.Templates() { 35 | buf.WriteString("\t- ") 36 | buf.WriteString(tmpl.Name()) 37 | buf.WriteString("\n") 38 | } 39 | debugPrint("Loaded HTML Templates (%d): \n%s\n", len(tmpl.Templates()), buf.String()) 40 | } 41 | } 42 | 43 | func debugPrint(format string, values ...interface{}) { 44 | if IsDebugging() { 45 | log.Printf("[GIN-debug] "+format, values...) 46 | } 47 | } 48 | 49 | func debugPrintWARNINGNew() { 50 | debugPrint(`[WARNING] Running in "debug" mode. Switch to "release" mode in production. 51 | - using env: export GIN_MODE=release 52 | - using code: gin.SetMode(gin.ReleaseMode) 53 | 54 | `) 55 | } 56 | 57 | func debugPrintWARNINGSetHTMLTemplate() { 58 | debugPrint(`[WARNING] Since SetHTMLTemplate() is NOT thread-safe. It should only be called 59 | at initialization. ie. before any route is registered or the router is listening in a socket: 60 | 61 | router := gin.Default() 62 | router.SetHTMLTemplate(template) // << good place 63 | 64 | `) 65 | } 66 | 67 | func debugPrintError(err error) { 68 | if err != nil { 69 | debugPrint("[ERROR] %v\n", err) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/testdata/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | 33 | include ../../Make.protobuf 34 | 35 | all: regenerate 36 | 37 | regenerate: 38 | rm -f test.pb.go 39 | make test.pb.go 40 | 41 | # The following rules are just aids to development. Not needed for typical testing. 42 | 43 | diff: regenerate 44 | git diff test.pb.go 45 | 46 | restore: 47 | cp test.pb.go.golden test.pb.go 48 | 49 | preserve: 50 | cp test.pb.go test.pb.go.golden 51 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/binding.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import "net/http" 8 | 9 | const ( 10 | MIMEJSON = "application/json" 11 | MIMEHTML = "text/html" 12 | MIMEXML = "application/xml" 13 | MIMEXML2 = "text/xml" 14 | MIMEPlain = "text/plain" 15 | MIMEPOSTForm = "application/x-www-form-urlencoded" 16 | MIMEMultipartPOSTForm = "multipart/form-data" 17 | MIMEPROTOBUF = "application/x-protobuf" 18 | ) 19 | 20 | type Binding interface { 21 | Name() string 22 | Bind(*http.Request, interface{}) error 23 | } 24 | 25 | type StructValidator interface { 26 | // ValidateStruct can receive any kind of type and it should never panic, even if the configuration is not right. 27 | // If the received type is not a struct, any validation should be skipped and nil must be returned. 28 | // If the received type is a struct or pointer to a struct, the validation should be performed. 29 | // If the struct is not valid or the validation itself fails, a descriptive error should be returned. 30 | // Otherwise nil must be returned. 31 | ValidateStruct(interface{}) error 32 | } 33 | 34 | var Validator StructValidator = &defaultValidator{} 35 | 36 | var ( 37 | JSON = jsonBinding{} 38 | XML = xmlBinding{} 39 | Form = formBinding{} 40 | FormPost = formPostBinding{} 41 | FormMultipart = formMultipartBinding{} 42 | ProtoBuf = protobufBinding{} 43 | ) 44 | 45 | func Default(method, contentType string) Binding { 46 | if method == "GET" { 47 | return Form 48 | } else { 49 | switch contentType { 50 | case MIMEJSON: 51 | return JSON 52 | case MIMEXML, MIMEXML2: 53 | return XML 54 | case MIMEPROTOBUF: 55 | return ProtoBuf 56 | default: //case MIMEPOSTForm, MIMEMultipartPOSTForm: 57 | return Form 58 | } 59 | } 60 | } 61 | 62 | func validate(obj interface{}) error { 63 | if Validator == nil { 64 | return nil 65 | } 66 | return Validator.ValidateStruct(obj) 67 | } 68 | -------------------------------------------------------------------------------- /routes.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "html/template" 5 | "log" 6 | "net/http" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | func IndexHandler(c *gin.Context) { 12 | c.HTML(http.StatusOK, "index.tmpl", gin.H{}) 13 | } 14 | 15 | func SearchHandler(c *gin.Context) { 16 | query := c.Query("query") 17 | 18 | c.HTML(http.StatusOK, "search.tmpl", gin.H{ 19 | "Query": query, 20 | "Resources": []interface{}{}, 21 | }) 22 | } 23 | 24 | //---------------------------------------------------------- 25 | // /resources routes 26 | //---------------------------------------------------------- 27 | 28 | func ResourcesIndexHandler(c *gin.Context) { 29 | resources, err := GetResources() 30 | if err != nil { 31 | log.Fatal(err) 32 | } 33 | 34 | c.HTML(http.StatusOK, "resource.tmpl", gin.H{ 35 | "Resources": resources, 36 | }) 37 | } 38 | 39 | func ResourceShowHandler(c *gin.Context) { 40 | slug := c.Param("slug") 41 | 42 | resource, err := GetResourceBySlug(slug) 43 | if err != nil { 44 | log.Fatal(err) 45 | } 46 | 47 | c.HTML(http.StatusOK, "resource.tmpl", gin.H{ 48 | "Query": slug, 49 | "Resources": []*Resource{resource}, 50 | }) 51 | } 52 | 53 | func ResourcesJsIndexHandler(c *gin.Context) { 54 | resources, err := GetResources() 55 | if err != nil { 56 | log.Fatal(err) 57 | } 58 | 59 | r := []*escapedResources{} 60 | 61 | for _, old := range resources { 62 | r = append(r, &escapedResources{ 63 | Name: template.HTML(old.Name), 64 | Categories: template.HTML(old.Categories), 65 | Description: template.HTML(old.Description), 66 | Services: template.HTML(old.Services), 67 | Email: template.HTML(old.Email), 68 | Address: template.HTML(old.Address), 69 | Languages: template.HTML(old.Languages), 70 | PopsServed: template.HTML(old.PopsServed), 71 | Website: template.HTML(old.Website), 72 | BusinessLine: template.HTML(old.BusinessLine), 73 | CrisisLine: template.HTML(old.CrisisLine), 74 | Fax: template.HTML(old.Fax), 75 | Slug: template.HTML(old.Slug), 76 | }) 77 | } 78 | 79 | c.HTML(http.StatusOK, "resources.js.tmpl", gin.H{ 80 | "Resources": r, 81 | }) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.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 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/examples_test.go: -------------------------------------------------------------------------------- 1 | package validator_test 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gopkg.in/go-playground/validator.v8" 7 | ) 8 | 9 | func ExampleValidate_new() { 10 | config := &validator.Config{TagName: "validate"} 11 | 12 | validator.New(config) 13 | } 14 | 15 | func ExampleValidate_field() { 16 | // This should be stored somewhere globally 17 | var validate *validator.Validate 18 | 19 | config := &validator.Config{TagName: "validate"} 20 | 21 | validate = validator.New(config) 22 | 23 | i := 0 24 | errs := validate.Field(i, "gt=1,lte=10") 25 | err := errs.(validator.ValidationErrors)[""] 26 | fmt.Println(err.Field) 27 | fmt.Println(err.Tag) 28 | fmt.Println(err.Kind) // NOTE: Kind and Type can be different i.e. time Kind=struct and Type=time.Time 29 | fmt.Println(err.Type) 30 | fmt.Println(err.Param) 31 | fmt.Println(err.Value) 32 | //Output: 33 | // 34 | //gt 35 | //int 36 | //int 37 | //1 38 | //0 39 | } 40 | 41 | func ExampleValidate_struct() { 42 | // This should be stored somewhere globally 43 | var validate *validator.Validate 44 | 45 | config := &validator.Config{TagName: "validate"} 46 | 47 | validate = validator.New(config) 48 | 49 | type ContactInformation struct { 50 | Phone string `validate:"required"` 51 | Street string `validate:"required"` 52 | City string `validate:"required"` 53 | } 54 | 55 | type User struct { 56 | Name string `validate:"required,excludesall=!@#$%^&*()_+-=:;?/0x2C"` // 0x2C = comma (,) 57 | Age int8 `validate:"required,gt=0,lt=150"` 58 | Email string `validate:"email"` 59 | ContactInformation []*ContactInformation 60 | } 61 | 62 | contactInfo := &ContactInformation{ 63 | Street: "26 Here Blvd.", 64 | City: "Paradeso", 65 | } 66 | 67 | user := &User{ 68 | Name: "Joey Bloggs", 69 | Age: 31, 70 | Email: "joeybloggs@gmail.com", 71 | ContactInformation: []*ContactInformation{contactInfo}, 72 | } 73 | 74 | errs := validate.Struct(user) 75 | for _, v := range errs.(validator.ValidationErrors) { 76 | fmt.Println(v.Field) // Phone 77 | fmt.Println(v.Tag) // required 78 | //... and so forth 79 | //Output: 80 | //Phone 81 | //required 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/path_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Julien Schmidt. All rights reserved. 2 | // Based on the path package, Copyright 2009 The Go Authors. 3 | // Use of this source code is governed by a BSD-style license that can be found 4 | // in the LICENSE file. 5 | 6 | package gin 7 | 8 | import ( 9 | "runtime" 10 | "testing" 11 | 12 | "github.com/stretchr/testify/assert" 13 | ) 14 | 15 | var cleanTests = []struct { 16 | path, result string 17 | }{ 18 | // Already clean 19 | {"/", "/"}, 20 | {"/abc", "/abc"}, 21 | {"/a/b/c", "/a/b/c"}, 22 | {"/abc/", "/abc/"}, 23 | {"/a/b/c/", "/a/b/c/"}, 24 | 25 | // missing root 26 | {"", "/"}, 27 | {"abc", "/abc"}, 28 | {"abc/def", "/abc/def"}, 29 | {"a/b/c", "/a/b/c"}, 30 | 31 | // Remove doubled slash 32 | {"//", "/"}, 33 | {"/abc//", "/abc/"}, 34 | {"/abc/def//", "/abc/def/"}, 35 | {"/a/b/c//", "/a/b/c/"}, 36 | {"/abc//def//ghi", "/abc/def/ghi"}, 37 | {"//abc", "/abc"}, 38 | {"///abc", "/abc"}, 39 | {"//abc//", "/abc/"}, 40 | 41 | // Remove . elements 42 | {".", "/"}, 43 | {"./", "/"}, 44 | {"/abc/./def", "/abc/def"}, 45 | {"/./abc/def", "/abc/def"}, 46 | {"/abc/.", "/abc/"}, 47 | 48 | // Remove .. elements 49 | {"..", "/"}, 50 | {"../", "/"}, 51 | {"../../", "/"}, 52 | {"../..", "/"}, 53 | {"../../abc", "/abc"}, 54 | {"/abc/def/ghi/../jkl", "/abc/def/jkl"}, 55 | {"/abc/def/../ghi/../jkl", "/abc/jkl"}, 56 | {"/abc/def/..", "/abc"}, 57 | {"/abc/def/../..", "/"}, 58 | {"/abc/def/../../..", "/"}, 59 | {"/abc/def/../../..", "/"}, 60 | {"/abc/def/../../../ghi/jkl/../../../mno", "/mno"}, 61 | 62 | // Combinations 63 | {"abc/./../def", "/def"}, 64 | {"abc//./../def", "/def"}, 65 | {"abc/../../././../def", "/def"}, 66 | } 67 | 68 | func TestPathClean(t *testing.T) { 69 | for _, test := range cleanTests { 70 | assert.Equal(t, cleanPath(test.path), test.result) 71 | assert.Equal(t, cleanPath(test.result), test.result) 72 | } 73 | } 74 | 75 | func TestPathCleanMallocs(t *testing.T) { 76 | if testing.Short() { 77 | t.Skip("skipping malloc count in short mode") 78 | } 79 | if runtime.GOMAXPROCS(0) > 1 { 80 | t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1") 81 | return 82 | } 83 | 84 | for _, test := range cleanTests { 85 | allocs := testing.AllocsPerRun(100, func() { cleanPath(test.result) }) 86 | assert.EqualValues(t, allocs, 0) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "strings" 8 | "syscall" 9 | "unicode/utf16" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | fileNameInfo uintptr = 2 15 | fileTypePipe = 3 16 | ) 17 | 18 | var ( 19 | kernel32 = syscall.NewLazyDLL("kernel32.dll") 20 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 21 | procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx") 22 | procGetFileType = kernel32.NewProc("GetFileType") 23 | ) 24 | 25 | func init() { 26 | // Check if GetFileInformationByHandleEx is available. 27 | if procGetFileInformationByHandleEx.Find() != nil { 28 | procGetFileInformationByHandleEx = nil 29 | } 30 | } 31 | 32 | // IsTerminal return true if the file descriptor is terminal. 33 | func IsTerminal(fd uintptr) bool { 34 | var st uint32 35 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 36 | return r != 0 && e == 0 37 | } 38 | 39 | // Check pipe name is used for cygwin/msys2 pty. 40 | // Cygwin/MSYS2 PTY has a name like: 41 | // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master 42 | func isCygwinPipeName(name string) bool { 43 | token := strings.Split(name, "-") 44 | if len(token) < 5 { 45 | return false 46 | } 47 | 48 | if token[0] != `\msys` && token[0] != `\cygwin` { 49 | return false 50 | } 51 | 52 | if token[1] == "" { 53 | return false 54 | } 55 | 56 | if !strings.HasPrefix(token[2], "pty") { 57 | return false 58 | } 59 | 60 | if token[3] != `from` && token[3] != `to` { 61 | return false 62 | } 63 | 64 | if token[4] != "master" { 65 | return false 66 | } 67 | 68 | return true 69 | } 70 | 71 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 72 | // terminal. 73 | func IsCygwinTerminal(fd uintptr) bool { 74 | if procGetFileInformationByHandleEx == nil { 75 | return false 76 | } 77 | 78 | // Cygwin/msys's pty is a pipe. 79 | ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0) 80 | if ft != fileTypePipe || e != 0 { 81 | return false 82 | } 83 | 84 | var buf [2 + syscall.MAX_PATH]uint16 85 | r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 86 | 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)), 87 | uintptr(len(buf)*2), 0, 0) 88 | if r == 0 || e != 0 { 89 | return false 90 | } 91 | 92 | l := *(*uint32)(unsafe.Pointer(&buf)) 93 | return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2]))) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/size2_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto 33 | 34 | import ( 35 | "testing" 36 | ) 37 | 38 | // This is a separate file and package from size_test.go because that one uses 39 | // generated messages and thus may not be in package proto without having a circular 40 | // dependency, whereas this file tests unexported details of size.go. 41 | 42 | func TestVarintSize(t *testing.T) { 43 | // Check the edge cases carefully. 44 | testCases := []struct { 45 | n uint64 46 | size int 47 | }{ 48 | {0, 1}, 49 | {1, 1}, 50 | {127, 1}, 51 | {128, 2}, 52 | {16383, 2}, 53 | {16384, 3}, 54 | {1<<63 - 1, 9}, 55 | {1 << 63, 10}, 56 | } 57 | for _, tc := range testCases { 58 | size := sizeVarint(tc.n) 59 | if size != tc.size { 60 | t.Errorf("sizeVarint(%d) = %d, want %d", tc.n, size, tc.size) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | // ByteSliceFromString returns a NUL-terminated slice of bytes 25 | // containing the text of s. If s contains a NUL byte at any 26 | // location, it returns (nil, EINVAL). 27 | func ByteSliceFromString(s string) ([]byte, error) { 28 | for i := 0; i < len(s); i++ { 29 | if s[i] == 0 { 30 | return nil, EINVAL 31 | } 32 | } 33 | a := make([]byte, len(s)+1) 34 | copy(a, s) 35 | return a, nil 36 | } 37 | 38 | // BytePtrFromString returns a pointer to a NUL-terminated array of 39 | // bytes containing the text of s. If s contains a NUL byte at any 40 | // location, it returns (nil, EINVAL). 41 | func BytePtrFromString(s string) (*byte, error) { 42 | a, err := ByteSliceFromString(s) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return &a[0], nil 47 | } 48 | 49 | // Single-word zero for use when we need a valid pointer to 0 bytes. 50 | // See mkunix.pl. 51 | var _zero uintptr 52 | 53 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 54 | return int64(ts.Sec), int64(ts.Nsec) 55 | } 56 | 57 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 58 | return int64(tv.Sec), int64(tv.Usec) * 1000 59 | } 60 | 61 | func (ts *Timespec) Nano() int64 { 62 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 63 | } 64 | 65 | func (tv *Timeval) Nano() int64 { 66 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 67 | } 68 | 69 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 70 | -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/sse-encoder.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package sse 6 | 7 | import ( 8 | "encoding/json" 9 | "fmt" 10 | "io" 11 | "net/http" 12 | "reflect" 13 | "strconv" 14 | "strings" 15 | ) 16 | 17 | // Server-Sent Events 18 | // W3C Working Draft 29 October 2009 19 | // http://www.w3.org/TR/2009/WD-eventsource-20091029/ 20 | 21 | const ContentType = "text/event-stream" 22 | 23 | var contentType = []string{ContentType} 24 | var noCache = []string{"no-cache"} 25 | 26 | var fieldReplacer = strings.NewReplacer( 27 | "\n", "\\n", 28 | "\r", "\\r") 29 | 30 | var dataReplacer = strings.NewReplacer( 31 | "\n", "\ndata:", 32 | "\r", "\\r") 33 | 34 | type Event struct { 35 | Event string 36 | Id string 37 | Retry uint 38 | Data interface{} 39 | } 40 | 41 | func Encode(writer io.Writer, event Event) error { 42 | w := checkWriter(writer) 43 | writeId(w, event.Id) 44 | writeEvent(w, event.Event) 45 | writeRetry(w, event.Retry) 46 | return writeData(w, event.Data) 47 | } 48 | 49 | func writeId(w stringWriter, id string) { 50 | if len(id) > 0 { 51 | w.WriteString("id:") 52 | fieldReplacer.WriteString(w, id) 53 | w.WriteString("\n") 54 | } 55 | } 56 | 57 | func writeEvent(w stringWriter, event string) { 58 | if len(event) > 0 { 59 | w.WriteString("event:") 60 | fieldReplacer.WriteString(w, event) 61 | w.WriteString("\n") 62 | } 63 | } 64 | 65 | func writeRetry(w stringWriter, retry uint) { 66 | if retry > 0 { 67 | w.WriteString("retry:") 68 | w.WriteString(strconv.FormatUint(uint64(retry), 10)) 69 | w.WriteString("\n") 70 | } 71 | } 72 | 73 | func writeData(w stringWriter, data interface{}) error { 74 | w.WriteString("data:") 75 | switch kindOfData(data) { 76 | case reflect.Struct, reflect.Slice, reflect.Map: 77 | err := json.NewEncoder(w).Encode(data) 78 | if err != nil { 79 | return err 80 | } 81 | w.WriteString("\n") 82 | default: 83 | dataReplacer.WriteString(w, fmt.Sprint(data)) 84 | w.WriteString("\n\n") 85 | } 86 | return nil 87 | } 88 | 89 | func (r Event) Render(w http.ResponseWriter) error { 90 | header := w.Header() 91 | header["Content-Type"] = contentType 92 | 93 | if _, exist := header["Cache-Control"]; !exist { 94 | header["Cache-Control"] = noCache 95 | } 96 | return Encode(w, r) 97 | } 98 | 99 | func kindOfData(data interface{}) reflect.Kind { 100 | value := reflect.ValueOf(data) 101 | valueType := value.Kind() 102 | if valueType == reflect.Ptr { 103 | valueType = value.Elem().Kind() 104 | } 105 | return valueType 106 | } 107 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/proto3_proto/proto3.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto3"; 33 | 34 | import "google/protobuf/any.proto"; 35 | import "testdata/test.proto"; 36 | 37 | package proto3_proto; 38 | 39 | message Message { 40 | enum Humour { 41 | UNKNOWN = 0; 42 | PUNS = 1; 43 | SLAPSTICK = 2; 44 | BILL_BAILEY = 3; 45 | } 46 | 47 | string name = 1; 48 | Humour hilarity = 2; 49 | uint32 height_in_cm = 3; 50 | bytes data = 4; 51 | int64 result_count = 7; 52 | bool true_scotsman = 8; 53 | float score = 9; 54 | 55 | repeated uint64 key = 5; 56 | Nested nested = 6; 57 | repeated Humour r_funny = 16; 58 | 59 | map terrain = 10; 60 | testdata.SubDefaults proto2_field = 11; 61 | map proto2_value = 13; 62 | 63 | google.protobuf.Any anything = 14; 64 | repeated google.protobuf.Any many_things = 15; 65 | } 66 | 67 | message Nested { 68 | string bunny = 1; 69 | } 70 | 71 | message MessageWithMap { 72 | map byte_mapping = 1; 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/sse-decoder_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package sse 6 | 7 | import ( 8 | "bytes" 9 | "testing" 10 | 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | func TestDecodeSingle1(t *testing.T) { 15 | events, err := Decode(bytes.NewBufferString( 16 | `data: this is a text 17 | event: message 18 | fake: 19 | id: 123456789010 20 | : we can append data 21 | : and multiple comments should not break it 22 | data: a very nice one`)) 23 | 24 | assert.NoError(t, err) 25 | assert.Len(t, events, 1) 26 | assert.Equal(t, events[0].Event, "message") 27 | assert.Equal(t, events[0].Id, "123456789010") 28 | } 29 | 30 | func TestDecodeSingle2(t *testing.T) { 31 | events, err := Decode(bytes.NewBufferString( 32 | `: starting with a comment 33 | fake: 34 | 35 | data:this is a \ntext 36 | event:a message\n\n 37 | fake 38 | :and multiple comments\n should not break it\n\n 39 | id:1234567890\n10 40 | :we can append data 41 | data:a very nice one\n! 42 | 43 | 44 | `)) 45 | assert.NoError(t, err) 46 | assert.Len(t, events, 1) 47 | assert.Equal(t, events[0].Event, "a message\\n\\n") 48 | assert.Equal(t, events[0].Id, "1234567890\\n10") 49 | } 50 | 51 | func TestDecodeSingle3(t *testing.T) { 52 | events, err := Decode(bytes.NewBufferString( 53 | ` 54 | id:123456ABCabc789010 55 | event: message123 56 | : we can append data 57 | data:this is a text 58 | data: a very nice one 59 | data: 60 | data 61 | : ending with a comment`)) 62 | 63 | assert.NoError(t, err) 64 | assert.Len(t, events, 1) 65 | assert.Equal(t, events[0].Event, "message123") 66 | assert.Equal(t, events[0].Id, "123456ABCabc789010") 67 | } 68 | 69 | func TestDecodeMulti1(t *testing.T) { 70 | events, err := Decode(bytes.NewBufferString( 71 | ` 72 | id: 73 | event: weird event 74 | data:this is a text 75 | :data: this should NOT APER 76 | data: second line 77 | 78 | : a comment 79 | event: message 80 | id:123 81 | data:this is a text 82 | :data: this should NOT APER 83 | data: second line 84 | 85 | 86 | : a comment 87 | event: message 88 | id:123 89 | data:this is a text 90 | data: second line 91 | 92 | :hola 93 | 94 | data 95 | 96 | event: 97 | 98 | id`)) 99 | assert.NoError(t, err) 100 | assert.Len(t, events, 3) 101 | assert.Equal(t, events[0].Event, "weird event") 102 | assert.Equal(t, events[0].Id, "") 103 | } 104 | 105 | func TestDecodeW3C(t *testing.T) { 106 | events, err := Decode(bytes.NewBufferString( 107 | `data 108 | 109 | data 110 | data 111 | 112 | data: 113 | `)) 114 | assert.NoError(t, err) 115 | assert.Len(t, events, 1) 116 | } 117 | -------------------------------------------------------------------------------- /static/js/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Attaches event handlers for IE8, stops event propagation and prevents default event behavior. 3 | * @param {object} el The element to which the event will be attached. 4 | * @param {object} eventName The event to be attached. 5 | * @param {function} handler The handler to be invoked when the event occurs. 6 | */ 7 | function addEventListener(el, eventName, handler) { 8 | eventName.preventDefault ? eventName.preventDefault() : 9 | (eventName.returnValue = false); 10 | eventName.stopPropagation ? eventName.stopPropagation() : 11 | (eventName.cancelBubble = true); 12 | if (el.addEventListener) { 13 | el.addEventListener(eventName, handler); 14 | } else { 15 | el.attachEvent('on' + eventName, function() { 16 | handler.call(el); 17 | }); 18 | } 19 | } 20 | 21 | /** Attaches event listeners to toggle dropdown menu elements */ 22 | function attachToggles() { 23 | var clickPairs = [['.category-option', toggleCategoryOption]]; 24 | var keydownPairs = [['.search-filter-container', searchNav], 25 | ['.search-filters', searchNav], 26 | ['.category-option', searchNav], 27 | ['.user-menu', userNav], 28 | ['.user-menu-item', userNav]]; 29 | for (var i = 0; i < clickPairs.length; i++) { 30 | var trigger = document.querySelectorAll(clickPairs[i][0]); 31 | for (var j = 0; j < trigger.length; j++) { 32 | addEventListener(trigger[j], 'click', clickPairs[i][1]); 33 | } 34 | } 35 | for (var k = 0; k < keydownPairs.length; k++) { 36 | var trigger = document.querySelectorAll(keydownPairs[k][0]); 37 | for (var l = 0; l < trigger.length; l++) { 38 | addEventListener(trigger[l], 'keydown', keydownPairs[k][1]); 39 | } 40 | } 41 | } 42 | 43 | function attachSearchListeners() { 44 | var searchClickTrigger = document.getElementById('search-submit-button'); 45 | var searchEnterTrigger = document.getElementById('query_field'); 46 | addEventListener(searchClickTrigger, 'click', fetchSearchResults); 47 | addEventListener(searchEnterTrigger, 'keypress', fetchSearchResults); 48 | } 49 | 50 | /** 51 | * Listens for document ready (i.e. readyState not loading), and invokes callback. 52 | * @param {function} fn The function to be invoked once ready detected. 53 | */ 54 | function ready(fn) { 55 | if (document.readyState != 'loading') { 56 | fn(); 57 | } else if (document.addEventListener) { 58 | document.addEventListener('DOMContentLoaded', fn); 59 | } else { 60 | document.attachEvent('onreadystatechange', function() { 61 | if (document.readyState != 'loading') { 62 | fn(); 63 | } 64 | }); 65 | } 66 | } 67 | 68 | /** Calls attachToggles once ready is detected */ 69 | ready(attachToggles); 70 | // will uncomment this out when we refactor to single page search 71 | // ready(attachSearchListeners); 72 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | // If the output encoding is UTF-8, we don't need to recode the buffer. 22 | if emitter.encoding == yaml_UTF8_ENCODING { 23 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 24 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 25 | } 26 | emitter.buffer_pos = 0 27 | return true 28 | } 29 | 30 | // Recode the buffer into the raw buffer. 31 | var low, high int 32 | if emitter.encoding == yaml_UTF16LE_ENCODING { 33 | low, high = 0, 1 34 | } else { 35 | high, low = 1, 0 36 | } 37 | 38 | pos := 0 39 | for pos < emitter.buffer_pos { 40 | // See the "reader.c" code for more details on UTF-8 encoding. Note 41 | // that we assume that the buffer contains a valid UTF-8 sequence. 42 | 43 | // Read the next UTF-8 character. 44 | octet := emitter.buffer[pos] 45 | 46 | var w int 47 | var value rune 48 | switch { 49 | case octet&0x80 == 0x00: 50 | w, value = 1, rune(octet&0x7F) 51 | case octet&0xE0 == 0xC0: 52 | w, value = 2, rune(octet&0x1F) 53 | case octet&0xF0 == 0xE0: 54 | w, value = 3, rune(octet&0x0F) 55 | case octet&0xF8 == 0xF0: 56 | w, value = 4, rune(octet&0x07) 57 | } 58 | for k := 1; k < w; k++ { 59 | octet = emitter.buffer[pos+k] 60 | value = (value << 6) + (rune(octet) & 0x3F) 61 | } 62 | pos += w 63 | 64 | // Write the character. 65 | if value < 0x10000 { 66 | var b [2]byte 67 | b[high] = byte(value >> 8) 68 | b[low] = byte(value & 0xFF) 69 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) 70 | } else { 71 | // Write the character using a surrogate pair (check "reader.c"). 72 | var b [4]byte 73 | value -= 0x10000 74 | b[high] = byte(0xD8 + (value >> 18)) 75 | b[low] = byte((value >> 10) & 0xFF) 76 | b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) 77 | b[low+2] = byte(value & 0xFF) 78 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) 79 | } 80 | } 81 | 82 | // Write the raw buffer. 83 | if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { 84 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 85 | } 86 | emitter.buffer_pos = 0 87 | emitter.raw_buffer = emitter.raw_buffer[:0] 88 | return true 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/message_set_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto 33 | 34 | import ( 35 | "bytes" 36 | "testing" 37 | ) 38 | 39 | func TestUnmarshalMessageSetWithDuplicate(t *testing.T) { 40 | // Check that a repeated message set entry will be concatenated. 41 | in := &messageSet{ 42 | Item: []*_MessageSet_Item{ 43 | {TypeId: Int32(12345), Message: []byte("hoo")}, 44 | {TypeId: Int32(12345), Message: []byte("hah")}, 45 | }, 46 | } 47 | b, err := Marshal(in) 48 | if err != nil { 49 | t.Fatalf("Marshal: %v", err) 50 | } 51 | t.Logf("Marshaled bytes: %q", b) 52 | 53 | var extensions XXX_InternalExtensions 54 | if err := UnmarshalMessageSet(b, &extensions); err != nil { 55 | t.Fatalf("UnmarshalMessageSet: %v", err) 56 | } 57 | ext, ok := extensions.p.extensionMap[12345] 58 | if !ok { 59 | t.Fatalf("Didn't retrieve extension 12345; map is %v", extensions.p.extensionMap) 60 | } 61 | // Skip wire type/field number and length varints. 62 | got := skipVarint(skipVarint(ext.enc)) 63 | if want := []byte("hoohah"); !bytes.Equal(got, want) { 64 | t.Errorf("Combined extension is %q, want %q", got, want) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.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 ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs; see README.md. 12 | package main 13 | 14 | import ( 15 | "bytes" 16 | "fmt" 17 | "go/format" 18 | "io/ioutil" 19 | "log" 20 | "os" 21 | "regexp" 22 | ) 23 | 24 | func main() { 25 | // Get the OS and architecture (using GOARCH_TARGET if it exists) 26 | goos := os.Getenv("GOOS") 27 | goarch := os.Getenv("GOARCH_TARGET") 28 | if goarch == "" { 29 | goarch = os.Getenv("GOARCH") 30 | } 31 | // Check that we are using the new build system if we should be. 32 | if goos == "linux" && goarch != "sparc64" { 33 | if os.Getenv("GOLANG_SYS_BUILD") != "docker" { 34 | os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n") 35 | os.Stderr.WriteString("See README.md\n") 36 | os.Exit(1) 37 | } 38 | } 39 | 40 | b, err := ioutil.ReadAll(os.Stdin) 41 | if err != nil { 42 | log.Fatal(err) 43 | } 44 | 45 | // If we have empty Ptrace structs, we should delete them. Only s390x emits 46 | // nonempty Ptrace structs. 47 | ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`) 48 | b = ptraceRexexp.ReplaceAll(b, nil) 49 | 50 | // Replace the control_regs union with a blank identifier for now. 51 | controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`) 52 | b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64")) 53 | 54 | // Remove fields that are added by glibc 55 | // Note that this is unstable as the identifers are private. 56 | removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`) 57 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 58 | 59 | // We refuse to export private fields on s390x 60 | if goarch == "s390x" && goos == "linux" { 61 | // Remove cgo padding fields 62 | removeFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`) 63 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 64 | 65 | // Remove padding, hidden, or unused fields 66 | removeFieldsRegex = regexp.MustCompile(`X_\S+`) 67 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 68 | } 69 | 70 | // Remove the first line of warning from cgo 71 | b = b[bytes.IndexByte(b, '\n')+1:] 72 | // Modify the command in the header to include: 73 | // mkpost, our own warning, and a build tag. 74 | replacement := fmt.Sprintf(`$1 | go run mkpost.go 75 | // Code generated by the command above; see README.md. DO NOT EDIT. 76 | 77 | // +build %s,%s`, goarch, goos) 78 | cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`) 79 | b = cgoCommandRegex.ReplaceAll(b, []byte(replacement)) 80 | 81 | // gofmt 82 | b, err = format.Source(b) 83 | if err != nil { 84 | log.Fatal(err) 85 | } 86 | 87 | os.Stdout.Write(b) 88 | } 89 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/sorter.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "reflect" 5 | "unicode" 6 | ) 7 | 8 | type keyList []reflect.Value 9 | 10 | func (l keyList) Len() int { return len(l) } 11 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } 12 | func (l keyList) Less(i, j int) bool { 13 | a := l[i] 14 | b := l[j] 15 | ak := a.Kind() 16 | bk := b.Kind() 17 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { 18 | a = a.Elem() 19 | ak = a.Kind() 20 | } 21 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { 22 | b = b.Elem() 23 | bk = b.Kind() 24 | } 25 | af, aok := keyFloat(a) 26 | bf, bok := keyFloat(b) 27 | if aok && bok { 28 | if af != bf { 29 | return af < bf 30 | } 31 | if ak != bk { 32 | return ak < bk 33 | } 34 | return numLess(a, b) 35 | } 36 | if ak != reflect.String || bk != reflect.String { 37 | return ak < bk 38 | } 39 | ar, br := []rune(a.String()), []rune(b.String()) 40 | for i := 0; i < len(ar) && i < len(br); i++ { 41 | if ar[i] == br[i] { 42 | continue 43 | } 44 | al := unicode.IsLetter(ar[i]) 45 | bl := unicode.IsLetter(br[i]) 46 | if al && bl { 47 | return ar[i] < br[i] 48 | } 49 | if al || bl { 50 | return bl 51 | } 52 | var ai, bi int 53 | var an, bn int64 54 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { 55 | an = an*10 + int64(ar[ai]-'0') 56 | } 57 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { 58 | bn = bn*10 + int64(br[bi]-'0') 59 | } 60 | if an != bn { 61 | return an < bn 62 | } 63 | if ai != bi { 64 | return ai < bi 65 | } 66 | return ar[i] < br[i] 67 | } 68 | return len(ar) < len(br) 69 | } 70 | 71 | // keyFloat returns a float value for v if it is a number/bool 72 | // and whether it is a number/bool or not. 73 | func keyFloat(v reflect.Value) (f float64, ok bool) { 74 | switch v.Kind() { 75 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 76 | return float64(v.Int()), true 77 | case reflect.Float32, reflect.Float64: 78 | return v.Float(), true 79 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 80 | return float64(v.Uint()), true 81 | case reflect.Bool: 82 | if v.Bool() { 83 | return 1, true 84 | } 85 | return 0, true 86 | } 87 | return 0, false 88 | } 89 | 90 | // numLess returns whether a < b. 91 | // a and b must necessarily have the same kind. 92 | func numLess(a, b reflect.Value) bool { 93 | switch a.Kind() { 94 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 95 | return a.Int() < b.Int() 96 | case reflect.Float32, reflect.Float64: 97 | return a.Float() < b.Float() 98 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 99 | return a.Uint() < b.Uint() 100 | case reflect.Bool: 101 | return !a.Bool() && b.Bool() 102 | } 103 | panic("not a number") 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/response_writer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "bufio" 9 | "io" 10 | "net" 11 | "net/http" 12 | ) 13 | 14 | const ( 15 | noWritten = -1 16 | defaultStatus = 200 17 | ) 18 | 19 | type ( 20 | ResponseWriter interface { 21 | http.ResponseWriter 22 | http.Hijacker 23 | http.Flusher 24 | http.CloseNotifier 25 | 26 | // Returns the HTTP response status code of the current request. 27 | Status() int 28 | 29 | // Returns the number of bytes already written into the response http body. 30 | // See Written() 31 | Size() int 32 | 33 | // Writes the string into the response body. 34 | WriteString(string) (int, error) 35 | 36 | // Returns true if the response body was already written. 37 | Written() bool 38 | 39 | // Forces to write the http header (status code + headers). 40 | WriteHeaderNow() 41 | } 42 | 43 | responseWriter struct { 44 | http.ResponseWriter 45 | size int 46 | status int 47 | } 48 | ) 49 | 50 | var _ ResponseWriter = &responseWriter{} 51 | 52 | func (w *responseWriter) reset(writer http.ResponseWriter) { 53 | w.ResponseWriter = writer 54 | w.size = noWritten 55 | w.status = defaultStatus 56 | } 57 | 58 | func (w *responseWriter) WriteHeader(code int) { 59 | if code > 0 && w.status != code { 60 | if w.Written() { 61 | debugPrint("[WARNING] Headers were already written. Wanted to override status code %d with %d", w.status, code) 62 | } 63 | w.status = code 64 | } 65 | } 66 | 67 | func (w *responseWriter) WriteHeaderNow() { 68 | if !w.Written() { 69 | w.size = 0 70 | w.ResponseWriter.WriteHeader(w.status) 71 | } 72 | } 73 | 74 | func (w *responseWriter) Write(data []byte) (n int, err error) { 75 | w.WriteHeaderNow() 76 | n, err = w.ResponseWriter.Write(data) 77 | w.size += n 78 | return 79 | } 80 | 81 | func (w *responseWriter) WriteString(s string) (n int, err error) { 82 | w.WriteHeaderNow() 83 | n, err = io.WriteString(w.ResponseWriter, s) 84 | w.size += n 85 | return 86 | } 87 | 88 | func (w *responseWriter) Status() int { 89 | return w.status 90 | } 91 | 92 | func (w *responseWriter) Size() int { 93 | return w.size 94 | } 95 | 96 | func (w *responseWriter) Written() bool { 97 | return w.size != noWritten 98 | } 99 | 100 | // Implements the http.Hijacker interface 101 | func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { 102 | if w.size < 0 { 103 | w.size = 0 104 | } 105 | return w.ResponseWriter.(http.Hijacker).Hijack() 106 | } 107 | 108 | // Implements the http.CloseNotify interface 109 | func (w *responseWriter) CloseNotify() <-chan bool { 110 | return w.ResponseWriter.(http.CloseNotifier).CloseNotify() 111 | } 112 | 113 | // Implements the http.Flush interface 114 | func (w *responseWriter) Flush() { 115 | w.ResponseWriter.(http.Flusher).Flush() 116 | } 117 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_test.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 openbsd 6 | 7 | // This, on the face of it, bizarre testing mechanism is necessary because 8 | // the only reliable way to gauge whether or not a pledge(2) call has succeeded 9 | // is that the program has been killed as a result of breaking its pledge. 10 | 11 | package unix_test 12 | 13 | import ( 14 | "flag" 15 | "fmt" 16 | "io/ioutil" 17 | "os" 18 | "os/exec" 19 | "path/filepath" 20 | "testing" 21 | 22 | "golang.org/x/sys/unix" 23 | ) 24 | 25 | type testProc struct { 26 | fn func() // should always exit instead of returning 27 | cleanup func() error // for instance, delete coredumps from testing pledge 28 | success bool // whether zero-exit means success or failure 29 | } 30 | 31 | var ( 32 | testProcs = map[string]testProc{} 33 | procName = "" 34 | ) 35 | 36 | const ( 37 | optName = "sys-unix-internal-procname" 38 | ) 39 | 40 | func init() { 41 | flag.StringVar(&procName, optName, "", "internal use only") 42 | } 43 | 44 | // testCmd generates a proper command that, when executed, runs the test 45 | // corresponding to the given key. 46 | func testCmd(procName string) (*exec.Cmd, error) { 47 | exe, err := filepath.Abs(os.Args[0]) 48 | if err != nil { 49 | return nil, err 50 | } 51 | cmd := exec.Command(exe, "-"+optName+"="+procName) 52 | cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr 53 | return cmd, nil 54 | } 55 | 56 | // ExitsCorrectly is a comprehensive, one-line-of-use wrapper for testing 57 | // a testProc with a key. 58 | func ExitsCorrectly(procName string, t *testing.T) { 59 | s := testProcs[procName] 60 | c, err := testCmd(procName) 61 | defer func() { 62 | if s.cleanup() != nil { 63 | t.Fatalf("Failed to run cleanup for %s", procName) 64 | } 65 | }() 66 | if err != nil { 67 | t.Fatalf("Failed to construct command for %s", procName) 68 | } 69 | if (c.Run() == nil) != s.success { 70 | result := "succeed" 71 | if !s.success { 72 | result = "fail" 73 | } 74 | t.Fatalf("Process did not %s when it was supposed to", result) 75 | } 76 | } 77 | 78 | func TestMain(m *testing.M) { 79 | flag.Parse() 80 | if procName != "" { 81 | testProcs[procName].fn() 82 | } 83 | os.Exit(m.Run()) 84 | } 85 | 86 | // For example, add a test for pledge. 87 | func init() { 88 | testProcs["pledge"] = testProc{ 89 | func() { 90 | fmt.Println(unix.Pledge("", nil)) 91 | os.Exit(0) 92 | }, 93 | func() error { 94 | files, err := ioutil.ReadDir(".") 95 | if err != nil { 96 | return err 97 | } 98 | for _, file := range files { 99 | if filepath.Ext(file.Name()) == ".core" { 100 | if err := os.Remove(file.Name()); err != nil { 101 | return err 102 | } 103 | } 104 | } 105 | return nil 106 | }, 107 | false, 108 | } 109 | } 110 | 111 | func TestPledge(t *testing.T) { 112 | ExitsCorrectly("pledge", t) 113 | } 114 | -------------------------------------------------------------------------------- /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/gin-gonic/gin/binding/example/test.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: test.proto 3 | // DO NOT EDIT! 4 | 5 | /* 6 | Package example is a generated protocol buffer package. 7 | 8 | It is generated from these files: 9 | test.proto 10 | 11 | It has these top-level messages: 12 | Test 13 | */ 14 | package example 15 | 16 | import proto "github.com/golang/protobuf/proto" 17 | import math "math" 18 | 19 | // Reference imports to suppress errors if they are not otherwise used. 20 | var _ = proto.Marshal 21 | var _ = math.Inf 22 | 23 | type FOO int32 24 | 25 | const ( 26 | FOO_X FOO = 17 27 | ) 28 | 29 | var FOO_name = map[int32]string{ 30 | 17: "X", 31 | } 32 | var FOO_value = map[string]int32{ 33 | "X": 17, 34 | } 35 | 36 | func (x FOO) Enum() *FOO { 37 | p := new(FOO) 38 | *p = x 39 | return p 40 | } 41 | func (x FOO) String() string { 42 | return proto.EnumName(FOO_name, int32(x)) 43 | } 44 | func (x *FOO) UnmarshalJSON(data []byte) error { 45 | value, err := proto.UnmarshalJSONEnum(FOO_value, data, "FOO") 46 | if err != nil { 47 | return err 48 | } 49 | *x = FOO(value) 50 | return nil 51 | } 52 | 53 | type Test struct { 54 | Label *string `protobuf:"bytes,1,req,name=label" json:"label,omitempty"` 55 | Type *int32 `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"` 56 | Reps []int64 `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"` 57 | Optionalgroup *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup" json:"optionalgroup,omitempty"` 58 | XXX_unrecognized []byte `json:"-"` 59 | } 60 | 61 | func (m *Test) Reset() { *m = Test{} } 62 | func (m *Test) String() string { return proto.CompactTextString(m) } 63 | func (*Test) ProtoMessage() {} 64 | 65 | const Default_Test_Type int32 = 77 66 | 67 | func (m *Test) GetLabel() string { 68 | if m != nil && m.Label != nil { 69 | return *m.Label 70 | } 71 | return "" 72 | } 73 | 74 | func (m *Test) GetType() int32 { 75 | if m != nil && m.Type != nil { 76 | return *m.Type 77 | } 78 | return Default_Test_Type 79 | } 80 | 81 | func (m *Test) GetReps() []int64 { 82 | if m != nil { 83 | return m.Reps 84 | } 85 | return nil 86 | } 87 | 88 | func (m *Test) GetOptionalgroup() *Test_OptionalGroup { 89 | if m != nil { 90 | return m.Optionalgroup 91 | } 92 | return nil 93 | } 94 | 95 | type Test_OptionalGroup struct { 96 | RequiredField *string `protobuf:"bytes,5,req" json:"RequiredField,omitempty"` 97 | XXX_unrecognized []byte `json:"-"` 98 | } 99 | 100 | func (m *Test_OptionalGroup) Reset() { *m = Test_OptionalGroup{} } 101 | func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) } 102 | func (*Test_OptionalGroup) ProtoMessage() {} 103 | 104 | func (m *Test_OptionalGroup) GetRequiredField() string { 105 | if m != nil && m.RequiredField != nil { 106 | return *m.RequiredField 107 | } 108 | return "" 109 | } 110 | 111 | func init() { 112 | proto.RegisterEnum("example.FOO", FOO_name, FOO_value) 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/auth.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "crypto/subtle" 9 | "encoding/base64" 10 | "strconv" 11 | ) 12 | 13 | const AuthUserKey = "user" 14 | 15 | type ( 16 | Accounts map[string]string 17 | authPair struct { 18 | Value string 19 | User string 20 | } 21 | authPairs []authPair 22 | ) 23 | 24 | func (a authPairs) searchCredential(authValue string) (string, bool) { 25 | if len(authValue) == 0 { 26 | return "", false 27 | } 28 | for _, pair := range a { 29 | if pair.Value == authValue { 30 | return pair.User, true 31 | } 32 | } 33 | return "", false 34 | } 35 | 36 | // BasicAuthForRealm returns a Basic HTTP Authorization middleware. It takes as arguments a map[string]string where 37 | // the key is the user name and the value is the password, as well as the name of the Realm. 38 | // If the realm is empty, "Authorization Required" will be used by default. 39 | // (see http://tools.ietf.org/html/rfc2617#section-1.2) 40 | func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc { 41 | if realm == "" { 42 | realm = "Authorization Required" 43 | } 44 | realm = "Basic realm=" + strconv.Quote(realm) 45 | pairs := processAccounts(accounts) 46 | return func(c *Context) { 47 | // Search user in the slice of allowed credentials 48 | user, found := pairs.searchCredential(c.Request.Header.Get("Authorization")) 49 | if !found { 50 | // Credentials doesn't match, we return 401 and abort handlers chain. 51 | c.Header("WWW-Authenticate", realm) 52 | c.AbortWithStatus(401) 53 | } else { 54 | // The user credentials was found, set user's id to key AuthUserKey in this context, the userId can be read later using 55 | // c.MustGet(gin.AuthUserKey) 56 | c.Set(AuthUserKey, user) 57 | } 58 | } 59 | } 60 | 61 | // BasicAuth returns a Basic HTTP Authorization middleware. It takes as argument a map[string]string where 62 | // the key is the user name and the value is the password. 63 | func BasicAuth(accounts Accounts) HandlerFunc { 64 | return BasicAuthForRealm(accounts, "") 65 | } 66 | 67 | func processAccounts(accounts Accounts) authPairs { 68 | assert1(len(accounts) > 0, "Empty list of authorized credentials") 69 | pairs := make(authPairs, 0, len(accounts)) 70 | for user, password := range accounts { 71 | assert1(len(user) > 0, "User can not be empty") 72 | value := authorizationHeader(user, password) 73 | pairs = append(pairs, authPair{ 74 | Value: value, 75 | User: user, 76 | }) 77 | } 78 | return pairs 79 | } 80 | 81 | func authorizationHeader(user, password string) string { 82 | base := user + ":" + password 83 | return "Basic " + base64.StdEncoding.EncodeToString([]byte(base)) 84 | } 85 | 86 | func secureCompare(given, actual string) bool { 87 | if subtle.ConstantTimeEq(int32(len(given)), int32(len(actual))) == 1 { 88 | return subtle.ConstantTimeCompare([]byte(given), []byte(actual)) == 1 89 | } 90 | /* Securely compare actual to itself to keep constant time, but always return false */ 91 | return subtle.ConstantTimeCompare([]byte(actual), []byte(actual)) == 1 && false 92 | } 93 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/testdata/golden_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // Verify that the compiler output for test.proto is unchanged. 33 | 34 | package testdata 35 | 36 | import ( 37 | "crypto/sha1" 38 | "fmt" 39 | "io/ioutil" 40 | "os" 41 | "os/exec" 42 | "path/filepath" 43 | "testing" 44 | ) 45 | 46 | // sum returns in string form (for easy comparison) the SHA-1 hash of the named file. 47 | func sum(t *testing.T, name string) string { 48 | data, err := ioutil.ReadFile(name) 49 | if err != nil { 50 | t.Fatal(err) 51 | } 52 | t.Logf("sum(%q): length is %d", name, len(data)) 53 | hash := sha1.New() 54 | _, err = hash.Write(data) 55 | if err != nil { 56 | t.Fatal(err) 57 | } 58 | return fmt.Sprintf("% x", hash.Sum(nil)) 59 | } 60 | 61 | func run(t *testing.T, name string, args ...string) { 62 | cmd := exec.Command(name, args...) 63 | cmd.Stdin = os.Stdin 64 | cmd.Stdout = os.Stdout 65 | cmd.Stderr = os.Stderr 66 | err := cmd.Run() 67 | if err != nil { 68 | t.Fatal(err) 69 | } 70 | } 71 | 72 | func TestGolden(t *testing.T) { 73 | // Compute the original checksum. 74 | goldenSum := sum(t, "test.pb.go") 75 | // Run the proto compiler. 76 | run(t, "protoc", "--go_out="+os.TempDir(), "test.proto") 77 | newFile := filepath.Join(os.TempDir(), "test.pb.go") 78 | defer os.Remove(newFile) 79 | // Compute the new checksum. 80 | newSum := sum(t, newFile) 81 | // Verify 82 | if newSum != goldenSum { 83 | run(t, "diff", "-u", "test.pb.go", newFile) 84 | t.Fatal("Code generated by protoc-gen-go has changed; update test.pb.go") 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Julien Schmidt. All rights reserved. 2 | // Based on the path package, Copyright 2009 The Go Authors. 3 | // Use of this source code is governed by a BSD-style license that can be found 4 | // in the LICENSE file. 5 | 6 | package gin 7 | 8 | // CleanPath is the URL version of path.Clean, it returns a canonical URL path 9 | // for p, eliminating . and .. elements. 10 | // 11 | // The following rules are applied iteratively until no further processing can 12 | // be done: 13 | // 1. Replace multiple slashes with a single slash. 14 | // 2. Eliminate each . path name element (the current directory). 15 | // 3. Eliminate each inner .. path name element (the parent directory) 16 | // along with the non-.. element that precedes it. 17 | // 4. Eliminate .. elements that begin a rooted path: 18 | // that is, replace "/.." by "/" at the beginning of a path. 19 | // 20 | // If the result of this process is an empty string, "/" is returned 21 | func cleanPath(p string) string { 22 | // Turn empty string into "/" 23 | if p == "" { 24 | return "/" 25 | } 26 | 27 | n := len(p) 28 | var buf []byte 29 | 30 | // Invariants: 31 | // reading from path; r is index of next byte to process. 32 | // writing to buf; w is index of next byte to write. 33 | 34 | // path must start with '/' 35 | r := 1 36 | w := 1 37 | 38 | if p[0] != '/' { 39 | r = 0 40 | buf = make([]byte, n+1) 41 | buf[0] = '/' 42 | } 43 | 44 | trailing := n > 2 && p[n-1] == '/' 45 | 46 | // A bit more clunky without a 'lazybuf' like the path package, but the loop 47 | // gets completely inlined (bufApp). So in contrast to the path package this 48 | // loop has no expensive function calls (except 1x make) 49 | 50 | for r < n { 51 | switch { 52 | case p[r] == '/': 53 | // empty path element, trailing slash is added after the end 54 | r++ 55 | 56 | case p[r] == '.' && r+1 == n: 57 | trailing = true 58 | r++ 59 | 60 | case p[r] == '.' && p[r+1] == '/': 61 | // . element 62 | r++ 63 | 64 | case p[r] == '.' && p[r+1] == '.' && (r+2 == n || p[r+2] == '/'): 65 | // .. element: remove to last / 66 | r += 2 67 | 68 | if w > 1 { 69 | // can backtrack 70 | w-- 71 | 72 | if buf == nil { 73 | for w > 1 && p[w] != '/' { 74 | w-- 75 | } 76 | } else { 77 | for w > 1 && buf[w] != '/' { 78 | w-- 79 | } 80 | } 81 | } 82 | 83 | default: 84 | // real path element. 85 | // add slash if needed 86 | if w > 1 { 87 | bufApp(&buf, p, w, '/') 88 | w++ 89 | } 90 | 91 | // copy element 92 | for r < n && p[r] != '/' { 93 | bufApp(&buf, p, w, p[r]) 94 | w++ 95 | r++ 96 | } 97 | } 98 | } 99 | 100 | // re-append trailing slash 101 | if trailing && w > 1 { 102 | bufApp(&buf, p, w, '/') 103 | w++ 104 | } 105 | 106 | if buf == nil { 107 | return p[:w] 108 | } 109 | return string(buf[:w]) 110 | } 111 | 112 | // internal helper to lazily create a buffer if necessary 113 | func bufApp(buf *[]byte, s string, w int, c byte) { 114 | if *buf == nil { 115 | if s[w] == c { 116 | return 117 | } 118 | 119 | *buf = make([]byte, len(s)) 120 | copy(*buf, s[:w]) 121 | } 122 | (*buf)[w] = c 123 | } 124 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/README.md: -------------------------------------------------------------------------------- 1 | # YAML support for the Go language 2 | 3 | Introduction 4 | ------------ 5 | 6 | The yaml package enables Go programs to comfortably encode and decode YAML 7 | values. It was developed within [Canonical](https://www.canonical.com) as 8 | part of the [juju](https://juju.ubuntu.com) project, and is based on a 9 | pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) 10 | C library to parse and generate YAML data quickly and reliably. 11 | 12 | Compatibility 13 | ------------- 14 | 15 | The yaml package supports most of YAML 1.1 and 1.2, including support for 16 | anchors, tags, map merging, etc. Multi-document unmarshalling is not yet 17 | implemented, and base-60 floats from YAML 1.1 are purposefully not 18 | supported since they're a poor design and are gone in YAML 1.2. 19 | 20 | Installation and usage 21 | ---------------------- 22 | 23 | The import path for the package is *gopkg.in/yaml.v2*. 24 | 25 | To install it, run: 26 | 27 | go get gopkg.in/yaml.v2 28 | 29 | API documentation 30 | ----------------- 31 | 32 | If opened in a browser, the import path itself leads to the API documentation: 33 | 34 | * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) 35 | 36 | API stability 37 | ------------- 38 | 39 | The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in). 40 | 41 | 42 | License 43 | ------- 44 | 45 | The yaml package is licensed under the LGPL with an exception that allows it to be linked statically. Please see the LICENSE file for details. 46 | 47 | 48 | Example 49 | ------- 50 | 51 | ```Go 52 | package main 53 | 54 | import ( 55 | "fmt" 56 | "log" 57 | 58 | "gopkg.in/yaml.v2" 59 | ) 60 | 61 | var data = ` 62 | a: Easy! 63 | b: 64 | c: 2 65 | d: [3, 4] 66 | ` 67 | 68 | type T struct { 69 | A string 70 | B struct { 71 | RenamedC int `yaml:"c"` 72 | D []int `yaml:",flow"` 73 | } 74 | } 75 | 76 | func main() { 77 | t := T{} 78 | 79 | err := yaml.Unmarshal([]byte(data), &t) 80 | if err != nil { 81 | log.Fatalf("error: %v", err) 82 | } 83 | fmt.Printf("--- t:\n%v\n\n", t) 84 | 85 | d, err := yaml.Marshal(&t) 86 | if err != nil { 87 | log.Fatalf("error: %v", err) 88 | } 89 | fmt.Printf("--- t dump:\n%s\n\n", string(d)) 90 | 91 | m := make(map[interface{}]interface{}) 92 | 93 | err = yaml.Unmarshal([]byte(data), &m) 94 | if err != nil { 95 | log.Fatalf("error: %v", err) 96 | } 97 | fmt.Printf("--- m:\n%v\n\n", m) 98 | 99 | d, err = yaml.Marshal(&m) 100 | if err != nil { 101 | log.Fatalf("error: %v", err) 102 | } 103 | fmt.Printf("--- m dump:\n%s\n\n", string(d)) 104 | } 105 | ``` 106 | 107 | This example will generate the following output: 108 | 109 | ``` 110 | --- t: 111 | {Easy! {2 [3 4]}} 112 | 113 | --- t dump: 114 | a: Easy! 115 | b: 116 | c: 2 117 | d: [3, 4] 118 | 119 | 120 | --- m: 121 | map[a:Easy! b:map[c:2 d:[3 4]]] 122 | 123 | --- m dump: 124 | a: Easy! 125 | b: 126 | c: 2 127 | d: 128 | - 3 129 | - 4 130 | ``` 131 | 132 | -------------------------------------------------------------------------------- /vendor/vendor.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "", 3 | "ignore": "", 4 | "package": [ 5 | { 6 | "checksumSHA1": "c5Pru79r8EEtMlIeQ+byw51AeN0=", 7 | "path": "github.com/gin-gonic/gin", 8 | "revision": "d5b353c5d5a560322e6d96121c814115562501f7", 9 | "revisionTime": "2017-04-28T10:59:23Z" 10 | }, 11 | { 12 | "checksumSHA1": "uJ5EaItCWkwh8Cb8r/08HGV6tso=", 13 | "path": "github.com/gin-gonic/gin/binding", 14 | "revision": "d5b353c5d5a560322e6d96121c814115562501f7", 15 | "revisionTime": "2017-04-28T10:59:23Z" 16 | }, 17 | { 18 | "checksumSHA1": "v+H/cD17kjyZLCVSVc4hVle+Ydw=", 19 | "path": "github.com/gin-gonic/gin/binding/example", 20 | "revision": "d5b353c5d5a560322e6d96121c814115562501f7", 21 | "revisionTime": "2017-04-28T10:59:23Z" 22 | }, 23 | { 24 | "checksumSHA1": "pcOdY6zOlIYt+MBeMcNBXm/7r4w=", 25 | "path": "github.com/gin-gonic/gin/render", 26 | "revision": "d5b353c5d5a560322e6d96121c814115562501f7", 27 | "revisionTime": "2017-04-28T10:59:23Z" 28 | }, 29 | { 30 | "checksumSHA1": "jeLwJeaFXe4ew+aTxptuYa80kzs=", 31 | "path": "github.com/golang/protobuf/proto", 32 | "revision": "9e6977f30c91c78396e719e164e57f9287fff42c", 33 | "revisionTime": "2016-05-24T19:56:25Z" 34 | }, 35 | { 36 | "checksumSHA1": "FAcShrpHCr+JlEzLtrlXb2509ng=", 37 | "path": "github.com/golang/protobuf/proto/proto3_proto", 38 | "revision": "9e6977f30c91c78396e719e164e57f9287fff42c", 39 | "revisionTime": "2016-05-24T19:56:25Z" 40 | }, 41 | { 42 | "checksumSHA1": "CVWIduKNqEO98FJM+Dnl5t/1OhY=", 43 | "path": "github.com/golang/protobuf/proto/testdata", 44 | "revision": "9e6977f30c91c78396e719e164e57f9287fff42c", 45 | "revisionTime": "2016-05-24T19:56:25Z" 46 | }, 47 | { 48 | "checksumSHA1": "ziJ4U3fMgzYUaflqefqATULDFv0=", 49 | "path": "github.com/golang/protobuf/ptypes/any", 50 | "revision": "9e6977f30c91c78396e719e164e57f9287fff42c", 51 | "revisionTime": "2016-05-24T19:56:25Z" 52 | }, 53 | { 54 | "checksumSHA1": "MkWZiVGFCx8xuyIFygL7bOvKK2g=", 55 | "path": "github.com/manucorporat/sse", 56 | "revision": "ee05b128a739a0fb76c7ebd3ae4810c1de808d6d", 57 | "revisionTime": "2016-01-26T18:01:36Z" 58 | }, 59 | { 60 | "checksumSHA1": "cAY8WWlvwXakO9nUpQbqNW13JkI=", 61 | "path": "github.com/mattn/go-isatty", 62 | "revision": "fc9e8d8ef48496124e79ae0df75490096eccf6fe", 63 | "revisionTime": "2017-03-22T23:44:13Z" 64 | }, 65 | { 66 | "checksumSHA1": "ujkdYz/AOSZ4dVskaUGW9g/V/dM=", 67 | "path": "golang.org/x/net/context", 68 | "revision": "ddf80d0970594e2e4cccf5a98861cad3d9eaa4cd", 69 | "revisionTime": "2017-06-14T13:40:53Z" 70 | }, 71 | { 72 | "checksumSHA1": "mPnNSOjRqLdZ9dO/KI0EC1Z03nE=", 73 | "path": "golang.org/x/sys/unix", 74 | "revision": "0b25a408a50076fbbcae6b7ac0ea5fbb0b085e79", 75 | "revisionTime": "2017-06-08T11:43:49Z" 76 | }, 77 | { 78 | "checksumSHA1": "24wxwYO57BWvjPPSmCmWNFmmkv8=", 79 | "path": "gopkg.in/go-playground/validator.v8", 80 | "revision": "5f57d2222ad794d0dffb07e664ea05e2ee07d60c", 81 | "revisionTime": "2016-07-18T13:41:25Z" 82 | }, 83 | { 84 | "checksumSHA1": "jOGdm8IZTAHZNv+6KIiXv0nloBM=", 85 | "path": "gopkg.in/yaml.v2", 86 | "revision": "e4d366fc3c7938e2958e662b4258c7a89e1f0e3e", 87 | "revisionTime": "2016-07-15T03:37:55Z" 88 | } 89 | ], 90 | "rootPath": "github.com/sent-hil/sfsbook-1" 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/errors_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "encoding/json" 9 | "errors" 10 | "testing" 11 | 12 | "github.com/stretchr/testify/assert" 13 | ) 14 | 15 | func TestError(t *testing.T) { 16 | baseError := errors.New("test error") 17 | err := &Error{ 18 | Err: baseError, 19 | Type: ErrorTypePrivate, 20 | } 21 | assert.Equal(t, err.Error(), baseError.Error()) 22 | assert.Equal(t, err.JSON(), H{"error": baseError.Error()}) 23 | 24 | assert.Equal(t, err.SetType(ErrorTypePublic), err) 25 | assert.Equal(t, err.Type, ErrorTypePublic) 26 | 27 | assert.Equal(t, err.SetMeta("some data"), err) 28 | assert.Equal(t, err.Meta, "some data") 29 | assert.Equal(t, err.JSON(), H{ 30 | "error": baseError.Error(), 31 | "meta": "some data", 32 | }) 33 | 34 | jsonBytes, _ := json.Marshal(err) 35 | assert.Equal(t, string(jsonBytes), "{\"error\":\"test error\",\"meta\":\"some data\"}") 36 | 37 | err.SetMeta(H{ 38 | "status": "200", 39 | "data": "some data", 40 | }) 41 | assert.Equal(t, err.JSON(), H{ 42 | "error": baseError.Error(), 43 | "status": "200", 44 | "data": "some data", 45 | }) 46 | 47 | err.SetMeta(H{ 48 | "error": "custom error", 49 | "status": "200", 50 | "data": "some data", 51 | }) 52 | assert.Equal(t, err.JSON(), H{ 53 | "error": "custom error", 54 | "status": "200", 55 | "data": "some data", 56 | }) 57 | } 58 | 59 | func TestErrorSlice(t *testing.T) { 60 | errs := errorMsgs{ 61 | {Err: errors.New("first"), Type: ErrorTypePrivate}, 62 | {Err: errors.New("second"), Type: ErrorTypePrivate, Meta: "some data"}, 63 | {Err: errors.New("third"), Type: ErrorTypePublic, Meta: H{"status": "400"}}, 64 | } 65 | 66 | assert.Equal(t, errs, errs.ByType(ErrorTypeAny)) 67 | assert.Equal(t, errs.Last().Error(), "third") 68 | assert.Equal(t, errs.Errors(), []string{"first", "second", "third"}) 69 | assert.Equal(t, errs.ByType(ErrorTypePublic).Errors(), []string{"third"}) 70 | assert.Equal(t, errs.ByType(ErrorTypePrivate).Errors(), []string{"first", "second"}) 71 | assert.Equal(t, errs.ByType(ErrorTypePublic|ErrorTypePrivate).Errors(), []string{"first", "second", "third"}) 72 | assert.Empty(t, errs.ByType(ErrorTypeBind)) 73 | assert.Empty(t, errs.ByType(ErrorTypeBind).String()) 74 | 75 | assert.Equal(t, errs.String(), `Error #01: first 76 | Error #02: second 77 | Meta: some data 78 | Error #03: third 79 | Meta: map[status:400] 80 | `) 81 | assert.Equal(t, errs.JSON(), []interface{}{ 82 | H{"error": "first"}, 83 | H{"error": "second", "meta": "some data"}, 84 | H{"error": "third", "status": "400"}, 85 | }) 86 | jsonBytes, _ := json.Marshal(errs) 87 | assert.Equal(t, string(jsonBytes), "[{\"error\":\"first\"},{\"error\":\"second\",\"meta\":\"some data\"},{\"error\":\"third\",\"status\":\"400\"}]") 88 | errs = errorMsgs{ 89 | {Err: errors.New("first"), Type: ErrorTypePrivate}, 90 | } 91 | assert.Equal(t, errs.JSON(), H{"error": "first"}) 92 | jsonBytes, _ = json.Marshal(errs) 93 | assert.Equal(t, string(jsonBytes), "{\"error\":\"first\"}") 94 | 95 | errs = errorMsgs{} 96 | assert.Nil(t, errs.Last()) 97 | assert.Nil(t, errs.JSON()) 98 | assert.Empty(t, errs.String()) 99 | } 100 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/recovery.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | "io" 11 | "io/ioutil" 12 | "log" 13 | "net/http/httputil" 14 | "runtime" 15 | ) 16 | 17 | var ( 18 | dunno = []byte("???") 19 | centerDot = []byte("·") 20 | dot = []byte(".") 21 | slash = []byte("/") 22 | ) 23 | 24 | // Recovery returns a middleware that recovers from any panics and writes a 500 if there was one. 25 | func Recovery() HandlerFunc { 26 | return RecoveryWithWriter(DefaultErrorWriter) 27 | } 28 | 29 | func RecoveryWithWriter(out io.Writer) HandlerFunc { 30 | var logger *log.Logger 31 | if out != nil { 32 | logger = log.New(out, "\n\n\x1b[31m", log.LstdFlags) 33 | } 34 | return func(c *Context) { 35 | defer func() { 36 | if err := recover(); err != nil { 37 | if logger != nil { 38 | stack := stack(3) 39 | httprequest, _ := httputil.DumpRequest(c.Request, false) 40 | logger.Printf("[Recovery] panic recovered:\n%s\n%s\n%s%s", string(httprequest), err, stack, reset) 41 | } 42 | c.AbortWithStatus(500) 43 | } 44 | }() 45 | c.Next() 46 | } 47 | } 48 | 49 | // stack returns a nicely formated stack frame, skipping skip frames 50 | func stack(skip int) []byte { 51 | buf := new(bytes.Buffer) // the returned data 52 | // As we loop, we open files and read them. These variables record the currently 53 | // loaded file. 54 | var lines [][]byte 55 | var lastFile string 56 | for i := skip; ; i++ { // Skip the expected number of frames 57 | pc, file, line, ok := runtime.Caller(i) 58 | if !ok { 59 | break 60 | } 61 | // Print this much at least. If we can't find the source, it won't show. 62 | fmt.Fprintf(buf, "%s:%d (0x%x)\n", file, line, pc) 63 | if file != lastFile { 64 | data, err := ioutil.ReadFile(file) 65 | if err != nil { 66 | continue 67 | } 68 | lines = bytes.Split(data, []byte{'\n'}) 69 | lastFile = file 70 | } 71 | fmt.Fprintf(buf, "\t%s: %s\n", function(pc), source(lines, line)) 72 | } 73 | return buf.Bytes() 74 | } 75 | 76 | // source returns a space-trimmed slice of the n'th line. 77 | func source(lines [][]byte, n int) []byte { 78 | n-- // in stack trace, lines are 1-indexed but our array is 0-indexed 79 | if n < 0 || n >= len(lines) { 80 | return dunno 81 | } 82 | return bytes.TrimSpace(lines[n]) 83 | } 84 | 85 | // function returns, if possible, the name of the function containing the PC. 86 | func function(pc uintptr) []byte { 87 | fn := runtime.FuncForPC(pc) 88 | if fn == nil { 89 | return dunno 90 | } 91 | name := []byte(fn.Name()) 92 | // The name includes the path name to the package, which is unnecessary 93 | // since the file name is already included. Plus, it has center dots. 94 | // That is, we see 95 | // runtime/debug.*T·ptrmethod 96 | // and want 97 | // *T.ptrmethod 98 | // Also the package path might contains dot (e.g. code.google.com/...), 99 | // so first eliminate the path prefix 100 | if lastslash := bytes.LastIndex(name, slash); lastslash >= 0 { 101 | name = name[lastslash+1:] 102 | } 103 | if period := bytes.Index(name, dot); period >= 0 { 104 | name = name[period+1:] 105 | } 106 | name = bytes.Replace(name, centerDot, dot, -1) 107 | return name 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/response_writer_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "net/http" 9 | "net/http/httptest" 10 | "testing" 11 | 12 | "github.com/stretchr/testify/assert" 13 | ) 14 | 15 | // TODO 16 | // func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { 17 | // func (w *responseWriter) CloseNotify() <-chan bool { 18 | // func (w *responseWriter) Flush() { 19 | 20 | var _ ResponseWriter = &responseWriter{} 21 | var _ http.ResponseWriter = &responseWriter{} 22 | var _ http.ResponseWriter = ResponseWriter(&responseWriter{}) 23 | var _ http.Hijacker = ResponseWriter(&responseWriter{}) 24 | var _ http.Flusher = ResponseWriter(&responseWriter{}) 25 | var _ http.CloseNotifier = ResponseWriter(&responseWriter{}) 26 | 27 | func init() { 28 | SetMode(TestMode) 29 | } 30 | 31 | func TestResponseWriterReset(t *testing.T) { 32 | testWritter := httptest.NewRecorder() 33 | writer := &responseWriter{} 34 | var w ResponseWriter = writer 35 | 36 | writer.reset(testWritter) 37 | assert.Equal(t, writer.size, -1) 38 | assert.Equal(t, writer.status, 200) 39 | assert.Equal(t, writer.ResponseWriter, testWritter) 40 | assert.Equal(t, w.Size(), -1) 41 | assert.Equal(t, w.Status(), 200) 42 | assert.False(t, w.Written()) 43 | } 44 | 45 | func TestResponseWriterWriteHeader(t *testing.T) { 46 | testWritter := httptest.NewRecorder() 47 | writer := &responseWriter{} 48 | writer.reset(testWritter) 49 | w := ResponseWriter(writer) 50 | 51 | w.WriteHeader(300) 52 | assert.False(t, w.Written()) 53 | assert.Equal(t, w.Status(), 300) 54 | assert.NotEqual(t, testWritter.Code, 300) 55 | 56 | w.WriteHeader(-1) 57 | assert.Equal(t, w.Status(), 300) 58 | } 59 | 60 | func TestResponseWriterWriteHeadersNow(t *testing.T) { 61 | testWritter := httptest.NewRecorder() 62 | writer := &responseWriter{} 63 | writer.reset(testWritter) 64 | w := ResponseWriter(writer) 65 | 66 | w.WriteHeader(300) 67 | w.WriteHeaderNow() 68 | 69 | assert.True(t, w.Written()) 70 | assert.Equal(t, w.Size(), 0) 71 | assert.Equal(t, testWritter.Code, 300) 72 | 73 | writer.size = 10 74 | w.WriteHeaderNow() 75 | assert.Equal(t, w.Size(), 10) 76 | } 77 | 78 | func TestResponseWriterWrite(t *testing.T) { 79 | testWritter := httptest.NewRecorder() 80 | writer := &responseWriter{} 81 | writer.reset(testWritter) 82 | w := ResponseWriter(writer) 83 | 84 | n, err := w.Write([]byte("hola")) 85 | assert.Equal(t, n, 4) 86 | assert.Equal(t, w.Size(), 4) 87 | assert.Equal(t, w.Status(), 200) 88 | assert.Equal(t, testWritter.Code, 200) 89 | assert.Equal(t, testWritter.Body.String(), "hola") 90 | assert.NoError(t, err) 91 | 92 | n, err = w.Write([]byte(" adios")) 93 | assert.Equal(t, n, 6) 94 | assert.Equal(t, w.Size(), 10) 95 | assert.Equal(t, testWritter.Body.String(), "hola adios") 96 | assert.NoError(t, err) 97 | } 98 | 99 | func TestResponseWriterHijack(t *testing.T) { 100 | testWritter := httptest.NewRecorder() 101 | writer := &responseWriter{} 102 | writer.reset(testWritter) 103 | w := ResponseWriter(writer) 104 | 105 | assert.Panics(t, func() { 106 | w.Hijack() 107 | }) 108 | assert.True(t, w.Written()) 109 | 110 | assert.Panics(t, func() { 111 | w.CloseNotify() 112 | }) 113 | 114 | w.Flush() 115 | } 116 | --------------------------------------------------------------------------------