├── Gopkg.lock
├── Gopkg.toml
├── README.md
├── cmd
└── frontend
│ └── main.go
├── config
├── config.go
└── config.json
├── entries.go
├── handler
├── entries.go
└── handler.go
├── server
├── entries.go
├── server.go
└── views
│ ├── entries_all.html
│ └── entries_new.html
├── storage
├── mysql
│ ├── entries.go
│ └── mysql.go
└── storage.go
└── vendor
├── github.com
├── dgrijalva
│ └── jwt-go
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── LICENSE
│ │ ├── MIGRATION_GUIDE.md
│ │ ├── README.md
│ │ ├── VERSION_HISTORY.md
│ │ ├── claims.go
│ │ ├── doc.go
│ │ ├── ecdsa.go
│ │ ├── ecdsa_utils.go
│ │ ├── errors.go
│ │ ├── hmac.go
│ │ ├── map_claims.go
│ │ ├── none.go
│ │ ├── parser.go
│ │ ├── rsa.go
│ │ ├── rsa_pss.go
│ │ ├── rsa_utils.go
│ │ ├── signing_method.go
│ │ └── token.go
├── go-sql-driver
│ └── mysql
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── AUTHORS
│ │ ├── CHANGELOG.md
│ │ ├── CONTRIBUTING.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── appengine.go
│ │ ├── auth.go
│ │ ├── buffer.go
│ │ ├── collations.go
│ │ ├── connection.go
│ │ ├── connection_go18.go
│ │ ├── const.go
│ │ ├── driver.go
│ │ ├── dsn.go
│ │ ├── errors.go
│ │ ├── fields.go
│ │ ├── infile.go
│ │ ├── packets.go
│ │ ├── result.go
│ │ ├── rows.go
│ │ ├── statement.go
│ │ ├── transaction.go
│ │ ├── utils.go
│ │ ├── utils_go17.go
│ │ └── utils_go18.go
├── jinzhu
│ ├── gorm
│ │ ├── .codeclimate.yml
│ │ ├── .gitignore
│ │ ├── License
│ │ ├── README.md
│ │ ├── association.go
│ │ ├── callback.go
│ │ ├── callback_create.go
│ │ ├── callback_delete.go
│ │ ├── callback_query.go
│ │ ├── callback_query_preload.go
│ │ ├── callback_row_query.go
│ │ ├── callback_save.go
│ │ ├── callback_update.go
│ │ ├── dialect.go
│ │ ├── dialect_common.go
│ │ ├── dialect_mysql.go
│ │ ├── dialect_postgres.go
│ │ ├── dialect_sqlite3.go
│ │ ├── dialects
│ │ │ └── mysql
│ │ │ │ └── mysql.go
│ │ ├── docker-compose.yml
│ │ ├── errors.go
│ │ ├── field.go
│ │ ├── interface.go
│ │ ├── join_table_handler.go
│ │ ├── logger.go
│ │ ├── main.go
│ │ ├── model.go
│ │ ├── model_struct.go
│ │ ├── scope.go
│ │ ├── search.go
│ │ ├── test_all.sh
│ │ ├── utils.go
│ │ └── wercker.yml
│ └── inflection
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── inflections.go
│ │ └── wercker.yml
├── labstack
│ ├── echo
│ │ ├── .editorconfig
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── Gopkg.lock
│ │ ├── Gopkg.toml
│ │ ├── LICENSE
│ │ ├── Makefile
│ │ ├── README.md
│ │ ├── bind.go
│ │ ├── context.go
│ │ ├── echo.go
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── group.go
│ │ ├── log.go
│ │ ├── middleware
│ │ │ ├── basic_auth.go
│ │ │ ├── body_dump.go
│ │ │ ├── body_limit.go
│ │ │ ├── compress.go
│ │ │ ├── cors.go
│ │ │ ├── csrf.go
│ │ │ ├── jwt.go
│ │ │ ├── key_auth.go
│ │ │ ├── logger.go
│ │ │ ├── method_override.go
│ │ │ ├── middleware.go
│ │ │ ├── proxy.go
│ │ │ ├── recover.go
│ │ │ ├── redirect.go
│ │ │ ├── request_id.go
│ │ │ ├── rewrite.go
│ │ │ ├── secure.go
│ │ │ ├── slash.go
│ │ │ └── static.go
│ │ ├── response.go
│ │ └── router.go
│ └── gommon
│ │ ├── LICENSE
│ │ ├── bytes
│ │ ├── README.md
│ │ └── bytes.go
│ │ ├── color
│ │ ├── README.md
│ │ └── color.go
│ │ ├── log
│ │ ├── README.md
│ │ ├── color.go
│ │ ├── log.go
│ │ └── white.go
│ │ └── random
│ │ └── random.go
├── mattn
│ ├── go-colorable
│ │ ├── .travis.yml
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── colorable_appengine.go
│ │ ├── colorable_others.go
│ │ ├── colorable_windows.go
│ │ └── noncolorable.go
│ └── go-isatty
│ │ ├── .travis.yml
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── doc.go
│ │ ├── isatty_appengine.go
│ │ ├── isatty_bsd.go
│ │ ├── isatty_linux.go
│ │ ├── isatty_linux_ppc64x.go
│ │ ├── isatty_others.go
│ │ ├── isatty_solaris.go
│ │ └── isatty_windows.go
└── valyala
│ ├── bytebufferpool
│ ├── .travis.yml
│ ├── LICENSE
│ ├── README.md
│ ├── bytebuffer.go
│ ├── doc.go
│ └── pool.go
│ └── fasttemplate
│ ├── LICENSE
│ ├── README.md
│ ├── template.go
│ ├── unsafe.go
│ └── unsafe_gae.go
├── golang.org
└── x
│ ├── crypto
│ ├── AUTHORS
│ ├── CONTRIBUTORS
│ ├── LICENSE
│ ├── PATENTS
│ └── acme
│ │ ├── acme.go
│ │ ├── autocert
│ │ ├── autocert.go
│ │ ├── cache.go
│ │ ├── listener.go
│ │ └── renewal.go
│ │ ├── http.go
│ │ ├── jws.go
│ │ └── types.go
│ └── sys
│ ├── AUTHORS
│ ├── CONTRIBUTORS
│ ├── LICENSE
│ ├── PATENTS
│ └── unix
│ ├── .gitignore
│ ├── README.md
│ ├── affinity_linux.go
│ ├── aliases.go
│ ├── asm_aix_ppc64.s
│ ├── asm_darwin_386.s
│ ├── asm_darwin_amd64.s
│ ├── asm_darwin_arm.s
│ ├── asm_darwin_arm64.s
│ ├── asm_dragonfly_amd64.s
│ ├── asm_freebsd_386.s
│ ├── asm_freebsd_amd64.s
│ ├── asm_freebsd_arm.s
│ ├── asm_linux_386.s
│ ├── asm_linux_amd64.s
│ ├── asm_linux_arm.s
│ ├── asm_linux_arm64.s
│ ├── asm_linux_mips64x.s
│ ├── asm_linux_mipsx.s
│ ├── asm_linux_ppc64x.s
│ ├── asm_linux_s390x.s
│ ├── asm_netbsd_386.s
│ ├── asm_netbsd_amd64.s
│ ├── asm_netbsd_arm.s
│ ├── asm_openbsd_386.s
│ ├── asm_openbsd_amd64.s
│ ├── asm_openbsd_arm.s
│ ├── asm_solaris_amd64.s
│ ├── bluetooth_linux.go
│ ├── cap_freebsd.go
│ ├── constants.go
│ ├── dev_aix_ppc.go
│ ├── dev_aix_ppc64.go
│ ├── dev_darwin.go
│ ├── dev_dragonfly.go
│ ├── dev_freebsd.go
│ ├── dev_linux.go
│ ├── dev_netbsd.go
│ ├── dev_openbsd.go
│ ├── dirent.go
│ ├── endian_big.go
│ ├── endian_little.go
│ ├── env_unix.go
│ ├── errors_freebsd_386.go
│ ├── errors_freebsd_amd64.go
│ ├── errors_freebsd_arm.go
│ ├── fcntl.go
│ ├── fcntl_linux_32bit.go
│ ├── gccgo.go
│ ├── gccgo_c.c
│ ├── gccgo_linux_amd64.go
│ ├── ioctl.go
│ ├── mkall.sh
│ ├── mkerrors.sh
│ ├── mkpost.go
│ ├── mksyscall.pl
│ ├── mksyscall_aix_ppc.pl
│ ├── mksyscall_aix_ppc64.pl
│ ├── mksyscall_solaris.pl
│ ├── mksysctl_openbsd.pl
│ ├── mksysnum_darwin.pl
│ ├── mksysnum_dragonfly.pl
│ ├── mksysnum_freebsd.pl
│ ├── mksysnum_netbsd.pl
│ ├── mksysnum_openbsd.pl
│ ├── openbsd_pledge.go
│ ├── openbsd_unveil.go
│ ├── pagesize_unix.go
│ ├── race.go
│ ├── race0.go
│ ├── sockcmsg_linux.go
│ ├── sockcmsg_unix.go
│ ├── str.go
│ ├── syscall.go
│ ├── syscall_aix.go
│ ├── syscall_aix_ppc.go
│ ├── syscall_aix_ppc64.go
│ ├── syscall_bsd.go
│ ├── syscall_darwin.go
│ ├── syscall_darwin_386.go
│ ├── syscall_darwin_amd64.go
│ ├── syscall_darwin_arm.go
│ ├── syscall_darwin_arm64.go
│ ├── syscall_dragonfly.go
│ ├── syscall_dragonfly_amd64.go
│ ├── syscall_freebsd.go
│ ├── syscall_freebsd_386.go
│ ├── syscall_freebsd_amd64.go
│ ├── syscall_freebsd_arm.go
│ ├── syscall_linux.go
│ ├── syscall_linux_386.go
│ ├── syscall_linux_amd64.go
│ ├── syscall_linux_amd64_gc.go
│ ├── syscall_linux_arm.go
│ ├── syscall_linux_arm64.go
│ ├── syscall_linux_gc.go
│ ├── syscall_linux_gc_386.go
│ ├── syscall_linux_gccgo_386.go
│ ├── syscall_linux_gccgo_arm.go
│ ├── syscall_linux_mips64x.go
│ ├── syscall_linux_mipsx.go
│ ├── syscall_linux_ppc64x.go
│ ├── syscall_linux_riscv64.go
│ ├── syscall_linux_s390x.go
│ ├── syscall_linux_sparc64.go
│ ├── syscall_netbsd.go
│ ├── syscall_netbsd_386.go
│ ├── syscall_netbsd_amd64.go
│ ├── syscall_netbsd_arm.go
│ ├── syscall_openbsd.go
│ ├── syscall_openbsd_386.go
│ ├── syscall_openbsd_amd64.go
│ ├── syscall_openbsd_arm.go
│ ├── syscall_solaris.go
│ ├── syscall_solaris_amd64.go
│ ├── syscall_unix.go
│ ├── syscall_unix_gc.go
│ ├── timestruct.go
│ ├── types_aix.go
│ ├── types_darwin.go
│ ├── types_dragonfly.go
│ ├── types_freebsd.go
│ ├── types_netbsd.go
│ ├── types_openbsd.go
│ ├── types_solaris.go
│ ├── xattr_bsd.go
│ ├── zerrors_aix_ppc.go
│ ├── zerrors_aix_ppc64.go
│ ├── zerrors_darwin_386.go
│ ├── zerrors_darwin_amd64.go
│ ├── zerrors_darwin_arm.go
│ ├── zerrors_darwin_arm64.go
│ ├── zerrors_dragonfly_amd64.go
│ ├── zerrors_freebsd_386.go
│ ├── zerrors_freebsd_amd64.go
│ ├── zerrors_freebsd_arm.go
│ ├── zerrors_linux_386.go
│ ├── zerrors_linux_amd64.go
│ ├── zerrors_linux_arm.go
│ ├── zerrors_linux_arm64.go
│ ├── zerrors_linux_mips.go
│ ├── zerrors_linux_mips64.go
│ ├── zerrors_linux_mips64le.go
│ ├── zerrors_linux_mipsle.go
│ ├── zerrors_linux_ppc64.go
│ ├── zerrors_linux_ppc64le.go
│ ├── zerrors_linux_riscv64.go
│ ├── zerrors_linux_s390x.go
│ ├── zerrors_linux_sparc64.go
│ ├── zerrors_netbsd_386.go
│ ├── zerrors_netbsd_amd64.go
│ ├── zerrors_netbsd_arm.go
│ ├── zerrors_openbsd_386.go
│ ├── zerrors_openbsd_amd64.go
│ ├── zerrors_openbsd_arm.go
│ ├── zerrors_solaris_amd64.go
│ ├── zptrace386_linux.go
│ ├── zptracearm_linux.go
│ ├── zptracemips_linux.go
│ ├── zptracemipsle_linux.go
│ ├── zsyscall_aix_ppc.go
│ ├── zsyscall_aix_ppc64.go
│ ├── zsyscall_aix_ppc64_gc.go
│ ├── zsyscall_aix_ppc64_gccgo.go
│ ├── zsyscall_darwin_386.go
│ ├── zsyscall_darwin_amd64.go
│ ├── zsyscall_darwin_arm.go
│ ├── zsyscall_darwin_arm64.go
│ ├── zsyscall_dragonfly_amd64.go
│ ├── zsyscall_freebsd_386.go
│ ├── zsyscall_freebsd_amd64.go
│ ├── zsyscall_freebsd_arm.go
│ ├── zsyscall_linux_386.go
│ ├── zsyscall_linux_amd64.go
│ ├── zsyscall_linux_arm.go
│ ├── zsyscall_linux_arm64.go
│ ├── zsyscall_linux_mips.go
│ ├── zsyscall_linux_mips64.go
│ ├── zsyscall_linux_mips64le.go
│ ├── zsyscall_linux_mipsle.go
│ ├── zsyscall_linux_ppc64.go
│ ├── zsyscall_linux_ppc64le.go
│ ├── zsyscall_linux_riscv64.go
│ ├── zsyscall_linux_s390x.go
│ ├── zsyscall_linux_sparc64.go
│ ├── zsyscall_netbsd_386.go
│ ├── zsyscall_netbsd_amd64.go
│ ├── zsyscall_netbsd_arm.go
│ ├── zsyscall_openbsd_386.go
│ ├── zsyscall_openbsd_amd64.go
│ ├── zsyscall_openbsd_arm.go
│ ├── zsyscall_solaris_amd64.go
│ ├── zsysctl_openbsd_386.go
│ ├── zsysctl_openbsd_amd64.go
│ ├── zsysctl_openbsd_arm.go
│ ├── zsysnum_darwin_386.go
│ ├── zsysnum_darwin_amd64.go
│ ├── zsysnum_darwin_arm.go
│ ├── zsysnum_darwin_arm64.go
│ ├── zsysnum_dragonfly_amd64.go
│ ├── zsysnum_freebsd_386.go
│ ├── zsysnum_freebsd_amd64.go
│ ├── zsysnum_freebsd_arm.go
│ ├── zsysnum_linux_386.go
│ ├── zsysnum_linux_amd64.go
│ ├── zsysnum_linux_arm.go
│ ├── zsysnum_linux_arm64.go
│ ├── zsysnum_linux_mips.go
│ ├── zsysnum_linux_mips64.go
│ ├── zsysnum_linux_mips64le.go
│ ├── zsysnum_linux_mipsle.go
│ ├── zsysnum_linux_ppc64.go
│ ├── zsysnum_linux_ppc64le.go
│ ├── zsysnum_linux_riscv64.go
│ ├── zsysnum_linux_s390x.go
│ ├── zsysnum_linux_sparc64.go
│ ├── zsysnum_netbsd_386.go
│ ├── zsysnum_netbsd_amd64.go
│ ├── zsysnum_netbsd_arm.go
│ ├── zsysnum_openbsd_386.go
│ ├── zsysnum_openbsd_amd64.go
│ ├── zsysnum_openbsd_arm.go
│ ├── ztypes_aix_ppc.go
│ ├── ztypes_aix_ppc64.go
│ ├── ztypes_darwin_386.go
│ ├── ztypes_darwin_amd64.go
│ ├── ztypes_darwin_arm.go
│ ├── ztypes_darwin_arm64.go
│ ├── ztypes_dragonfly_amd64.go
│ ├── ztypes_freebsd_386.go
│ ├── ztypes_freebsd_amd64.go
│ ├── ztypes_freebsd_arm.go
│ ├── ztypes_linux_386.go
│ ├── ztypes_linux_amd64.go
│ ├── ztypes_linux_arm.go
│ ├── ztypes_linux_arm64.go
│ ├── ztypes_linux_mips.go
│ ├── ztypes_linux_mips64.go
│ ├── ztypes_linux_mips64le.go
│ ├── ztypes_linux_mipsle.go
│ ├── ztypes_linux_ppc64.go
│ ├── ztypes_linux_ppc64le.go
│ ├── ztypes_linux_riscv64.go
│ ├── ztypes_linux_s390x.go
│ ├── ztypes_linux_sparc64.go
│ ├── ztypes_netbsd_386.go
│ ├── ztypes_netbsd_amd64.go
│ ├── ztypes_netbsd_arm.go
│ ├── ztypes_openbsd_386.go
│ ├── ztypes_openbsd_amd64.go
│ ├── ztypes_openbsd_arm.go
│ └── ztypes_solaris_amd64.go
└── google.golang.org
└── appengine
├── LICENSE
└── cloudsql
├── cloudsql.go
├── cloudsql_classic.go
└── cloudsql_vm.go
/Gopkg.toml:
--------------------------------------------------------------------------------
1 | # Gopkg.toml example
2 | #
3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4 | # for detailed Gopkg.toml documentation.
5 | #
6 | # required = ["github.com/user/thing/cmd/thing"]
7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8 | #
9 | # [[constraint]]
10 | # name = "github.com/user/project"
11 | # version = "1.0.0"
12 | #
13 | # [[constraint]]
14 | # name = "github.com/user/project2"
15 | # branch = "dev"
16 | # source = "github.com/myfork/project2"
17 | #
18 | # [[override]]
19 | # name = "github.com/x/y"
20 | # version = "2.4.0"
21 | #
22 | # [prune]
23 | # non-go = false
24 | # go-tests = true
25 | # unused-packages = true
26 |
27 |
28 | [[constraint]]
29 | name = "github.com/jinzhu/gorm"
30 | version = "1.9.1"
31 |
32 | [[constraint]]
33 | name = "github.com/labstack/echo"
34 | version = "3.3.6"
35 |
36 | [prune]
37 | go-tests = true
38 | unused-packages = true
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Example Go Language Application
2 |
3 | This application is a guestbook, it will walk through a basic CRUD application, the logic on the server and how to work with golang templates.
4 |
5 | ## Setup
6 |
7 | ### Prerequisites
8 |
9 | 1. Ensure you know the login credentials for the MySQL instance you will be working with
10 | 2. Create a database that will be used to store entry information.
11 | 3. Modify `config/config.json` to match your environments credentials so the application can connect to MySQL.
12 |
13 | ## Run
14 |
15 | To run, from the root of the project run the following:
16 |
17 | `go run ./cmd/frontend/main.go`
--------------------------------------------------------------------------------
/cmd/frontend/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "log"
7 | "os"
8 |
9 | "github.com/dougbarrett/example-golang-app/config"
10 | "github.com/dougbarrett/example-golang-app/handler"
11 | "github.com/dougbarrett/example-golang-app/server"
12 | "github.com/dougbarrett/example-golang-app/storage/mysql"
13 | )
14 |
15 | const defaultConfigPath = "./config/config.json"
16 | const defaultPortVariable = "PORT"
17 | const defaultPort = "3000"
18 |
19 | /* Setup is the function `main` calls in order to start the web server bootstrapped with the handler */
20 | func Setup(config *config.Config) {
21 | ds, err := mysql.NewFrontend(
22 | config.MySQL.User,
23 | config.MySQL.Password,
24 | config.MySQL.Host,
25 | config.MySQL.DB,
26 | )
27 |
28 | if err != nil {
29 | log.Fatalf("Cannot set up mysql: %v", err)
30 | }
31 |
32 | // cache := cache.New(ds)
33 |
34 | frontend, err := handler.NewFrontend(
35 | ds,
36 | )
37 |
38 | if err != nil {
39 | panic(err)
40 | }
41 |
42 | e, err := server.NewFrontend(
43 | frontend,
44 | )
45 |
46 | if err != nil {
47 | panic(err)
48 | }
49 |
50 | port := defaultPort
51 |
52 | if os.Getenv(defaultPortVariable) != "" {
53 | port = os.Getenv(defaultPortVariable)
54 | }
55 |
56 | addr := fmt.Sprintf(":%s", port)
57 |
58 | e.Start(addr)
59 | }
60 |
61 | func main() {
62 | configPath := flag.String("config", defaultConfigPath, "path of th config file")
63 |
64 | flag.Parse()
65 |
66 | config, err := config.FromFile(*configPath)
67 |
68 | if err != nil {
69 | panic(err)
70 | }
71 | Setup(config)
72 | }
73 |
--------------------------------------------------------------------------------
/config/config.go:
--------------------------------------------------------------------------------
1 | package config
2 |
3 | import (
4 | "encoding/json"
5 | "io/ioutil"
6 | )
7 |
8 | type Config struct {
9 | MySQL struct {
10 | Host string `json:"host"`
11 | User string `json:"user"`
12 | Password string `json:"password"`
13 | DB string `json:"db"`
14 | } `json:"mysql"`
15 | }
16 |
17 | func FromFile(path string) (*Config, error) {
18 | b, err := ioutil.ReadFile(path)
19 | if err != nil {
20 | return nil, err
21 | }
22 |
23 | var cfg Config
24 | if err := json.Unmarshal(b, &cfg); err != nil {
25 | return nil, err
26 | }
27 |
28 | return &cfg, nil
29 | }
30 |
--------------------------------------------------------------------------------
/config/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "mysql": {
3 | "host": "127.0.0.1:3306",
4 | "user": "username",
5 | "password": "password",
6 | "db": "example_guestbook"
7 | }
8 | }
--------------------------------------------------------------------------------
/entries.go:
--------------------------------------------------------------------------------
1 | package guestbook
2 |
3 | import "github.com/jinzhu/gorm"
4 |
5 | type Entry struct {
6 | gorm.Model
7 | Title string
8 | Name string
9 | Email string
10 | Message string `gorm:"type:longtext"`
11 | }
12 |
--------------------------------------------------------------------------------
/handler/entries.go:
--------------------------------------------------------------------------------
1 | package handler
2 |
3 | import (
4 | "errors"
5 |
6 | "github.com/dougbarrett/example-golang-app"
7 | )
8 |
9 | func (h *handler) CreateEntry(
10 | title string,
11 | name string,
12 | email string,
13 | message string,
14 | ) (
15 | entry guestbook.Entry,
16 | err error,
17 | ) {
18 | entry.Title = title
19 | entry.Name = name
20 | entry.Email = email
21 | entry.Message = message
22 |
23 | err = h.svc.SaveEntry(&entry)
24 | return
25 | }
26 |
27 | func (h *handler) UpdateEntry(
28 | id uint,
29 | title string,
30 | name string,
31 | email string,
32 | message string,
33 | ) (
34 | entry guestbook.Entry,
35 | err error,
36 | ) {
37 | entry, err = h.svc.GetEntry(id)
38 | if err != nil {
39 | return
40 | }
41 |
42 | entry.Title = title
43 | entry.Name = name
44 | entry.Email = email
45 | entry.Message = message
46 |
47 | err = h.svc.SaveEntry(&entry)
48 | return
49 | }
50 |
51 | func (h *handler) ListEntries() (
52 | entries []guestbook.Entry,
53 | err error,
54 | ) {
55 | return h.svc.GetAllEntries()
56 | }
57 |
58 | func (h *handler) DeleteEntry(
59 | entryID uint,
60 | ) (
61 | err error,
62 | ) {
63 | entry, err := h.svc.GetEntry(entryID)
64 |
65 | if entry.ID == 0 || err != nil {
66 | return errors.New("Entry doesn't exist")
67 | }
68 |
69 | return h.svc.DeleteEntry(entryID)
70 | }
71 |
--------------------------------------------------------------------------------
/handler/handler.go:
--------------------------------------------------------------------------------
1 | package handler
2 |
3 | import (
4 | "github.com/dougbarrett/example-golang-app"
5 | "github.com/dougbarrett/example-golang-app/storage"
6 | )
7 |
8 | type handler struct {
9 | svc storage.Service
10 | }
11 |
12 | type Service interface {
13 | CreateEntry(
14 | title string,
15 | name string,
16 | email string,
17 | message string,
18 | ) (
19 | entry guestbook.Entry,
20 | err error,
21 | )
22 | UpdateEntry(
23 | id uint,
24 | title string,
25 | name string,
26 | email string,
27 | message string,
28 | ) (
29 | entry guestbook.Entry,
30 | err error,
31 | )
32 | ListEntries() (
33 | entries []guestbook.Entry,
34 | err error,
35 | )
36 | DeleteEntry(
37 | entryID uint,
38 | ) (
39 | err error,
40 | )
41 | }
42 |
43 | func NewFrontend(
44 | svc storage.Service,
45 | ) (
46 | Service,
47 | error,
48 | ) {
49 | h := handler{}
50 | h.svc = svc
51 | return &h, nil
52 | }
53 |
--------------------------------------------------------------------------------
/server/entries.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "net/http"
5 |
6 | "github.com/dougbarrett/example-golang-app"
7 | "github.com/labstack/echo"
8 | )
9 |
10 | func (s *server) getAllEntries(c echo.Context) error {
11 |
12 | var retData struct {
13 | Entries []guestbook.Entry
14 | }
15 | var err error
16 |
17 | retData.Entries, err = s.handler.ListEntries()
18 |
19 | if err != nil {
20 | return err
21 | }
22 |
23 | return c.Render(http.StatusOK, "entries_all.html", retData)
24 | }
25 |
26 | func (s *server) newEntry(c echo.Context) error {
27 | return c.Render(http.StatusOK, "entries_new.html", nil)
28 | }
29 |
30 | type createEntryData struct {
31 | guestbook.Entry
32 | }
33 |
34 | func (s *server) createEntry(c echo.Context) error {
35 | e := new(createEntryData)
36 | if err := c.Bind(e); err != nil {
37 | return err
38 | }
39 | _, err := s.handler.CreateEntry(
40 | e.Title,
41 | e.Name,
42 | e.Email,
43 | e.Message,
44 | )
45 | if err != nil {
46 | return err
47 | }
48 |
49 | return c.Redirect(302, "/")
50 | }
51 |
52 | func (s *server) deleteEntry(c echo.Context) error {
53 | e := new(createEntryData)
54 | if err := c.Bind(e); err != nil {
55 | return err
56 | }
57 |
58 | err := s.handler.DeleteEntry(e.ID)
59 |
60 | if err != nil {
61 | return err
62 | }
63 |
64 | return c.Redirect(302, "/")
65 | }
66 |
--------------------------------------------------------------------------------
/server/server.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "html/template"
5 | "io"
6 |
7 | "github.com/dougbarrett/example-golang-app/handler"
8 | "github.com/labstack/echo"
9 | "github.com/labstack/echo/middleware"
10 | )
11 |
12 | type server struct {
13 | handler handler.Service
14 | }
15 |
16 | type Template struct {
17 | templates *template.Template
18 | }
19 |
20 | func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
21 | return t.templates.ExecuteTemplate(w, name, data)
22 | }
23 |
24 | func NewFrontend(
25 | handler handler.Service,
26 | ) (
27 | *echo.Echo,
28 | error,
29 | ) {
30 | s := &server{}
31 | s.handler = handler
32 |
33 | mux := echo.New()
34 |
35 | // Middleware
36 | mux.Use(middleware.Logger())
37 | mux.Use(middleware.Recover())
38 |
39 | t := &Template{
40 | templates: template.Must(template.ParseGlob("server/views/*.html")),
41 | }
42 | mux.Renderer = t
43 |
44 | mux.GET("/", s.getAllEntries)
45 | mux.GET("/entries/new", s.newEntry)
46 | mux.POST("/entries/create", s.createEntry)
47 | mux.POST("/entries/delete", s.deleteEntry)
48 |
49 | return mux, nil
50 | }
51 |
--------------------------------------------------------------------------------
/server/views/entries_all.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Guestbook
8 |
9 |
10 |
11 | New Entry | List All Entries
12 |
13 |
14 |
15 |
16 | Name |
17 | Email |
18 | Title |
19 | Message |
20 | |
21 |
22 |
23 |
24 | {{ range .Entries }}
25 |
26 | {{ .Name }} |
27 | {{ .Email }} |
28 | {{ .Title }} |
29 | {{ .Message }} |
30 |
31 |
35 | |
36 |
37 | {{ end }}
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/server/views/entries_new.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | New Entry | Guestbook
8 |
9 |
10 | New Entry | List All Entries
11 |
12 | New Entry
13 |
14 |
23 |
24 |
--------------------------------------------------------------------------------
/storage/mysql/entries.go:
--------------------------------------------------------------------------------
1 | package mysql
2 |
3 | import (
4 | "github.com/dougbarrett/example-golang-app"
5 | )
6 |
7 | func (m *mysql) GetAllEntries() (
8 | entries []guestbook.Entry,
9 | err error,
10 | ) {
11 | err = m.db.Find(&entries).Error
12 | return
13 | }
14 |
15 | func (m *mysql) SaveEntry(
16 | entry *guestbook.Entry,
17 | ) (
18 | err error,
19 | ) {
20 | err = m.db.Save(entry).Error
21 | return
22 | }
23 |
24 | func (m *mysql) GetEntry(
25 | entryID uint,
26 | ) (
27 | entry guestbook.Entry,
28 | err error,
29 | ) {
30 | err = m.db.Find(&entry, "id = ?", entryID).Error
31 | return
32 | }
33 |
34 | func (m *mysql) DeleteEntry(
35 | entryID uint,
36 | ) (
37 | err error,
38 | ) {
39 | return m.db.Delete(guestbook.Entry{}, "id = ?", entryID).Error
40 | }
41 |
--------------------------------------------------------------------------------
/storage/mysql/mysql.go:
--------------------------------------------------------------------------------
1 | package mysql
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/dougbarrett/example-golang-app"
7 | "github.com/dougbarrett/example-golang-app/storage"
8 | "github.com/jinzhu/gorm"
9 | _ "github.com/jinzhu/gorm/dialects/mysql"
10 | )
11 |
12 | type mysql struct {
13 | db *gorm.DB
14 | }
15 |
16 | func NewFrontend(
17 | username string,
18 | password string,
19 | host string,
20 | database string,
21 | ) (
22 | storage.Service,
23 | error,
24 | ) {
25 | m := &mysql{}
26 | connect := fmt.Sprintf("%v:%v@tcp(%v)/%v?parseTime=true", username, password, host, database)
27 |
28 | db, err := gorm.Open("mysql", connect)
29 |
30 | if err != nil {
31 | return nil, err
32 | }
33 |
34 | err = db.DB().Ping()
35 | if err != nil {
36 | return nil, err
37 | }
38 |
39 | err = db.AutoMigrate(&guestbook.Entry{}).Error
40 |
41 | if err != nil {
42 | return nil, err
43 | }
44 |
45 | m.db = db
46 | return m, nil
47 | }
48 |
--------------------------------------------------------------------------------
/storage/storage.go:
--------------------------------------------------------------------------------
1 | package storage
2 |
3 | import (
4 | "github.com/dougbarrett/example-golang-app"
5 | )
6 |
7 | type Service interface {
8 | GetAllEntries() (
9 | entries []guestbook.Entry,
10 | err error,
11 | )
12 | SaveEntry(
13 | entry *guestbook.Entry,
14 | ) (
15 | err error,
16 | )
17 | GetEntry(
18 | entryID uint,
19 | ) (
20 | entry guestbook.Entry,
21 | err error,
22 | )
23 | DeleteEntry(
24 | entryID uint,
25 | ) (
26 | err error,
27 | )
28 | }
29 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | bin
3 |
4 |
5 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 |
3 | script:
4 | - go vet ./...
5 | - go test -v ./...
6 |
7 | go:
8 | - 1.3
9 | - 1.4
10 | - 1.5
11 | - 1.6
12 | - 1.7
13 | - tip
14 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 Dave Grijalva
2 |
3 | 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:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | 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.
8 |
9 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/doc.go:
--------------------------------------------------------------------------------
1 | // Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html
2 | //
3 | // See README.md for more info.
4 | package jwt
5 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "crypto/ecdsa"
5 | "crypto/x509"
6 | "encoding/pem"
7 | "errors"
8 | )
9 |
10 | var (
11 | ErrNotECPublicKey = errors.New("Key is not a valid ECDSA public key")
12 | ErrNotECPrivateKey = errors.New("Key is not a valid ECDSA private key")
13 | )
14 |
15 | // Parse PEM encoded Elliptic Curve Private Key Structure
16 | func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) {
17 | var err error
18 |
19 | // Parse PEM block
20 | var block *pem.Block
21 | if block, _ = pem.Decode(key); block == nil {
22 | return nil, ErrKeyMustBePEMEncoded
23 | }
24 |
25 | // Parse the key
26 | var parsedKey interface{}
27 | if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil {
28 | return nil, err
29 | }
30 |
31 | var pkey *ecdsa.PrivateKey
32 | var ok bool
33 | if pkey, ok = parsedKey.(*ecdsa.PrivateKey); !ok {
34 | return nil, ErrNotECPrivateKey
35 | }
36 |
37 | return pkey, nil
38 | }
39 |
40 | // Parse PEM encoded PKCS1 or PKCS8 public key
41 | func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) {
42 | var err error
43 |
44 | // Parse PEM block
45 | var block *pem.Block
46 | if block, _ = pem.Decode(key); block == nil {
47 | return nil, ErrKeyMustBePEMEncoded
48 | }
49 |
50 | // Parse the key
51 | var parsedKey interface{}
52 | if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
53 | if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
54 | parsedKey = cert.PublicKey
55 | } else {
56 | return nil, err
57 | }
58 | }
59 |
60 | var pkey *ecdsa.PublicKey
61 | var ok bool
62 | if pkey, ok = parsedKey.(*ecdsa.PublicKey); !ok {
63 | return nil, ErrNotECPublicKey
64 | }
65 |
66 | return pkey, nil
67 | }
68 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/errors.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "errors"
5 | )
6 |
7 | // Error constants
8 | var (
9 | ErrInvalidKey = errors.New("key is invalid")
10 | ErrInvalidKeyType = errors.New("key is of invalid type")
11 | ErrHashUnavailable = errors.New("the requested hash function is unavailable")
12 | )
13 |
14 | // The errors that might occur when parsing and validating a token
15 | const (
16 | ValidationErrorMalformed uint32 = 1 << iota // Token is malformed
17 | ValidationErrorUnverifiable // Token could not be verified because of signing problems
18 | ValidationErrorSignatureInvalid // Signature validation failed
19 |
20 | // Standard Claim validation errors
21 | ValidationErrorAudience // AUD validation failed
22 | ValidationErrorExpired // EXP validation failed
23 | ValidationErrorIssuedAt // IAT validation failed
24 | ValidationErrorIssuer // ISS validation failed
25 | ValidationErrorNotValidYet // NBF validation failed
26 | ValidationErrorId // JTI validation failed
27 | ValidationErrorClaimsInvalid // Generic claims validation error
28 | )
29 |
30 | // Helper for constructing a ValidationError with a string error message
31 | func NewValidationError(errorText string, errorFlags uint32) *ValidationError {
32 | return &ValidationError{
33 | text: errorText,
34 | Errors: errorFlags,
35 | }
36 | }
37 |
38 | // The error from Parse if token is not valid
39 | type ValidationError struct {
40 | Inner error // stores the error returned by external dependencies, i.e.: KeyFunc
41 | Errors uint32 // bitfield. see ValidationError... constants
42 | text string // errors that do not have a valid error just have text
43 | }
44 |
45 | // Validation error is an error type
46 | func (e ValidationError) Error() string {
47 | if e.Inner != nil {
48 | return e.Inner.Error()
49 | } else if e.text != "" {
50 | return e.text
51 | } else {
52 | return "token is invalid"
53 | }
54 | }
55 |
56 | // No errors
57 | func (e *ValidationError) valid() bool {
58 | return e.Errors == 0
59 | }
60 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/hmac.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "crypto"
5 | "crypto/hmac"
6 | "errors"
7 | )
8 |
9 | // Implements the HMAC-SHA family of signing methods signing methods
10 | // Expects key type of []byte for both signing and validation
11 | type SigningMethodHMAC struct {
12 | Name string
13 | Hash crypto.Hash
14 | }
15 |
16 | // Specific instances for HS256 and company
17 | var (
18 | SigningMethodHS256 *SigningMethodHMAC
19 | SigningMethodHS384 *SigningMethodHMAC
20 | SigningMethodHS512 *SigningMethodHMAC
21 | ErrSignatureInvalid = errors.New("signature is invalid")
22 | )
23 |
24 | func init() {
25 | // HS256
26 | SigningMethodHS256 = &SigningMethodHMAC{"HS256", crypto.SHA256}
27 | RegisterSigningMethod(SigningMethodHS256.Alg(), func() SigningMethod {
28 | return SigningMethodHS256
29 | })
30 |
31 | // HS384
32 | SigningMethodHS384 = &SigningMethodHMAC{"HS384", crypto.SHA384}
33 | RegisterSigningMethod(SigningMethodHS384.Alg(), func() SigningMethod {
34 | return SigningMethodHS384
35 | })
36 |
37 | // HS512
38 | SigningMethodHS512 = &SigningMethodHMAC{"HS512", crypto.SHA512}
39 | RegisterSigningMethod(SigningMethodHS512.Alg(), func() SigningMethod {
40 | return SigningMethodHS512
41 | })
42 | }
43 |
44 | func (m *SigningMethodHMAC) Alg() string {
45 | return m.Name
46 | }
47 |
48 | // Verify the signature of HSXXX tokens. Returns nil if the signature is valid.
49 | func (m *SigningMethodHMAC) Verify(signingString, signature string, key interface{}) error {
50 | // Verify the key is the right type
51 | keyBytes, ok := key.([]byte)
52 | if !ok {
53 | return ErrInvalidKeyType
54 | }
55 |
56 | // Decode signature, for comparison
57 | sig, err := DecodeSegment(signature)
58 | if err != nil {
59 | return err
60 | }
61 |
62 | // Can we use the specified hashing method?
63 | if !m.Hash.Available() {
64 | return ErrHashUnavailable
65 | }
66 |
67 | // This signing method is symmetric, so we validate the signature
68 | // by reproducing the signature from the signing string and key, then
69 | // comparing that against the provided signature.
70 | hasher := hmac.New(m.Hash.New, keyBytes)
71 | hasher.Write([]byte(signingString))
72 | if !hmac.Equal(sig, hasher.Sum(nil)) {
73 | return ErrSignatureInvalid
74 | }
75 |
76 | // No validation errors. Signature is good.
77 | return nil
78 | }
79 |
80 | // Implements the Sign method from SigningMethod for this signing method.
81 | // Key must be []byte
82 | func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) (string, error) {
83 | if keyBytes, ok := key.([]byte); ok {
84 | if !m.Hash.Available() {
85 | return "", ErrHashUnavailable
86 | }
87 |
88 | hasher := hmac.New(m.Hash.New, keyBytes)
89 | hasher.Write([]byte(signingString))
90 |
91 | return EncodeSegment(hasher.Sum(nil)), nil
92 | }
93 |
94 | return "", ErrInvalidKeyType
95 | }
96 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/none.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | // Implements the none signing method. This is required by the spec
4 | // but you probably should never use it.
5 | var SigningMethodNone *signingMethodNone
6 |
7 | const UnsafeAllowNoneSignatureType unsafeNoneMagicConstant = "none signing method allowed"
8 |
9 | var NoneSignatureTypeDisallowedError error
10 |
11 | type signingMethodNone struct{}
12 | type unsafeNoneMagicConstant string
13 |
14 | func init() {
15 | SigningMethodNone = &signingMethodNone{}
16 | NoneSignatureTypeDisallowedError = NewValidationError("'none' signature type is not allowed", ValidationErrorSignatureInvalid)
17 |
18 | RegisterSigningMethod(SigningMethodNone.Alg(), func() SigningMethod {
19 | return SigningMethodNone
20 | })
21 | }
22 |
23 | func (m *signingMethodNone) Alg() string {
24 | return "none"
25 | }
26 |
27 | // Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key
28 | func (m *signingMethodNone) Verify(signingString, signature string, key interface{}) (err error) {
29 | // Key must be UnsafeAllowNoneSignatureType to prevent accidentally
30 | // accepting 'none' signing method
31 | if _, ok := key.(unsafeNoneMagicConstant); !ok {
32 | return NoneSignatureTypeDisallowedError
33 | }
34 | // If signing method is none, signature must be an empty string
35 | if signature != "" {
36 | return NewValidationError(
37 | "'none' signing method with non-empty signature",
38 | ValidationErrorSignatureInvalid,
39 | )
40 | }
41 |
42 | // Accept 'none' signing method.
43 | return nil
44 | }
45 |
46 | // Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key
47 | func (m *signingMethodNone) Sign(signingString string, key interface{}) (string, error) {
48 | if _, ok := key.(unsafeNoneMagicConstant); ok {
49 | return "", nil
50 | }
51 | return "", NoneSignatureTypeDisallowedError
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "crypto/rsa"
5 | "crypto/x509"
6 | "encoding/pem"
7 | "errors"
8 | )
9 |
10 | var (
11 | ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key")
12 | ErrNotRSAPrivateKey = errors.New("Key is not a valid RSA private key")
13 | ErrNotRSAPublicKey = errors.New("Key is not a valid RSA public key")
14 | )
15 |
16 | // Parse PEM encoded PKCS1 or PKCS8 private key
17 | func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) {
18 | var err error
19 |
20 | // Parse PEM block
21 | var block *pem.Block
22 | if block, _ = pem.Decode(key); block == nil {
23 | return nil, ErrKeyMustBePEMEncoded
24 | }
25 |
26 | var parsedKey interface{}
27 | if parsedKey, err = x509.ParsePKCS1PrivateKey(block.Bytes); err != nil {
28 | if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
29 | return nil, err
30 | }
31 | }
32 |
33 | var pkey *rsa.PrivateKey
34 | var ok bool
35 | if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok {
36 | return nil, ErrNotRSAPrivateKey
37 | }
38 |
39 | return pkey, nil
40 | }
41 |
42 | // Parse PEM encoded PKCS1 or PKCS8 private key protected with password
43 | func ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error) {
44 | var err error
45 |
46 | // Parse PEM block
47 | var block *pem.Block
48 | if block, _ = pem.Decode(key); block == nil {
49 | return nil, ErrKeyMustBePEMEncoded
50 | }
51 |
52 | var parsedKey interface{}
53 |
54 | var blockDecrypted []byte
55 | if blockDecrypted, err = x509.DecryptPEMBlock(block, []byte(password)); err != nil {
56 | return nil, err
57 | }
58 |
59 | if parsedKey, err = x509.ParsePKCS1PrivateKey(blockDecrypted); err != nil {
60 | if parsedKey, err = x509.ParsePKCS8PrivateKey(blockDecrypted); err != nil {
61 | return nil, err
62 | }
63 | }
64 |
65 | var pkey *rsa.PrivateKey
66 | var ok bool
67 | if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok {
68 | return nil, ErrNotRSAPrivateKey
69 | }
70 |
71 | return pkey, nil
72 | }
73 |
74 | // Parse PEM encoded PKCS1 or PKCS8 public key
75 | func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) {
76 | var err error
77 |
78 | // Parse PEM block
79 | var block *pem.Block
80 | if block, _ = pem.Decode(key); block == nil {
81 | return nil, ErrKeyMustBePEMEncoded
82 | }
83 |
84 | // Parse the key
85 | var parsedKey interface{}
86 | if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
87 | if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
88 | parsedKey = cert.PublicKey
89 | } else {
90 | return nil, err
91 | }
92 | }
93 |
94 | var pkey *rsa.PublicKey
95 | var ok bool
96 | if pkey, ok = parsedKey.(*rsa.PublicKey); !ok {
97 | return nil, ErrNotRSAPublicKey
98 | }
99 |
100 | return pkey, nil
101 | }
102 |
--------------------------------------------------------------------------------
/vendor/github.com/dgrijalva/jwt-go/signing_method.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "sync"
5 | )
6 |
7 | var signingMethods = map[string]func() SigningMethod{}
8 | var signingMethodLock = new(sync.RWMutex)
9 |
10 | // Implement SigningMethod to add new methods for signing or verifying tokens.
11 | type SigningMethod interface {
12 | Verify(signingString, signature string, key interface{}) error // Returns nil if signature is valid
13 | Sign(signingString string, key interface{}) (string, error) // Returns encoded signature or error
14 | Alg() string // returns the alg identifier for this method (example: 'HS256')
15 | }
16 |
17 | // Register the "alg" name and a factory function for signing method.
18 | // This is typically done during init() in the method's implementation
19 | func RegisterSigningMethod(alg string, f func() SigningMethod) {
20 | signingMethodLock.Lock()
21 | defer signingMethodLock.Unlock()
22 |
23 | signingMethods[alg] = f
24 | }
25 |
26 | // Get a signing method from an "alg" string
27 | func GetSigningMethod(alg string) (method SigningMethod) {
28 | signingMethodLock.RLock()
29 | defer signingMethodLock.RUnlock()
30 |
31 | if methodF, ok := signingMethods[alg]; ok {
32 | method = methodF()
33 | }
34 | return
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .DS_Store?
3 | ._*
4 | .Spotlight-V100
5 | .Trashes
6 | Icon?
7 | ehthumbs.db
8 | Thumbs.db
9 | .idea
10 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | ## Reporting Issues
4 |
5 | Before creating a new Issue, please check first if a similar Issue [already exists](https://github.com/go-sql-driver/mysql/issues?state=open) or was [recently closed](https://github.com/go-sql-driver/mysql/issues?direction=desc&page=1&sort=updated&state=closed).
6 |
7 | ## Contributing Code
8 |
9 | By contributing to this project, you share your code under the Mozilla Public License 2, as specified in the LICENSE file.
10 | Don't forget to add yourself to the AUTHORS file.
11 |
12 | ### Code Review
13 |
14 | Everyone is invited to review and comment on pull requests.
15 | If it looks fine to you, comment with "LGTM" (Looks good to me).
16 |
17 | If changes are required, notice the reviewers with "PTAL" (Please take another look) after committing the fixes.
18 |
19 | Before merging the Pull Request, at least one [team member](https://github.com/go-sql-driver?tab=members) must have commented with "LGTM".
20 |
21 | ## Development Ideas
22 |
23 | If you are looking for ideas for code contributions, please check our [Development Ideas](https://github.com/go-sql-driver/mysql/wiki/Development-Ideas) Wiki page.
24 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/appengine.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2 | //
3 | // Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
4 | //
5 | // This Source Code Form is subject to the terms of the Mozilla Public
6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 | // You can obtain one at http://mozilla.org/MPL/2.0/.
8 |
9 | // +build appengine
10 |
11 | package mysql
12 |
13 | import (
14 | "google.golang.org/appengine/cloudsql"
15 | )
16 |
17 | func init() {
18 | RegisterDial("cloudsql", cloudsql.Dial)
19 | }
20 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/result.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2 | //
3 | // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved.
4 | //
5 | // This Source Code Form is subject to the terms of the Mozilla Public
6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 | // You can obtain one at http://mozilla.org/MPL/2.0/.
8 |
9 | package mysql
10 |
11 | type mysqlResult struct {
12 | affectedRows int64
13 | insertId int64
14 | }
15 |
16 | func (res *mysqlResult) LastInsertId() (int64, error) {
17 | return res.insertId, nil
18 | }
19 |
20 | func (res *mysqlResult) RowsAffected() (int64, error) {
21 | return res.affectedRows, nil
22 | }
23 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/transaction.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2 | //
3 | // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved.
4 | //
5 | // This Source Code Form is subject to the terms of the Mozilla Public
6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 | // You can obtain one at http://mozilla.org/MPL/2.0/.
8 |
9 | package mysql
10 |
11 | type mysqlTx struct {
12 | mc *mysqlConn
13 | }
14 |
15 | func (tx *mysqlTx) Commit() (err error) {
16 | if tx.mc == nil || tx.mc.closed.IsSet() {
17 | return ErrInvalidConn
18 | }
19 | err = tx.mc.exec("COMMIT")
20 | tx.mc = nil
21 | return
22 | }
23 |
24 | func (tx *mysqlTx) Rollback() (err error) {
25 | if tx.mc == nil || tx.mc.closed.IsSet() {
26 | return ErrInvalidConn
27 | }
28 | err = tx.mc.exec("ROLLBACK")
29 | tx.mc = nil
30 | return
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/utils_go17.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2 | //
3 | // Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved.
4 | //
5 | // This Source Code Form is subject to the terms of the Mozilla Public
6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 | // You can obtain one at http://mozilla.org/MPL/2.0/.
8 |
9 | // +build go1.7
10 | // +build !go1.8
11 |
12 | package mysql
13 |
14 | import "crypto/tls"
15 |
16 | func cloneTLSConfig(c *tls.Config) *tls.Config {
17 | return &tls.Config{
18 | Rand: c.Rand,
19 | Time: c.Time,
20 | Certificates: c.Certificates,
21 | NameToCertificate: c.NameToCertificate,
22 | GetCertificate: c.GetCertificate,
23 | RootCAs: c.RootCAs,
24 | NextProtos: c.NextProtos,
25 | ServerName: c.ServerName,
26 | ClientAuth: c.ClientAuth,
27 | ClientCAs: c.ClientCAs,
28 | InsecureSkipVerify: c.InsecureSkipVerify,
29 | CipherSuites: c.CipherSuites,
30 | PreferServerCipherSuites: c.PreferServerCipherSuites,
31 | SessionTicketsDisabled: c.SessionTicketsDisabled,
32 | SessionTicketKey: c.SessionTicketKey,
33 | ClientSessionCache: c.ClientSessionCache,
34 | MinVersion: c.MinVersion,
35 | MaxVersion: c.MaxVersion,
36 | CurvePreferences: c.CurvePreferences,
37 | DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled,
38 | Renegotiation: c.Renegotiation,
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/utils_go18.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2 | //
3 | // Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved.
4 | //
5 | // This Source Code Form is subject to the terms of the Mozilla Public
6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 | // You can obtain one at http://mozilla.org/MPL/2.0/.
8 |
9 | // +build go1.8
10 |
11 | package mysql
12 |
13 | import (
14 | "crypto/tls"
15 | "database/sql"
16 | "database/sql/driver"
17 | "errors"
18 | "fmt"
19 | )
20 |
21 | func cloneTLSConfig(c *tls.Config) *tls.Config {
22 | return c.Clone()
23 | }
24 |
25 | func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) {
26 | dargs := make([]driver.Value, len(named))
27 | for n, param := range named {
28 | if len(param.Name) > 0 {
29 | // TODO: support the use of Named Parameters #561
30 | return nil, errors.New("mysql: driver does not support the use of Named Parameters")
31 | }
32 | dargs[n] = param.Value
33 | }
34 | return dargs, nil
35 | }
36 |
37 | func mapIsolationLevel(level driver.IsolationLevel) (string, error) {
38 | switch sql.IsolationLevel(level) {
39 | case sql.LevelRepeatableRead:
40 | return "REPEATABLE READ", nil
41 | case sql.LevelReadCommitted:
42 | return "READ COMMITTED", nil
43 | case sql.LevelReadUncommitted:
44 | return "READ UNCOMMITTED", nil
45 | case sql.LevelSerializable:
46 | return "SERIALIZABLE", nil
47 | default:
48 | return "", fmt.Errorf("mysql: unsupported isolation level: %v", level)
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | ---
2 | engines:
3 | gofmt:
4 | enabled: true
5 | govet:
6 | enabled: true
7 | golint:
8 | enabled: true
9 | ratings:
10 | paths:
11 | - "**.go"
12 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/.gitignore:
--------------------------------------------------------------------------------
1 | documents
2 | _book
3 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/License:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-NOW Jinzhu
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/jinzhu/gorm/README.md:
--------------------------------------------------------------------------------
1 | # GORM
2 |
3 | The fantastic ORM library for Golang, aims to be developer friendly.
4 |
5 | [](https://goreportcard.com/report/github.com/jinzhu/gorm)
6 | [](https://app.wercker.com/project/byKey/8596cace912c9947dd9c8542ecc8cb8b)
7 | [](https://gitter.im/jinzhu/gorm?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8 | [](https://opencollective.com/gorm)
9 | [](https://opencollective.com/gorm)
10 | [](http://opensource.org/licenses/MIT)
11 | [](https://godoc.org/github.com/jinzhu/gorm)
12 |
13 | ## Overview
14 |
15 | * Full-Featured ORM (almost)
16 | * Associations (Has One, Has Many, Belongs To, Many To Many, Polymorphism)
17 | * Hooks (Before/After Create/Save/Update/Delete/Find)
18 | * Preloading (eager loading)
19 | * Transactions
20 | * Composite Primary Key
21 | * SQL Builder
22 | * Auto Migrations
23 | * Logger
24 | * Extendable, write Plugins based on GORM callbacks
25 | * Every feature comes with tests
26 | * Developer Friendly
27 |
28 | ## Getting Started
29 |
30 | * GORM Guides [http://gorm.io](http://gorm.io)
31 |
32 | ## Contributing
33 |
34 | [You can help to deliver a better GORM, check out things you can do](http://gorm.io/contribute.html)
35 |
36 | ## License
37 |
38 | © Jinzhu, 2013~time.Now
39 |
40 | Released under the [MIT License](https://github.com/jinzhu/gorm/blob/master/License)
41 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/callback_delete.go:
--------------------------------------------------------------------------------
1 | package gorm
2 |
3 | import (
4 | "errors"
5 | "fmt"
6 | )
7 |
8 | // Define callbacks for deleting
9 | func init() {
10 | DefaultCallback.Delete().Register("gorm:begin_transaction", beginTransactionCallback)
11 | DefaultCallback.Delete().Register("gorm:before_delete", beforeDeleteCallback)
12 | DefaultCallback.Delete().Register("gorm:delete", deleteCallback)
13 | DefaultCallback.Delete().Register("gorm:after_delete", afterDeleteCallback)
14 | DefaultCallback.Delete().Register("gorm:commit_or_rollback_transaction", commitOrRollbackTransactionCallback)
15 | }
16 |
17 | // beforeDeleteCallback will invoke `BeforeDelete` method before deleting
18 | func beforeDeleteCallback(scope *Scope) {
19 | if scope.DB().HasBlockGlobalUpdate() && !scope.hasConditions() {
20 | scope.Err(errors.New("Missing WHERE clause while deleting"))
21 | return
22 | }
23 | if !scope.HasError() {
24 | scope.CallMethod("BeforeDelete")
25 | }
26 | }
27 |
28 | // deleteCallback used to delete data from database or set deleted_at to current time (when using with soft delete)
29 | func deleteCallback(scope *Scope) {
30 | if !scope.HasError() {
31 | var extraOption string
32 | if str, ok := scope.Get("gorm:delete_option"); ok {
33 | extraOption = fmt.Sprint(str)
34 | }
35 |
36 | deletedAtField, hasDeletedAtField := scope.FieldByName("DeletedAt")
37 |
38 | if !scope.Search.Unscoped && hasDeletedAtField {
39 | scope.Raw(fmt.Sprintf(
40 | "UPDATE %v SET %v=%v%v%v",
41 | scope.QuotedTableName(),
42 | scope.Quote(deletedAtField.DBName),
43 | scope.AddToVars(NowFunc()),
44 | addExtraSpaceIfExist(scope.CombinedConditionSql()),
45 | addExtraSpaceIfExist(extraOption),
46 | )).Exec()
47 | } else {
48 | scope.Raw(fmt.Sprintf(
49 | "DELETE FROM %v%v%v",
50 | scope.QuotedTableName(),
51 | addExtraSpaceIfExist(scope.CombinedConditionSql()),
52 | addExtraSpaceIfExist(extraOption),
53 | )).Exec()
54 | }
55 | }
56 | }
57 |
58 | // afterDeleteCallback will invoke `AfterDelete` method after deleting
59 | func afterDeleteCallback(scope *Scope) {
60 | if !scope.HasError() {
61 | scope.CallMethod("AfterDelete")
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/callback_query.go:
--------------------------------------------------------------------------------
1 | package gorm
2 |
3 | import (
4 | "errors"
5 | "fmt"
6 | "reflect"
7 | )
8 |
9 | // Define callbacks for querying
10 | func init() {
11 | DefaultCallback.Query().Register("gorm:query", queryCallback)
12 | DefaultCallback.Query().Register("gorm:preload", preloadCallback)
13 | DefaultCallback.Query().Register("gorm:after_query", afterQueryCallback)
14 | }
15 |
16 | // queryCallback used to query data from database
17 | func queryCallback(scope *Scope) {
18 | if _, skip := scope.InstanceGet("gorm:skip_query_callback"); skip {
19 | return
20 | }
21 |
22 | defer scope.trace(NowFunc())
23 |
24 | var (
25 | isSlice, isPtr bool
26 | resultType reflect.Type
27 | results = scope.IndirectValue()
28 | )
29 |
30 | if orderBy, ok := scope.Get("gorm:order_by_primary_key"); ok {
31 | if primaryField := scope.PrimaryField(); primaryField != nil {
32 | scope.Search.Order(fmt.Sprintf("%v.%v %v", scope.QuotedTableName(), scope.Quote(primaryField.DBName), orderBy))
33 | }
34 | }
35 |
36 | if value, ok := scope.Get("gorm:query_destination"); ok {
37 | results = indirect(reflect.ValueOf(value))
38 | }
39 |
40 | if kind := results.Kind(); kind == reflect.Slice {
41 | isSlice = true
42 | resultType = results.Type().Elem()
43 | results.Set(reflect.MakeSlice(results.Type(), 0, 0))
44 |
45 | if resultType.Kind() == reflect.Ptr {
46 | isPtr = true
47 | resultType = resultType.Elem()
48 | }
49 | } else if kind != reflect.Struct {
50 | scope.Err(errors.New("unsupported destination, should be slice or struct"))
51 | return
52 | }
53 |
54 | scope.prepareQuerySQL()
55 |
56 | if !scope.HasError() {
57 | scope.db.RowsAffected = 0
58 | if str, ok := scope.Get("gorm:query_option"); ok {
59 | scope.SQL += addExtraSpaceIfExist(fmt.Sprint(str))
60 | }
61 |
62 | if rows, err := scope.SQLDB().Query(scope.SQL, scope.SQLVars...); scope.Err(err) == nil {
63 | defer rows.Close()
64 |
65 | columns, _ := rows.Columns()
66 | for rows.Next() {
67 | scope.db.RowsAffected++
68 |
69 | elem := results
70 | if isSlice {
71 | elem = reflect.New(resultType).Elem()
72 | }
73 |
74 | scope.scan(rows, columns, scope.New(elem.Addr().Interface()).Fields())
75 |
76 | if isSlice {
77 | if isPtr {
78 | results.Set(reflect.Append(results, elem.Addr()))
79 | } else {
80 | results.Set(reflect.Append(results, elem))
81 | }
82 | }
83 | }
84 |
85 | if err := rows.Err(); err != nil {
86 | scope.Err(err)
87 | } else if scope.db.RowsAffected == 0 && !isSlice {
88 | scope.Err(ErrRecordNotFound)
89 | }
90 | }
91 | }
92 | }
93 |
94 | // afterQueryCallback will invoke `AfterFind` method after querying
95 | func afterQueryCallback(scope *Scope) {
96 | if !scope.HasError() {
97 | scope.CallMethod("AfterFind")
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/callback_row_query.go:
--------------------------------------------------------------------------------
1 | package gorm
2 |
3 | import "database/sql"
4 |
5 | // Define callbacks for row query
6 | func init() {
7 | DefaultCallback.RowQuery().Register("gorm:row_query", rowQueryCallback)
8 | }
9 |
10 | type RowQueryResult struct {
11 | Row *sql.Row
12 | }
13 |
14 | type RowsQueryResult struct {
15 | Rows *sql.Rows
16 | Error error
17 | }
18 |
19 | // queryCallback used to query data from database
20 | func rowQueryCallback(scope *Scope) {
21 | if result, ok := scope.InstanceGet("row_query_result"); ok {
22 | scope.prepareQuerySQL()
23 |
24 | if rowResult, ok := result.(*RowQueryResult); ok {
25 | rowResult.Row = scope.SQLDB().QueryRow(scope.SQL, scope.SQLVars...)
26 | } else if rowsResult, ok := result.(*RowsQueryResult); ok {
27 | rowsResult.Rows, rowsResult.Error = scope.SQLDB().Query(scope.SQL, scope.SQLVars...)
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/dialects/mysql/mysql.go:
--------------------------------------------------------------------------------
1 | package mysql
2 |
3 | import _ "github.com/go-sql-driver/mysql"
4 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | mysql:
5 | image: 'mysql:latest'
6 | ports:
7 | - 9910:3306
8 | environment:
9 | - MYSQL_DATABASE=gorm
10 | - MYSQL_USER=gorm
11 | - MYSQL_PASSWORD=gorm
12 | - MYSQL_RANDOM_ROOT_PASSWORD="yes"
13 | postgres:
14 | image: 'postgres:latest'
15 | ports:
16 | - 9920:5432
17 | environment:
18 | - POSTGRES_USER=gorm
19 | - POSTGRES_DB=gorm
20 | - POSTGRES_PASSWORD=gorm
21 | mssql:
22 | image: 'mcmoe/mssqldocker:latest'
23 | ports:
24 | - 9930:1433
25 | environment:
26 | - ACCEPT_EULA=Y
27 | - SA_PASSWORD=LoremIpsum86
28 | - MSSQL_DB=gorm
29 | - MSSQL_USER=gorm
30 | - MSSQL_PASSWORD=LoremIpsum86
31 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/errors.go:
--------------------------------------------------------------------------------
1 | package gorm
2 |
3 | import (
4 | "errors"
5 | "strings"
6 | )
7 |
8 | var (
9 | // ErrRecordNotFound record not found error, happens when haven't find any matched data when looking up with a struct
10 | ErrRecordNotFound = errors.New("record not found")
11 | // ErrInvalidSQL invalid SQL error, happens when you passed invalid SQL
12 | ErrInvalidSQL = errors.New("invalid SQL")
13 | // ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback`
14 | ErrInvalidTransaction = errors.New("no valid transaction")
15 | // ErrCantStartTransaction can't start transaction when you are trying to start one with `Begin`
16 | ErrCantStartTransaction = errors.New("can't start transaction")
17 | // ErrUnaddressable unaddressable value
18 | ErrUnaddressable = errors.New("using unaddressable value")
19 | )
20 |
21 | // Errors contains all happened errors
22 | type Errors []error
23 |
24 | // IsRecordNotFoundError returns current error has record not found error or not
25 | func IsRecordNotFoundError(err error) bool {
26 | if errs, ok := err.(Errors); ok {
27 | for _, err := range errs {
28 | if err == ErrRecordNotFound {
29 | return true
30 | }
31 | }
32 | }
33 | return err == ErrRecordNotFound
34 | }
35 |
36 | // GetErrors gets all happened errors
37 | func (errs Errors) GetErrors() []error {
38 | return errs
39 | }
40 |
41 | // Add adds an error
42 | func (errs Errors) Add(newErrors ...error) Errors {
43 | for _, err := range newErrors {
44 | if err == nil {
45 | continue
46 | }
47 |
48 | if errors, ok := err.(Errors); ok {
49 | errs = errs.Add(errors...)
50 | } else {
51 | ok = true
52 | for _, e := range errs {
53 | if err == e {
54 | ok = false
55 | }
56 | }
57 | if ok {
58 | errs = append(errs, err)
59 | }
60 | }
61 | }
62 | return errs
63 | }
64 |
65 | // Error format happened errors
66 | func (errs Errors) Error() string {
67 | var errors = []string{}
68 | for _, e := range errs {
69 | errors = append(errors, e.Error())
70 | }
71 | return strings.Join(errors, "; ")
72 | }
73 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/field.go:
--------------------------------------------------------------------------------
1 | package gorm
2 |
3 | import (
4 | "database/sql"
5 | "errors"
6 | "fmt"
7 | "reflect"
8 | )
9 |
10 | // Field model field definition
11 | type Field struct {
12 | *StructField
13 | IsBlank bool
14 | Field reflect.Value
15 | }
16 |
17 | // Set set a value to the field
18 | func (field *Field) Set(value interface{}) (err error) {
19 | if !field.Field.IsValid() {
20 | return errors.New("field value not valid")
21 | }
22 |
23 | if !field.Field.CanAddr() {
24 | return ErrUnaddressable
25 | }
26 |
27 | reflectValue, ok := value.(reflect.Value)
28 | if !ok {
29 | reflectValue = reflect.ValueOf(value)
30 | }
31 |
32 | fieldValue := field.Field
33 | if reflectValue.IsValid() {
34 | if reflectValue.Type().ConvertibleTo(fieldValue.Type()) {
35 | fieldValue.Set(reflectValue.Convert(fieldValue.Type()))
36 | } else {
37 | if fieldValue.Kind() == reflect.Ptr {
38 | if fieldValue.IsNil() {
39 | fieldValue.Set(reflect.New(field.Struct.Type.Elem()))
40 | }
41 | fieldValue = fieldValue.Elem()
42 | }
43 |
44 | if reflectValue.Type().ConvertibleTo(fieldValue.Type()) {
45 | fieldValue.Set(reflectValue.Convert(fieldValue.Type()))
46 | } else if scanner, ok := fieldValue.Addr().Interface().(sql.Scanner); ok {
47 | err = scanner.Scan(reflectValue.Interface())
48 | } else {
49 | err = fmt.Errorf("could not convert argument of field %s from %s to %s", field.Name, reflectValue.Type(), fieldValue.Type())
50 | }
51 | }
52 | } else {
53 | field.Field.Set(reflect.Zero(field.Field.Type()))
54 | }
55 |
56 | field.IsBlank = isBlank(field.Field)
57 | return err
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/interface.go:
--------------------------------------------------------------------------------
1 | package gorm
2 |
3 | import "database/sql"
4 |
5 | // SQLCommon is the minimal database connection functionality gorm requires. Implemented by *sql.DB.
6 | type SQLCommon interface {
7 | Exec(query string, args ...interface{}) (sql.Result, error)
8 | Prepare(query string) (*sql.Stmt, error)
9 | Query(query string, args ...interface{}) (*sql.Rows, error)
10 | QueryRow(query string, args ...interface{}) *sql.Row
11 | }
12 |
13 | type sqlDb interface {
14 | Begin() (*sql.Tx, error)
15 | }
16 |
17 | type sqlTx interface {
18 | Commit() error
19 | Rollback() error
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/model.go:
--------------------------------------------------------------------------------
1 | package gorm
2 |
3 | import "time"
4 |
5 | // Model base model definition, including fields `ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in your models
6 | // type User struct {
7 | // gorm.Model
8 | // }
9 | type Model struct {
10 | ID uint `gorm:"primary_key"`
11 | CreatedAt time.Time
12 | UpdatedAt time.Time
13 | DeletedAt *time.Time `sql:"index"`
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/gorm/test_all.sh:
--------------------------------------------------------------------------------
1 | dialects=("postgres" "mysql" "mssql" "sqlite")
2 |
3 | for dialect in "${dialects[@]}" ; do
4 | DEBUG=false GORM_DIALECT=${dialect} go test
5 | done
6 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/inflection/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 - Jinzhu
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/jinzhu/inflection/README.md:
--------------------------------------------------------------------------------
1 | # Inflection
2 |
3 | Inflection pluralizes and singularizes English nouns
4 |
5 | [](https://app.wercker.com/project/byKey/f8c7432b097d1f4ce636879670be0930)
6 |
7 | ## Basic Usage
8 |
9 | ```go
10 | inflection.Plural("person") => "people"
11 | inflection.Plural("Person") => "People"
12 | inflection.Plural("PERSON") => "PEOPLE"
13 | inflection.Plural("bus") => "buses"
14 | inflection.Plural("BUS") => "BUSES"
15 | inflection.Plural("Bus") => "Buses"
16 |
17 | inflection.Singular("people") => "person"
18 | inflection.Singular("People") => "Person"
19 | inflection.Singular("PEOPLE") => "PERSON"
20 | inflection.Singular("buses") => "bus"
21 | inflection.Singular("BUSES") => "BUS"
22 | inflection.Singular("Buses") => "Bus"
23 |
24 | inflection.Plural("FancyPerson") => "FancyPeople"
25 | inflection.Singular("FancyPeople") => "FancyPerson"
26 | ```
27 |
28 | ## Register Rules
29 |
30 | Standard rules are from Rails's ActiveSupport (https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflections.rb)
31 |
32 | If you want to register more rules, follow:
33 |
34 | ```
35 | inflection.AddUncountable("fish")
36 | inflection.AddIrregular("person", "people")
37 | inflection.AddPlural("(bu)s$", "${1}ses") # "bus" => "buses" / "BUS" => "BUSES" / "Bus" => "Buses"
38 | inflection.AddSingular("(bus)(es)?$", "${1}") # "buses" => "bus" / "Buses" => "Bus" / "BUSES" => "BUS"
39 | ```
40 |
41 | ## Contributing
42 |
43 | You can help to make the project better, check out [http://gorm.io/contribute.html](http://gorm.io/contribute.html) for things you can do.
44 |
45 | ## Author
46 |
47 | **jinzhu**
48 |
49 | *
50 | *
51 | *
52 |
53 | ## License
54 |
55 | Released under the [MIT License](http://www.opensource.org/licenses/MIT).
56 |
--------------------------------------------------------------------------------
/vendor/github.com/jinzhu/inflection/wercker.yml:
--------------------------------------------------------------------------------
1 | box: golang
2 |
3 | build:
4 | steps:
5 | - setup-go-workspace
6 |
7 | # Gets the dependencies
8 | - script:
9 | name: go get
10 | code: |
11 | go get
12 |
13 | # Build the project
14 | - script:
15 | name: go build
16 | code: |
17 | go build ./...
18 |
19 | # Test the project
20 | - script:
21 | name: go test
22 | code: |
23 | go test ./...
24 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig coding styles definitions. For more information about the
2 | # properties used in this file, please see the EditorConfig documentation:
3 | # http://editorconfig.org/
4 |
5 | # indicate this is the root of the project
6 | root = true
7 |
8 | [*]
9 | charset = utf-8
10 |
11 | end_of_line = LF
12 | insert_final_newline = true
13 | trim_trailing_whitespace = true
14 |
15 | indent_style = space
16 | indent_size = 2
17 |
18 | [Makefile]
19 | indent_style = tab
20 |
21 | [*.md]
22 | trim_trailing_whitespace = false
23 |
24 | [*.go]
25 | indent_style = tab
26 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/.gitattributes:
--------------------------------------------------------------------------------
1 | # Automatically normalize line endings for all text-based files
2 | # http://git-scm.com/docs/gitattributes#_end_of_line_conversion
3 | * text=auto
4 |
5 | # For the following file types, normalize line endings to LF on checking and
6 | # prevent conversion to CRLF when they are checked out (this is required in
7 | # order to prevent newline related issues)
8 | .* text eol=lf
9 | *.go text eol=lf
10 | *.yml text eol=lf
11 | *.html text eol=lf
12 | *.css text eol=lf
13 | *.js text eol=lf
14 | *.json text eol=lf
15 | LICENSE text eol=lf
16 |
17 | # Exclude `website` and `cookbook` from GitHub's language statistics
18 | # https://github.com/github/linguist#using-gitattributes
19 | cookbook/* linguist-documentation
20 | website/* linguist-documentation
21 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | coverage.txt
3 | _test
4 | vendor
5 | .idea
6 | *.iml
7 | *.out
8 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - 1.9.x
4 | - 1.10.x
5 | - 1.11.x
6 | - tip
7 | install:
8 | - make dependency
9 | script:
10 | - make test
11 | after_success:
12 | - bash <(curl -s https://codecov.io/bash)
13 | matrix:
14 | allow_failures:
15 | - go: tip
16 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/Gopkg.toml:
--------------------------------------------------------------------------------
1 | # Gopkg.toml example
2 | #
3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4 | # for detailed Gopkg.toml documentation.
5 | #
6 | # required = ["github.com/user/thing/cmd/thing"]
7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8 | #
9 | # [[constraint]]
10 | # name = "github.com/user/project"
11 | # version = "1.0.0"
12 | #
13 | # [[constraint]]
14 | # name = "github.com/user/project2"
15 | # branch = "dev"
16 | # source = "github.com/myfork/project2"
17 | #
18 | # [[override]]
19 | # name = "github.com/x/y"
20 | # version = "2.4.0"
21 | #
22 | # [prune]
23 | # non-go = false
24 | # go-tests = true
25 | # unused-packages = true
26 |
27 |
28 | [[constraint]]
29 | name = "github.com/dgrijalva/jwt-go"
30 | version = "3.2.0"
31 |
32 | [[constraint]]
33 | name = "github.com/labstack/gommon"
34 | version = "0.2.7"
35 |
36 | [[constraint]]
37 | name = "github.com/stretchr/testify"
38 | version = "1.2.2"
39 |
40 | [[constraint]]
41 | branch = "master"
42 | name = "github.com/valyala/fasttemplate"
43 |
44 | [[constraint]]
45 | branch = "master"
46 | name = "golang.org/x/crypto"
47 |
48 | [prune]
49 | go-tests = true
50 | unused-packages = true
51 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 LabStack
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/labstack/echo/Makefile:
--------------------------------------------------------------------------------
1 | DEP_VERSION=0.4.1
2 |
3 | dependency:
4 | curl -fsSL -o ${GOPATH}/bin/dep https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64
5 | chmod +x ${GOPATH}/bin/dep
6 | dep ensure
7 |
8 | test:
9 | echo "" > coverage.txt
10 | for d in $(shell go list ./... | grep -v vendor); do \
11 | go test -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
12 | [ -f profile.out ] && cat profile.out >> coverage.txt && rm profile.out; \
13 | done
14 |
15 | tag:
16 | @git tag `grep -P '^\tversion = ' echo.go|cut -f2 -d'"'`
17 | @git tag|grep -v ^v
18 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/labstack/echo
2 |
3 | require (
4 | github.com/davecgh/go-spew v1.1.0 // indirect
5 | github.com/dgrijalva/jwt-go v3.2.0+incompatible
6 | github.com/labstack/gommon v0.0.0-20180312174116-6fe1405d73ec
7 | github.com/mattn/go-colorable v0.0.9 // indirect
8 | github.com/mattn/go-isatty v0.0.3 // indirect
9 | github.com/pmezard/go-difflib v1.0.0 // indirect
10 | github.com/stretchr/testify v1.2.1
11 | github.com/valyala/bytebufferpool v0.0.0-20160817181652-e746df99fe4a // indirect
12 | github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4
13 | golang.org/x/crypto v0.0.0-20180312195533-182114d58262
14 | golang.org/x/sys v0.0.0-20180312081825-c28acc882ebc // indirect
15 | )
16 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/go.sum:
--------------------------------------------------------------------------------
1 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3 | github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
4 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
5 | github.com/labstack/gommon v0.0.0-20180312174116-6fe1405d73ec h1:aYKwS4iCpqxskMuvI8+Byq0CxnnWHO/xuLk2pZJ96tY=
6 | github.com/labstack/gommon v0.0.0-20180312174116-6fe1405d73ec/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4=
7 | github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
8 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
9 | github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
10 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
11 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
12 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
13 | github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
14 | github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
15 | github.com/valyala/bytebufferpool v0.0.0-20160817181652-e746df99fe4a h1:AOcehBWpFhYPYw0ioDTppQzgI8pAAahVCiMSKTp9rbo=
16 | github.com/valyala/bytebufferpool v0.0.0-20160817181652-e746df99fe4a/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
17 | github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 h1:gKMu1Bf6QINDnvyZuTaACm9ofY+PRh+5vFz4oxBZeF8=
18 | github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw=
19 | golang.org/x/crypto v0.0.0-20180312195533-182114d58262 h1:1NLVUmR8SQ7cNNA5Vo7ronpXbR+5A+9IwIC/bLE7D8Y=
20 | golang.org/x/crypto v0.0.0-20180312195533-182114d58262/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
21 | golang.org/x/sys v0.0.0-20180312081825-c28acc882ebc h1:eCzBKjjvhDDXMoH5l7eA+YK1PEtyJ2QLj3f4IArr+zg=
22 | golang.org/x/sys v0.0.0-20180312081825-c28acc882ebc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
23 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/log.go:
--------------------------------------------------------------------------------
1 | package echo
2 |
3 | import (
4 | "io"
5 |
6 | "github.com/labstack/gommon/log"
7 | )
8 |
9 | type (
10 | // Logger defines the logging interface.
11 | Logger interface {
12 | Output() io.Writer
13 | SetOutput(w io.Writer)
14 | Prefix() string
15 | SetPrefix(p string)
16 | Level() log.Lvl
17 | SetLevel(v log.Lvl)
18 | Print(i ...interface{})
19 | Printf(format string, args ...interface{})
20 | Printj(j log.JSON)
21 | Debug(i ...interface{})
22 | Debugf(format string, args ...interface{})
23 | Debugj(j log.JSON)
24 | Info(i ...interface{})
25 | Infof(format string, args ...interface{})
26 | Infoj(j log.JSON)
27 | Warn(i ...interface{})
28 | Warnf(format string, args ...interface{})
29 | Warnj(j log.JSON)
30 | Error(i ...interface{})
31 | Errorf(format string, args ...interface{})
32 | Errorj(j log.JSON)
33 | Fatal(i ...interface{})
34 | Fatalj(j log.JSON)
35 | Fatalf(format string, args ...interface{})
36 | Panic(i ...interface{})
37 | Panicj(j log.JSON)
38 | Panicf(format string, args ...interface{})
39 | }
40 | )
41 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/middleware/method_override.go:
--------------------------------------------------------------------------------
1 | package middleware
2 |
3 | import "github.com/labstack/echo"
4 |
5 | type (
6 | // MethodOverrideConfig defines the config for MethodOverride middleware.
7 | MethodOverrideConfig struct {
8 | // Skipper defines a function to skip middleware.
9 | Skipper Skipper
10 |
11 | // Getter is a function that gets overridden method from the request.
12 | // Optional. Default values MethodFromHeader(echo.HeaderXHTTPMethodOverride).
13 | Getter MethodOverrideGetter
14 | }
15 |
16 | // MethodOverrideGetter is a function that gets overridden method from the request
17 | MethodOverrideGetter func(echo.Context) string
18 | )
19 |
20 | var (
21 | // DefaultMethodOverrideConfig is the default MethodOverride middleware config.
22 | DefaultMethodOverrideConfig = MethodOverrideConfig{
23 | Skipper: DefaultSkipper,
24 | Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride),
25 | }
26 | )
27 |
28 | // MethodOverride returns a MethodOverride middleware.
29 | // MethodOverride middleware checks for the overridden method from the request and
30 | // uses it instead of the original method.
31 | //
32 | // For security reasons, only `POST` method can be overridden.
33 | func MethodOverride() echo.MiddlewareFunc {
34 | return MethodOverrideWithConfig(DefaultMethodOverrideConfig)
35 | }
36 |
37 | // MethodOverrideWithConfig returns a MethodOverride middleware with config.
38 | // See: `MethodOverride()`.
39 | func MethodOverrideWithConfig(config MethodOverrideConfig) echo.MiddlewareFunc {
40 | // Defaults
41 | if config.Skipper == nil {
42 | config.Skipper = DefaultMethodOverrideConfig.Skipper
43 | }
44 | if config.Getter == nil {
45 | config.Getter = DefaultMethodOverrideConfig.Getter
46 | }
47 |
48 | return func(next echo.HandlerFunc) echo.HandlerFunc {
49 | return func(c echo.Context) error {
50 | if config.Skipper(c) {
51 | return next(c)
52 | }
53 |
54 | req := c.Request()
55 | if req.Method == echo.POST {
56 | m := config.Getter(c)
57 | if m != "" {
58 | req.Method = m
59 | }
60 | }
61 | return next(c)
62 | }
63 | }
64 | }
65 |
66 | // MethodFromHeader is a `MethodOverrideGetter` that gets overridden method from
67 | // the request header.
68 | func MethodFromHeader(header string) MethodOverrideGetter {
69 | return func(c echo.Context) string {
70 | return c.Request().Header.Get(header)
71 | }
72 | }
73 |
74 | // MethodFromForm is a `MethodOverrideGetter` that gets overridden method from the
75 | // form parameter.
76 | func MethodFromForm(param string) MethodOverrideGetter {
77 | return func(c echo.Context) string {
78 | return c.FormValue(param)
79 | }
80 | }
81 |
82 | // MethodFromQuery is a `MethodOverrideGetter` that gets overridden method from
83 | // the query parameter.
84 | func MethodFromQuery(param string) MethodOverrideGetter {
85 | return func(c echo.Context) string {
86 | return c.QueryParam(param)
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/middleware/middleware.go:
--------------------------------------------------------------------------------
1 | package middleware
2 |
3 | import (
4 | "regexp"
5 | "strconv"
6 | "strings"
7 |
8 | "github.com/labstack/echo"
9 | )
10 |
11 | type (
12 | // Skipper defines a function to skip middleware. Returning true skips processing
13 | // the middleware.
14 | Skipper func(echo.Context) bool
15 |
16 | // BeforeFunc defines a function which is executed just before the middleware.
17 | BeforeFunc func(echo.Context)
18 | )
19 |
20 | func captureTokens(pattern *regexp.Regexp, input string) *strings.Replacer {
21 | groups := pattern.FindAllStringSubmatch(input, -1)
22 | if groups == nil {
23 | return nil
24 | }
25 | values := groups[0][1:]
26 | replace := make([]string, 2*len(values))
27 | for i, v := range values {
28 | j := 2 * i
29 | replace[j] = "$" + strconv.Itoa(i+1)
30 | replace[j+1] = v
31 | }
32 | return strings.NewReplacer(replace...)
33 | }
34 |
35 | // DefaultSkipper returns false which processes the middleware.
36 | func DefaultSkipper(echo.Context) bool {
37 | return false
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/middleware/recover.go:
--------------------------------------------------------------------------------
1 | package middleware
2 |
3 | import (
4 | "fmt"
5 | "runtime"
6 |
7 | "github.com/labstack/echo"
8 | )
9 |
10 | type (
11 | // RecoverConfig defines the config for Recover middleware.
12 | RecoverConfig struct {
13 | // Skipper defines a function to skip middleware.
14 | Skipper Skipper
15 |
16 | // Size of the stack to be printed.
17 | // Optional. Default value 4KB.
18 | StackSize int `yaml:"stack_size"`
19 |
20 | // DisableStackAll disables formatting stack traces of all other goroutines
21 | // into buffer after the trace for the current goroutine.
22 | // Optional. Default value false.
23 | DisableStackAll bool `yaml:"disable_stack_all"`
24 |
25 | // DisablePrintStack disables printing stack trace.
26 | // Optional. Default value as false.
27 | DisablePrintStack bool `yaml:"disable_print_stack"`
28 | }
29 | )
30 |
31 | var (
32 | // DefaultRecoverConfig is the default Recover middleware config.
33 | DefaultRecoverConfig = RecoverConfig{
34 | Skipper: DefaultSkipper,
35 | StackSize: 4 << 10, // 4 KB
36 | DisableStackAll: false,
37 | DisablePrintStack: false,
38 | }
39 | )
40 |
41 | // Recover returns a middleware which recovers from panics anywhere in the chain
42 | // and handles the control to the centralized HTTPErrorHandler.
43 | func Recover() echo.MiddlewareFunc {
44 | return RecoverWithConfig(DefaultRecoverConfig)
45 | }
46 |
47 | // RecoverWithConfig returns a Recover middleware with config.
48 | // See: `Recover()`.
49 | func RecoverWithConfig(config RecoverConfig) echo.MiddlewareFunc {
50 | // Defaults
51 | if config.Skipper == nil {
52 | config.Skipper = DefaultRecoverConfig.Skipper
53 | }
54 | if config.StackSize == 0 {
55 | config.StackSize = DefaultRecoverConfig.StackSize
56 | }
57 |
58 | return func(next echo.HandlerFunc) echo.HandlerFunc {
59 | return func(c echo.Context) error {
60 | if config.Skipper(c) {
61 | return next(c)
62 | }
63 |
64 | defer func() {
65 | if r := recover(); r != nil {
66 | err, ok := r.(error)
67 | if !ok {
68 | err = fmt.Errorf("%v", r)
69 | }
70 | stack := make([]byte, config.StackSize)
71 | length := runtime.Stack(stack, !config.DisableStackAll)
72 | if !config.DisablePrintStack {
73 | c.Logger().Printf("[PANIC RECOVER] %v %s\n", err, stack[:length])
74 | }
75 | c.Error(err)
76 | }
77 | }()
78 | return next(c)
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/middleware/request_id.go:
--------------------------------------------------------------------------------
1 | package middleware
2 |
3 | import (
4 | "github.com/labstack/echo"
5 | "github.com/labstack/gommon/random"
6 | )
7 |
8 | type (
9 | // RequestIDConfig defines the config for RequestID middleware.
10 | RequestIDConfig struct {
11 | // Skipper defines a function to skip middleware.
12 | Skipper Skipper
13 |
14 | // Generator defines a function to generate an ID.
15 | // Optional. Default value random.String(32).
16 | Generator func() string
17 | }
18 | )
19 |
20 | var (
21 | // DefaultRequestIDConfig is the default RequestID middleware config.
22 | DefaultRequestIDConfig = RequestIDConfig{
23 | Skipper: DefaultSkipper,
24 | Generator: generator,
25 | }
26 | )
27 |
28 | // RequestID returns a X-Request-ID middleware.
29 | func RequestID() echo.MiddlewareFunc {
30 | return RequestIDWithConfig(DefaultRequestIDConfig)
31 | }
32 |
33 | // RequestIDWithConfig returns a X-Request-ID middleware with config.
34 | func RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc {
35 | // Defaults
36 | if config.Skipper == nil {
37 | config.Skipper = DefaultRequestIDConfig.Skipper
38 | }
39 | if config.Generator == nil {
40 | config.Generator = generator
41 | }
42 |
43 | return func(next echo.HandlerFunc) echo.HandlerFunc {
44 | return func(c echo.Context) error {
45 | if config.Skipper(c) {
46 | return next(c)
47 | }
48 |
49 | req := c.Request()
50 | res := c.Response()
51 | rid := req.Header.Get(echo.HeaderXRequestID)
52 | if rid == "" {
53 | rid = config.Generator()
54 | }
55 | res.Header().Set(echo.HeaderXRequestID, rid)
56 |
57 | return next(c)
58 | }
59 | }
60 | }
61 |
62 | func generator() string {
63 | return random.String(32)
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/echo/middleware/rewrite.go:
--------------------------------------------------------------------------------
1 | package middleware
2 |
3 | import (
4 | "regexp"
5 | "strings"
6 |
7 | "github.com/labstack/echo"
8 | )
9 |
10 | type (
11 | // RewriteConfig defines the config for Rewrite middleware.
12 | RewriteConfig struct {
13 | // Skipper defines a function to skip middleware.
14 | Skipper Skipper
15 |
16 | // Rules defines the URL path rewrite rules. The values captured in asterisk can be
17 | // retrieved by index e.g. $1, $2 and so on.
18 | // Example:
19 | // "/old": "/new",
20 | // "/api/*": "/$1",
21 | // "/js/*": "/public/javascripts/$1",
22 | // "/users/*/orders/*": "/user/$1/order/$2",
23 | // Required.
24 | Rules map[string]string `yaml:"rules"`
25 |
26 | rulesRegex map[*regexp.Regexp]string
27 | }
28 | )
29 |
30 | var (
31 | // DefaultRewriteConfig is the default Rewrite middleware config.
32 | DefaultRewriteConfig = RewriteConfig{
33 | Skipper: DefaultSkipper,
34 | }
35 | )
36 |
37 | // Rewrite returns a Rewrite middleware.
38 | //
39 | // Rewrite middleware rewrites the URL path based on the provided rules.
40 | func Rewrite(rules map[string]string) echo.MiddlewareFunc {
41 | c := DefaultRewriteConfig
42 | c.Rules = rules
43 | return RewriteWithConfig(c)
44 | }
45 |
46 | // RewriteWithConfig returns a Rewrite middleware with config.
47 | // See: `Rewrite()`.
48 | func RewriteWithConfig(config RewriteConfig) echo.MiddlewareFunc {
49 | // Defaults
50 | if config.Rules == nil {
51 | panic("echo: rewrite middleware requires url path rewrite rules")
52 | }
53 | if config.Skipper == nil {
54 | config.Skipper = DefaultBodyDumpConfig.Skipper
55 | }
56 | config.rulesRegex = map[*regexp.Regexp]string{}
57 |
58 | // Initialize
59 | for k, v := range config.Rules {
60 | k = strings.Replace(k, "*", "(.*)", -1)
61 | k = k + "$"
62 | config.rulesRegex[regexp.MustCompile(k)] = v
63 | }
64 |
65 | return func(next echo.HandlerFunc) echo.HandlerFunc {
66 | return func(c echo.Context) (err error) {
67 | if config.Skipper(c) {
68 | return next(c)
69 | }
70 |
71 | req := c.Request()
72 |
73 | // Rewrite
74 | for k, v := range config.rulesRegex {
75 | replacer := captureTokens(k, req.URL.Path)
76 | if replacer != nil {
77 | req.URL.Path = replacer.Replace(v)
78 | break
79 | }
80 | }
81 | return next(c)
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/gommon/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 labstack
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/github.com/labstack/gommon/bytes/README.md:
--------------------------------------------------------------------------------
1 | # Bytes
2 |
3 | - Format bytes integer to human readable bytes string.
4 | - Parse human readable bytes string to bytes integer.
5 |
6 | ## Installation
7 |
8 | ```go
9 | go get github.com/labstack/gommon/bytes
10 | ```
11 |
12 | ## [Usage](https://github.com/labstack/gommon/blob/master/bytes/bytes_test.go)
13 |
14 | ### Format
15 |
16 | ```go
17 | println(bytes.Format(13231323))
18 | ```
19 |
20 | `12.62MB`
21 |
22 | ### Parse
23 |
24 | ```go
25 | b, _ = Parse("2M")
26 | println(b)
27 | ```
28 |
29 | `2097152`
30 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/gommon/bytes/bytes.go:
--------------------------------------------------------------------------------
1 | package bytes
2 |
3 | import (
4 | "fmt"
5 | "regexp"
6 | "strconv"
7 | )
8 |
9 | type (
10 | // Bytes struct
11 | Bytes struct{}
12 | )
13 |
14 | const (
15 | _ = 1.0 << (10 * iota) // ignore first value by assigning to blank identifier
16 | KB
17 | MB
18 | GB
19 | TB
20 | PB
21 | EB
22 | )
23 |
24 | var (
25 | pattern = regexp.MustCompile(`(?i)^(-?\d+(?:\.\d+)?)([KMGTPE]B?|B?)$`)
26 | global = New()
27 | )
28 |
29 | // New creates a Bytes instance.
30 | func New() *Bytes {
31 | return &Bytes{}
32 | }
33 |
34 | // Format formats bytes integer to human readable string.
35 | // For example, 31323 bytes will return 30.59KB.
36 | func (*Bytes) Format(b int64) string {
37 | multiple := ""
38 | value := float64(b)
39 |
40 | switch {
41 | case b >= EB:
42 | value /= EB
43 | multiple = "EB"
44 | case b >= PB:
45 | value /= PB
46 | multiple = "PB"
47 | case b >= TB:
48 | value /= TB
49 | multiple = "TB"
50 | case b >= GB:
51 | value /= GB
52 | multiple = "GB"
53 | case b >= MB:
54 | value /= MB
55 | multiple = "MB"
56 | case b >= KB:
57 | value /= KB
58 | multiple = "KB"
59 | case b == 0:
60 | return "0"
61 | default:
62 | return strconv.FormatInt(b, 10) + "B"
63 | }
64 |
65 | return fmt.Sprintf("%.2f%s", value, multiple)
66 | }
67 |
68 | // Parse parses human readable bytes string to bytes integer.
69 | // For example, 6GB (6G is also valid) will return 6442450944.
70 | func (*Bytes) Parse(value string) (i int64, err error) {
71 | parts := pattern.FindStringSubmatch(value)
72 | if len(parts) < 3 {
73 | return 0, fmt.Errorf("error parsing value=%s", value)
74 | }
75 | bytesString := parts[1]
76 | multiple := parts[2]
77 | bytes, err := strconv.ParseFloat(bytesString, 64)
78 | if err != nil {
79 | return
80 | }
81 |
82 | switch multiple {
83 | default:
84 | return int64(bytes), nil
85 | case "K", "KB":
86 | return int64(bytes * KB), nil
87 | case "M", "MB":
88 | return int64(bytes * MB), nil
89 | case "G", "GB":
90 | return int64(bytes * GB), nil
91 | case "T", "TB":
92 | return int64(bytes * TB), nil
93 | case "P", "PB":
94 | return int64(bytes * PB), nil
95 | case "E", "EB":
96 | return int64(bytes * EB), nil
97 | }
98 | }
99 |
100 | // Format wraps global Bytes's Format function.
101 | func Format(b int64) string {
102 | return global.Format(b)
103 | }
104 |
105 | // Parse wraps global Bytes's Parse function.
106 | func Parse(val string) (int64, error) {
107 | return global.Parse(val)
108 | }
109 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/gommon/color/README.md:
--------------------------------------------------------------------------------
1 | # Color
2 |
3 | Style terminal text.
4 |
5 | ## Installation
6 |
7 | ```sh
8 | go get github.com/labstack/gommon/color
9 | ```
10 |
11 | ## Windows?
12 |
13 | Try [cmder](http://bliker.github.io/cmder) or https://github.com/mattn/go-colorable
14 |
15 | ## [Usage](https://github.com/labstack/gommon/blob/master/color/color_test.go)
16 |
17 | ```sh
18 | import github.com/labstack/gommon/color
19 | ```
20 |
21 | ### Colored text
22 |
23 | ```go
24 | color.Println(color.Black("black"))
25 | color.Println(color.Red("red"))
26 | color.Println(color.Green("green"))
27 | color.Println(color.Yellow("yellow"))
28 | color.Println(color.Blue("blue"))
29 | color.Println(color.Magenta("magenta"))
30 | color.Println(color.Cyan("cyan"))
31 | color.Println(color.White("white"))
32 | color.Println(color.Grey("grey"))
33 | ```
34 | 
35 |
36 | ### Colored background
37 |
38 | ```go
39 | color.Println(color.BlackBg("black background", color.Wht))
40 | color.Println(color.RedBg("red background"))
41 | color.Println(color.GreenBg("green background"))
42 | color.Println(color.YellowBg("yellow background"))
43 | color.Println(color.BlueBg("blue background"))
44 | color.Println(color.MagentaBg("magenta background"))
45 | color.Println(color.CyanBg("cyan background"))
46 | color.Println(color.WhiteBg("white background"))
47 | ```
48 | 
49 |
50 | ### Emphasis
51 |
52 | ```go
53 | color.Println(color.Bold("bold"))
54 | color.Println(color.Dim("dim"))
55 | color.Println(color.Italic("italic"))
56 | color.Println(color.Underline("underline"))
57 | color.Println(color.Inverse("inverse"))
58 | color.Println(color.Hidden("hidden"))
59 | color.Println(color.Strikeout("strikeout"))
60 | ```
61 | 
62 |
63 | ### Mix and match
64 |
65 | ```go
66 | color.Println(color.Green("bold green with white background", color.B, color.WhtBg))
67 | color.Println(color.Red("underline red", color.U))
68 | color.Println(color.Yellow("dim yellow", color.D))
69 | color.Println(color.Cyan("inverse cyan", color.In))
70 | color.Println(color.Blue("bold underline dim blue", color.B, color.U, color.D))
71 | ```
72 | 
73 |
74 | ### Enable/Disable the package
75 |
76 | ```go
77 | color.Disable()
78 | color.Enable()
79 | ```
80 |
81 | ### New instance
82 |
83 | ```go
84 | c := New()
85 | c.Green("green")
86 | ```
87 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/gommon/log/README.md:
--------------------------------------------------------------------------------
1 | ## WORK IN PROGRESS
2 |
3 | ### Usage
4 |
5 | [log_test.go](log_test.go)
6 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/gommon/log/color.go:
--------------------------------------------------------------------------------
1 | // +build !appengine
2 |
3 | package log
4 |
5 | import (
6 | "io"
7 |
8 | "github.com/mattn/go-colorable"
9 | )
10 |
11 | func output() io.Writer {
12 | return colorable.NewColorableStdout()
13 | }
14 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/gommon/log/white.go:
--------------------------------------------------------------------------------
1 | // +build appengine
2 |
3 | package log
4 |
5 | import (
6 | "io"
7 | "os"
8 | )
9 |
10 | func output() io.Writer {
11 | return os.Stdout
12 | }
13 |
--------------------------------------------------------------------------------
/vendor/github.com/labstack/gommon/random/random.go:
--------------------------------------------------------------------------------
1 | package random
2 |
3 | import (
4 | "math/rand"
5 | "strings"
6 | "time"
7 | )
8 |
9 | type (
10 | Random struct {
11 | }
12 | )
13 |
14 | // Charsets
15 | const (
16 | Uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
17 | Lowercase = "abcdefghijklmnopqrstuvwxyz"
18 | Alphabetic = Uppercase + Lowercase
19 | Numeric = "0123456789"
20 | Alphanumeric = Alphabetic + Numeric
21 | Symbols = "`" + `~!@#$%^&*()-_+={}[]|\;:"<>,./?`
22 | Hex = Numeric + "abcdef"
23 | )
24 |
25 | var (
26 | global = New()
27 | )
28 |
29 | func New() *Random {
30 | rand.Seed(time.Now().UnixNano())
31 | return new(Random)
32 | }
33 |
34 | func (r *Random) String(length uint8, charsets ...string) string {
35 | charset := strings.Join(charsets, "")
36 | if charset == "" {
37 | charset = Alphanumeric
38 | }
39 | b := make([]byte, length)
40 | for i := range b {
41 | b[i] = charset[rand.Int63()%int64(len(charset))]
42 | }
43 | return string(b)
44 | }
45 |
46 | func String(length uint8, charsets ...string) string {
47 | return global.String(length, charsets...)
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-colorable/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - tip
4 |
5 | before_install:
6 | - go get github.com/mattn/goveralls
7 | - go get golang.org/x/tools/cmd/cover
8 | script:
9 | - $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw
10 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-colorable/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Yasuhiro Matsumoto
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/mattn/go-colorable/README.md:
--------------------------------------------------------------------------------
1 | # go-colorable
2 |
3 | [](http://godoc.org/github.com/mattn/go-colorable)
4 | [](https://travis-ci.org/mattn/go-colorable)
5 | [](https://coveralls.io/github/mattn/go-colorable?branch=master)
6 | [](https://goreportcard.com/report/mattn/go-colorable)
7 |
8 | Colorable writer for windows.
9 |
10 | For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.)
11 | This package is possible to handle escape sequence for ansi color on windows.
12 |
13 | ## Too Bad!
14 |
15 | 
16 |
17 |
18 | ## So Good!
19 |
20 | 
21 |
22 | ## Usage
23 |
24 | ```go
25 | logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
26 | logrus.SetOutput(colorable.NewColorableStdout())
27 |
28 | logrus.Info("succeeded")
29 | logrus.Warn("not correct")
30 | logrus.Error("something error")
31 | logrus.Fatal("panic")
32 | ```
33 |
34 | You can compile above code on non-windows OSs.
35 |
36 | ## Installation
37 |
38 | ```
39 | $ go get github.com/mattn/go-colorable
40 | ```
41 |
42 | # License
43 |
44 | MIT
45 |
46 | # Author
47 |
48 | Yasuhiro Matsumoto (a.k.a mattn)
49 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-colorable/colorable_appengine.go:
--------------------------------------------------------------------------------
1 | // +build appengine
2 |
3 | package colorable
4 |
5 | import (
6 | "io"
7 | "os"
8 |
9 | _ "github.com/mattn/go-isatty"
10 | )
11 |
12 | // NewColorable return new instance of Writer which handle escape sequence.
13 | func NewColorable(file *os.File) io.Writer {
14 | if file == nil {
15 | panic("nil passed instead of *os.File to NewColorable()")
16 | }
17 |
18 | return file
19 | }
20 |
21 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
22 | func NewColorableStdout() io.Writer {
23 | return os.Stdout
24 | }
25 |
26 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
27 | func NewColorableStderr() io.Writer {
28 | return os.Stderr
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-colorable/colorable_others.go:
--------------------------------------------------------------------------------
1 | // +build !windows
2 | // +build !appengine
3 |
4 | package colorable
5 |
6 | import (
7 | "io"
8 | "os"
9 |
10 | _ "github.com/mattn/go-isatty"
11 | )
12 |
13 | // NewColorable return new instance of Writer which handle escape sequence.
14 | func NewColorable(file *os.File) io.Writer {
15 | if file == nil {
16 | panic("nil passed instead of *os.File to NewColorable()")
17 | }
18 |
19 | return file
20 | }
21 |
22 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
23 | func NewColorableStdout() io.Writer {
24 | return os.Stdout
25 | }
26 |
27 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
28 | func NewColorableStderr() io.Writer {
29 | return os.Stderr
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-colorable/noncolorable.go:
--------------------------------------------------------------------------------
1 | package colorable
2 |
3 | import (
4 | "bytes"
5 | "io"
6 | )
7 |
8 | // NonColorable hold writer but remove escape sequence.
9 | type NonColorable struct {
10 | out io.Writer
11 | }
12 |
13 | // NewNonColorable return new instance of Writer which remove escape sequence from Writer.
14 | func NewNonColorable(w io.Writer) io.Writer {
15 | return &NonColorable{out: w}
16 | }
17 |
18 | // Write write data on console
19 | func (w *NonColorable) Write(data []byte) (n int, err error) {
20 | er := bytes.NewReader(data)
21 | var bw [1]byte
22 | loop:
23 | for {
24 | c1, err := er.ReadByte()
25 | if err != nil {
26 | break loop
27 | }
28 | if c1 != 0x1b {
29 | bw[0] = c1
30 | w.out.Write(bw[:])
31 | continue
32 | }
33 | c2, err := er.ReadByte()
34 | if err != nil {
35 | break loop
36 | }
37 | if c2 != 0x5b {
38 | continue
39 | }
40 |
41 | var buf bytes.Buffer
42 | for {
43 | c, err := er.ReadByte()
44 | if err != nil {
45 | break loop
46 | }
47 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
48 | break
49 | }
50 | buf.Write([]byte(string(c)))
51 | }
52 | }
53 |
54 | return len(data), nil
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - tip
4 |
5 | os:
6 | - linux
7 | - osx
8 |
9 | before_install:
10 | - go get github.com/mattn/goveralls
11 | - go get golang.org/x/tools/cmd/cover
12 | script:
13 | - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5
14 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) Yasuhiro MATSUMOTO
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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/README.md:
--------------------------------------------------------------------------------
1 | # go-isatty
2 |
3 | [](http://godoc.org/github.com/mattn/go-isatty)
4 | [](https://travis-ci.org/mattn/go-isatty)
5 | [](https://coveralls.io/github/mattn/go-isatty?branch=master)
6 | [](https://goreportcard.com/report/mattn/go-isatty)
7 |
8 | isatty for golang
9 |
10 | ## Usage
11 |
12 | ```go
13 | package main
14 |
15 | import (
16 | "fmt"
17 | "github.com/mattn/go-isatty"
18 | "os"
19 | )
20 |
21 | func main() {
22 | if isatty.IsTerminal(os.Stdout.Fd()) {
23 | fmt.Println("Is Terminal")
24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
25 | fmt.Println("Is Cygwin/MSYS2 Terminal")
26 | } else {
27 | fmt.Println("Is Not Terminal")
28 | }
29 | }
30 | ```
31 |
32 | ## Installation
33 |
34 | ```
35 | $ go get github.com/mattn/go-isatty
36 | ```
37 |
38 | ## License
39 |
40 | MIT
41 |
42 | ## Author
43 |
44 | Yasuhiro Matsumoto (a.k.a mattn)
45 |
46 | ## Thanks
47 |
48 | * k-takata: base idea for IsCygwinTerminal
49 |
50 | https://github.com/k-takata/go-iscygpty
51 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/doc.go:
--------------------------------------------------------------------------------
1 | // Package isatty implements interface to isatty
2 | package isatty
3 |
--------------------------------------------------------------------------------
/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/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/github.com/mattn/go-isatty/isatty_linux.go:
--------------------------------------------------------------------------------
1 | // +build linux
2 | // +build !appengine,!ppc64,!ppc64le
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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go:
--------------------------------------------------------------------------------
1 | // +build linux
2 | // +build ppc64 ppc64le
3 |
4 | package isatty
5 |
6 | import (
7 | "unsafe"
8 |
9 | syscall "golang.org/x/sys/unix"
10 | )
11 |
12 | const ioctlReadTermios = syscall.TCGETS
13 |
14 | // IsTerminal return true if the file descriptor is terminal.
15 | func IsTerminal(fd uintptr) bool {
16 | var termios syscall.Termios
17 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
18 | return err == 0
19 | }
20 |
--------------------------------------------------------------------------------
/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/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_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/valyala/bytebufferpool/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 |
3 | go:
4 | - 1.6
5 |
6 | script:
7 | # build test for supported platforms
8 | - GOOS=linux go build
9 | - GOOS=darwin go build
10 | - GOOS=freebsd go build
11 | - GOOS=windows go build
12 | - GOARCH=386 go build
13 |
14 | # run tests on a standard platform
15 | - go test -v ./...
16 |
--------------------------------------------------------------------------------
/vendor/github.com/valyala/bytebufferpool/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Aliaksandr Valialkin, VertaMedia
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/github.com/valyala/bytebufferpool/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/valyala/bytebufferpool)
2 | [](http://godoc.org/github.com/valyala/bytebufferpool)
3 | [](http://goreportcard.com/report/valyala/bytebufferpool)
4 |
5 | # bytebufferpool
6 |
7 | An implementation of a pool of byte buffers with anti-memory-waste protection.
8 |
9 | The pool may waste limited amount of memory due to fragmentation.
10 | This amount equals to the maximum total size of the byte buffers
11 | in concurrent use.
12 |
13 | # Benchmark results
14 | Currently bytebufferpool is fastest and most effective buffer pool written in Go.
15 |
16 | You can find results [here](https://omgnull.github.io/go-benchmark/buffer/).
17 |
18 | # bytebufferpool users
19 |
20 | * [fasthttp](https://github.com/valyala/fasthttp)
21 | * [quicktemplate](https://github.com/valyala/quicktemplate)
22 |
--------------------------------------------------------------------------------
/vendor/github.com/valyala/bytebufferpool/doc.go:
--------------------------------------------------------------------------------
1 | // Package bytebufferpool implements a pool of byte buffers
2 | // with anti-fragmentation protection.
3 | //
4 | // The pool may waste limited amount of memory due to fragmentation.
5 | // This amount equals to the maximum total size of the byte buffers
6 | // in concurrent use.
7 | package bytebufferpool
8 |
--------------------------------------------------------------------------------
/vendor/github.com/valyala/fasttemplate/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Aliaksandr Valialkin
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/github.com/valyala/fasttemplate/unsafe.go:
--------------------------------------------------------------------------------
1 | // +build !appengine
2 |
3 | package fasttemplate
4 |
5 | import (
6 | "reflect"
7 | "unsafe"
8 | )
9 |
10 | func unsafeBytes2String(b []byte) string {
11 | return *(*string)(unsafe.Pointer(&b))
12 | }
13 |
14 | func unsafeString2Bytes(s string) []byte {
15 | sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
16 | bh := reflect.SliceHeader{
17 | Data: sh.Data,
18 | Len: sh.Len,
19 | Cap: sh.Len,
20 | }
21 | return *(*[]byte)(unsafe.Pointer(&bh))
22 | }
23 |
--------------------------------------------------------------------------------
/vendor/github.com/valyala/fasttemplate/unsafe_gae.go:
--------------------------------------------------------------------------------
1 | // +build appengine
2 |
3 | package fasttemplate
4 |
5 | func unsafeBytes2String(b []byte) string {
6 | return string(b)
7 | }
8 |
9 | func unsafeString2Bytes(s string) []byte {
10 | return []byte(s)
11 | }
12 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/AUTHORS:
--------------------------------------------------------------------------------
1 | # This source code refers to The Go Authors for copyright purposes.
2 | # The master list of authors is in the main Go distribution,
3 | # visible at https://tip.golang.org/AUTHORS.
4 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/CONTRIBUTORS:
--------------------------------------------------------------------------------
1 | # This source code was written by the Go contributors.
2 | # The master list of contributors is in the main Go distribution,
3 | # visible at https://tip.golang.org/CONTRIBUTORS.
4 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009 The Go Authors. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google Inc. nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/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/AUTHORS:
--------------------------------------------------------------------------------
1 | # This source code refers to The Go Authors for copyright purposes.
2 | # The master list of authors is in the main Go distribution,
3 | # visible at http://tip.golang.org/AUTHORS.
4 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/CONTRIBUTORS:
--------------------------------------------------------------------------------
1 | # This source code was written by the Go contributors.
2 | # The master list of contributors is in the main Go distribution,
3 | # visible at http://tip.golang.org/CONTRIBUTORS.
4 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009 The Go Authors. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google Inc. nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/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/golang.org/x/sys/unix/.gitignore:
--------------------------------------------------------------------------------
1 | _obj/
2 | unix.test
3 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/aliases.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
6 | // +build go1.9
7 |
8 | package unix
9 |
10 | import "syscall"
11 |
12 | type Signal = syscall.Signal
13 | type Errno = syscall.Errno
14 | type SysProcAttr = syscall.SysProcAttr
15 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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 ppc64, AIX are implemented in runtime/syscall_aix.go
11 | //
12 |
13 | TEXT ·syscall6(SB),NOSPLIT,$0-88
14 | JMP syscall·syscall6(SB)
15 |
16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88
17 | JMP syscall·rawSyscall6(SB)
18 |
--------------------------------------------------------------------------------
/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_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_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/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 |
--------------------------------------------------------------------------------
/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-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_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_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_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_linux_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 calls for 386, Linux
11 | //
12 |
13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
14 | // instead of the glibc-specific "CALL 0x10(GS)".
15 | #define INVOKE_SYSCALL INT $0x80
16 |
17 | // Just jump to package syscall's implementation for all these functions.
18 | // The runtime may know about them.
19 |
20 | TEXT ·Syscall(SB),NOSPLIT,$0-28
21 | JMP syscall·Syscall(SB)
22 |
23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
24 | JMP syscall·Syscall6(SB)
25 |
26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
27 | CALL runtime·entersyscall(SB)
28 | MOVL trap+0(FP), AX // syscall entry
29 | MOVL a1+4(FP), BX
30 | MOVL a2+8(FP), CX
31 | MOVL a3+12(FP), DX
32 | MOVL $0, SI
33 | MOVL $0, DI
34 | INVOKE_SYSCALL
35 | MOVL AX, r1+16(FP)
36 | MOVL DX, r2+20(FP)
37 | CALL runtime·exitsyscall(SB)
38 | RET
39 |
40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
41 | JMP syscall·RawSyscall(SB)
42 |
43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
44 | JMP syscall·RawSyscall6(SB)
45 |
46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
47 | MOVL trap+0(FP), AX // syscall entry
48 | MOVL a1+4(FP), BX
49 | MOVL a2+8(FP), CX
50 | MOVL a3+12(FP), DX
51 | MOVL $0, SI
52 | MOVL $0, DI
53 | INVOKE_SYSCALL
54 | MOVL AX, r1+16(FP)
55 | MOVL DX, r2+20(FP)
56 | RET
57 |
58 | TEXT ·socketcall(SB),NOSPLIT,$0-36
59 | JMP syscall·socketcall(SB)
60 |
61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
62 | JMP syscall·rawsocketcall(SB)
63 |
64 | TEXT ·seek(SB),NOSPLIT,$0-28
65 | JMP syscall·seek(SB)
66 |
--------------------------------------------------------------------------------
/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 ·SyscallNoError(SB),NOSPLIT,$0-48
23 | CALL runtime·entersyscall(SB)
24 | MOVQ a1+8(FP), DI
25 | MOVQ a2+16(FP), SI
26 | MOVQ a3+24(FP), DX
27 | MOVQ $0, R10
28 | MOVQ $0, R8
29 | MOVQ $0, R9
30 | MOVQ trap+0(FP), AX // syscall entry
31 | SYSCALL
32 | MOVQ AX, r1+32(FP)
33 | MOVQ DX, r2+40(FP)
34 | CALL runtime·exitsyscall(SB)
35 | RET
36 |
37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
38 | JMP syscall·RawSyscall(SB)
39 |
40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
41 | JMP syscall·RawSyscall6(SB)
42 |
43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
44 | MOVQ a1+8(FP), DI
45 | MOVQ a2+16(FP), SI
46 | MOVQ a3+24(FP), DX
47 | MOVQ $0, R10
48 | MOVQ $0, R8
49 | MOVQ $0, R9
50 | MOVQ trap+0(FP), AX // syscall entry
51 | SYSCALL
52 | MOVQ AX, r1+32(FP)
53 | MOVQ DX, r2+40(FP)
54 | RET
55 |
56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16
57 | JMP syscall·gettimeofday(SB)
58 |
--------------------------------------------------------------------------------
/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 ·SyscallNoError(SB),NOSPLIT,$0-24
23 | BL runtime·entersyscall(SB)
24 | MOVW trap+0(FP), R7
25 | MOVW a1+4(FP), R0
26 | MOVW a2+8(FP), R1
27 | MOVW a3+12(FP), R2
28 | MOVW $0, R3
29 | MOVW $0, R4
30 | MOVW $0, R5
31 | SWI $0
32 | MOVW R0, r1+16(FP)
33 | MOVW $0, R0
34 | MOVW R0, r2+20(FP)
35 | BL runtime·exitsyscall(SB)
36 | RET
37 |
38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
39 | B syscall·RawSyscall(SB)
40 |
41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
42 | B syscall·RawSyscall6(SB)
43 |
44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
45 | MOVW trap+0(FP), R7 // syscall entry
46 | MOVW a1+4(FP), R0
47 | MOVW a2+8(FP), R1
48 | MOVW a3+12(FP), R2
49 | SWI $0
50 | MOVW R0, r1+16(FP)
51 | MOVW $0, R0
52 | MOVW R0, r2+20(FP)
53 | RET
54 |
55 | TEXT ·seek(SB),NOSPLIT,$0-28
56 | B syscall·seek(SB)
57 |
--------------------------------------------------------------------------------
/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 ·SyscallNoError(SB),NOSPLIT,$0-48
21 | BL runtime·entersyscall(SB)
22 | MOVD a1+8(FP), R0
23 | MOVD a2+16(FP), R1
24 | MOVD a3+24(FP), R2
25 | MOVD $0, R3
26 | MOVD $0, R4
27 | MOVD $0, R5
28 | MOVD trap+0(FP), R8 // syscall entry
29 | SVC
30 | MOVD R0, r1+32(FP) // r1
31 | MOVD R1, r2+40(FP) // r2
32 | BL runtime·exitsyscall(SB)
33 | RET
34 |
35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
36 | B syscall·RawSyscall(SB)
37 |
38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
39 | B syscall·RawSyscall6(SB)
40 |
41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
42 | MOVD a1+8(FP), R0
43 | MOVD a2+16(FP), R1
44 | MOVD a3+24(FP), R2
45 | MOVD $0, R3
46 | MOVD $0, R4
47 | MOVD $0, R5
48 | MOVD trap+0(FP), R8 // syscall entry
49 | SVC
50 | MOVD R0, r1+32(FP)
51 | MOVD R1, r2+40(FP)
52 | RET
53 |
--------------------------------------------------------------------------------
/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 ·SyscallNoError(SB),NOSPLIT,$0-48
25 | JAL runtime·entersyscall(SB)
26 | MOVV a1+8(FP), R4
27 | MOVV a2+16(FP), R5
28 | MOVV a3+24(FP), R6
29 | MOVV R0, R7
30 | MOVV R0, R8
31 | MOVV R0, R9
32 | MOVV trap+0(FP), R2 // syscall entry
33 | SYSCALL
34 | MOVV R2, r1+32(FP)
35 | MOVV R3, r2+40(FP)
36 | JAL runtime·exitsyscall(SB)
37 | RET
38 |
39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
40 | JMP syscall·RawSyscall(SB)
41 |
42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
43 | JMP syscall·RawSyscall6(SB)
44 |
45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
46 | MOVV a1+8(FP), R4
47 | MOVV a2+16(FP), R5
48 | MOVV a3+24(FP), R6
49 | MOVV R0, R7
50 | MOVV R0, R8
51 | MOVV R0, R9
52 | MOVV trap+0(FP), R2 // syscall entry
53 | SYSCALL
54 | MOVV R2, r1+32(FP)
55 | MOVV R3, r2+40(FP)
56 | RET
57 |
--------------------------------------------------------------------------------
/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 ·SyscallNoError(SB),NOSPLIT,$0-24
28 | JAL runtime·entersyscall(SB)
29 | MOVW a1+4(FP), R4
30 | MOVW a2+8(FP), R5
31 | MOVW a3+12(FP), R6
32 | MOVW R0, R7
33 | MOVW trap+0(FP), R2 // syscall entry
34 | SYSCALL
35 | MOVW R2, r1+16(FP) // r1
36 | MOVW R3, r2+20(FP) // r2
37 | JAL runtime·exitsyscall(SB)
38 | RET
39 |
40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
41 | JMP syscall·RawSyscall(SB)
42 |
43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
44 | JMP syscall·RawSyscall6(SB)
45 |
46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
47 | MOVW a1+4(FP), R4
48 | MOVW a2+8(FP), R5
49 | MOVW a3+12(FP), R6
50 | MOVW trap+0(FP), R2 // syscall entry
51 | SYSCALL
52 | MOVW R2, r1+16(FP)
53 | MOVW R3, r2+20(FP)
54 | RET
55 |
--------------------------------------------------------------------------------
/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 ·SyscallNoError(SB),NOSPLIT,$0-48
25 | BL runtime·entersyscall(SB)
26 | MOVD a1+8(FP), R3
27 | MOVD a2+16(FP), R4
28 | MOVD a3+24(FP), R5
29 | MOVD R0, R6
30 | MOVD R0, R7
31 | MOVD R0, R8
32 | MOVD trap+0(FP), R9 // syscall entry
33 | SYSCALL R9
34 | MOVD R3, r1+32(FP)
35 | MOVD R4, r2+40(FP)
36 | BL runtime·exitsyscall(SB)
37 | RET
38 |
39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
40 | BR syscall·RawSyscall(SB)
41 |
42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
43 | BR syscall·RawSyscall6(SB)
44 |
45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
46 | MOVD a1+8(FP), R3
47 | MOVD a2+16(FP), R4
48 | MOVD a3+24(FP), R5
49 | MOVD R0, R6
50 | MOVD R0, R7
51 | MOVD R0, R8
52 | MOVD trap+0(FP), R9 // syscall entry
53 | SYSCALL R9
54 | MOVD R3, r1+32(FP)
55 | MOVD R4, r2+40(FP)
56 | RET
57 |
--------------------------------------------------------------------------------
/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 ·SyscallNoError(SB),NOSPLIT,$0-48
25 | BL runtime·entersyscall(SB)
26 | MOVD a1+8(FP), R2
27 | MOVD a2+16(FP), R3
28 | MOVD a3+24(FP), R4
29 | MOVD $0, R5
30 | MOVD $0, R6
31 | MOVD $0, R7
32 | MOVD trap+0(FP), R1 // syscall entry
33 | SYSCALL
34 | MOVD R2, r1+32(FP)
35 | MOVD R3, r2+40(FP)
36 | BL runtime·exitsyscall(SB)
37 | RET
38 |
39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
40 | BR syscall·RawSyscall(SB)
41 |
42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
43 | BR syscall·RawSyscall6(SB)
44 |
45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
46 | MOVD a1+8(FP), R2
47 | MOVD a2+16(FP), R3
48 | MOVD a3+24(FP), R4
49 | MOVD $0, R5
50 | MOVD $0, R6
51 | MOVD $0, R7
52 | MOVD trap+0(FP), R1 // syscall entry
53 | SYSCALL
54 | MOVD R2, r1+32(FP)
55 | MOVD R3, r2+40(FP)
56 | RET
57 |
--------------------------------------------------------------------------------
/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_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_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_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/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_openbsd_arm.s:
--------------------------------------------------------------------------------
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 !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for ARM, 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 | 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_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/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/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 aix 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/dev_aix_ppc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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 aix
6 | // +build ppc
7 |
8 | // Functions to access/create device major and minor numbers matching the
9 | // encoding used by AIX.
10 |
11 | package unix
12 |
13 | // Major returns the major component of a Linux device number.
14 | func Major(dev uint64) uint32 {
15 | return uint32((dev >> 16) & 0xffff)
16 | }
17 |
18 | // Minor returns the minor component of a Linux device number.
19 | func Minor(dev uint64) uint32 {
20 | return uint32(dev & 0xffff)
21 | }
22 |
23 | // Mkdev returns a Linux device number generated from the given major and minor
24 | // components.
25 | func Mkdev(major, minor uint32) uint64 {
26 | return uint64(((major) << 16) | (minor))
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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 aix
6 | // +build ppc64
7 |
8 | // Functions to access/create device major and minor numbers matching the
9 | // encoding used AIX.
10 |
11 | package unix
12 |
13 | // Major returns the major component of a Linux device number.
14 | func Major(dev uint64) uint32 {
15 | return uint32((dev & 0x3fffffff00000000) >> 32)
16 | }
17 |
18 | // Minor returns the minor component of a Linux device number.
19 | func Minor(dev uint64) uint32 {
20 | return uint32((dev & 0x00000000ffffffff) >> 0)
21 | }
22 |
23 | // Mkdev returns a Linux device number generated from the given major and minor
24 | // components.
25 | func Mkdev(major, minor uint32) uint64 {
26 | var DEVNO64 uint64
27 | DEVNO64 = 0x8000000000000000
28 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64)
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dev_darwin.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 | // Functions to access/create device major and minor numbers matching the
6 | // encoding used in Darwin's sys/types.h header.
7 |
8 | package unix
9 |
10 | // Major returns the major component of a Darwin device number.
11 | func Major(dev uint64) uint32 {
12 | return uint32((dev >> 24) & 0xff)
13 | }
14 |
15 | // Minor returns the minor component of a Darwin device number.
16 | func Minor(dev uint64) uint32 {
17 | return uint32(dev & 0xffffff)
18 | }
19 |
20 | // Mkdev returns a Darwin device number generated from the given major and minor
21 | // components.
22 | func Mkdev(major, minor uint32) uint64 {
23 | return (uint64(major) << 24) | uint64(minor)
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dev_dragonfly.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 | // Functions to access/create device major and minor numbers matching the
6 | // encoding used in Dragonfly's sys/types.h header.
7 | //
8 | // The information below is extracted and adapted from sys/types.h:
9 | //
10 | // Minor gives a cookie instead of an index since in order to avoid changing the
11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
12 | // devices that don't use them.
13 |
14 | package unix
15 |
16 | // Major returns the major component of a DragonFlyBSD device number.
17 | func Major(dev uint64) uint32 {
18 | return uint32((dev >> 8) & 0xff)
19 | }
20 |
21 | // Minor returns the minor component of a DragonFlyBSD device number.
22 | func Minor(dev uint64) uint32 {
23 | return uint32(dev & 0xffff00ff)
24 | }
25 |
26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and
27 | // minor components.
28 | func Mkdev(major, minor uint32) uint64 {
29 | return (uint64(major) << 8) | uint64(minor)
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dev_freebsd.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 | // Functions to access/create device major and minor numbers matching the
6 | // encoding used in FreeBSD's sys/types.h header.
7 | //
8 | // The information below is extracted and adapted from sys/types.h:
9 | //
10 | // Minor gives a cookie instead of an index since in order to avoid changing the
11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
12 | // devices that don't use them.
13 |
14 | package unix
15 |
16 | // Major returns the major component of a FreeBSD device number.
17 | func Major(dev uint64) uint32 {
18 | return uint32((dev >> 8) & 0xff)
19 | }
20 |
21 | // Minor returns the minor component of a FreeBSD device number.
22 | func Minor(dev uint64) uint32 {
23 | return uint32(dev & 0xffff00ff)
24 | }
25 |
26 | // Mkdev returns a FreeBSD device number generated from the given major and
27 | // minor components.
28 | func Mkdev(major, minor uint32) uint64 {
29 | return (uint64(major) << 8) | uint64(minor)
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dev_linux.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 | // Functions to access/create device major and minor numbers matching the
6 | // encoding used by the Linux kernel and glibc.
7 | //
8 | // The information below is extracted and adapted from bits/sysmacros.h in the
9 | // glibc sources:
10 | //
11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
13 | // number and m is a hex digit of the minor number. This is backward compatible
14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
15 | // backward compatible with the Linux kernel, which for some architectures uses
16 | // 32-bit dev_t, encoded as mmmM MMmm.
17 |
18 | package unix
19 |
20 | // Major returns the major component of a Linux device number.
21 | func Major(dev uint64) uint32 {
22 | major := uint32((dev & 0x00000000000fff00) >> 8)
23 | major |= uint32((dev & 0xfffff00000000000) >> 32)
24 | return major
25 | }
26 |
27 | // Minor returns the minor component of a Linux device number.
28 | func Minor(dev uint64) uint32 {
29 | minor := uint32((dev & 0x00000000000000ff) >> 0)
30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12)
31 | return minor
32 | }
33 |
34 | // Mkdev returns a Linux device number generated from the given major and minor
35 | // components.
36 | func Mkdev(major, minor uint32) uint64 {
37 | dev := (uint64(major) & 0x00000fff) << 8
38 | dev |= (uint64(major) & 0xfffff000) << 32
39 | dev |= (uint64(minor) & 0x000000ff) << 0
40 | dev |= (uint64(minor) & 0xffffff00) << 12
41 | return dev
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dev_netbsd.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 | // Functions to access/create device major and minor numbers matching the
6 | // encoding used in NetBSD's sys/types.h header.
7 |
8 | package unix
9 |
10 | // Major returns the major component of a NetBSD device number.
11 | func Major(dev uint64) uint32 {
12 | return uint32((dev & 0x000fff00) >> 8)
13 | }
14 |
15 | // Minor returns the minor component of a NetBSD device number.
16 | func Minor(dev uint64) uint32 {
17 | minor := uint32((dev & 0x000000ff) >> 0)
18 | minor |= uint32((dev & 0xfff00000) >> 12)
19 | return minor
20 | }
21 |
22 | // Mkdev returns a NetBSD device number generated from the given major and minor
23 | // components.
24 | func Mkdev(major, minor uint32) uint64 {
25 | dev := (uint64(major) << 8) & 0x000fff00
26 | dev |= (uint64(minor) << 12) & 0xfff00000
27 | dev |= (uint64(minor) << 0) & 0x000000ff
28 | return dev
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dev_openbsd.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 | // Functions to access/create device major and minor numbers matching the
6 | // encoding used in OpenBSD's sys/types.h header.
7 |
8 | package unix
9 |
10 | // Major returns the major component of an OpenBSD device number.
11 | func Major(dev uint64) uint32 {
12 | return uint32((dev & 0x0000ff00) >> 8)
13 | }
14 |
15 | // Minor returns the minor component of an OpenBSD device number.
16 | func Minor(dev uint64) uint32 {
17 | minor := uint32((dev & 0x000000ff) >> 0)
18 | minor |= uint32((dev & 0xffff0000) >> 8)
19 | return minor
20 | }
21 |
22 | // Mkdev returns an OpenBSD device number generated from the given major and minor
23 | // components.
24 | func Mkdev(major, minor uint32) uint64 {
25 | dev := (uint64(major) << 8) & 0x0000ff00
26 | dev |= (uint64(minor) << 8) & 0xffff0000
27 | dev |= (uint64(minor) << 0) & 0x000000ff
28 | return dev
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dirent.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 aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | // ParseDirent parses up to max directory entries in buf,
12 | // appending the names to names. It returns the number of
13 | // bytes consumed from buf, the number of entries added
14 | // to names, and the new names slice.
15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
16 | return syscall.ParseDirent(buf, max, names)
17 | }
18 |
--------------------------------------------------------------------------------
/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/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/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 aix 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 |
29 | func Unsetenv(key string) error {
30 | return syscall.Unsetenv(key)
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/fcntl.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
6 |
7 | package unix
8 |
9 | import "unsafe"
10 |
11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64.
13 | var fcntl64Syscall uintptr = SYS_FCNTL
14 |
15 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument.
16 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
17 | valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg))
18 | var err error
19 | if errno != 0 {
20 | err = errno
21 | }
22 | return int(valptr), err
23 | }
24 |
25 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
26 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
27 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
28 | if errno == 0 {
29 | return nil
30 | }
31 | return errno
32 | }
33 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/fcntl_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 |
--------------------------------------------------------------------------------
/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 | // +build !aix
7 |
8 | package unix
9 |
10 | import "syscall"
11 |
12 | // We can't use the gc-syntax .s files for gccgo. On the plus side
13 | // much of the functionality can be written directly in Go.
14 |
15 | //extern gccgoRealSyscallNoError
16 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
17 |
18 | //extern gccgoRealSyscall
19 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
20 |
21 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
22 | syscall.Entersyscall()
23 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
24 | syscall.Exitsyscall()
25 | return r, 0
26 | }
27 |
28 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
29 | syscall.Entersyscall()
30 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
31 | syscall.Exitsyscall()
32 | return r, 0, syscall.Errno(errno)
33 | }
34 |
35 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
36 | syscall.Entersyscall()
37 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
38 | syscall.Exitsyscall()
39 | return r, 0, syscall.Errno(errno)
40 | }
41 |
42 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
43 | syscall.Entersyscall()
44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
45 | syscall.Exitsyscall()
46 | return r, 0, syscall.Errno(errno)
47 | }
48 |
49 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
50 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
51 | return r, 0
52 | }
53 |
54 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
55 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
56 | return r, 0, syscall.Errno(errno)
57 | }
58 |
59 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
60 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
61 | return r, 0, syscall.Errno(errno)
62 | }
63 |
--------------------------------------------------------------------------------
/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 | // +build !aix
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #define _STRINGIFY2_(x) #x
13 | #define _STRINGIFY_(x) _STRINGIFY2_(x)
14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
15 |
16 | // Call syscall from C code because the gccgo support for calling from
17 | // Go to C does not support varargs functions.
18 |
19 | struct ret {
20 | uintptr_t r;
21 | uintptr_t err;
22 | };
23 |
24 | struct ret
25 | 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)
26 | {
27 | struct ret r;
28 |
29 | errno = 0;
30 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
31 | r.err = errno;
32 | return r;
33 | }
34 |
35 | uintptr_t
36 | gccgoRealSyscallNoError(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)
37 | {
38 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
39 | }
40 |
--------------------------------------------------------------------------------
/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/golang.org/x/sys/unix/ioctl.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | import "runtime"
10 |
11 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
12 | //
13 | // To change fd's window size, the req argument should be TIOCSWINSZ.
14 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
15 | // TODO: if we get the chance, remove the req parameter and
16 | // hardcode TIOCSWINSZ.
17 | err := ioctlSetWinsize(fd, req, value)
18 | runtime.KeepAlive(value)
19 | return err
20 | }
21 |
22 | // IoctlSetTermios performs an ioctl on fd with a *Termios.
23 | //
24 | // The req value will usually be TCSETA or TIOCSETA.
25 | func IoctlSetTermios(fd int, req uint, value *Termios) error {
26 | // TODO: if we get the chance, remove the req parameter.
27 | err := ioctlSetTermios(fd, req, value)
28 | runtime.KeepAlive(value)
29 | return err
30 | }
31 |
--------------------------------------------------------------------------------
/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 <){
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+\S+\s+(?:NO)?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 <){
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 '13' || $compat eq '30' || $compat eq '50') {
51 | print " $name = $num; // $proto\n";
52 | }
53 | }
54 | }
55 |
56 | 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 <= 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/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 aix 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 | //
15 | // The primary use of this package is inside other packages that provide a more
16 | // portable interface to the system, such as "os", "time" and "net". Use
17 | // those packages rather than this one if you can.
18 | //
19 | // For details of the functions and data types in this package consult
20 | // the manuals for the appropriate operating system.
21 | //
22 | // These calls return err == nil to indicate success; otherwise
23 | // err represents an operating system error describing the failure and
24 | // holds a value of type syscall.Errno.
25 | package unix // import "golang.org/x/sys/unix"
26 |
27 | import "strings"
28 |
29 | // ByteSliceFromString returns a NUL-terminated slice of bytes
30 | // containing the text of s. If s contains a NUL byte at any
31 | // location, it returns (nil, EINVAL).
32 | func ByteSliceFromString(s string) ([]byte, error) {
33 | if strings.IndexByte(s, 0) != -1 {
34 | return nil, EINVAL
35 | }
36 | a := make([]byte, len(s)+1)
37 | copy(a, s)
38 | return a, nil
39 | }
40 |
41 | // BytePtrFromString returns a pointer to a NUL-terminated array of
42 | // bytes containing the text of s. If s contains a NUL byte at any
43 | // location, it returns (nil, EINVAL).
44 | func BytePtrFromString(s string) (*byte, error) {
45 | a, err := ByteSliceFromString(s)
46 | if err != nil {
47 | return nil, err
48 | }
49 | return &a[0], nil
50 | }
51 |
52 | // Single-word zero for use when we need a valid pointer to 0 bytes.
53 | // See mkunix.pl.
54 | var _zero uintptr
55 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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 aix
6 | // +build ppc
7 |
8 | package unix
9 |
10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64
11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64
12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64
13 |
14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
15 |
16 | func setTimespec(sec, nsec int64) Timespec {
17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
18 | }
19 |
20 | func setTimeval(sec, usec int64) Timeval {
21 | return Timeval{Sec: int32(sec), Usec: int32(usec)}
22 | }
23 |
24 | func (iov *Iovec) SetLen(length int) {
25 | iov.Len = uint32(length)
26 | }
27 |
28 | func (msghdr *Msghdr) SetControllen(length int) {
29 | msghdr.Controllen = uint32(length)
30 | }
31 |
32 | func (cmsg *Cmsghdr) SetLen(length int) {
33 | cmsg.Len = uint32(length)
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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 aix
6 | // +build ppc64
7 |
8 | package unix
9 |
10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek
13 |
14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64
15 |
16 | func setTimespec(sec, nsec int64) Timespec {
17 | return Timespec{Sec: sec, Nsec: nsec}
18 | }
19 |
20 | func setTimeval(sec, usec int64) Timeval {
21 | return Timeval{Sec: int64(sec), Usec: int32(usec)}
22 | }
23 |
24 | func (iov *Iovec) SetLen(length int) {
25 | iov.Len = uint64(length)
26 | }
27 |
28 | func (msghdr *Msghdr) SetControllen(length int) {
29 | msghdr.Controllen = uint32(length)
30 | }
31 |
32 | func (cmsg *Cmsghdr) SetLen(length int) {
33 | cmsg.Len = uint32(length)
34 | }
35 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
16 | }
17 |
18 | func setTimeval(sec, usec int64) Timeval {
19 | return Timeval{Sec: int32(sec), Usec: int32(usec)}
20 | }
21 |
22 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
23 | func Gettimeofday(tv *Timeval) (err error) {
24 | // The tv passed to gettimeofday must be non-nil
25 | // but is otherwise unused. The answers come back
26 | // in the two registers.
27 | sec, usec, err := gettimeofday(tv)
28 | tv.Sec = int32(sec)
29 | tv.Usec = int32(usec)
30 | return err
31 | }
32 |
33 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
34 | k.Ident = uint32(fd)
35 | k.Filter = int16(mode)
36 | k.Flags = uint16(flags)
37 | }
38 |
39 | func (iov *Iovec) SetLen(length int) {
40 | iov.Len = uint32(length)
41 | }
42 |
43 | func (msghdr *Msghdr) SetControllen(length int) {
44 | msghdr.Controllen = uint32(length)
45 | }
46 |
47 | func (cmsg *Cmsghdr) SetLen(length int) {
48 | cmsg.Len = uint32(length)
49 | }
50 |
51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
52 | var length = uint64(count)
53 |
54 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
55 |
56 | written = int(length)
57 |
58 | if e1 != 0 {
59 | err = e1
60 | }
61 | return
62 | }
63 |
64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
65 |
66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
67 | // of darwin/386 the syscall is called sysctl instead of __sysctl.
68 | const SYS___SYSCTL = SYS_SYSCTL
69 |
--------------------------------------------------------------------------------
/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 | func setTimespec(sec, nsec int64) Timespec {
15 | return Timespec{Sec: sec, Nsec: nsec}
16 | }
17 |
18 | func setTimeval(sec, usec int64) Timeval {
19 | return Timeval{Sec: sec, Usec: int32(usec)}
20 | }
21 |
22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
23 | func Gettimeofday(tv *Timeval) (err error) {
24 | // The tv passed to gettimeofday must be non-nil
25 | // but is otherwise unused. The answers come back
26 | // in the two registers.
27 | sec, usec, err := gettimeofday(tv)
28 | tv.Sec = sec
29 | tv.Usec = usec
30 | return err
31 | }
32 |
33 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
34 | k.Ident = uint64(fd)
35 | k.Filter = int16(mode)
36 | k.Flags = uint16(flags)
37 | }
38 |
39 | func (iov *Iovec) SetLen(length int) {
40 | iov.Len = uint64(length)
41 | }
42 |
43 | func (msghdr *Msghdr) SetControllen(length int) {
44 | msghdr.Controllen = uint32(length)
45 | }
46 |
47 | func (cmsg *Cmsghdr) SetLen(length int) {
48 | cmsg.Len = uint32(length)
49 | }
50 |
51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
52 | var length = uint64(count)
53 |
54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
55 |
56 | written = int(length)
57 |
58 | if e1 != 0 {
59 | err = e1
60 | }
61 | return
62 | }
63 |
64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
65 |
66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
67 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl.
68 | const SYS___SYSCTL = SYS_SYSCTL
69 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
13 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
14 | }
15 |
16 | func setTimeval(sec, usec int64) Timeval {
17 | return Timeval{Sec: int32(sec), Usec: int32(usec)}
18 | }
19 |
20 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
21 | func Gettimeofday(tv *Timeval) (err error) {
22 | // The tv passed to gettimeofday must be non-nil
23 | // but is otherwise unused. The answers come back
24 | // in the two registers.
25 | sec, usec, err := gettimeofday(tv)
26 | tv.Sec = int32(sec)
27 | tv.Usec = int32(usec)
28 | return err
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 length = uint64(count)
51 |
52 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
53 |
54 | written = int(length)
55 |
56 | if e1 != 0 {
57 | err = e1
58 | }
59 | return
60 | }
61 |
62 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
63 |
64 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
65 | // of darwin/arm the syscall is called sysctl instead of __sysctl.
66 | const SYS___SYSCTL = SYS_SYSCTL
67 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
15 | return Timespec{Sec: sec, Nsec: nsec}
16 | }
17 |
18 | func setTimeval(sec, usec int64) Timeval {
19 | return Timeval{Sec: sec, Usec: int32(usec)}
20 | }
21 |
22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
23 | func Gettimeofday(tv *Timeval) (err error) {
24 | // The tv passed to gettimeofday must be non-nil
25 | // but is otherwise unused. The answers come back
26 | // in the two registers.
27 | sec, usec, err := gettimeofday(tv)
28 | tv.Sec = sec
29 | tv.Usec = usec
30 | return err
31 | }
32 |
33 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
34 | k.Ident = uint64(fd)
35 | k.Filter = int16(mode)
36 | k.Flags = uint16(flags)
37 | }
38 |
39 | func (iov *Iovec) SetLen(length int) {
40 | iov.Len = uint64(length)
41 | }
42 |
43 | func (msghdr *Msghdr) SetControllen(length int) {
44 | msghdr.Controllen = uint32(length)
45 | }
46 |
47 | func (cmsg *Cmsghdr) SetLen(length int) {
48 | cmsg.Len = uint32(length)
49 | }
50 |
51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
52 | var length = uint64(count)
53 |
54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
55 |
56 | written = int(length)
57 |
58 | if e1 != 0 {
59 | err = e1
60 | }
61 | return
62 | }
63 |
64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
65 |
66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
67 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl.
68 | const SYS___SYSCTL = SYS_SYSCTL
69 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
15 | return Timespec{Sec: sec, Nsec: nsec}
16 | }
17 |
18 | func setTimeval(sec, usec int64) Timeval {
19 | return Timeval{Sec: sec, Usec: usec}
20 | }
21 |
22 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
23 | k.Ident = uint64(fd)
24 | k.Filter = int16(mode)
25 | k.Flags = uint16(flags)
26 | }
27 |
28 | func (iov *Iovec) SetLen(length int) {
29 | iov.Len = uint64(length)
30 | }
31 |
32 | func (msghdr *Msghdr) SetControllen(length int) {
33 | msghdr.Controllen = uint32(length)
34 | }
35 |
36 | func (cmsg *Cmsghdr) SetLen(length int) {
37 | cmsg.Len = uint32(length)
38 | }
39 |
40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
41 | var writtenOut uint64 = 0
42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
43 |
44 | written = int(writtenOut)
45 |
46 | if e1 != 0 {
47 | err = e1
48 | }
49 | return
50 | }
51 |
52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
53 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
16 | }
17 |
18 | func setTimeval(sec, usec int64) Timeval {
19 | return Timeval{Sec: int32(sec), Usec: int32(usec)}
20 | }
21 |
22 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
23 | k.Ident = uint32(fd)
24 | k.Filter = int16(mode)
25 | k.Flags = uint16(flags)
26 | }
27 |
28 | func (iov *Iovec) SetLen(length int) {
29 | iov.Len = uint32(length)
30 | }
31 |
32 | func (msghdr *Msghdr) SetControllen(length int) {
33 | msghdr.Controllen = uint32(length)
34 | }
35 |
36 | func (cmsg *Cmsghdr) SetLen(length int) {
37 | cmsg.Len = uint32(length)
38 | }
39 |
40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
41 | var writtenOut uint64 = 0
42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
43 |
44 | written = int(writtenOut)
45 |
46 | if e1 != 0 {
47 | err = e1
48 | }
49 | return
50 | }
51 |
52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
53 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
15 | return Timespec{Sec: sec, Nsec: nsec}
16 | }
17 |
18 | func setTimeval(sec, usec int64) Timeval {
19 | return Timeval{Sec: sec, Usec: usec}
20 | }
21 |
22 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
23 | k.Ident = uint64(fd)
24 | k.Filter = int16(mode)
25 | k.Flags = uint16(flags)
26 | }
27 |
28 | func (iov *Iovec) SetLen(length int) {
29 | iov.Len = uint64(length)
30 | }
31 |
32 | func (msghdr *Msghdr) SetControllen(length int) {
33 | msghdr.Controllen = uint32(length)
34 | }
35 |
36 | func (cmsg *Cmsghdr) SetLen(length int) {
37 | cmsg.Len = uint32(length)
38 | }
39 |
40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
41 | var writtenOut uint64 = 0
42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
43 |
44 | written = int(writtenOut)
45 |
46 | if e1 != 0 {
47 | err = e1
48 | }
49 | return
50 | }
51 |
52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
53 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
15 | return Timespec{Sec: sec, Nsec: int32(nsec)}
16 | }
17 |
18 | func setTimeval(sec, usec int64) Timeval {
19 | return Timeval{Sec: sec, Usec: int32(usec)}
20 | }
21 |
22 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
23 | k.Ident = uint32(fd)
24 | k.Filter = int16(mode)
25 | k.Flags = uint16(flags)
26 | }
27 |
28 | func (iov *Iovec) SetLen(length int) {
29 | iov.Len = uint32(length)
30 | }
31 |
32 | func (msghdr *Msghdr) SetControllen(length int) {
33 | msghdr.Controllen = uint32(length)
34 | }
35 |
36 | func (cmsg *Cmsghdr) SetLen(length int) {
37 | cmsg.Len = uint32(length)
38 | }
39 |
40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
41 | var writtenOut uint64 = 0
42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
43 |
44 | written = int(writtenOut)
45 |
46 | if e1 != 0 {
47 | err = e1
48 | }
49 | return
50 | }
51 |
52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
53 |
--------------------------------------------------------------------------------
/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/golang.org/x/sys/unix/syscall_linux_gc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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,!gccgo
6 |
7 | package unix
8 |
9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail.
10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr)
11 |
12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't
13 | // fail.
14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr)
15 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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,!gccgo,386
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | // Underlying system call writes to newoffset via pointer.
12 | // Implemented in assembly to avoid allocation.
13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
14 |
15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
17 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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,gccgo,386
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) {
15 | var newoffset int64
16 | offsetLow := uint32(offset & 0xffffffff)
17 | offsetHigh := uint32((offset >> 32) & 0xffffffff)
18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0)
19 | return newoffset, err
20 | }
21 |
22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) {
23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0)
24 | return int(fd), err
25 | }
26 |
27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) {
28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0)
29 | return int(fd), err
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 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,gccgo,arm
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) {
15 | var newoffset int64
16 | offsetLow := uint32(offset & 0xffffffff)
17 | offsetHigh := uint32((offset >> 32) & 0xffffffff)
18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0)
19 | return newoffset, err
20 | }
21 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
10 | return Timespec{Sec: sec, Nsec: int32(nsec)}
11 | }
12 |
13 | func setTimeval(sec, usec int64) Timeval {
14 | return Timeval{Sec: sec, Usec: int32(usec)}
15 | }
16 |
17 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
18 | k.Ident = uint32(fd)
19 | k.Filter = uint32(mode)
20 | k.Flags = uint32(flags)
21 | }
22 |
23 | func (iov *Iovec) SetLen(length int) {
24 | iov.Len = uint32(length)
25 | }
26 |
27 | func (msghdr *Msghdr) SetControllen(length int) {
28 | msghdr.Controllen = uint32(length)
29 | }
30 |
31 | func (cmsg *Cmsghdr) SetLen(length int) {
32 | cmsg.Len = uint32(length)
33 | }
34 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
10 | return Timespec{Sec: sec, Nsec: nsec}
11 | }
12 |
13 | func setTimeval(sec, usec int64) Timeval {
14 | return Timeval{Sec: sec, Usec: int32(usec)}
15 | }
16 |
17 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
18 | k.Ident = uint64(fd)
19 | k.Filter = uint32(mode)
20 | k.Flags = uint32(flags)
21 | }
22 |
23 | func (iov *Iovec) SetLen(length int) {
24 | iov.Len = uint64(length)
25 | }
26 |
27 | func (msghdr *Msghdr) SetControllen(length int) {
28 | msghdr.Controllen = uint32(length)
29 | }
30 |
31 | func (cmsg *Cmsghdr) SetLen(length int) {
32 | cmsg.Len = uint32(length)
33 | }
34 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
10 | return Timespec{Sec: sec, Nsec: int32(nsec)}
11 | }
12 |
13 | func setTimeval(sec, usec int64) Timeval {
14 | return Timeval{Sec: sec, Usec: int32(usec)}
15 | }
16 |
17 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
18 | k.Ident = uint32(fd)
19 | k.Filter = uint32(mode)
20 | k.Flags = uint32(flags)
21 | }
22 |
23 | func (iov *Iovec) SetLen(length int) {
24 | iov.Len = uint32(length)
25 | }
26 |
27 | func (msghdr *Msghdr) SetControllen(length int) {
28 | msghdr.Controllen = uint32(length)
29 | }
30 |
31 | func (cmsg *Cmsghdr) SetLen(length int) {
32 | cmsg.Len = uint32(length)
33 | }
34 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
10 | return Timespec{Sec: sec, Nsec: int32(nsec)}
11 | }
12 |
13 | func setTimeval(sec, usec int64) Timeval {
14 | return Timeval{Sec: sec, Usec: int32(usec)}
15 | }
16 |
17 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
18 | k.Ident = uint32(fd)
19 | k.Filter = int16(mode)
20 | k.Flags = uint16(flags)
21 | }
22 |
23 | func (iov *Iovec) SetLen(length int) {
24 | iov.Len = uint32(length)
25 | }
26 |
27 | func (msghdr *Msghdr) SetControllen(length int) {
28 | msghdr.Controllen = uint32(length)
29 | }
30 |
31 | func (cmsg *Cmsghdr) SetLen(length int) {
32 | cmsg.Len = uint32(length)
33 | }
34 |
35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
36 | // of openbsd/386 the syscall is called sysctl instead of __sysctl.
37 | const SYS___SYSCTL = SYS_SYSCTL
38 |
--------------------------------------------------------------------------------
/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 setTimespec(sec, nsec int64) Timespec {
10 | return Timespec{Sec: sec, Nsec: nsec}
11 | }
12 |
13 | func setTimeval(sec, usec int64) Timeval {
14 | return Timeval{Sec: sec, Usec: usec}
15 | }
16 |
17 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
18 | k.Ident = uint64(fd)
19 | k.Filter = int16(mode)
20 | k.Flags = uint16(flags)
21 | }
22 |
23 | func (iov *Iovec) SetLen(length int) {
24 | iov.Len = uint64(length)
25 | }
26 |
27 | func (msghdr *Msghdr) SetControllen(length int) {
28 | msghdr.Controllen = uint32(length)
29 | }
30 |
31 | func (cmsg *Cmsghdr) SetLen(length int) {
32 | cmsg.Len = uint32(length)
33 | }
34 |
35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl.
37 | const SYS___SYSCTL = SYS_SYSCTL
38 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.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 arm,openbsd
6 |
7 | package unix
8 |
9 | func setTimespec(sec, nsec int64) Timespec {
10 | return Timespec{Sec: sec, Nsec: int32(nsec)}
11 | }
12 |
13 | func setTimeval(sec, usec int64) Timeval {
14 | return Timeval{Sec: sec, Usec: int32(usec)}
15 | }
16 |
17 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
18 | k.Ident = uint32(fd)
19 | k.Filter = int16(mode)
20 | k.Flags = uint16(flags)
21 | }
22 |
23 | func (iov *Iovec) SetLen(length int) {
24 | iov.Len = uint32(length)
25 | }
26 |
27 | func (msghdr *Msghdr) SetControllen(length int) {
28 | msghdr.Controllen = uint32(length)
29 | }
30 |
31 | func (cmsg *Cmsghdr) SetLen(length int) {
32 | cmsg.Len = uint32(length)
33 | }
34 |
35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
36 | // of openbsd/arm the syscall is called sysctl instead of __sysctl.
37 | const SYS___SYSCTL = SYS_SYSCTL
38 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_solaris_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,solaris
6 |
7 | package unix
8 |
9 | func setTimespec(sec, nsec int64) Timespec {
10 | return Timespec{Sec: sec, Nsec: nsec}
11 | }
12 |
13 | func setTimeval(sec, usec int64) Timeval {
14 | return Timeval{Sec: sec, Usec: usec}
15 | }
16 |
17 | func (iov *Iovec) SetLen(length int) {
18 | iov.Len = uint64(length)
19 | }
20 |
21 | func (cmsg *Cmsghdr) SetLen(length int) {
22 | cmsg.Len = uint32(length)
23 | }
24 |
--------------------------------------------------------------------------------
/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/timestruct.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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | import "time"
10 |
11 | // TimespecToNsec converts a Timespec value into a number of
12 | // nanoseconds since the Unix epoch.
13 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
14 |
15 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch
16 | // and returns the corresponding Timespec value.
17 | func NsecToTimespec(nsec int64) Timespec {
18 | sec := nsec / 1e9
19 | nsec = nsec % 1e9
20 | if nsec < 0 {
21 | nsec += 1e9
22 | sec--
23 | }
24 | return setTimespec(sec, nsec)
25 | }
26 |
27 | // TimeToTimespec converts t into a Timespec.
28 | // On some 32-bit systems the range of valid Timespec values are smaller
29 | // than that of time.Time values. So if t is out of the valid range of
30 | // Timespec, it returns a zero Timespec and ERANGE.
31 | func TimeToTimespec(t time.Time) (Timespec, error) {
32 | sec := t.Unix()
33 | nsec := int64(t.Nanosecond())
34 | ts := setTimespec(sec, nsec)
35 |
36 | // Currently all targets have either int32 or int64 for Timespec.Sec.
37 | // If there were a new target with floating point type for it, we have
38 | // to consider the rounding error.
39 | if int64(ts.Sec) != sec {
40 | return Timespec{}, ERANGE
41 | }
42 | return ts, nil
43 | }
44 |
45 | // TimevalToNsec converts a Timeval value into a number of nanoseconds
46 | // since the Unix epoch.
47 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
48 |
49 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch
50 | // and returns the corresponding Timeval value.
51 | func NsecToTimeval(nsec int64) Timeval {
52 | nsec += 999 // round up to microsecond
53 | usec := nsec % 1e9 / 1e3
54 | sec := nsec / 1e9
55 | if usec < 0 {
56 | usec += 1e6
57 | sec--
58 | }
59 | return setTimeval(sec, usec)
60 | }
61 |
62 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the
63 | // Unix epoch.
64 | func (ts *Timespec) Unix() (sec int64, nsec int64) {
65 | return int64(ts.Sec), int64(ts.Nsec)
66 | }
67 |
68 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the
69 | // Unix epoch.
70 | func (tv *Timeval) Unix() (sec int64, nsec int64) {
71 | return int64(tv.Sec), int64(tv.Usec) * 1000
72 | }
73 |
74 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch.
75 | func (ts *Timespec) Nano() int64 {
76 | return int64(ts.Sec)*1e9 + int64(ts.Nsec)
77 | }
78 |
79 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch.
80 | func (tv *Timeval) Nano() int64 {
81 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
82 | }
83 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/zptrace386_linux.go:
--------------------------------------------------------------------------------
1 | // Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT.
2 |
3 | // +build linux
4 | // +build 386 amd64
5 |
6 | package unix
7 |
8 | import "unsafe"
9 |
10 | // PtraceRegs386 is the registers used by 386 binaries.
11 | type PtraceRegs386 struct {
12 | Ebx int32
13 | Ecx int32
14 | Edx int32
15 | Esi int32
16 | Edi int32
17 | Ebp int32
18 | Eax int32
19 | Xds int32
20 | Xes int32
21 | Xfs int32
22 | Xgs int32
23 | Orig_eax int32
24 | Eip int32
25 | Xcs int32
26 | Eflags int32
27 | Esp int32
28 | Xss int32
29 | }
30 |
31 | // PtraceGetRegs386 fetches the registers used by 386 binaries.
32 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error {
33 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
34 | }
35 |
36 | // PtraceSetRegs386 sets the registers used by 386 binaries.
37 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error {
38 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
39 | }
40 |
41 | // PtraceRegsAmd64 is the registers used by amd64 binaries.
42 | type PtraceRegsAmd64 struct {
43 | R15 uint64
44 | R14 uint64
45 | R13 uint64
46 | R12 uint64
47 | Rbp uint64
48 | Rbx uint64
49 | R11 uint64
50 | R10 uint64
51 | R9 uint64
52 | R8 uint64
53 | Rax uint64
54 | Rcx uint64
55 | Rdx uint64
56 | Rsi uint64
57 | Rdi uint64
58 | Orig_rax uint64
59 | Rip uint64
60 | Cs uint64
61 | Eflags uint64
62 | Rsp uint64
63 | Ss uint64
64 | Fs_base uint64
65 | Gs_base uint64
66 | Ds uint64
67 | Es uint64
68 | Fs uint64
69 | Gs uint64
70 | }
71 |
72 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries.
73 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error {
74 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
75 | }
76 |
77 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries.
78 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error {
79 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
80 | }
81 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/zptracearm_linux.go:
--------------------------------------------------------------------------------
1 | // Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT.
2 |
3 | // +build linux
4 | // +build arm arm64
5 |
6 | package unix
7 |
8 | import "unsafe"
9 |
10 | // PtraceRegsArm is the registers used by arm binaries.
11 | type PtraceRegsArm struct {
12 | Uregs [18]uint32
13 | }
14 |
15 | // PtraceGetRegsArm fetches the registers used by arm binaries.
16 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error {
17 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
18 | }
19 |
20 | // PtraceSetRegsArm sets the registers used by arm binaries.
21 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error {
22 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
23 | }
24 |
25 | // PtraceRegsArm64 is the registers used by arm64 binaries.
26 | type PtraceRegsArm64 struct {
27 | Regs [31]uint64
28 | Sp uint64
29 | Pc uint64
30 | Pstate uint64
31 | }
32 |
33 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries.
34 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error {
35 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
36 | }
37 |
38 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries.
39 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error {
40 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
41 | }
42 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/zptracemips_linux.go:
--------------------------------------------------------------------------------
1 | // Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT.
2 |
3 | // +build linux
4 | // +build mips mips64
5 |
6 | package unix
7 |
8 | import "unsafe"
9 |
10 | // PtraceRegsMips is the registers used by mips binaries.
11 | type PtraceRegsMips struct {
12 | Regs [32]uint64
13 | Lo uint64
14 | Hi uint64
15 | Epc uint64
16 | Badvaddr uint64
17 | Status uint64
18 | Cause uint64
19 | }
20 |
21 | // PtraceGetRegsMips fetches the registers used by mips binaries.
22 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error {
23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
24 | }
25 |
26 | // PtraceSetRegsMips sets the registers used by mips binaries.
27 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error {
28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
29 | }
30 |
31 | // PtraceRegsMips64 is the registers used by mips64 binaries.
32 | type PtraceRegsMips64 struct {
33 | Regs [32]uint64
34 | Lo uint64
35 | Hi uint64
36 | Epc uint64
37 | Badvaddr uint64
38 | Status uint64
39 | Cause uint64
40 | }
41 |
42 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries.
43 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error {
44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
45 | }
46 |
47 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries.
48 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error {
49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/zptracemipsle_linux.go:
--------------------------------------------------------------------------------
1 | // Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT.
2 |
3 | // +build linux
4 | // +build mipsle mips64le
5 |
6 | package unix
7 |
8 | import "unsafe"
9 |
10 | // PtraceRegsMipsle is the registers used by mipsle binaries.
11 | type PtraceRegsMipsle struct {
12 | Regs [32]uint64
13 | Lo uint64
14 | Hi uint64
15 | Epc uint64
16 | Badvaddr uint64
17 | Status uint64
18 | Cause uint64
19 | }
20 |
21 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries.
22 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error {
23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
24 | }
25 |
26 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries.
27 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error {
28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
29 | }
30 |
31 | // PtraceRegsMips64le is the registers used by mips64le binaries.
32 | type PtraceRegsMips64le struct {
33 | Regs [32]uint64
34 | Lo uint64
35 | Hi uint64
36 | Epc uint64
37 | Badvaddr uint64
38 | Status uint64
39 | Cause uint64
40 | }
41 |
42 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries.
43 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error {
44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
45 | }
46 |
47 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries.
48 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error {
49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/google.golang.org/appengine/cloudsql/cloudsql.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Google Inc. All rights reserved.
2 | // Use of this source code is governed by the Apache 2.0
3 | // license that can be found in the LICENSE file.
4 |
5 | /*
6 | Package cloudsql exposes access to Google Cloud SQL databases.
7 |
8 | This package does not work in App Engine "flexible environment".
9 |
10 | This package is intended for MySQL drivers to make App Engine-specific
11 | connections. Applications should use this package through database/sql:
12 | Select a pure Go MySQL driver that supports this package, and use sql.Open
13 | with protocol "cloudsql" and an address of the Cloud SQL instance.
14 |
15 | A Go MySQL driver that has been tested to work well with Cloud SQL
16 | is the go-sql-driver:
17 | import "database/sql"
18 | import _ "github.com/go-sql-driver/mysql"
19 |
20 | db, err := sql.Open("mysql", "user@cloudsql(project-id:instance-name)/dbname")
21 |
22 |
23 | Another driver that works well with Cloud SQL is the mymysql driver:
24 | import "database/sql"
25 | import _ "github.com/ziutek/mymysql/godrv"
26 |
27 | db, err := sql.Open("mymysql", "cloudsql:instance-name*dbname/user/password")
28 |
29 |
30 | Using either of these drivers, you can perform a standard SQL query.
31 | This example assumes there is a table named 'users' with
32 | columns 'first_name' and 'last_name':
33 |
34 | rows, err := db.Query("SELECT first_name, last_name FROM users")
35 | if err != nil {
36 | log.Errorf(ctx, "db.Query: %v", err)
37 | }
38 | defer rows.Close()
39 |
40 | for rows.Next() {
41 | var firstName string
42 | var lastName string
43 | if err := rows.Scan(&firstName, &lastName); err != nil {
44 | log.Errorf(ctx, "rows.Scan: %v", err)
45 | continue
46 | }
47 | log.Infof(ctx, "First: %v - Last: %v", firstName, lastName)
48 | }
49 | if err := rows.Err(); err != nil {
50 | log.Errorf(ctx, "Row error: %v", err)
51 | }
52 | */
53 | package cloudsql
54 |
55 | import (
56 | "net"
57 | )
58 |
59 | // Dial connects to the named Cloud SQL instance.
60 | func Dial(instance string) (net.Conn, error) {
61 | return connect(instance)
62 | }
63 |
--------------------------------------------------------------------------------
/vendor/google.golang.org/appengine/cloudsql/cloudsql_classic.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Google Inc. All rights reserved.
2 | // Use of this source code is governed by the Apache 2.0
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build appengine
6 |
7 | package cloudsql
8 |
9 | import (
10 | "net"
11 |
12 | "appengine/cloudsql"
13 | )
14 |
15 | func connect(instance string) (net.Conn, error) {
16 | return cloudsql.Dial(instance)
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/google.golang.org/appengine/cloudsql/cloudsql_vm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Google Inc. All rights reserved.
2 | // Use of this source code is governed by the Apache 2.0
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !appengine
6 |
7 | package cloudsql
8 |
9 | import (
10 | "errors"
11 | "net"
12 | )
13 |
14 | func connect(instance string) (net.Conn, error) {
15 | return nil, errors.New(`cloudsql: not supported in App Engine "flexible environment"`)
16 | }
17 |
--------------------------------------------------------------------------------