├── .gitignore ├── .promu.yml ├── .travis.yml ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── cmd └── sql_exporter │ ├── content.go │ ├── main.go │ └── promhttp.go ├── collector.go ├── config └── config.go ├── documentation └── sql_exporter.yml ├── errors └── errors.go ├── examples ├── mssql_standard.collector.yml └── sql_exporter.yml ├── exporter.go ├── job.go ├── metric.go ├── query.go ├── sql.go ├── target.go └── vendor ├── github.com ├── ClickHouse │ └── clickhouse-go │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── array.go │ │ ├── bootstrap.go │ │ ├── clickhouse.go │ │ ├── clickhouse_exception.go │ │ ├── clickhouse_ping.go │ │ ├── clickhouse_profile_info.go │ │ ├── clickhouse_progress.go │ │ ├── clickhouse_read_block.go │ │ ├── clickhouse_read_meta.go │ │ ├── clickhouse_send_query.go │ │ ├── clickhouse_write_block.go │ │ ├── connect.go │ │ ├── docker-compose.yml │ │ ├── go.mod │ │ ├── go.sum │ │ ├── go.test.sh │ │ ├── helpers.go │ │ ├── lib │ │ ├── binary │ │ │ ├── compress_reader.go │ │ │ ├── compress_reader_clz4.go │ │ │ ├── compress_settings.go │ │ │ ├── compress_writer.go │ │ │ ├── compress_writer_clz4.go │ │ │ ├── decoder.go │ │ │ └── encoder.go │ │ ├── cityhash102 │ │ │ ├── city64.go │ │ │ ├── cityhash.go │ │ │ └── doc.go │ │ ├── column │ │ │ ├── array.go │ │ │ ├── column.go │ │ │ ├── common.go │ │ │ ├── date.go │ │ │ ├── datetime.go │ │ │ ├── decimal.go │ │ │ ├── enum.go │ │ │ ├── fixed_string.go │ │ │ ├── float32.go │ │ │ ├── float64.go │ │ │ ├── int16.go │ │ │ ├── int32.go │ │ │ ├── int64.go │ │ │ ├── int8.go │ │ │ ├── ip.go │ │ │ ├── ipv4.go │ │ │ ├── ipv6.go │ │ │ ├── nullable.go │ │ │ ├── string.go │ │ │ ├── uint16.go │ │ │ ├── uint32.go │ │ │ ├── uint64.go │ │ │ ├── uint8.go │ │ │ └── uuid.go │ │ ├── data │ │ │ ├── block.go │ │ │ ├── block_write_column.go │ │ │ ├── client_info.go │ │ │ ├── server_info.go │ │ │ └── value.go │ │ ├── leakypool │ │ │ └── leaky_pool.go │ │ ├── lz4 │ │ │ ├── LICENSE │ │ │ ├── doc.go │ │ │ ├── fuzz.go │ │ │ ├── reader.go │ │ │ └── writer.go │ │ ├── protocol │ │ │ ├── README.md │ │ │ └── protocol.go │ │ ├── types │ │ │ ├── date.go │ │ │ └── uuid.go │ │ └── writebuffer │ │ │ └── buffer.go │ │ ├── query_settings.go │ │ ├── result.go │ │ ├── rows.go │ │ ├── stmt.go │ │ ├── tls_config.go │ │ ├── word_matcher.go │ │ └── write_column.go ├── beorn7 │ └── perks │ │ ├── LICENSE │ │ └── quantile │ │ ├── exampledata.txt │ │ └── stream.go ├── cespare │ └── xxhash │ │ └── v2 │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── xxhash.go │ │ ├── xxhash_amd64.go │ │ ├── xxhash_amd64.s │ │ ├── xxhash_other.go │ │ └── xxhash_unsafe.go ├── cloudflare │ └── golz4 │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── doc.go │ │ ├── lz4.go │ │ ├── lz4_hc.go │ │ └── sample.txt ├── denisenkom │ └── go-mssqldb │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── appveyor.yml │ │ ├── buf.go │ │ ├── bulkcopy.go │ │ ├── bulkcopy_sql.go │ │ ├── conn_str.go │ │ ├── convert.go │ │ ├── doc.go │ │ ├── error.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── internal │ │ ├── cp │ │ │ ├── charset.go │ │ │ ├── collation.go │ │ │ ├── cp1250.go │ │ │ ├── cp1251.go │ │ │ ├── cp1252.go │ │ │ ├── cp1253.go │ │ │ ├── cp1254.go │ │ │ ├── cp1255.go │ │ │ ├── cp1256.go │ │ │ ├── cp1257.go │ │ │ ├── cp1258.go │ │ │ ├── cp437.go │ │ │ ├── cp850.go │ │ │ ├── cp874.go │ │ │ ├── cp932.go │ │ │ ├── cp936.go │ │ │ ├── cp949.go │ │ │ └── cp950.go │ │ ├── decimal │ │ │ └── decimal.go │ │ └── querytext │ │ │ └── parser.go │ │ ├── log.go │ │ ├── mssql.go │ │ ├── mssql_go110.go │ │ ├── mssql_go110pre.go │ │ ├── mssql_go19.go │ │ ├── mssql_go19pre.go │ │ ├── net.go │ │ ├── ntlm.go │ │ ├── rpc.go │ │ ├── sspi_windows.go │ │ ├── tds.go │ │ ├── token.go │ │ ├── token_string.go │ │ ├── tran.go │ │ ├── tvp_go19.go │ │ ├── types.go │ │ └── uniqueidentifier.go ├── go-sql-driver │ └── mysql │ │ ├── AUTHORS │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── auth.go │ │ ├── buffer.go │ │ ├── collations.go │ │ ├── conncheck.go │ │ ├── conncheck_dummy.go │ │ ├── connection.go │ │ ├── connector.go │ │ ├── const.go │ │ ├── driver.go │ │ ├── driver_go110.go │ │ ├── dsn.go │ │ ├── errors.go │ │ ├── fields.go │ │ ├── go.mod │ │ ├── infile.go │ │ ├── nulltime.go │ │ ├── nulltime_go113.go │ │ ├── nulltime_legacy.go │ │ ├── packets.go │ │ ├── result.go │ │ ├── rows.go │ │ ├── statement.go │ │ ├── transaction.go │ │ └── utils.go ├── golang-sql │ └── civil │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── README.md │ │ └── civil.go ├── golang │ ├── glog │ │ ├── LICENSE │ │ ├── README │ │ ├── glog.go │ │ └── glog_file.go │ └── protobuf │ │ ├── LICENSE │ │ └── proto │ │ ├── clone.go │ │ ├── decode.go │ │ ├── deprecated.go │ │ ├── discard.go │ │ ├── encode.go │ │ ├── equal.go │ │ ├── extensions.go │ │ ├── lib.go │ │ ├── message_set.go │ │ ├── pointer_reflect.go │ │ ├── pointer_unsafe.go │ │ ├── properties.go │ │ ├── table_marshal.go │ │ ├── table_merge.go │ │ ├── table_unmarshal.go │ │ ├── text.go │ │ └── text_parser.go ├── lib │ └── pq │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── TESTS.md │ │ ├── array.go │ │ ├── buf.go │ │ ├── conn.go │ │ ├── conn_go18.go │ │ ├── connector.go │ │ ├── copy.go │ │ ├── doc.go │ │ ├── encode.go │ │ ├── error.go │ │ ├── go.mod │ │ ├── notify.go │ │ ├── oid │ │ ├── doc.go │ │ └── types.go │ │ ├── rows.go │ │ ├── scram │ │ └── scram.go │ │ ├── ssl.go │ │ ├── ssl_permissions.go │ │ ├── ssl_windows.go │ │ ├── url.go │ │ ├── user_posix.go │ │ ├── user_windows.go │ │ └── uuid.go ├── matttproud │ └── golang_protobuf_extensions │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── pbutil │ │ ├── Makefile │ │ ├── decode.go │ │ ├── doc.go │ │ └── encode.go └── prometheus │ ├── client_golang │ ├── LICENSE │ ├── NOTICE │ └── prometheus │ │ ├── README.md │ │ ├── build_info.go │ │ ├── build_info_pre_1.12.go │ │ ├── collector.go │ │ ├── counter.go │ │ ├── desc.go │ │ ├── doc.go │ │ ├── expvar_collector.go │ │ ├── fnv.go │ │ ├── gauge.go │ │ ├── go_collector.go │ │ ├── histogram.go │ │ ├── internal │ │ └── metric.go │ │ ├── labels.go │ │ ├── metric.go │ │ ├── observer.go │ │ ├── process_collector.go │ │ ├── process_collector_other.go │ │ ├── process_collector_windows.go │ │ ├── promhttp │ │ ├── delegator.go │ │ ├── http.go │ │ ├── instrument_client.go │ │ └── instrument_server.go │ │ ├── registry.go │ │ ├── summary.go │ │ ├── timer.go │ │ ├── untyped.go │ │ ├── value.go │ │ ├── vec.go │ │ └── wrap.go │ ├── client_model │ ├── LICENSE │ ├── NOTICE │ └── go │ │ └── metrics.pb.go │ ├── common │ ├── LICENSE │ ├── NOTICE │ ├── expfmt │ │ ├── decode.go │ │ ├── encode.go │ │ ├── expfmt.go │ │ ├── fuzz.go │ │ ├── text_create.go │ │ └── text_parse.go │ ├── internal │ │ └── bitbucket.org │ │ │ └── ww │ │ │ └── goautoneg │ │ │ ├── README.txt │ │ │ └── autoneg.go │ ├── model │ │ ├── alert.go │ │ ├── fingerprinting.go │ │ ├── fnv.go │ │ ├── labels.go │ │ ├── labelset.go │ │ ├── metric.go │ │ ├── model.go │ │ ├── signature.go │ │ ├── silence.go │ │ ├── time.go │ │ └── value.go │ └── version │ │ └── info.go │ └── procfs │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── MAINTAINERS.md │ ├── Makefile │ ├── Makefile.common │ ├── NOTICE │ ├── README.md │ ├── arp.go │ ├── buddyinfo.go │ ├── cpuinfo.go │ ├── crypto.go │ ├── doc.go │ ├── fixtures.ttar │ ├── fs.go │ ├── go.mod │ ├── go.sum │ ├── internal │ ├── fs │ │ └── fs.go │ └── util │ │ ├── parse.go │ │ ├── readfile.go │ │ ├── sysreadfile.go │ │ ├── sysreadfile_compat.go │ │ └── valueparser.go │ ├── ipvs.go │ ├── mdstat.go │ ├── meminfo.go │ ├── mountinfo.go │ ├── mountstats.go │ ├── net_dev.go │ ├── net_softnet.go │ ├── net_unix.go │ ├── proc.go │ ├── proc_environ.go │ ├── proc_fdinfo.go │ ├── proc_io.go │ ├── proc_limits.go │ ├── proc_ns.go │ ├── proc_psi.go │ ├── proc_stat.go │ ├── proc_status.go │ ├── schedstat.go │ ├── stat.go │ ├── ttar │ ├── vm.go │ ├── xfrm.go │ └── zoneinfo.go ├── golang.org └── x │ ├── crypto │ ├── LICENSE │ ├── PATENTS │ └── md4 │ │ ├── md4.go │ │ └── md4block.go │ └── sys │ ├── LICENSE │ ├── PATENTS │ └── windows │ ├── aliases.go │ ├── dll_windows.go │ ├── empty.s │ ├── env_windows.go │ ├── eventlog.go │ ├── exec_windows.go │ ├── memory_windows.go │ ├── mkerrors.bash │ ├── mkknownfolderids.bash │ ├── mksyscall.go │ ├── race.go │ ├── race0.go │ ├── security_windows.go │ ├── service.go │ ├── str.go │ ├── syscall.go │ ├── syscall_windows.go │ ├── types_windows.go │ ├── types_windows_386.go │ ├── types_windows_amd64.go │ ├── types_windows_arm.go │ ├── zerrors_windows.go │ ├── zknownfolderids_windows.go │ └── zsyscall_windows.go ├── gopkg.in └── yaml.v2 │ ├── LICENSE │ ├── LICENSE.libyaml │ ├── NOTICE │ ├── README.md │ ├── apic.go │ ├── decode.go │ ├── emitterc.go │ ├── encode.go │ ├── go.mod │ ├── parserc.go │ ├── readerc.go │ ├── resolve.go │ ├── scannerc.go │ ├── sorter.go │ ├── writerc.go │ ├── yaml.go │ ├── yamlh.go │ └── yamlprivateh.go └── vendor.json /.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /sql_exporter 4 | /sql_exporter.yml 5 | -------------------------------------------------------------------------------- /.promu.yml: -------------------------------------------------------------------------------- 1 | go: 2 | cgo: false 3 | repository: 4 | path: github.com/free/sql_exporter 5 | build: 6 | binaries: 7 | - name: sql_exporter 8 | path: ./cmd/sql_exporter 9 | flags: -a -tags netgo 10 | ldflags: | 11 | -X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}} 12 | -X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}} 13 | -X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}} 14 | -X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}} 15 | -X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}} 16 | tarball: 17 | files: 18 | - LICENSE 19 | - README.md 20 | - examples/sql_exporter.yml 21 | - examples/mssql_standard.collector.yml 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: "1.12" 4 | 5 | script: 6 | - make style 7 | - make vet 8 | - make test 9 | - make build 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/prometheus/golang-builder AS builder 2 | 3 | # Get sql_exporter 4 | ADD . /go/src/github.com/free/sql_exporter 5 | WORKDIR /go/src/github.com/free/sql_exporter 6 | 7 | # Do makefile 8 | RUN make 9 | 10 | # Make image and copy build sql_exporter 11 | FROM quay.io/prometheus/busybox:glibc 12 | MAINTAINER The Prometheus Authors 13 | COPY --from=builder /go/src/github.com/free/sql_exporter/sql_exporter /bin/sql_exporter 14 | 15 | EXPOSE 9399 16 | ENTRYPOINT [ "/bin/sql_exporter" ] 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alin Sinpalean 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Prometheus Authors 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | 14 | GO := go 15 | GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) 16 | PROMU := $(GOPATH)/bin/promu 17 | pkgs = $(shell $(GO) list ./... | grep -v /vendor/) 18 | 19 | PREFIX ?= $(shell pwd) 20 | BIN_DIR ?= $(shell pwd) 21 | DOCKER_IMAGE_NAME ?= sql-exporter 22 | DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) 23 | 24 | 25 | all: format build test 26 | 27 | style: 28 | @echo ">> checking code style" 29 | @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' 30 | 31 | test: 32 | @echo ">> running tests" 33 | @$(GO) test -short -race $(pkgs) 34 | 35 | format: 36 | @echo ">> formatting code" 37 | @$(GO) fmt $(pkgs) 38 | 39 | vet: 40 | @echo ">> vetting code" 41 | @$(GO) vet $(pkgs) 42 | 43 | build: promu 44 | @echo ">> building binaries" 45 | @$(PROMU) build --prefix $(PREFIX) 46 | 47 | tarball: promu 48 | @echo ">> building release tarball" 49 | @$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) 50 | 51 | docker: 52 | @echo ">> building docker image" 53 | @docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . 54 | 55 | promu: 56 | @GOOS=$(shell uname -s | tr A-Z a-z) \ 57 | GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ 58 | $(GO) get -u github.com/prometheus/promu 59 | 60 | 61 | .PHONY: all style format build test vet tarball docker promu 62 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.5 -------------------------------------------------------------------------------- /errors/errors.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // WithContext is an error associated with a logging context string (e.g. `job="foo", instance="bar"`). It is formatted 8 | // as: 9 | // fmt.Sprintf("[%s] %s", Context(), RawError()) 10 | type WithContext interface { 11 | error 12 | 13 | Context() string 14 | RawError() string 15 | } 16 | 17 | // withContext implements WithContext. 18 | type withContext struct { 19 | context string 20 | err string 21 | } 22 | 23 | // New creates a new WithContext. 24 | func New(context, err string) WithContext { 25 | return &withContext{context, err} 26 | } 27 | 28 | // Errorf formats according to a format specifier and returns a new WithContext. 29 | func Errorf(context, format string, a ...interface{}) WithContext { 30 | return &withContext{context, fmt.Sprintf(format, a...)} 31 | } 32 | 33 | // Wrap returns a WithContext wrapping err. If err is nil, it returns nil. If err is a WithContext, it is returned 34 | // unchanged. 35 | func Wrap(context string, err error) WithContext { 36 | if err == nil { 37 | return nil 38 | } 39 | if w, ok := err.(WithContext); ok { 40 | return w 41 | } 42 | return &withContext{context, err.Error()} 43 | } 44 | 45 | // Wrapf returns a WithContext that prepends a formatted message to err.Error(). If err is nil, it returns nil. If err 46 | // is a WithContext, the returned WithContext will have the message prepended but the same context as err (presumed to 47 | // be more specific). 48 | func Wrapf(context string, err error, format string, a ...interface{}) WithContext { 49 | if err == nil { 50 | return nil 51 | } 52 | prefix := format 53 | if len(a) > 0 { 54 | prefix = fmt.Sprintf(format, a...) 55 | } 56 | if w, ok := err.(WithContext); ok { 57 | return &withContext{w.Context(), prefix + ": " + w.RawError()} 58 | } 59 | return &withContext{context, prefix + ": " + err.Error()} 60 | } 61 | 62 | // Error implements error. 63 | func (w *withContext) Error() string { 64 | if len(w.context) == 0 { 65 | return w.err 66 | } 67 | return "[" + w.context + "] " + w.err 68 | } 69 | 70 | // Context implements WithContext. 71 | func (w *withContext) Context() string { 72 | return w.context 73 | } 74 | 75 | // RawError implements WithContext. 76 | func (w *withContext) RawError() string { 77 | return w.err 78 | } 79 | -------------------------------------------------------------------------------- /examples/sql_exporter.yml: -------------------------------------------------------------------------------- 1 | # Global defaults. 2 | global: 3 | # Subtracted from Prometheus' scrape_timeout to give us some headroom and prevent Prometheus from timing out first. 4 | scrape_timeout_offset: 500ms 5 | # Minimum interval between collector runs: by default (0s) collectors are executed on every scrape. 6 | min_interval: 0s 7 | # Maximum number of open connections to any one target. Metric queries will run concurrently on multiple connections, 8 | # as will concurrent scrapes. 9 | max_connections: 3 10 | # Maximum number of idle connections to any one target. Unless you use very long collection intervals, this should 11 | # always be the same as max_connections. 12 | max_idle_connections: 3 13 | 14 | # The target to monitor and the collectors to execute on it. 15 | target: 16 | # Data source name always has a URI schema that matches the driver name. In some cases (e.g. MySQL) 17 | # the schema gets dropped or replaced to match the driver expected DSN format. 18 | data_source_name: 'sqlserver://prom_user:prom_password@dbserver1.example.com:1433' 19 | 20 | # Collectors (referenced by name) to execute on the target. 21 | collectors: [mssql_standard] 22 | 23 | # Collector files specifies a list of globs. One collector definition is read from each matching file. 24 | collector_files: 25 | - "*.collector.yml" 26 | -------------------------------------------------------------------------------- /job.go: -------------------------------------------------------------------------------- 1 | package sql_exporter 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/free/sql_exporter/config" 7 | "github.com/free/sql_exporter/errors" 8 | "github.com/prometheus/client_golang/prometheus" 9 | ) 10 | 11 | // Job is a collection of targets with the same collectors applied. 12 | type Job interface { 13 | Targets() []Target 14 | } 15 | 16 | // job implements Job. It wraps the corresponding JobConfig and a set of Targets. 17 | type job struct { 18 | config *config.JobConfig 19 | targets []Target 20 | logContext string 21 | } 22 | 23 | // NewJob returns a new Job with the given configuration. 24 | func NewJob(jc *config.JobConfig, gc *config.GlobalConfig) (Job, errors.WithContext) { 25 | j := job{ 26 | config: jc, 27 | targets: make([]Target, 0, 10), 28 | logContext: fmt.Sprintf("job=%q", jc.Name), 29 | } 30 | 31 | for _, sc := range jc.StaticConfigs { 32 | for tname, dsn := range sc.Targets { 33 | constLabels := prometheus.Labels{ 34 | "job": jc.Name, 35 | "instance": tname, 36 | } 37 | for name, value := range sc.Labels { 38 | // Shouldn't happen as there are sanity checks in config, but check nonetheless. 39 | if _, found := constLabels[name]; found { 40 | return nil, errors.Errorf(j.logContext, "duplicate label %q", name) 41 | } 42 | constLabels[name] = value 43 | } 44 | t, err := NewTarget(j.logContext, tname, string(dsn), jc.Collectors(), constLabels, gc) 45 | if err != nil { 46 | return nil, err 47 | } 48 | j.targets = append(j.targets, t) 49 | } 50 | } 51 | 52 | return &j, nil 53 | } 54 | 55 | func (j *job) Targets() []Target { 56 | return j.targets 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing notes 2 | 3 | ## Local setup 4 | 5 | The easiest way to run tests is to use Docker Compose: 6 | 7 | ``` 8 | docker-compose up 9 | make 10 | ``` 11 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kirill Shvakov 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/ClickHouse/clickhouse-go/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | go install -race -v 3 | go test -i -v 4 | go test -race -timeout 30s -v . 5 | 6 | coverage: 7 | go test -coverprofile=coverage.out -v . 8 | go tool cover -html=coverage.out 9 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/array.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func Array(v interface{}) interface{} { 8 | return v 9 | } 10 | 11 | func ArrayFixedString(len int, v interface{}) interface{} { 12 | return v 13 | } 14 | 15 | func ArrayDate(v []time.Time) interface{} { 16 | return v 17 | } 18 | 19 | func ArrayDateTime(v []time.Time) interface{} { 20 | return v 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/clickhouse_exception.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type Exception struct { 9 | Code int32 10 | Name string 11 | Message string 12 | StackTrace string 13 | nested error 14 | } 15 | 16 | func (e *Exception) Error() string { 17 | return fmt.Sprintf("code: %d, message: %s", e.Code, e.Message) 18 | } 19 | 20 | func (ch *clickhouse) exception() error { 21 | defer ch.conn.Close() 22 | var ( 23 | e Exception 24 | err error 25 | hasNested bool 26 | ) 27 | if e.Code, err = ch.decoder.Int32(); err != nil { 28 | return err 29 | } 30 | if e.Name, err = ch.decoder.String(); err != nil { 31 | return err 32 | } 33 | if e.Message, err = ch.decoder.String(); err != nil { 34 | return err 35 | } 36 | e.Message = strings.TrimSpace(strings.TrimPrefix(e.Message, e.Name+":")) 37 | if e.StackTrace, err = ch.decoder.String(); err != nil { 38 | return err 39 | } 40 | if hasNested, err = ch.decoder.Bool(); err != nil { 41 | return err 42 | } 43 | if hasNested { 44 | e.nested = ch.exception() 45 | } 46 | return &e 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/clickhouse_ping.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "context" 5 | "database/sql/driver" 6 | 7 | "github.com/ClickHouse/clickhouse-go/lib/protocol" 8 | ) 9 | 10 | func (ch *clickhouse) Ping(ctx context.Context) error { 11 | return ch.ping(ctx) 12 | } 13 | 14 | func (ch *clickhouse) ping(ctx context.Context) error { 15 | if ch.conn.closed { 16 | return driver.ErrBadConn 17 | } 18 | ch.logf("-> ping") 19 | finish := ch.watchCancel(ctx) 20 | defer finish() 21 | if err := ch.encoder.Uvarint(protocol.ClientPing); err != nil { 22 | return err 23 | } 24 | if err := ch.encoder.Flush(); err != nil { 25 | return err 26 | } 27 | return ch.process() 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/clickhouse_profile_info.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | type profileInfo struct { 4 | rows uint64 5 | bytes uint64 6 | blocks uint64 7 | appliedLimit bool 8 | rowsBeforeLimit uint64 9 | calculatedRowsBeforeLimit bool 10 | } 11 | 12 | func (ch *clickhouse) profileInfo() (*profileInfo, error) { 13 | var ( 14 | p profileInfo 15 | err error 16 | ) 17 | if p.rows, err = ch.decoder.Uvarint(); err != nil { 18 | return nil, err 19 | } 20 | if p.blocks, err = ch.decoder.Uvarint(); err != nil { 21 | return nil, err 22 | } 23 | if p.bytes, err = ch.decoder.Uvarint(); err != nil { 24 | return nil, err 25 | } 26 | 27 | if p.appliedLimit, err = ch.decoder.Bool(); err != nil { 28 | return nil, err 29 | } 30 | if p.rowsBeforeLimit, err = ch.decoder.Uvarint(); err != nil { 31 | return nil, err 32 | } 33 | if p.calculatedRowsBeforeLimit, err = ch.decoder.Bool(); err != nil { 34 | return nil, err 35 | } 36 | return &p, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/clickhouse_progress.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | type progress struct { 4 | rows uint64 5 | bytes uint64 6 | totalRows uint64 7 | } 8 | 9 | func (ch *clickhouse) progress() (*progress, error) { 10 | var ( 11 | p progress 12 | err error 13 | ) 14 | if p.rows, err = ch.decoder.Uvarint(); err != nil { 15 | return nil, err 16 | } 17 | if p.bytes, err = ch.decoder.Uvarint(); err != nil { 18 | return nil, err 19 | } 20 | 21 | if p.totalRows, err = ch.decoder.Uvarint(); err != nil { 22 | return nil, err 23 | } 24 | 25 | return &p, nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/clickhouse_read_block.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/data" 5 | ) 6 | 7 | func (ch *clickhouse) readBlock() (*data.Block, error) { 8 | if _, err := ch.decoder.String(); err != nil { // temporary table 9 | return nil, err 10 | } 11 | 12 | ch.decoder.SelectCompress(ch.compress) 13 | var block data.Block 14 | if err := block.Read(&ch.ServerInfo, ch.decoder); err != nil { 15 | return nil, err 16 | } 17 | ch.decoder.SelectCompress(false) 18 | return &block, nil 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/clickhouse_read_meta.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/ClickHouse/clickhouse-go/lib/data" 7 | "github.com/ClickHouse/clickhouse-go/lib/protocol" 8 | ) 9 | 10 | func (ch *clickhouse) readMeta() (*data.Block, error) { 11 | for { 12 | packet, err := ch.decoder.Uvarint() 13 | if err != nil { 14 | return nil, err 15 | } 16 | 17 | switch packet { 18 | case protocol.ServerException: 19 | ch.logf("[read meta] <- exception") 20 | return nil, ch.exception() 21 | case protocol.ServerProgress: 22 | progress, err := ch.progress() 23 | if err != nil { 24 | return nil, err 25 | } 26 | ch.logf("[read meta] <- progress: rows=%d, bytes=%d, total rows=%d", 27 | progress.rows, 28 | progress.bytes, 29 | progress.totalRows, 30 | ) 31 | case protocol.ServerProfileInfo: 32 | profileInfo, err := ch.profileInfo() 33 | if err != nil { 34 | return nil, err 35 | } 36 | ch.logf("[read meta] <- profiling: rows=%d, bytes=%d, blocks=%d", profileInfo.rows, profileInfo.bytes, profileInfo.blocks) 37 | case protocol.ServerData: 38 | block, err := ch.readBlock() 39 | if err != nil { 40 | return nil, err 41 | } 42 | ch.logf("[read meta] <- data: packet=%d, columns=%d, rows=%d", packet, block.NumColumns, block.NumRows) 43 | return block, nil 44 | case protocol.ServerEndOfStream: 45 | _, err := ch.readBlock() 46 | ch.logf("[process] <- end of stream") 47 | return nil, err 48 | default: 49 | ch.conn.Close() 50 | return nil, fmt.Errorf("[read meta] unexpected packet [%d] from server", packet) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/clickhouse_send_query.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/data" 5 | "github.com/ClickHouse/clickhouse-go/lib/protocol" 6 | ) 7 | 8 | func (ch *clickhouse) sendQuery(query string) error { 9 | ch.logf("[send query] %s", query) 10 | if err := ch.encoder.Uvarint(protocol.ClientQuery); err != nil { 11 | return err 12 | } 13 | if err := ch.encoder.String(""); err != nil { 14 | return err 15 | } 16 | { // client info 17 | ch.encoder.Uvarint(1) 18 | ch.encoder.String("") 19 | ch.encoder.String("") //initial_query_id 20 | ch.encoder.String("[::ffff:127.0.0.1]:0") 21 | ch.encoder.Uvarint(1) // iface type TCP 22 | ch.encoder.String(hostname) 23 | ch.encoder.String(hostname) 24 | } 25 | if err := ch.ClientInfo.Write(ch.encoder); err != nil { 26 | return err 27 | } 28 | if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO { 29 | ch.encoder.String("") 30 | } 31 | 32 | // the settings are written as list of contiguous name-value pairs, finished with empty name 33 | if !ch.settings.IsEmpty() { 34 | ch.logf("[query settings] %s", ch.settings.settingsStr) 35 | if err := ch.settings.Serialize(ch.encoder); err != nil { 36 | return err 37 | } 38 | } 39 | // empty string is a marker of the end of the settings 40 | if err := ch.encoder.String(""); err != nil { 41 | return err 42 | } 43 | if err := ch.encoder.Uvarint(protocol.StateComplete); err != nil { 44 | return err 45 | } 46 | compress := protocol.CompressDisable 47 | if ch.compress { 48 | compress = protocol.CompressEnable 49 | } 50 | if err := ch.encoder.Uvarint(compress); err != nil { 51 | return err 52 | } 53 | if err := ch.encoder.String(query); err != nil { 54 | return err 55 | } 56 | if err := ch.writeBlock(&data.Block{}); err != nil { 57 | return err 58 | } 59 | return ch.encoder.Flush() 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/clickhouse_write_block.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/data" 5 | "github.com/ClickHouse/clickhouse-go/lib/protocol" 6 | ) 7 | 8 | func (ch *clickhouse) writeBlock(block *data.Block) error { 9 | ch.Lock() 10 | defer ch.Unlock() 11 | if err := ch.encoder.Uvarint(protocol.ClientData); err != nil { 12 | return err 13 | } 14 | 15 | if err := ch.encoder.String(""); err != nil { // temporary table 16 | return err 17 | } 18 | 19 | // implement CityHash v 1.0.2 and add LZ4 compression 20 | /* 21 | From Alexey Milovidov 22 | Насколько я помню, сжимаются блоки с данными Native формата, а всё остальное (всякие номера пакетов и т. п.) передаётся без сжатия. 23 | 24 | Сжатые данные устроены так. Они представляют собой набор сжатых фреймов. 25 | Каждый фрейм имеет следующий вид: 26 | чексумма (16 байт), 27 | идентификатор алгоритма сжатия (1 байт), 28 | размер сжатых данных (4 байта, little endian, размер не включает в себя чексумму, но включает в себя остальные 9 байт заголовка), 29 | размер несжатых данных (4 байта, little endian), затем сжатые данные. 30 | Идентификатор алгоритма: 0x82 - lz4, 0x90 - zstd. 31 | Чексумма - CityHash128 из CityHash версии 1.0.2, вычисленный от сжатых данных с учётом 9 байт заголовка. 32 | 33 | См. CompressedReadBufferBase, CompressedWriteBuffer, 34 | utils/compressor, TCPHandler. 35 | */ 36 | ch.encoder.SelectCompress(ch.compress) 37 | err := block.Write(&ch.ServerInfo, ch.encoder) 38 | ch.encoder.SelectCompress(false) 39 | return err 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3' 3 | services: 4 | clickhouse: 5 | image: yandex/clickhouse-server 6 | ports: 7 | - 127.0.0.1:8123:8123 8 | - 127.0.0.1:9000:9000 9 | - 127.0.0.1:9009:9009 10 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ClickHouse/clickhouse-go 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/bkaradzic/go-lz4 v1.0.0 7 | github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 8 | github.com/jmoiron/sqlx v1.2.0 9 | github.com/pierrec/lz4 v2.0.5+incompatible 10 | github.com/stretchr/testify v1.3.0 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/go.sum: -------------------------------------------------------------------------------- 1 | github.com/bkaradzic/go-lz4 v1.0.0 h1:RXc4wYsyz985CkXXeX04y4VnZFGG8Rd43pRaHsOXAKk= 2 | github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= 3 | github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg= 4 | github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= 5 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 6 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 7 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= 8 | github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA= 9 | github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= 10 | github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= 11 | github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= 12 | github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= 13 | github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= 14 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 15 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 16 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 17 | github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= 18 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 19 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/go.test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list ./... | grep -v vendor | grep -v examples); do 7 | go test -race -coverprofile=profile.out -covermode=atomic $d 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_reader.go: -------------------------------------------------------------------------------- 1 | // +build !clz4 2 | 3 | package binary 4 | 5 | import ( 6 | "encoding/binary" 7 | "fmt" 8 | "io" 9 | 10 | "github.com/ClickHouse/clickhouse-go/lib/lz4" 11 | ) 12 | 13 | type compressReader struct { 14 | reader io.Reader 15 | // data uncompressed 16 | data []byte 17 | // data position 18 | pos int 19 | // data compressed 20 | zdata []byte 21 | // lz4 headers 22 | header []byte 23 | } 24 | 25 | // NewCompressReader wrap the io.Reader 26 | func NewCompressReader(r io.Reader) *compressReader { 27 | p := &compressReader{ 28 | reader: r, 29 | header: make([]byte, HeaderSize), 30 | } 31 | p.data = make([]byte, BlockMaxSize, BlockMaxSize) 32 | 33 | zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize 34 | p.zdata = make([]byte, zlen, zlen) 35 | 36 | p.pos = len(p.data) 37 | return p 38 | } 39 | 40 | func (cr *compressReader) Read(buf []byte) (n int, err error) { 41 | var bytesRead = 0 42 | n = len(buf) 43 | 44 | if cr.pos < len(cr.data) { 45 | copyedSize := copy(buf, cr.data[cr.pos:]) 46 | 47 | bytesRead += copyedSize 48 | cr.pos += copyedSize 49 | } 50 | 51 | for bytesRead < n { 52 | if err = cr.readCompressedData(); err != nil { 53 | return bytesRead, err 54 | } 55 | copyedSize := copy(buf[bytesRead:], cr.data) 56 | 57 | bytesRead += copyedSize 58 | cr.pos = copyedSize 59 | } 60 | return n, nil 61 | } 62 | 63 | func (cr *compressReader) readCompressedData() (err error) { 64 | cr.pos = 0 65 | var n int 66 | n, err = cr.reader.Read(cr.header) 67 | if err != nil { 68 | return 69 | } 70 | if n != len(cr.header) { 71 | return fmt.Errorf("Lz4 decompression header EOF") 72 | } 73 | 74 | compressedSize := int(binary.LittleEndian.Uint32(cr.header[17:])) - 9 75 | decompressedSize := int(binary.LittleEndian.Uint32(cr.header[21:])) 76 | 77 | if compressedSize > cap(cr.zdata) { 78 | cr.zdata = make([]byte, compressedSize) 79 | } 80 | if decompressedSize > cap(cr.data) { 81 | cr.data = make([]byte, decompressedSize) 82 | } 83 | 84 | cr.zdata = cr.zdata[:compressedSize] 85 | cr.data = cr.data[:decompressedSize] 86 | 87 | // @TODO checksum 88 | if cr.header[16] == LZ4 { 89 | n, err = cr.reader.Read(cr.zdata) 90 | if err != nil { 91 | return 92 | } 93 | 94 | if n != len(cr.zdata) { 95 | return fmt.Errorf("Decompress read size not match") 96 | } 97 | 98 | _, err = lz4.Decode(cr.data, cr.zdata) 99 | if err != nil { 100 | return 101 | } 102 | } else { 103 | return fmt.Errorf("Unknown compression method: 0x%02x ", cr.header[16]) 104 | } 105 | 106 | return nil 107 | } 108 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_reader_clz4.go: -------------------------------------------------------------------------------- 1 | // +build clz4 2 | 3 | package binary 4 | 5 | import ( 6 | "encoding/binary" 7 | "fmt" 8 | "io" 9 | 10 | lz4 "github.com/cloudflare/golz4" 11 | ) 12 | 13 | type compressReader struct { 14 | reader io.Reader 15 | // data uncompressed 16 | data []byte 17 | // data position 18 | pos int 19 | // data compressed 20 | zdata []byte 21 | // lz4 headers 22 | header []byte 23 | } 24 | 25 | // NewCompressReader wrap the io.Reader 26 | func NewCompressReader(r io.Reader) *compressReader { 27 | p := &compressReader{ 28 | reader: r, 29 | header: make([]byte, HeaderSize), 30 | } 31 | p.data = make([]byte, BlockMaxSize, BlockMaxSize) 32 | 33 | zlen := lz4.CompressBound(p.data) + HeaderSize 34 | p.zdata = make([]byte, zlen, zlen) 35 | 36 | p.pos = len(p.data) 37 | return p 38 | } 39 | 40 | func (cr *compressReader) Read(buf []byte) (n int, err error) { 41 | var bytesRead = 0 42 | n = len(buf) 43 | 44 | if cr.pos < len(cr.data) { 45 | copyedSize := copy(buf, cr.data[cr.pos:]) 46 | 47 | bytesRead += copyedSize 48 | cr.pos += copyedSize 49 | } 50 | 51 | for bytesRead < n { 52 | if err = cr.readCompressedData(); err != nil { 53 | return bytesRead, err 54 | } 55 | copyedSize := copy(buf[bytesRead:], cr.data) 56 | 57 | bytesRead += copyedSize 58 | cr.pos = copyedSize 59 | } 60 | return n, nil 61 | } 62 | 63 | func (cr *compressReader) readCompressedData() (err error) { 64 | cr.pos = 0 65 | var n int 66 | n, err = cr.reader.Read(cr.header) 67 | if err != nil { 68 | return 69 | } 70 | if n != len(cr.header) { 71 | return fmt.Errorf("Lz4 decompression header EOF") 72 | } 73 | 74 | compressedSize := int(binary.LittleEndian.Uint32(cr.header[17:])) - 9 75 | decompressedSize := int(binary.LittleEndian.Uint32(cr.header[21:])) 76 | 77 | if compressedSize > cap(cr.zdata) { 78 | cr.zdata = make([]byte, compressedSize) 79 | } 80 | if decompressedSize > cap(cr.data) { 81 | cr.data = make([]byte, decompressedSize) 82 | } 83 | 84 | cr.zdata = cr.zdata[:compressedSize] 85 | cr.data = cr.data[:decompressedSize] 86 | 87 | // @TODO checksum 88 | if cr.header[16] == LZ4 { 89 | n, err = cr.reader.Read(cr.zdata) 90 | if err != nil { 91 | return 92 | } 93 | 94 | if n != len(cr.zdata) { 95 | return fmt.Errorf("Decompress read size not match") 96 | } 97 | 98 | err = lz4.Uncompress(cr.zdata, cr.data) 99 | if err != nil { 100 | return 101 | } 102 | } else { 103 | return fmt.Errorf("Unknown compression method: 0x%02x ", cr.header[16]) 104 | } 105 | 106 | return nil 107 | } 108 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_settings.go: -------------------------------------------------------------------------------- 1 | package binary 2 | 3 | type CompressionMethodByte byte 4 | 5 | const ( 6 | NONE CompressionMethodByte = 0x02 7 | LZ4 = 0x82 8 | ZSTD = 0x90 9 | ) 10 | 11 | const ( 12 | // ChecksumSize is 128bits for cityhash102 checksum 13 | ChecksumSize = 16 14 | // CompressHeader magic + compressed_size + uncompressed_size 15 | CompressHeaderSize = 1 + 4 + 4 16 | 17 | // HeaderSize 18 | HeaderSize = ChecksumSize + CompressHeaderSize 19 | // BlockMaxSize 1MB 20 | BlockMaxSize = 1 << 20 21 | ) 22 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_writer.go: -------------------------------------------------------------------------------- 1 | // +build !clz4 2 | 3 | package binary 4 | 5 | import ( 6 | "encoding/binary" 7 | "io" 8 | 9 | "github.com/ClickHouse/clickhouse-go/lib/cityhash102" 10 | "github.com/ClickHouse/clickhouse-go/lib/lz4" 11 | ) 12 | 13 | type compressWriter struct { 14 | writer io.Writer 15 | // data uncompressed 16 | data []byte 17 | // data position 18 | pos int 19 | // data compressed 20 | zdata []byte 21 | } 22 | 23 | // NewCompressWriter wrap the io.Writer 24 | func NewCompressWriter(w io.Writer) *compressWriter { 25 | p := &compressWriter{writer: w} 26 | p.data = make([]byte, BlockMaxSize, BlockMaxSize) 27 | 28 | zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize 29 | p.zdata = make([]byte, zlen, zlen) 30 | return p 31 | } 32 | 33 | func (cw *compressWriter) Write(buf []byte) (int, error) { 34 | var n int 35 | for len(buf) > 0 { 36 | // Accumulate the data to be compressed. 37 | m := copy(cw.data[cw.pos:], buf) 38 | cw.pos += m 39 | buf = buf[m:] 40 | 41 | if cw.pos == len(cw.data) { 42 | err := cw.Flush() 43 | if err != nil { 44 | return n, err 45 | } 46 | } 47 | n += m 48 | } 49 | return n, nil 50 | } 51 | 52 | func (cw *compressWriter) Flush() (err error) { 53 | if cw.pos == 0 { 54 | return 55 | } 56 | 57 | // write the headers 58 | compressedSize, err := lz4.Encode(cw.zdata[HeaderSize:], cw.data[:cw.pos]) 59 | if err != nil { 60 | return err 61 | } 62 | compressedSize += CompressHeaderSize 63 | // fill the header, compressed_size_32 + uncompressed_size_32 64 | cw.zdata[16] = LZ4 65 | binary.LittleEndian.PutUint32(cw.zdata[17:], uint32(compressedSize)) 66 | binary.LittleEndian.PutUint32(cw.zdata[21:], uint32(cw.pos)) 67 | 68 | // fill the checksum 69 | checkSum := cityhash102.CityHash128(cw.zdata[16:], uint32(compressedSize)) 70 | binary.LittleEndian.PutUint64(cw.zdata[0:], checkSum.Lower64()) 71 | binary.LittleEndian.PutUint64(cw.zdata[8:], checkSum.Higher64()) 72 | 73 | cw.writer.Write(cw.zdata[:compressedSize+ChecksumSize]) 74 | if w, ok := cw.writer.(WriteFlusher); ok { 75 | err = w.Flush() 76 | } 77 | cw.pos = 0 78 | return 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/binary/compress_writer_clz4.go: -------------------------------------------------------------------------------- 1 | // +build clz4 2 | 3 | package binary 4 | 5 | import ( 6 | "encoding/binary" 7 | "io" 8 | 9 | lz4 "github.com/cloudflare/golz4" 10 | "github.com/ClickHouse/clickhouse-go/lib/cityhash102" 11 | ) 12 | 13 | type compressWriter struct { 14 | writer io.Writer 15 | // data uncompressed 16 | data []byte 17 | // data position 18 | pos int 19 | // data compressed 20 | zdata []byte 21 | } 22 | 23 | // NewCompressWriter wrap the io.Writer 24 | func NewCompressWriter(w io.Writer) *compressWriter { 25 | p := &compressWriter{writer: w} 26 | p.data = make([]byte, BlockMaxSize, BlockMaxSize) 27 | 28 | zlen := lz4.CompressBound(p.data) + HeaderSize 29 | p.zdata = make([]byte, zlen, zlen) 30 | return p 31 | } 32 | 33 | func (cw *compressWriter) Write(buf []byte) (int, error) { 34 | var n int 35 | for len(buf) > 0 { 36 | // Accumulate the data to be compressed. 37 | m := copy(cw.data[cw.pos:], buf) 38 | cw.pos += m 39 | buf = buf[m:] 40 | 41 | if cw.pos == len(cw.data) { 42 | err := cw.Flush() 43 | if err != nil { 44 | return n, err 45 | } 46 | } 47 | n += m 48 | } 49 | return n, nil 50 | } 51 | 52 | func (cw *compressWriter) Flush() (err error) { 53 | if cw.pos == 0 { 54 | return 55 | } 56 | // write the headers 57 | compressedSize, err := lz4.Compress(cw.data[:cw.pos], cw.zdata[HeaderSize:]) 58 | if err != nil { 59 | return err 60 | } 61 | compressedSize += CompressHeaderSize 62 | // fill the header, compressed_size_32 + uncompressed_size_32 63 | cw.zdata[16] = LZ4 64 | binary.LittleEndian.PutUint32(cw.zdata[17:], uint32(compressedSize)) 65 | binary.LittleEndian.PutUint32(cw.zdata[21:], uint32(cw.pos)) 66 | 67 | // fill the checksum 68 | checkSum := cityhash102.CityHash128(cw.zdata[16:], uint32(compressedSize)) 69 | binary.LittleEndian.PutUint64(cw.zdata[0:], checkSum.Lower64()) 70 | binary.LittleEndian.PutUint64(cw.zdata[8:], checkSum.Higher64()) 71 | 72 | cw.writer.Write(cw.zdata[:compressedSize+ChecksumSize]) 73 | if w, ok := cw.writer.(WriteFlusher); ok { 74 | err = w.Flush() 75 | } 76 | cw.pos = 0 77 | return 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/city64.go: -------------------------------------------------------------------------------- 1 | package cityhash102 2 | 3 | import ( 4 | "encoding/binary" 5 | "hash" 6 | ) 7 | 8 | type City64 struct { 9 | s []byte 10 | } 11 | 12 | var _ hash.Hash64 = (*City64)(nil) 13 | var _ hash.Hash = (*City64)(nil) 14 | 15 | func New64() hash.Hash64 { 16 | return &City64{} 17 | } 18 | 19 | func (this *City64) Sum(b []byte) []byte { 20 | b2 := make([]byte, 8) 21 | binary.BigEndian.PutUint64(b2, this.Sum64()) 22 | b = append(b, b2...) 23 | return b 24 | } 25 | 26 | func (this *City64) Sum64() uint64 { 27 | return CityHash64(this.s, uint32(len(this.s))) 28 | } 29 | 30 | func (this *City64) Reset() { 31 | this.s = this.s[0:0] 32 | } 33 | 34 | func (this *City64) BlockSize() int { 35 | return 1 36 | } 37 | 38 | func (this *City64) Write(s []byte) (n int, err error) { 39 | this.s = append(this.s, s...) 40 | return len(s), nil 41 | } 42 | 43 | func (this *City64) Size() int { 44 | return 8 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/cityhash102/doc.go: -------------------------------------------------------------------------------- 1 | /** COPY from https://github.com/zentures/cityhash/ 2 | 3 | NOTE: The code is modified to be compatible with CityHash128 used in ClickHouse 4 | */ 5 | package cityhash102 6 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/common.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "reflect" 7 | "time" 8 | ) 9 | 10 | type ErrUnexpectedType struct { 11 | Column Column 12 | T interface{} 13 | } 14 | 15 | func (err *ErrUnexpectedType) Error() string { 16 | return fmt.Sprintf("%s: unexpected type %T", err.Column, err.T) 17 | } 18 | 19 | var columnBaseTypes = map[interface{}]reflect.Value{ 20 | int8(0): reflect.ValueOf(int8(0)), 21 | int16(0): reflect.ValueOf(int16(0)), 22 | int32(0): reflect.ValueOf(int32(0)), 23 | int64(0): reflect.ValueOf(int64(0)), 24 | uint8(0): reflect.ValueOf(uint8(0)), 25 | uint16(0): reflect.ValueOf(uint16(0)), 26 | uint32(0): reflect.ValueOf(uint32(0)), 27 | uint64(0): reflect.ValueOf(uint64(0)), 28 | float32(0): reflect.ValueOf(float32(0)), 29 | float64(0): reflect.ValueOf(float64(0)), 30 | string(""): reflect.ValueOf(string("")), 31 | time.Time{}: reflect.ValueOf(time.Time{}), 32 | IPv4{}: reflect.ValueOf(net.IP{}), 33 | IPv6{}: reflect.ValueOf(net.IP{}), 34 | } 35 | 36 | var arrayBaseTypes = map[interface{}]reflect.Type{ 37 | int8(0): reflect.ValueOf(int8(0)).Type(), 38 | int16(0): reflect.ValueOf(int16(0)).Type(), 39 | int32(0): reflect.ValueOf(int32(0)).Type(), 40 | int64(0): reflect.ValueOf(int64(0)).Type(), 41 | uint8(0): reflect.ValueOf(uint8(0)).Type(), 42 | uint16(0): reflect.ValueOf(uint16(0)).Type(), 43 | uint32(0): reflect.ValueOf(uint32(0)).Type(), 44 | uint64(0): reflect.ValueOf(uint64(0)).Type(), 45 | float32(0): reflect.ValueOf(float32(0)).Type(), 46 | float64(0): reflect.ValueOf(float64(0)).Type(), 47 | string(""): reflect.ValueOf(string("")).Type(), 48 | time.Time{}: reflect.ValueOf(time.Time{}).Type(), 49 | IPv4{}: reflect.ValueOf(net.IP{}).Type(), 50 | IPv6{}: reflect.ValueOf(net.IP{}).Type(), 51 | } 52 | 53 | type base struct { 54 | name, chType string 55 | valueOf reflect.Value 56 | } 57 | 58 | func (base *base) Name() string { 59 | return base.name 60 | } 61 | 62 | func (base *base) CHType() string { 63 | return base.chType 64 | } 65 | 66 | func (base *base) ScanType() reflect.Type { 67 | return base.valueOf.Type() 68 | } 69 | 70 | func (base *base) defaultValue() interface{} { 71 | return base.valueOf.Interface() 72 | } 73 | 74 | func (base *base) String() string { 75 | return fmt.Sprintf("%s (%s)", base.name, base.chType) 76 | } 77 | 78 | func (base *base) Depth() int { 79 | return 0 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/date.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/ClickHouse/clickhouse-go/lib/binary" 7 | ) 8 | 9 | type Date struct { 10 | base 11 | Timezone *time.Location 12 | offset int64 13 | } 14 | 15 | func (dt *Date) Read(decoder *binary.Decoder) (interface{}, error) { 16 | sec, err := decoder.Int16() 17 | if err != nil { 18 | return nil, err 19 | } 20 | return time.Unix(int64(sec)*24*3600-dt.offset, 0).In(dt.Timezone), nil 21 | } 22 | 23 | func (dt *Date) Write(encoder *binary.Encoder, v interface{}) error { 24 | var timestamp int64 25 | switch value := v.(type) { 26 | case time.Time: 27 | _, offset := value.Zone() 28 | timestamp = value.Unix() + int64(offset) 29 | case int16: 30 | return encoder.Int16(value) 31 | case int32: 32 | timestamp = int64(value) + dt.offset 33 | case int64: 34 | timestamp = value + dt.offset 35 | case string: 36 | var err error 37 | timestamp, err = dt.parse(value) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | // this relies on Nullable never sending nil values through 43 | case *time.Time: 44 | _, offset := value.Zone() 45 | timestamp = (*value).Unix() + int64(offset) 46 | case *int16: 47 | return encoder.Int16(*value) 48 | case *int32: 49 | timestamp = int64(*value) + dt.offset 50 | case *int64: 51 | timestamp = *value + dt.offset 52 | case *string: 53 | var err error 54 | timestamp, err = dt.parse(*value) 55 | if err != nil { 56 | return err 57 | } 58 | 59 | default: 60 | return &ErrUnexpectedType{ 61 | T: v, 62 | Column: dt, 63 | } 64 | } 65 | 66 | return encoder.Int16(int16(timestamp / 24 / 3600)) 67 | } 68 | 69 | func (dt *Date) parse(value string) (int64, error) { 70 | tv, err := time.Parse("2006-01-02", value) 71 | if err != nil { 72 | return 0, err 73 | } 74 | return time.Date( 75 | time.Time(tv).Year(), 76 | time.Time(tv).Month(), 77 | time.Time(tv).Day(), 78 | 0, 0, 0, 0, time.UTC, 79 | ).Unix(), nil 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/datetime.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/ClickHouse/clickhouse-go/lib/binary" 7 | ) 8 | 9 | type DateTime struct { 10 | base 11 | Timezone *time.Location 12 | } 13 | 14 | func (dt *DateTime) Read(decoder *binary.Decoder) (interface{}, error) { 15 | sec, err := decoder.Int32() 16 | if err != nil { 17 | return nil, err 18 | } 19 | return time.Unix(int64(sec), 0).In(dt.Timezone), nil 20 | } 21 | 22 | func (dt *DateTime) Write(encoder *binary.Encoder, v interface{}) error { 23 | var timestamp int64 24 | switch value := v.(type) { 25 | case time.Time: 26 | if !value.IsZero() { 27 | timestamp = value.Unix() 28 | } 29 | case int16: 30 | timestamp = int64(value) 31 | case int32: 32 | timestamp = int64(value) 33 | case int64: 34 | timestamp = value 35 | case string: 36 | var err error 37 | timestamp, err = dt.parse(value) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | case *time.Time: 43 | if value != nil && !(*value).IsZero() { 44 | timestamp = (*value).Unix() 45 | } 46 | case *int16: 47 | timestamp = int64(*value) 48 | case *int32: 49 | timestamp = int64(*value) 50 | case *int64: 51 | timestamp = *value 52 | case *string: 53 | var err error 54 | timestamp, err = dt.parse(*value) 55 | if err != nil { 56 | return err 57 | } 58 | 59 | default: 60 | return &ErrUnexpectedType{ 61 | T: v, 62 | Column: dt, 63 | } 64 | } 65 | 66 | return encoder.Int32(int32(timestamp)) 67 | } 68 | 69 | func (dt *DateTime) parse(value string) (int64, error) { 70 | tv, err := time.Parse("2006-01-02 15:04:05", value) 71 | if err != nil { 72 | return 0, err 73 | } 74 | return time.Date( 75 | time.Time(tv).Year(), 76 | time.Time(tv).Month(), 77 | time.Time(tv).Day(), 78 | time.Time(tv).Hour(), 79 | time.Time(tv).Minute(), 80 | time.Time(tv).Second(), 81 | 0, time.UTC, 82 | ).Unix(), nil 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/fixed_string.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "encoding" 5 | "fmt" 6 | "reflect" 7 | 8 | "github.com/ClickHouse/clickhouse-go/lib/binary" 9 | ) 10 | 11 | type FixedString struct { 12 | base 13 | len int 14 | scanType reflect.Type 15 | } 16 | 17 | func (str *FixedString) Read(decoder *binary.Decoder) (interface{}, error) { 18 | v, err := decoder.Fixed(str.len) 19 | if err != nil { 20 | return "", err 21 | } 22 | return string(v), nil 23 | } 24 | 25 | func (str *FixedString) Write(encoder *binary.Encoder, v interface{}) error { 26 | var fixedString []byte 27 | switch v := v.(type) { 28 | case string: 29 | fixedString = binary.Str2Bytes(v) 30 | case []byte: 31 | fixedString = v 32 | case encoding.BinaryMarshaler: 33 | bytes, err := v.MarshalBinary() 34 | if err != nil { 35 | return err 36 | } 37 | fixedString = bytes 38 | default: 39 | return &ErrUnexpectedType{ 40 | T: v, 41 | Column: str, 42 | } 43 | } 44 | switch { 45 | case len(fixedString) > str.len: 46 | return fmt.Errorf("too large value '%s' (expected %d, got %d)", fixedString, str.len, len(fixedString)) 47 | case len(fixedString) < str.len: 48 | tmp := make([]byte, str.len) 49 | copy(tmp, fixedString) 50 | fixedString = tmp 51 | } 52 | if _, err := encoder.Write(fixedString); err != nil { 53 | return err 54 | } 55 | return nil 56 | } 57 | 58 | func parseFixedString(name, chType string) (*FixedString, error) { 59 | var strLen int 60 | if _, err := fmt.Sscanf(chType, "FixedString(%d)", &strLen); err != nil { 61 | return nil, err 62 | } 63 | return &FixedString{ 64 | base: base{ 65 | name: name, 66 | chType: chType, 67 | valueOf: columnBaseTypes[string("")], 68 | }, 69 | len: strLen, 70 | }, nil 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/float32.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type Float32 struct{ base } 8 | 9 | func (Float32) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Float32() 11 | if err != nil { 12 | return float32(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (float *Float32) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case float32: 20 | return encoder.Float32(v) 21 | case float64: 22 | return encoder.Float32(float32(v)) 23 | 24 | // this relies on Nullable never sending nil values through 25 | case *float32: 26 | return encoder.Float32(*v) 27 | case *float64: 28 | return encoder.Float32(float32(*v)) 29 | } 30 | 31 | return &ErrUnexpectedType{ 32 | T: v, 33 | Column: float, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/float64.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type Float64 struct{ base } 8 | 9 | func (Float64) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Float64() 11 | if err != nil { 12 | return float64(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (float *Float64) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case float32: 20 | return encoder.Float64(float64(v)) 21 | case float64: 22 | return encoder.Float64(v) 23 | 24 | // this relies on Nullable never sending nil values through 25 | case *float32: 26 | return encoder.Float64(float64(*v)) 27 | case *float64: 28 | return encoder.Float64(*v) 29 | } 30 | 31 | return &ErrUnexpectedType{ 32 | T: v, 33 | Column: float, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/int16.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type Int16 struct{ base } 8 | 9 | func (Int16) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Int16() 11 | if err != nil { 12 | return int16(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (i *Int16) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case int16: 20 | return encoder.Int16(v) 21 | case int64: 22 | return encoder.Int16(int16(v)) 23 | case int: 24 | return encoder.Int16(int16(v)) 25 | 26 | // this relies on Nullable never sending nil values through 27 | case *int16: 28 | return encoder.Int16(*v) 29 | case *int64: 30 | return encoder.Int16(int16(*v)) 31 | case *int: 32 | return encoder.Int16(int16(*v)) 33 | } 34 | 35 | return &ErrUnexpectedType{ 36 | T: v, 37 | Column: i, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/int32.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type Int32 struct{ base } 8 | 9 | func (Int32) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Int32() 11 | if err != nil { 12 | return int32(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (i *Int32) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case int32: 20 | return encoder.Int32(v) 21 | case int64: 22 | return encoder.Int32(int32(v)) 23 | case int: 24 | return encoder.Int32(int32(v)) 25 | 26 | // this relies on Nullable never sending nil values through 27 | case *int32: 28 | return encoder.Int32(*v) 29 | case *int64: 30 | return encoder.Int32(int32(*v)) 31 | case *int: 32 | return encoder.Int32(int32(*v)) 33 | } 34 | 35 | return &ErrUnexpectedType{ 36 | T: v, 37 | Column: i, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/int64.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type Int64 struct{ base } 8 | 9 | func (Int64) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Int64() 11 | if err != nil { 12 | return int64(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (i *Int64) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case int: 20 | return encoder.Int64(int64(v)) 21 | case int64: 22 | return encoder.Int64(v) 23 | case []byte: 24 | if _, err := encoder.Write(v); err != nil { 25 | return err 26 | } 27 | return nil 28 | 29 | // this relies on Nullable never sending nil values through 30 | case *int: 31 | return encoder.Int64(int64(*v)) 32 | case *int64: 33 | return encoder.Int64(*v) 34 | } 35 | 36 | return &ErrUnexpectedType{ 37 | T: v, 38 | Column: i, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/int8.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type Int8 struct{ base } 8 | 9 | func (Int8) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.Int8() 11 | if err != nil { 12 | return int8(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (i *Int8) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case int8: 20 | return encoder.Int8(v) 21 | case int64: 22 | return encoder.Int8(int8(v)) 23 | case int: 24 | return encoder.Int8(int8(v)) 25 | case bool: 26 | if v { 27 | return encoder.Int8(int8(1)) 28 | } 29 | return encoder.Int8(int8(0)) 30 | 31 | // this relies on Nullable never sending nil values through 32 | case *int8: 33 | return encoder.Int8(*v) 34 | case *int64: 35 | return encoder.Int8(int8(*v)) 36 | case *int: 37 | return encoder.Int8(int8(*v)) 38 | case *bool: 39 | if *v { 40 | return encoder.Int8(int8(1)) 41 | } 42 | return encoder.Int8(int8(0)) 43 | } 44 | 45 | return &ErrUnexpectedType{ 46 | T: v, 47 | Column: i, 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/ip.go: -------------------------------------------------------------------------------- 1 | /* 2 | IP type supporting for clickhouse as FixedString(16) 3 | */ 4 | 5 | package column 6 | 7 | import ( 8 | "database/sql/driver" 9 | "errors" 10 | "net" 11 | "strings" 12 | ) 13 | 14 | var ( 15 | errInvalidScanType = errors.New("Invalid scan types") 16 | errInvalidScanValue = errors.New("Invalid scan value") 17 | ) 18 | 19 | // IP column type 20 | type IP net.IP 21 | 22 | // Value implements the driver.Valuer interface, json field interface 23 | // Alignment on the right side 24 | func (ip IP) Value() (driver.Value, error) { 25 | return ip.MarshalBinary() 26 | } 27 | 28 | func (ip IP) MarshalBinary() ([]byte, error) { 29 | if len(ip) < 16 { 30 | var ( 31 | buff = make([]byte, 16) 32 | j = 0 33 | ) 34 | for i := 16 - len(ip); i < 16; i++ { 35 | buff[i] = ip[j] 36 | j++ 37 | } 38 | for i := 0; i < 16-len(ip); i++ { 39 | buff[i] = '\x00' 40 | } 41 | if len(ip) == 4 { 42 | buff[11] = '\xff' 43 | buff[10] = '\xff' 44 | } 45 | return buff, nil 46 | } 47 | return []byte(ip), nil 48 | } 49 | 50 | // Scan implements the driver.Valuer interface, json field interface 51 | func (ip *IP) Scan(value interface{}) (err error) { 52 | switch v := value.(type) { 53 | case []byte: 54 | if len(v) == 4 || len(v) == 16 { 55 | *ip = IP(v) 56 | } else { 57 | err = errInvalidScanValue 58 | } 59 | case string: 60 | if v == "" { 61 | err = errInvalidScanValue 62 | return 63 | } 64 | if (len(v) == 4 || len(v) == 16) && !strings.Contains(v, ".") && !strings.Contains(v, ":"){ 65 | *ip = IP([]byte(v)) 66 | return 67 | } 68 | if strings.Contains(v, ":") { 69 | *ip = IP(net.ParseIP(v)) 70 | return 71 | } 72 | *ip = IP(net.ParseIP(v).To4()) 73 | case net.IP: 74 | *ip = IP(v) 75 | default: 76 | err = errInvalidScanType 77 | } 78 | return 79 | } 80 | 81 | // String implements the fmt.Stringer interface 82 | func (ip IP) String() string { 83 | return net.IP(ip).String() 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/ipv4.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "net" 5 | 6 | "github.com/ClickHouse/clickhouse-go/lib/binary" 7 | ) 8 | 9 | type IPv4 struct { 10 | base 11 | } 12 | 13 | func (*IPv4) Read(decoder *binary.Decoder) (interface{}, error) { 14 | v, err := decoder.Fixed(4) 15 | if err != nil { 16 | return nil, err 17 | } 18 | return net.IPv4(v[3], v[2], v[1], v[0]), nil 19 | } 20 | 21 | func (ip *IPv4) Write(encoder *binary.Encoder, v interface{}) error { 22 | var netIP net.IP 23 | switch v.(type) { 24 | case string: 25 | netIP = net.ParseIP(v.(string)) 26 | case net.IP: 27 | netIP = v.(net.IP) 28 | case *net.IP: 29 | netIP = *(v.(*net.IP)) 30 | default: 31 | return &ErrUnexpectedType{ 32 | T: v, 33 | Column: ip, 34 | } 35 | } 36 | 37 | if netIP == nil { 38 | return &ErrUnexpectedType{ 39 | T: v, 40 | Column: ip, 41 | } 42 | } 43 | ip4 := netIP.To4() 44 | if ip4 == nil { 45 | return &ErrUnexpectedType{ 46 | T: v, 47 | Column: ip, 48 | } 49 | } 50 | if _, err := encoder.Write([]byte{ip4[3], ip4[2], ip4[1], ip4[0]}); err != nil { 51 | return err 52 | } 53 | return nil 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/ipv6.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "net" 5 | 6 | "github.com/ClickHouse/clickhouse-go/lib/binary" 7 | ) 8 | 9 | type IPv6 struct { 10 | base 11 | } 12 | 13 | func (*IPv6) Read(decoder *binary.Decoder) (interface{}, error) { 14 | v, err := decoder.Fixed(16) 15 | if err != nil { 16 | return nil, err 17 | } 18 | return net.IP(v), nil 19 | } 20 | 21 | func (ip *IPv6) Write(encoder *binary.Encoder, v interface{}) error { 22 | var netIP net.IP 23 | switch v.(type) { 24 | case string: 25 | netIP = net.ParseIP(v.(string)) 26 | case net.IP: 27 | netIP = v.(net.IP) 28 | case *net.IP: 29 | netIP = *(v.(*net.IP)) 30 | default: 31 | return &ErrUnexpectedType{ 32 | T: v, 33 | Column: ip, 34 | } 35 | } 36 | 37 | if netIP == nil { 38 | return &ErrUnexpectedType{ 39 | T: v, 40 | Column: ip, 41 | } 42 | } 43 | if _, err := encoder.Write([]byte(netIP.To16())); err != nil { 44 | return err 45 | } 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/nullable.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "time" 7 | 8 | "github.com/ClickHouse/clickhouse-go/lib/binary" 9 | ) 10 | 11 | type Nullable struct { 12 | base 13 | column Column 14 | } 15 | 16 | func (null *Nullable) ScanType() reflect.Type { 17 | return null.column.ScanType() 18 | } 19 | 20 | func (null *Nullable) Read(decoder *binary.Decoder) (interface{}, error) { 21 | return null.column.Read(decoder) 22 | } 23 | 24 | func (null *Nullable) Write(encoder *binary.Encoder, v interface{}) error { 25 | return nil 26 | } 27 | 28 | func (null *Nullable) ReadNull(decoder *binary.Decoder, rows int) (_ []interface{}, err error) { 29 | var ( 30 | isNull byte 31 | value interface{} 32 | nulls = make([]byte, rows) 33 | values = make([]interface{}, rows) 34 | ) 35 | for i := 0; i < rows; i++ { 36 | if isNull, err = decoder.ReadByte(); err != nil { 37 | return nil, err 38 | } 39 | nulls[i] = isNull 40 | } 41 | for i, isNull := range nulls { 42 | switch value, err = null.column.Read(decoder); true { 43 | case err != nil: 44 | return nil, err 45 | case isNull == 0: 46 | values[i] = value 47 | default: 48 | values[i] = nil 49 | } 50 | } 51 | return values, nil 52 | } 53 | func (null *Nullable) WriteNull(nulls, encoder *binary.Encoder, v interface{}) error { 54 | if value := reflect.ValueOf(v); v == nil || (value.Kind() == reflect.Ptr && value.IsNil()) { 55 | if _, err := nulls.Write([]byte{1}); err != nil { 56 | return err 57 | } 58 | return null.column.Write(encoder, null.column.defaultValue()) 59 | } 60 | if _, err := nulls.Write([]byte{0}); err != nil { 61 | return err 62 | } 63 | return null.column.Write(encoder, v) 64 | } 65 | 66 | func parseNullable(name, chType string, timezone *time.Location) (*Nullable, error) { 67 | if len(chType) < 14 { 68 | return nil, fmt.Errorf("invalid Nullable column type: %s", chType) 69 | } 70 | column, err := Factory(name, chType[9:][:len(chType)-10], timezone) 71 | if err != nil { 72 | return nil, fmt.Errorf("Nullable(T): %v", err) 73 | } 74 | return &Nullable{ 75 | base: base{ 76 | name: name, 77 | chType: chType, 78 | }, 79 | column: column, 80 | }, nil 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/string.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type String struct{ base } 8 | 9 | func (String) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.String() 11 | if err != nil { 12 | return "", err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (str *String) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case string: 20 | return encoder.String(v) 21 | case []byte: 22 | return encoder.RawString(v) 23 | 24 | // this relies on Nullable never sending nil values through 25 | case *string: 26 | return encoder.String(*v) 27 | } 28 | 29 | return &ErrUnexpectedType{ 30 | T: v, 31 | Column: str, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint16.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type UInt16 struct{ base } 8 | 9 | func (UInt16) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.UInt16() 11 | if err != nil { 12 | return uint16(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (u *UInt16) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case uint16: 20 | return encoder.UInt16(v) 21 | case int64: 22 | return encoder.UInt16(uint16(v)) 23 | case uint64: 24 | return encoder.UInt16(uint16(v)) 25 | case int: 26 | return encoder.UInt16(uint16(v)) 27 | 28 | // this relies on Nullable never sending nil values through 29 | case *uint16: 30 | return encoder.UInt16(*v) 31 | case *int64: 32 | return encoder.UInt16(uint16(*v)) 33 | case *uint64: 34 | return encoder.UInt16(uint16(*v)) 35 | case *int: 36 | return encoder.UInt16(uint16(*v)) 37 | } 38 | 39 | return &ErrUnexpectedType{ 40 | T: v, 41 | Column: u, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint32.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type UInt32 struct{ base } 8 | 9 | func (UInt32) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.UInt32() 11 | if err != nil { 12 | return uint32(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (u *UInt32) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case uint32: 20 | return encoder.UInt32(v) 21 | case uint64: 22 | return encoder.UInt32(uint32(v)) 23 | case int64: 24 | return encoder.UInt32(uint32(v)) 25 | case int: 26 | return encoder.UInt32(uint32(v)) 27 | 28 | // this relies on Nullable never sending nil values through 29 | case *uint64: 30 | return encoder.UInt32(uint32(*v)) 31 | case *uint32: 32 | return encoder.UInt32(*v) 33 | case *int64: 34 | return encoder.UInt32(uint32(*v)) 35 | case *int: 36 | return encoder.UInt32(uint32(*v)) 37 | } 38 | 39 | return &ErrUnexpectedType{ 40 | T: v, 41 | Column: u, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint64.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type UInt64 struct{ base } 8 | 9 | func (UInt64) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.UInt64() 11 | if err != nil { 12 | return uint64(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (u *UInt64) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case []byte: 20 | if _, err := encoder.Write(v); err != nil { 21 | return err 22 | } 23 | return nil 24 | case uint64: 25 | return encoder.UInt64(v) 26 | case int64: 27 | return encoder.UInt64(uint64(v)) 28 | case int: 29 | return encoder.UInt64(uint64(v)) 30 | 31 | // this relies on Nullable never sending nil values through 32 | case *uint64: 33 | return encoder.UInt64(*v) 34 | case *int64: 35 | return encoder.UInt64(uint64(*v)) 36 | case *int: 37 | return encoder.UInt64(uint64(*v)) 38 | } 39 | 40 | return &ErrUnexpectedType{ 41 | T: v, 42 | Column: u, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/column/uint8.go: -------------------------------------------------------------------------------- 1 | package column 2 | 3 | import ( 4 | "github.com/ClickHouse/clickhouse-go/lib/binary" 5 | ) 6 | 7 | type UInt8 struct{ base } 8 | 9 | func (UInt8) Read(decoder *binary.Decoder) (interface{}, error) { 10 | v, err := decoder.UInt8() 11 | if err != nil { 12 | return uint8(0), err 13 | } 14 | return v, nil 15 | } 16 | 17 | func (u *UInt8) Write(encoder *binary.Encoder, v interface{}) error { 18 | switch v := v.(type) { 19 | case bool: 20 | return encoder.Bool(v) 21 | case uint8: 22 | return encoder.UInt8(v) 23 | case int64: 24 | return encoder.UInt8(uint8(v)) 25 | case uint64: 26 | return encoder.UInt8(uint8(v)) 27 | case int: 28 | return encoder.UInt8(uint8(v)) 29 | 30 | // this relies on Nullable never sending nil values through 31 | case *bool: 32 | return encoder.Bool(*v) 33 | case *uint8: 34 | return encoder.UInt8(*v) 35 | case *int64: 36 | return encoder.UInt8(uint8(*v)) 37 | case *uint64: 38 | return encoder.UInt8(uint8(*v)) 39 | case *int: 40 | return encoder.UInt8(uint8(*v)) 41 | } 42 | 43 | return &ErrUnexpectedType{ 44 | T: v, 45 | Column: u, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/data/client_info.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/ClickHouse/clickhouse-go/lib/binary" 7 | ) 8 | 9 | const ClientName = "Golang SQLDriver" 10 | 11 | const ( 12 | ClickHouseRevision = 54213 13 | ClickHouseDBMSVersionMajor = 1 14 | ClickHouseDBMSVersionMinor = 1 15 | ) 16 | 17 | type ClientInfo struct{} 18 | 19 | func (ClientInfo) Write(encoder *binary.Encoder) error { 20 | encoder.String(ClientName) 21 | encoder.Uvarint(ClickHouseDBMSVersionMajor) 22 | encoder.Uvarint(ClickHouseDBMSVersionMinor) 23 | encoder.Uvarint(ClickHouseRevision) 24 | return nil 25 | } 26 | 27 | func (ClientInfo) String() string { 28 | return fmt.Sprintf("%s %d.%d.%d", ClientName, ClickHouseDBMSVersionMajor, ClickHouseDBMSVersionMinor, ClickHouseRevision) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/data/server_info.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "fmt" 5 | //"io" 6 | "time" 7 | 8 | "github.com/ClickHouse/clickhouse-go/lib/binary" 9 | "github.com/ClickHouse/clickhouse-go/lib/protocol" 10 | ) 11 | 12 | type ServerInfo struct { 13 | Name string 14 | Revision uint64 15 | MinorVersion uint64 16 | MajorVersion uint64 17 | Timezone *time.Location 18 | } 19 | 20 | func (srv *ServerInfo) Read(decoder *binary.Decoder) (err error) { 21 | if srv.Name, err = decoder.String(); err != nil { 22 | return fmt.Errorf("could not read server name: %v", err) 23 | } 24 | if srv.MajorVersion, err = decoder.Uvarint(); err != nil { 25 | return fmt.Errorf("could not read server major version: %v", err) 26 | } 27 | if srv.MinorVersion, err = decoder.Uvarint(); err != nil { 28 | return fmt.Errorf("could not read server minor version: %v", err) 29 | } 30 | if srv.Revision, err = decoder.Uvarint(); err != nil { 31 | return fmt.Errorf("could not read server revision: %v", err) 32 | } 33 | if srv.Revision >= protocol.DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE { 34 | timezone, err := decoder.String() 35 | if err != nil { 36 | return fmt.Errorf("could not read server timezone: %v", err) 37 | } 38 | if srv.Timezone, err = time.LoadLocation(timezone); err != nil { 39 | return fmt.Errorf("could not load time location: %v", err) 40 | } 41 | } 42 | return nil 43 | } 44 | 45 | func (srv ServerInfo) String() string { 46 | return fmt.Sprintf("%s %d.%d.%d (%s)", srv.Name, srv.MajorVersion, srv.MinorVersion, srv.Revision, srv.Timezone) 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/data/value.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import "reflect" 4 | 5 | // Value is a writable value. 6 | type Value interface { 7 | // Kind returns value's Kind. 8 | Kind() reflect.Kind 9 | 10 | // Len returns value's length. 11 | // It panics if value's Kind is not Array, Chan, Map, Slice, or String. 12 | Len() int 13 | 14 | // Index returns value's i'th element. 15 | // It panics if value's Kind is not Array, Slice, or String or i is out of range. 16 | Index(i int) Value 17 | 18 | // Interface returns value's current value as an interface{}. 19 | Interface() interface{} 20 | } 21 | 22 | // value is a wrapper that wraps reflect.Value to comply with Value interface. 23 | type value struct { 24 | reflect.Value 25 | } 26 | 27 | func newValue(v reflect.Value) Value { 28 | return value{Value: v} 29 | } 30 | 31 | func (v value) Index(i int) Value { 32 | return newValue(v.Value.Index(i)) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/leakypool/leaky_pool.go: -------------------------------------------------------------------------------- 1 | package leakypool 2 | 3 | var pool chan []byte 4 | 5 | func InitBytePool(size int) { 6 | pool = make(chan []byte, size) 7 | } 8 | 9 | func GetBytes(size, capacity int) (b []byte) { 10 | select { 11 | case b = <-pool: 12 | default: 13 | b = make([]byte, size, capacity) 14 | } 15 | return 16 | } 17 | 18 | func PutBytes(b []byte) { 19 | select { 20 | case pool <- b: 21 | default: 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2012 Branimir Karadzic. All rights reserved. 2 | Copyright 2013 Damian Gryski. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 22 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 | THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2012 Branimir Karadzic. All rights reserved. 2 | // Copyright 2013 Damian Gryski. All rights reserved. 3 | 4 | // @LINK: https://github.com/bkaradzic/go-lz4 5 | // @NOTE: The code is modified to be high performance and less memory usage 6 | 7 | package lz4 8 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/lz4/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package lz4 4 | 5 | import "encoding/binary" 6 | 7 | func Fuzz(data []byte) int { 8 | 9 | if len(data) < 4 { 10 | return 0 11 | } 12 | 13 | ln := binary.LittleEndian.Uint32(data) 14 | if ln > (1 << 21) { 15 | return 0 16 | } 17 | 18 | if _, err := Decode(nil, data); err != nil { 19 | return 0 20 | } 21 | 22 | return 1 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/protocol/README.md: -------------------------------------------------------------------------------- 1 | # ClickHouse Native protocol 2 | 3 | # Handshake 4 | 5 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/protocol/protocol.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | const ( 4 | DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE = 54058 5 | DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO = 54060 6 | ) 7 | 8 | const ( 9 | ClientHello = 0 10 | ClientQuery = 1 11 | ClientData = 2 12 | ClientCancel = 3 13 | ClientPing = 4 14 | ) 15 | 16 | const ( 17 | CompressEnable uint64 = 1 18 | CompressDisable uint64 = 0 19 | ) 20 | 21 | const ( 22 | StateComplete = 2 23 | ) 24 | 25 | const ( 26 | ServerHello = 0 27 | ServerData = 1 28 | ServerException = 2 29 | ServerProgress = 3 30 | ServerPong = 4 31 | ServerEndOfStream = 5 32 | ServerProfileInfo = 6 33 | ServerTotals = 7 34 | ServerExtremes = 8 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/lib/types/date.go: -------------------------------------------------------------------------------- 1 | // Timezoneless date/datetime types 2 | 3 | package types 4 | 5 | import ( 6 | "database/sql/driver" 7 | "time" 8 | ) 9 | 10 | // Truncate timezone 11 | // 12 | // clickhouse.Date(time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local)) -> time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC) 13 | type Date time.Time 14 | 15 | func (date Date) Value() (driver.Value, error) { 16 | return date.convert(), nil 17 | } 18 | 19 | func (date Date) convert() time.Time { 20 | return time.Date(time.Time(date).Year(), time.Time(date).Month(), time.Time(date).Day(), 0, 0, 0, 0, time.UTC) 21 | } 22 | 23 | // Truncate timezone 24 | // 25 | // clickhouse.DateTime(time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local)) -> time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC) 26 | type DateTime time.Time 27 | 28 | func (datetime DateTime) Value() (driver.Value, error) { 29 | return datetime.convert(), nil 30 | } 31 | 32 | func (datetime DateTime) convert() time.Time { 33 | return time.Date( 34 | time.Time(datetime).Year(), 35 | time.Time(datetime).Month(), 36 | time.Time(datetime).Day(), 37 | time.Time(datetime).Hour(), 38 | time.Time(datetime).Minute(), 39 | time.Time(datetime).Second(), 40 | 1, 41 | time.UTC, 42 | ) 43 | } 44 | 45 | var ( 46 | _ driver.Valuer = Date{} 47 | _ driver.Valuer = DateTime{} 48 | ) 49 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/result.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import "errors" 4 | 5 | type result struct{} 6 | 7 | func (*result) LastInsertId() (int64, error) { return 0, errors.New("LastInsertId is not supported") } 8 | func (*result) RowsAffected() (int64, error) { return 0, errors.New("RowsAffected is not supported") } 9 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/tls_config.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "crypto/tls" 5 | "sync" 6 | ) 7 | 8 | // Based on the original implementation in the project go-sql-driver/mysql: 9 | // https://github.com/go-sql-driver/mysql/blob/master/utils.go 10 | 11 | var ( 12 | tlsConfigLock sync.RWMutex 13 | tlsConfigRegistry map[string]*tls.Config 14 | ) 15 | 16 | // RegisterTLSConfig registers a custom tls.Config to be used with sql.Open. 17 | func RegisterTLSConfig(key string, config *tls.Config) error { 18 | tlsConfigLock.Lock() 19 | if tlsConfigRegistry == nil { 20 | tlsConfigRegistry = make(map[string]*tls.Config) 21 | } 22 | 23 | tlsConfigRegistry[key] = config 24 | tlsConfigLock.Unlock() 25 | return nil 26 | } 27 | 28 | // DeregisterTLSConfig removes the tls.Config associated with key. 29 | func DeregisterTLSConfig(key string) { 30 | tlsConfigLock.Lock() 31 | if tlsConfigRegistry != nil { 32 | delete(tlsConfigRegistry, key) 33 | } 34 | tlsConfigLock.Unlock() 35 | } 36 | 37 | func getTLSConfigClone(key string) (config *tls.Config) { 38 | tlsConfigLock.RLock() 39 | if v, ok := tlsConfigRegistry[key]; ok { 40 | config = v.Clone() 41 | } 42 | tlsConfigLock.RUnlock() 43 | return 44 | } 45 | 46 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/word_matcher.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "strings" 5 | "unicode" 6 | ) 7 | 8 | // wordMatcher is a simple automata to match a single word (case insensitive) 9 | type wordMatcher struct { 10 | word []rune 11 | position uint8 12 | } 13 | 14 | // newMatcher returns matcher for word needle 15 | func newMatcher(needle string) *wordMatcher { 16 | return &wordMatcher{word: []rune(strings.ToUpper(needle)), 17 | position: 0} 18 | } 19 | 20 | func (m *wordMatcher) matchRune(r rune) bool { 21 | if m.word[m.position] == unicode.ToUpper(r) { 22 | if m.position == uint8(len(m.word)-1) { 23 | m.position = 0 24 | return true 25 | } 26 | m.position++ 27 | } else { 28 | m.position = 0 29 | } 30 | return false 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/ClickHouse/clickhouse-go/write_column.go: -------------------------------------------------------------------------------- 1 | package clickhouse 2 | 3 | import ( 4 | "database/sql" 5 | "database/sql/driver" 6 | "time" 7 | 8 | "github.com/ClickHouse/clickhouse-go/lib/data" 9 | ) 10 | 11 | // Interface for Clickhouse driver 12 | type Clickhouse interface { 13 | Block() (*data.Block, error) 14 | Prepare(query string) (driver.Stmt, error) 15 | Begin() (driver.Tx, error) 16 | Commit() error 17 | Rollback() error 18 | Close() error 19 | WriteBlock(block *data.Block) error 20 | } 21 | 22 | // Interface for Block allowing writes to individual columns 23 | type ColumnWriter interface { 24 | WriteDate(c int, v time.Time) error 25 | WriteDateTime(c int, v time.Time) error 26 | WriteUInt8(c int, v uint8) error 27 | WriteUInt16(c int, v uint16) error 28 | WriteUInt32(c int, v uint32) error 29 | WriteUInt64(c int, v uint64) error 30 | WriteFloat32(c int, v float32) error 31 | WriteFloat64(c int, v float64) error 32 | WriteBytes(c int, v []byte) error 33 | WriteArray(c int, v interface{}) error 34 | WriteString(c int, v string) error 35 | WriteFixedString(c int, v []byte) error 36 | } 37 | 38 | func OpenDirect(dsn string) (Clickhouse, error) { 39 | return open(dsn) 40 | } 41 | 42 | func (ch *clickhouse) Block() (*data.Block, error) { 43 | if ch.block == nil { 44 | return nil, sql.ErrTxDone 45 | } 46 | return ch.block, nil 47 | } 48 | 49 | func (ch *clickhouse) WriteBlock(block *data.Block) error { 50 | if block == nil { 51 | return sql.ErrTxDone 52 | } 53 | return ch.writeBlock(block) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/beorn7/perks/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Blake Mizerany 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Caleb Spare 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/README.md: -------------------------------------------------------------------------------- 1 | # xxhash 2 | 3 | [![GoDoc](https://godoc.org/github.com/cespare/xxhash?status.svg)](https://godoc.org/github.com/cespare/xxhash) 4 | [![Build Status](https://travis-ci.org/cespare/xxhash.svg?branch=master)](https://travis-ci.org/cespare/xxhash) 5 | 6 | xxhash is a Go implementation of the 64-bit 7 | [xxHash](http://cyan4973.github.io/xxHash/) algorithm, XXH64. This is a 8 | high-quality hashing algorithm that is much faster than anything in the Go 9 | standard library. 10 | 11 | This package provides a straightforward API: 12 | 13 | ``` 14 | func Sum64(b []byte) uint64 15 | func Sum64String(s string) uint64 16 | type Digest struct{ ... } 17 | func New() *Digest 18 | ``` 19 | 20 | The `Digest` type implements hash.Hash64. Its key methods are: 21 | 22 | ``` 23 | func (*Digest) Write([]byte) (int, error) 24 | func (*Digest) WriteString(string) (int, error) 25 | func (*Digest) Sum64() uint64 26 | ``` 27 | 28 | This implementation provides a fast pure-Go implementation and an even faster 29 | assembly implementation for amd64. 30 | 31 | ## Compatibility 32 | 33 | This package is in a module and the latest code is in version 2 of the module. 34 | You need a version of Go with at least "minimal module compatibility" to use 35 | github.com/cespare/xxhash/v2: 36 | 37 | * 1.9.7+ for Go 1.9 38 | * 1.10.3+ for Go 1.10 39 | * Go 1.11 or later 40 | 41 | I recommend using the latest release of Go. 42 | 43 | ## Benchmarks 44 | 45 | Here are some quick benchmarks comparing the pure-Go and assembly 46 | implementations of Sum64. 47 | 48 | | input size | purego | asm | 49 | | --- | --- | --- | 50 | | 5 B | 979.66 MB/s | 1291.17 MB/s | 51 | | 100 B | 7475.26 MB/s | 7973.40 MB/s | 52 | | 4 KB | 17573.46 MB/s | 17602.65 MB/s | 53 | | 10 MB | 17131.46 MB/s | 17142.16 MB/s | 54 | 55 | These numbers were generated on Ubuntu 18.04 with an Intel i7-8700K CPU using 56 | the following commands under Go 1.11.2: 57 | 58 | ``` 59 | $ go test -tags purego -benchtime 10s -bench '/xxhash,direct,bytes' 60 | $ go test -benchtime 10s -bench '/xxhash,direct,bytes' 61 | ``` 62 | 63 | ## Projects using this package 64 | 65 | - [InfluxDB](https://github.com/influxdata/influxdb) 66 | - [Prometheus](https://github.com/prometheus/prometheus) 67 | - [FreeCache](https://github.com/coocood/freecache) 68 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cespare/xxhash/v2 2 | 3 | go 1.11 4 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free/sql_exporter/6f96b0d6b40340929e4d84c902378e7ead113ff1/vendor/github.com/cespare/xxhash/v2/go.sum -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | // +build gc 3 | // +build !purego 4 | 5 | package xxhash 6 | 7 | // Sum64 computes the 64-bit xxHash digest of b. 8 | // 9 | //go:noescape 10 | func Sum64(b []byte) uint64 11 | 12 | //go:noescape 13 | func writeBlocks(d *Digest, b []byte) int 14 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/xxhash_other.go: -------------------------------------------------------------------------------- 1 | // +build !amd64 appengine !gc purego 2 | 3 | package xxhash 4 | 5 | // Sum64 computes the 64-bit xxHash digest of b. 6 | func Sum64(b []byte) uint64 { 7 | // A simpler version would be 8 | // d := New() 9 | // d.Write(b) 10 | // return d.Sum64() 11 | // but this is faster, particularly for small inputs. 12 | 13 | n := len(b) 14 | var h uint64 15 | 16 | if n >= 32 { 17 | v1 := prime1v + prime2 18 | v2 := prime2 19 | v3 := uint64(0) 20 | v4 := -prime1v 21 | for len(b) >= 32 { 22 | v1 = round(v1, u64(b[0:8:len(b)])) 23 | v2 = round(v2, u64(b[8:16:len(b)])) 24 | v3 = round(v3, u64(b[16:24:len(b)])) 25 | v4 = round(v4, u64(b[24:32:len(b)])) 26 | b = b[32:len(b):len(b)] 27 | } 28 | h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4) 29 | h = mergeRound(h, v1) 30 | h = mergeRound(h, v2) 31 | h = mergeRound(h, v3) 32 | h = mergeRound(h, v4) 33 | } else { 34 | h = prime5 35 | } 36 | 37 | h += uint64(n) 38 | 39 | i, end := 0, len(b) 40 | for ; i+8 <= end; i += 8 { 41 | k1 := round(0, u64(b[i:i+8:len(b)])) 42 | h ^= k1 43 | h = rol27(h)*prime1 + prime4 44 | } 45 | if i+4 <= end { 46 | h ^= uint64(u32(b[i:i+4:len(b)])) * prime1 47 | h = rol23(h)*prime2 + prime3 48 | i += 4 49 | } 50 | for ; i < end; i++ { 51 | h ^= uint64(b[i]) * prime5 52 | h = rol11(h) * prime1 53 | } 54 | 55 | h ^= h >> 33 56 | h *= prime2 57 | h ^= h >> 29 58 | h *= prime3 59 | h ^= h >> 32 60 | 61 | return h 62 | } 63 | 64 | func writeBlocks(d *Digest, b []byte) int { 65 | v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4 66 | n := len(b) 67 | for len(b) >= 32 { 68 | v1 = round(v1, u64(b[0:8:len(b)])) 69 | v2 = round(v2, u64(b[8:16:len(b)])) 70 | v3 = round(v3, u64(b[16:24:len(b)])) 71 | v4 = round(v4, u64(b[24:32:len(b)])) 72 | b = b[32:len(b):len(b)] 73 | } 74 | d.v1, d.v2, d.v3, d.v4 = v1, v2, v3, v4 75 | return n - len(b) 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | // This file encapsulates usage of unsafe. 4 | // xxhash_safe.go contains the safe implementations. 5 | 6 | package xxhash 7 | 8 | import ( 9 | "reflect" 10 | "unsafe" 11 | ) 12 | 13 | // Notes: 14 | // 15 | // See https://groups.google.com/d/msg/golang-nuts/dcjzJy-bSpw/tcZYBzQqAQAJ 16 | // for some discussion about these unsafe conversions. 17 | // 18 | // In the future it's possible that compiler optimizations will make these 19 | // unsafe operations unnecessary: https://golang.org/issue/2205. 20 | // 21 | // Both of these wrapper functions still incur function call overhead since they 22 | // will not be inlined. We could write Go/asm copies of Sum64 and Digest.Write 23 | // for strings to squeeze out a bit more speed. Mid-stack inlining should 24 | // eventually fix this. 25 | 26 | // Sum64String computes the 64-bit xxHash digest of s. 27 | // It may be faster than Sum64([]byte(s)) by avoiding a copy. 28 | func Sum64String(s string) uint64 { 29 | var b []byte 30 | bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) 31 | bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data 32 | bh.Len = len(s) 33 | bh.Cap = len(s) 34 | return Sum64(b) 35 | } 36 | 37 | // WriteString adds more data to d. It always returns len(s), nil. 38 | // It may be faster than Write([]byte(s)) by avoiding a copy. 39 | func (d *Digest) WriteString(s string) (n int, err error) { 40 | var b []byte 41 | bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) 42 | bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data 43 | bh.Len = len(s) 44 | bh.Cap = len(s) 45 | return d.Write(b) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 CloudFlare, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | * Neither the name of the CloudFlare, Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/Makefile: -------------------------------------------------------------------------------- 1 | GCFLAGS := 2 | LDFLAGS := 3 | 4 | .PHONY: install 5 | install: 6 | @go install -v . 7 | 8 | .PHONY: test 9 | test: 10 | @go test -gcflags='$(GCFLAGS)' -ldflags='$(LDFLAGS)' . 11 | 12 | .PHONY: bench 13 | bench: 14 | @go test -gcflags='$(GCFLAGS)' -ldflags='$(LDFLAGS)' -bench . 15 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/README.md: -------------------------------------------------------------------------------- 1 | golz4 2 | ===== 3 | 4 | Golang interface to LZ4 compression 5 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/doc.go: -------------------------------------------------------------------------------- 1 | // Package lz4 implements compression using lz4.c and lz4hc.c 2 | // 3 | // Copyright (c) 2013 CloudFlare, Inc. 4 | package lz4 5 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/lz4.go: -------------------------------------------------------------------------------- 1 | package lz4 2 | 3 | // #cgo CFLAGS: -O3 4 | // #include "src/lz4.h" 5 | // #include "src/lz4.c" 6 | import "C" 7 | 8 | import ( 9 | "errors" 10 | "fmt" 11 | "unsafe" 12 | ) 13 | 14 | // p gets a char pointer to the first byte of a []byte slice 15 | func p(in []byte) *C.char { 16 | if len(in) == 0 { 17 | return (*C.char)(unsafe.Pointer(nil)) 18 | } 19 | return (*C.char)(unsafe.Pointer(&in[0])) 20 | } 21 | 22 | // clen gets the length of a []byte slice as a char * 23 | func clen(s []byte) C.int { 24 | return C.int(len(s)) 25 | } 26 | 27 | // Uncompress with a known output size. len(out) should be equal to 28 | // the length of the uncompressed out. 29 | func Uncompress(in, out []byte) (error) { 30 | if int(C.LZ4_decompress_safe(p(in), p(out), clen(in), clen(out))) < 0 { 31 | return errors.New("Malformed compression stream") 32 | } 33 | 34 | return nil 35 | } 36 | 37 | // CompressBound calculates the size of the output buffer needed by 38 | // Compress. This is based on the following macro: 39 | // 40 | // #define LZ4_COMPRESSBOUND(isize) 41 | // ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) 42 | func CompressBound(in []byte) int { 43 | return len(in) + ((len(in) / 255) + 16) 44 | } 45 | 46 | // Compress compresses in and puts the content in out. len(out) 47 | // should have enough space for the compressed data (use CompressBound 48 | // to calculate). Returns the number of bytes in the out slice. 49 | func Compress(in, out []byte) (outSize int, err error) { 50 | outSize = int(C.LZ4_compress_limitedOutput(p(in), p(out), clen(in), clen(out))) 51 | if outSize == 0 { 52 | err = fmt.Errorf("insufficient space for compression") 53 | } 54 | return 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/cloudflare/golz4/lz4_hc.go: -------------------------------------------------------------------------------- 1 | package lz4 2 | 3 | // #cgo CFLAGS: -O3 4 | // #include "src/lz4hc.h" 5 | // #include "src/lz4hc.c" 6 | import "C" 7 | 8 | import ( 9 | "fmt" 10 | ) 11 | 12 | // CompressHC compresses in and puts the content in out. len(out) 13 | // should have enough space for the compressed data (use CompressBound 14 | // to calculate). Returns the number of bytes in the out slice. Determines 15 | // the compression level automatically. 16 | func CompressHC(in, out []byte) (int, error) { 17 | // 0 automatically sets the compression level. 18 | return CompressHCLevel(in, out, 0) 19 | } 20 | 21 | // CompressHCLevel compresses in at the given compression level and puts the 22 | // content in out. len(out) should have enough space for the compressed data 23 | // (use CompressBound to calculate). Returns the number of bytes in the out 24 | // slice. To automatically choose the compression level, use 0. Otherwise, use 25 | // any value in the inclusive range 1 (worst) through 16 (best). Most 26 | // applications will prefer CompressHC. 27 | func CompressHCLevel(in, out []byte, level int) (outSize int, err error) { 28 | // LZ4HC does not handle empty buffers. Pass through to Compress. 29 | if len(in) == 0 || len(out) == 0 { 30 | return Compress(in, out) 31 | } 32 | 33 | outSize = int(C.LZ4_compressHC2_limitedOutput(p(in), p(out), clen(in), clen(out), C.int(level))) 34 | if outSize == 0 { 35 | err = fmt.Errorf("insufficient space for compression") 36 | } 37 | return 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\denisenkom\go-mssqldb 6 | 7 | environment: 8 | GOPATH: c:\gopath 9 | HOST: localhost 10 | SQLUSER: sa 11 | SQLPASSWORD: Password12! 12 | DATABASE: test 13 | GOVERSION: 111 14 | matrix: 15 | - GOVERSION: 18 16 | SQLINSTANCE: SQL2016 17 | - GOVERSION: 19 18 | SQLINSTANCE: SQL2016 19 | - GOVERSION: 110 20 | SQLINSTANCE: SQL2016 21 | - GOVERSION: 111 22 | SQLINSTANCE: SQL2016 23 | - SQLINSTANCE: SQL2014 24 | - SQLINSTANCE: SQL2012SP1 25 | - SQLINSTANCE: SQL2008R2SP2 26 | 27 | install: 28 | - set GOROOT=c:\go%GOVERSION% 29 | - set PATH=%GOPATH%\bin;%GOROOT%\bin;%PATH% 30 | - go version 31 | - go env 32 | - go get -u github.com/golang-sql/civil 33 | 34 | build_script: 35 | - go build 36 | 37 | before_test: 38 | # setup SQL Server 39 | - ps: | 40 | $instanceName = $env:SQLINSTANCE 41 | Start-Service "MSSQL`$$instanceName" 42 | Start-Service "SQLBrowser" 43 | - sqlcmd -S "(local)\%SQLINSTANCE%" -Q "Use [master]; CREATE DATABASE test;" 44 | - sqlcmd -S "(local)\%SQLINSTANCE%" -h -1 -Q "set nocount on; Select @@version" 45 | - pip install codecov 46 | 47 | 48 | test_script: 49 | - go test -race -cpu 4 -coverprofile=coverage.txt -covermode=atomic 50 | - codecov -f coverage.txt 51 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/bulkcopy_sql.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "context" 5 | "database/sql/driver" 6 | "encoding/json" 7 | "errors" 8 | ) 9 | 10 | type copyin struct { 11 | cn *Conn 12 | bulkcopy *Bulk 13 | closed bool 14 | } 15 | 16 | type serializableBulkConfig struct { 17 | TableName string 18 | ColumnsName []string 19 | Options BulkOptions 20 | } 21 | 22 | func (d *Driver) OpenConnection(dsn string) (*Conn, error) { 23 | return d.open(context.Background(), dsn) 24 | } 25 | 26 | func (c *Conn) prepareCopyIn(ctx context.Context, query string) (_ driver.Stmt, err error) { 27 | config_json := query[11:] 28 | 29 | bulkconfig := serializableBulkConfig{} 30 | err = json.Unmarshal([]byte(config_json), &bulkconfig) 31 | if err != nil { 32 | return 33 | } 34 | 35 | bulkcopy := c.CreateBulkContext(ctx, bulkconfig.TableName, bulkconfig.ColumnsName) 36 | bulkcopy.Options = bulkconfig.Options 37 | 38 | ci := ©in{ 39 | cn: c, 40 | bulkcopy: bulkcopy, 41 | } 42 | 43 | return ci, nil 44 | } 45 | 46 | func CopyIn(table string, options BulkOptions, columns ...string) string { 47 | bulkconfig := &serializableBulkConfig{TableName: table, Options: options, ColumnsName: columns} 48 | 49 | config_json, err := json.Marshal(bulkconfig) 50 | if err != nil { 51 | panic(err) 52 | } 53 | 54 | stmt := "INSERTBULK " + string(config_json) 55 | 56 | return stmt 57 | } 58 | 59 | func (ci *copyin) NumInput() int { 60 | return -1 61 | } 62 | 63 | func (ci *copyin) Query(v []driver.Value) (r driver.Rows, err error) { 64 | panic("should never be called") 65 | } 66 | 67 | func (ci *copyin) Exec(v []driver.Value) (r driver.Result, err error) { 68 | if ci.closed { 69 | return nil, errors.New("copyin query is closed") 70 | } 71 | 72 | if len(v) == 0 { 73 | rowCount, err := ci.bulkcopy.Done() 74 | ci.closed = true 75 | return driver.RowsAffected(rowCount), err 76 | } 77 | 78 | t := make([]interface{}, len(v)) 79 | for i, val := range v { 80 | t[i] = val 81 | } 82 | 83 | err = ci.bulkcopy.AddRow(t) 84 | if err != nil { 85 | return 86 | } 87 | 88 | return driver.RowsAffected(0), nil 89 | } 90 | 91 | func (ci *copyin) Close() (err error) { 92 | return nil 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/doc.go: -------------------------------------------------------------------------------- 1 | // package mssql implements the TDS protocol used to connect to MS SQL Server (sqlserver) 2 | // database servers. 3 | // 4 | // This package registers the driver: 5 | // sqlserver: uses native "@" parameter placeholder names and does no pre-processing. 6 | // 7 | // If the ordinal position is used for query parameters, identifiers will be named 8 | // "@p1", "@p2", ... "@pN". 9 | // 10 | // Please refer to the README for the format of the DSN. There are multiple DSN 11 | // formats accepted: ADO style, ODBC style, and URL style. The following is an 12 | // example of a URL style DSN: 13 | // sqlserver://sa:mypass@localhost:1234?database=master&connection+timeout=30 14 | package mssql 15 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/error.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // Error represents an SQL Server error. This 8 | // type includes methods for reading the contents 9 | // of the struct, which allows calling programs 10 | // to check for specific error conditions without 11 | // having to import this package directly. 12 | type Error struct { 13 | Number int32 14 | State uint8 15 | Class uint8 16 | Message string 17 | ServerName string 18 | ProcName string 19 | LineNo int32 20 | } 21 | 22 | func (e Error) Error() string { 23 | return "mssql: " + e.Message 24 | } 25 | 26 | // SQLErrorNumber returns the SQL Server error number. 27 | func (e Error) SQLErrorNumber() int32 { 28 | return e.Number 29 | } 30 | 31 | func (e Error) SQLErrorState() uint8 { 32 | return e.State 33 | } 34 | 35 | func (e Error) SQLErrorClass() uint8 { 36 | return e.Class 37 | } 38 | 39 | func (e Error) SQLErrorMessage() string { 40 | return e.Message 41 | } 42 | 43 | func (e Error) SQLErrorServerName() string { 44 | return e.ServerName 45 | } 46 | 47 | func (e Error) SQLErrorProcName() string { 48 | return e.ProcName 49 | } 50 | 51 | func (e Error) SQLErrorLineNo() int32 { 52 | return e.LineNo 53 | } 54 | 55 | type StreamError struct { 56 | Message string 57 | } 58 | 59 | func (e StreamError) Error() string { 60 | return e.Message 61 | } 62 | 63 | func streamErrorf(format string, v ...interface{}) StreamError { 64 | return StreamError{"Invalid TDS stream: " + fmt.Sprintf(format, v...)} 65 | } 66 | 67 | func badStreamPanic(err error) { 68 | panic(err) 69 | } 70 | 71 | func badStreamPanicf(format string, v ...interface{}) { 72 | panic(streamErrorf(format, v...)) 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/denisenkom/go-mssqldb 2 | 3 | go 1.11 4 | 5 | require ( 6 | github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe 7 | golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c 8 | ) 9 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/go.sum: -------------------------------------------------------------------------------- 1 | github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= 2 | github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= 3 | golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= 4 | golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 5 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 6 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/internal/cp/collation.go: -------------------------------------------------------------------------------- 1 | package cp 2 | 3 | // http://msdn.microsoft.com/en-us/library/dd340437.aspx 4 | 5 | type Collation struct { 6 | LcidAndFlags uint32 7 | SortId uint8 8 | } 9 | 10 | func (c Collation) getLcid() uint32 { 11 | return c.LcidAndFlags & 0x000fffff 12 | } 13 | 14 | func (c Collation) getFlags() uint32 { 15 | return (c.LcidAndFlags & 0x0ff00000) >> 20 16 | } 17 | 18 | func (c Collation) getVersion() uint32 { 19 | return (c.LcidAndFlags & 0xf0000000) >> 28 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/log.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "log" 5 | ) 6 | 7 | type Logger interface { 8 | Printf(format string, v ...interface{}) 9 | Println(v ...interface{}) 10 | } 11 | 12 | type optionalLogger struct { 13 | logger Logger 14 | } 15 | 16 | func (o optionalLogger) Printf(format string, v ...interface{}) { 17 | if o.logger != nil { 18 | o.logger.Printf(format, v...) 19 | } else { 20 | log.Printf(format, v...) 21 | } 22 | } 23 | 24 | func (o optionalLogger) Println(v ...interface{}) { 25 | if o.logger != nil { 26 | o.logger.Println(v...) 27 | } else { 28 | log.Println(v...) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/mssql_go110.go: -------------------------------------------------------------------------------- 1 | // +build go1.10 2 | 3 | package mssql 4 | 5 | import ( 6 | "context" 7 | "database/sql/driver" 8 | "errors" 9 | ) 10 | 11 | var _ driver.Connector = &Connector{} 12 | var _ driver.SessionResetter = &Conn{} 13 | 14 | func (c *Conn) ResetSession(ctx context.Context) error { 15 | if !c.connectionGood { 16 | return driver.ErrBadConn 17 | } 18 | c.resetSession = true 19 | 20 | if c.connector == nil || len(c.connector.SessionInitSQL) == 0 { 21 | return nil 22 | } 23 | 24 | s, err := c.prepareContext(ctx, c.connector.SessionInitSQL) 25 | if err != nil { 26 | return driver.ErrBadConn 27 | } 28 | _, err = s.exec(ctx, nil) 29 | if err != nil { 30 | return driver.ErrBadConn 31 | } 32 | 33 | return nil 34 | } 35 | 36 | // Connect to the server and return a TDS connection. 37 | func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) { 38 | conn, err := c.driver.connect(ctx, c, c.params) 39 | if err == nil { 40 | err = conn.ResetSession(ctx) 41 | } 42 | return conn, err 43 | } 44 | 45 | // Driver underlying the Connector. 46 | func (c *Connector) Driver() driver.Driver { 47 | return c.driver 48 | } 49 | 50 | func (r *Result) LastInsertId() (int64, error) { 51 | return -1, errors.New("LastInsertId is not supported. Please use the OUTPUT clause or add `select ID = convert(bigint, SCOPE_IDENTITY())` to the end of your query.") 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/mssql_go110pre.go: -------------------------------------------------------------------------------- 1 | // +build !go1.10 2 | 3 | package mssql 4 | 5 | import ( 6 | "database/sql/driver" 7 | "errors" 8 | ) 9 | 10 | func (r *Result) LastInsertId() (int64, error) { 11 | s, err := r.c.Prepare("select cast(@@identity as bigint)") 12 | if err != nil { 13 | return 0, err 14 | } 15 | defer s.Close() 16 | rows, err := s.Query(nil) 17 | if err != nil { 18 | return 0, err 19 | } 20 | defer rows.Close() 21 | dest := make([]driver.Value, 1) 22 | err = rows.Next(dest) 23 | if err != nil { 24 | return 0, err 25 | } 26 | if dest[0] == nil { 27 | return -1, errors.New("There is no generated identity value") 28 | } 29 | lastInsertId := dest[0].(int64) 30 | return lastInsertId, nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/mssql_go19pre.go: -------------------------------------------------------------------------------- 1 | // +build !go1.9 2 | 3 | package mssql 4 | 5 | import ( 6 | "database/sql/driver" 7 | "fmt" 8 | ) 9 | 10 | func (s *Stmt) makeParamExtra(val driver.Value) (param, error) { 11 | return param{}, fmt.Errorf("mssql: unknown type for %T", val) 12 | } 13 | 14 | func scanIntoOut(name string, fromServer, scanInto interface{}) error { 15 | return fmt.Errorf("mssql: unsupported OUTPUT type, use a newer Go version") 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/rpc.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "encoding/binary" 5 | ) 6 | 7 | type procId struct { 8 | id uint16 9 | name string 10 | } 11 | 12 | // parameter flags 13 | const ( 14 | fByRevValue = 1 15 | fDefaultValue = 2 16 | ) 17 | 18 | type param struct { 19 | Name string 20 | Flags uint8 21 | ti typeInfo 22 | buffer []byte 23 | } 24 | 25 | const ( 26 | fWithRecomp = 1 27 | fNoMetaData = 2 28 | fReuseMetaData = 4 29 | ) 30 | 31 | var ( 32 | sp_Cursor = procId{1, ""} 33 | sp_CursorOpen = procId{2, ""} 34 | sp_CursorPrepare = procId{3, ""} 35 | sp_CursorExecute = procId{4, ""} 36 | sp_CursorPrepExec = procId{5, ""} 37 | sp_CursorUnprepare = procId{6, ""} 38 | sp_CursorFetch = procId{7, ""} 39 | sp_CursorOption = procId{8, ""} 40 | sp_CursorClose = procId{9, ""} 41 | sp_ExecuteSql = procId{10, ""} 42 | sp_Prepare = procId{11, ""} 43 | sp_PrepExec = procId{13, ""} 44 | sp_PrepExecRpc = procId{14, ""} 45 | sp_Unprepare = procId{15, ""} 46 | ) 47 | 48 | // http://msdn.microsoft.com/en-us/library/dd357576.aspx 49 | func sendRpc(buf *tdsBuffer, headers []headerStruct, proc procId, flags uint16, params []param, resetSession bool) (err error) { 50 | buf.BeginPacket(packRPCRequest, resetSession) 51 | writeAllHeaders(buf, headers) 52 | if len(proc.name) == 0 { 53 | var idswitch uint16 = 0xffff 54 | err = binary.Write(buf, binary.LittleEndian, &idswitch) 55 | if err != nil { 56 | return 57 | } 58 | err = binary.Write(buf, binary.LittleEndian, &proc.id) 59 | if err != nil { 60 | return 61 | } 62 | } else { 63 | err = writeUsVarChar(buf, proc.name) 64 | if err != nil { 65 | return 66 | } 67 | } 68 | err = binary.Write(buf, binary.LittleEndian, &flags) 69 | if err != nil { 70 | return 71 | } 72 | for _, param := range params { 73 | if err = writeBVarChar(buf, param.Name); err != nil { 74 | return 75 | } 76 | if err = binary.Write(buf, binary.LittleEndian, param.Flags); err != nil { 77 | return 78 | } 79 | err = writeTypeInfo(buf, ¶m.ti) 80 | if err != nil { 81 | return 82 | } 83 | err = param.ti.Writer(buf, param.ti, param.buffer) 84 | if err != nil { 85 | return 86 | } 87 | } 88 | return buf.FinishPacket() 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/token_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type token"; DO NOT EDIT 2 | 3 | package mssql 4 | 5 | import "fmt" 6 | 7 | const ( 8 | _token_name_0 = "tokenReturnStatus" 9 | _token_name_1 = "tokenColMetadata" 10 | _token_name_2 = "tokenOrdertokenErrortokenInfo" 11 | _token_name_3 = "tokenLoginAck" 12 | _token_name_4 = "tokenRowtokenNbcRow" 13 | _token_name_5 = "tokenEnvChange" 14 | _token_name_6 = "tokenSSPI" 15 | _token_name_7 = "tokenDonetokenDoneProctokenDoneInProc" 16 | ) 17 | 18 | var ( 19 | _token_index_0 = [...]uint8{0, 17} 20 | _token_index_1 = [...]uint8{0, 16} 21 | _token_index_2 = [...]uint8{0, 10, 20, 29} 22 | _token_index_3 = [...]uint8{0, 13} 23 | _token_index_4 = [...]uint8{0, 8, 19} 24 | _token_index_5 = [...]uint8{0, 14} 25 | _token_index_6 = [...]uint8{0, 9} 26 | _token_index_7 = [...]uint8{0, 9, 22, 37} 27 | ) 28 | 29 | func (i token) String() string { 30 | switch { 31 | case i == 121: 32 | return _token_name_0 33 | case i == 129: 34 | return _token_name_1 35 | case 169 <= i && i <= 171: 36 | i -= 169 37 | return _token_name_2[_token_index_2[i]:_token_index_2[i+1]] 38 | case i == 173: 39 | return _token_name_3 40 | case 209 <= i && i <= 210: 41 | i -= 209 42 | return _token_name_4[_token_index_4[i]:_token_index_4[i+1]] 43 | case i == 227: 44 | return _token_name_5 45 | case i == 237: 46 | return _token_name_6 47 | case 253 <= i && i <= 255: 48 | i -= 253 49 | return _token_name_7[_token_index_7[i]:_token_index_7[i+1]] 50 | default: 51 | return fmt.Sprintf("token(%d)", i) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/denisenkom/go-mssqldb/uniqueidentifier.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "database/sql/driver" 5 | "encoding/hex" 6 | "errors" 7 | "fmt" 8 | ) 9 | 10 | type UniqueIdentifier [16]byte 11 | 12 | func (u *UniqueIdentifier) Scan(v interface{}) error { 13 | reverse := func(b []byte) { 14 | for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 15 | b[i], b[j] = b[j], b[i] 16 | } 17 | } 18 | 19 | switch vt := v.(type) { 20 | case []byte: 21 | if len(vt) != 16 { 22 | return errors.New("mssql: invalid UniqueIdentifier length") 23 | } 24 | 25 | var raw UniqueIdentifier 26 | 27 | copy(raw[:], vt) 28 | 29 | reverse(raw[0:4]) 30 | reverse(raw[4:6]) 31 | reverse(raw[6:8]) 32 | *u = raw 33 | 34 | return nil 35 | case string: 36 | if len(vt) != 36 { 37 | return errors.New("mssql: invalid UniqueIdentifier string length") 38 | } 39 | 40 | b := []byte(vt) 41 | for i, c := range b { 42 | switch c { 43 | case '-': 44 | b = append(b[:i], b[i+1:]...) 45 | } 46 | } 47 | 48 | _, err := hex.Decode(u[:], []byte(b)) 49 | return err 50 | default: 51 | return fmt.Errorf("mssql: cannot convert %T to UniqueIdentifier", v) 52 | } 53 | } 54 | 55 | func (u UniqueIdentifier) Value() (driver.Value, error) { 56 | reverse := func(b []byte) { 57 | for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 58 | b[i], b[j] = b[j], b[i] 59 | } 60 | } 61 | 62 | raw := make([]byte, len(u)) 63 | copy(raw, u[:]) 64 | 65 | reverse(raw[0:4]) 66 | reverse(raw[4:6]) 67 | reverse(raw[6:8]) 68 | 69 | return raw, nil 70 | } 71 | 72 | func (u UniqueIdentifier) String() string { 73 | return fmt.Sprintf("%X-%X-%X-%X-%X", u[0:4], u[4:6], u[6:8], u[8:10], u[10:]) 74 | } 75 | 76 | // MarshalText converts Uniqueidentifier to bytes corresponding to the stringified hexadecimal representation of the Uniqueidentifier 77 | // e.g., "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA" -> [65 65 65 65 65 65 65 65 45 65 65 65 65 45 65 65 65 65 45 65 65 65 65 65 65 65 65 65 65 65 65] 78 | func (u UniqueIdentifier) MarshalText() []byte { 79 | return []byte(u.String()) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/conncheck.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2019 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 !windows,!appengine 10 | 11 | package mysql 12 | 13 | import ( 14 | "errors" 15 | "io" 16 | "net" 17 | "syscall" 18 | ) 19 | 20 | var errUnexpectedRead = errors.New("unexpected read from socket") 21 | 22 | func connCheck(conn net.Conn) error { 23 | var sysErr error 24 | 25 | sysConn, ok := conn.(syscall.Conn) 26 | if !ok { 27 | return nil 28 | } 29 | rawConn, err := sysConn.SyscallConn() 30 | if err != nil { 31 | return err 32 | } 33 | 34 | err = rawConn.Read(func(fd uintptr) bool { 35 | var buf [1]byte 36 | n, err := syscall.Read(int(fd), buf[:]) 37 | switch { 38 | case n == 0 && err == nil: 39 | sysErr = io.EOF 40 | case n > 0: 41 | sysErr = errUnexpectedRead 42 | case err == syscall.EAGAIN || err == syscall.EWOULDBLOCK: 43 | sysErr = nil 44 | default: 45 | sysErr = err 46 | } 47 | return true 48 | }) 49 | if err != nil { 50 | return err 51 | } 52 | 53 | return sysErr 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/conncheck_dummy.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2019 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 windows appengine 10 | 11 | package mysql 12 | 13 | import "net" 14 | 15 | func connCheck(conn net.Conn) error { 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/driver_go110.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2018 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.10 10 | 11 | package mysql 12 | 13 | import ( 14 | "database/sql/driver" 15 | ) 16 | 17 | // NewConnector returns new driver.Connector. 18 | func NewConnector(cfg *Config) (driver.Connector, error) { 19 | cfg = cfg.Clone() 20 | // normalize the contents of cfg so calls to NewConnector have the same 21 | // behavior as MySQLDriver.OpenConnector 22 | if err := cfg.normalize(); err != nil { 23 | return nil, err 24 | } 25 | return &connector{cfg: cfg}, nil 26 | } 27 | 28 | // OpenConnector implements driver.DriverContext. 29 | func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error) { 30 | cfg, err := ParseDSN(dsn) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return &connector{ 35 | cfg: cfg, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-sql-driver/mysql 2 | 3 | go 1.9 4 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/nulltime.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 | package mysql 10 | 11 | import ( 12 | "database/sql/driver" 13 | "fmt" 14 | "time" 15 | ) 16 | 17 | // Scan implements the Scanner interface. 18 | // The value type must be time.Time or string / []byte (formatted time-string), 19 | // otherwise Scan fails. 20 | func (nt *NullTime) Scan(value interface{}) (err error) { 21 | if value == nil { 22 | nt.Time, nt.Valid = time.Time{}, false 23 | return 24 | } 25 | 26 | switch v := value.(type) { 27 | case time.Time: 28 | nt.Time, nt.Valid = v, true 29 | return 30 | case []byte: 31 | nt.Time, err = parseDateTime(string(v), time.UTC) 32 | nt.Valid = (err == nil) 33 | return 34 | case string: 35 | nt.Time, err = parseDateTime(v, time.UTC) 36 | nt.Valid = (err == nil) 37 | return 38 | } 39 | 40 | nt.Valid = false 41 | return fmt.Errorf("Can't convert %T to time.Time", value) 42 | } 43 | 44 | // Value implements the driver Valuer interface. 45 | func (nt NullTime) Value() (driver.Value, error) { 46 | if !nt.Valid { 47 | return nil, nil 48 | } 49 | return nt.Time, nil 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/nulltime_go113.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 go1.13 10 | 11 | package mysql 12 | 13 | import ( 14 | "database/sql" 15 | ) 16 | 17 | // NullTime represents a time.Time that may be NULL. 18 | // NullTime implements the Scanner interface so 19 | // it can be used as a scan destination: 20 | // 21 | // var nt NullTime 22 | // err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt) 23 | // ... 24 | // if nt.Valid { 25 | // // use nt.Time 26 | // } else { 27 | // // NULL value 28 | // } 29 | // 30 | // This NullTime implementation is not driver-specific 31 | type NullTime sql.NullTime 32 | -------------------------------------------------------------------------------- /vendor/github.com/go-sql-driver/mysql/nulltime_legacy.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 !go1.13 10 | 11 | package mysql 12 | 13 | import ( 14 | "time" 15 | ) 16 | 17 | // NullTime represents a time.Time that may be NULL. 18 | // NullTime implements the Scanner interface so 19 | // it can be used as a scan destination: 20 | // 21 | // var nt NullTime 22 | // err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt) 23 | // ... 24 | // if nt.Valid { 25 | // // use nt.Time 26 | // } else { 27 | // // NULL value 28 | // } 29 | // 30 | // This NullTime implementation is not driver-specific 31 | type NullTime struct { 32 | Time time.Time 33 | Valid bool // Valid is true if Time is not NULL 34 | } 35 | -------------------------------------------------------------------------------- /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/golang-sql/civil/README.md: -------------------------------------------------------------------------------- 1 | # Civil Date and Time 2 | 3 | [![GoDoc](https://godoc.org/github.com/golang-sql/civil?status.svg)](https://godoc.org/github.com/golang-sql/civil) 4 | 5 | Civil provides Date, Time of Day, and DateTime data types. 6 | 7 | While there are many uses, using specific types when working 8 | with databases make is conceptually eaiser to understand what value 9 | is set in the remote system. 10 | 11 | ## Source 12 | 13 | This civil package was extracted and forked from `cloud.google.com/go/civil`. 14 | As such the license and contributing requirements remain the same as that 15 | module. 16 | -------------------------------------------------------------------------------- /vendor/github.com/golang/glog/README: -------------------------------------------------------------------------------- 1 | glog 2 | ==== 3 | 4 | Leveled execution logs for Go. 5 | 6 | This is an efficient pure Go implementation of leveled logs in the 7 | manner of the open source C++ package 8 | https://github.com/google/glog 9 | 10 | By binding methods to booleans it is possible to use the log package 11 | without paying the expense of evaluating the arguments to the log. 12 | Through the -vmodule flag, the package also provides fine-grained 13 | control over logging at the file level. 14 | 15 | The comment from glog.go introduces the ideas: 16 | 17 | Package glog implements logging analogous to the Google-internal 18 | C++ INFO/ERROR/V setup. It provides functions Info, Warning, 19 | Error, Fatal, plus formatting variants such as Infof. It 20 | also provides V-style logging controlled by the -v and 21 | -vmodule=file=2 flags. 22 | 23 | Basic examples: 24 | 25 | glog.Info("Prepare to repel boarders") 26 | 27 | glog.Fatalf("Initialization failed: %s", err) 28 | 29 | See the documentation for the V function for an explanation 30 | of these examples: 31 | 32 | if glog.V(2) { 33 | glog.Info("Starting transaction...") 34 | } 35 | 36 | glog.V(2).Infoln("Processed", nItems, "elements") 37 | 38 | 39 | The repository contains an open source version of the log package 40 | used inside Google. The master copy of the source lives inside 41 | Google, not here. The code in this repo is for export only and is not itself 42 | under development. Feature requests will be ignored. 43 | 44 | Send bug reports to golang-nuts@googlegroups.com. 45 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010 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 | 29 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to pq 2 | 3 | `pq` has a backlog of pull requests, but contributions are still very 4 | much welcome. You can help with patch review, submitting bug reports, 5 | or adding new functionality. There is no formal style guide, but 6 | please conform to the style of existing code and general Go formatting 7 | conventions when submitting patches. 8 | 9 | ### Patch review 10 | 11 | Help review existing open pull requests by commenting on the code or 12 | proposed functionality. 13 | 14 | ### Bug reports 15 | 16 | We appreciate any bug reports, but especially ones with self-contained 17 | (doesn't depend on code outside of pq), minimal (can't be simplified 18 | further) test cases. It's especially helpful if you can submit a pull 19 | request with just the failing test case (you'll probably want to 20 | pattern it after the tests in 21 | [conn_test.go](https://github.com/lib/pq/blob/master/conn_test.go). 22 | 23 | ### New functionality 24 | 25 | There are a number of pending patches for new functionality, so 26 | additional feature patches will take a while to merge. Still, patches 27 | are generally reviewed based on usefulness and complexity in addition 28 | to time-in-queue, so if you have a knockout idea, take a shot. Feel 29 | free to open an issue discussion your proposed patch beforehand. 30 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, 'pq' Contributors 2 | Portions Copyright (C) 2011 Blake Mizerany 3 | 4 | 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: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | 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. 9 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/TESTS.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | ## Running Tests 4 | 5 | `go test` is used for testing. A running PostgreSQL 6 | server is required, with the ability to log in. The 7 | database to connect to test with is "pqgotest," on 8 | "localhost" but these can be overridden using [environment 9 | variables](https://www.postgresql.org/docs/9.3/static/libpq-envars.html). 10 | 11 | Example: 12 | 13 | PGHOST=/run/postgresql go test 14 | 15 | ## Benchmarks 16 | 17 | A benchmark suite can be run as part of the tests: 18 | 19 | go test -bench . 20 | 21 | ## Example setup (Docker) 22 | 23 | Run a postgres container: 24 | 25 | ``` 26 | docker run --expose 5432:5432 postgres 27 | ``` 28 | 29 | Run tests: 30 | 31 | ``` 32 | PGHOST=localhost PGPORT=5432 PGUSER=postgres PGSSLMODE=disable PGDATABASE=postgres go test 33 | ``` 34 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/buf.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | 7 | "github.com/lib/pq/oid" 8 | ) 9 | 10 | type readBuf []byte 11 | 12 | func (b *readBuf) int32() (n int) { 13 | n = int(int32(binary.BigEndian.Uint32(*b))) 14 | *b = (*b)[4:] 15 | return 16 | } 17 | 18 | func (b *readBuf) oid() (n oid.Oid) { 19 | n = oid.Oid(binary.BigEndian.Uint32(*b)) 20 | *b = (*b)[4:] 21 | return 22 | } 23 | 24 | // N.B: this is actually an unsigned 16-bit integer, unlike int32 25 | func (b *readBuf) int16() (n int) { 26 | n = int(binary.BigEndian.Uint16(*b)) 27 | *b = (*b)[2:] 28 | return 29 | } 30 | 31 | func (b *readBuf) string() string { 32 | i := bytes.IndexByte(*b, 0) 33 | if i < 0 { 34 | errorf("invalid message format; expected string terminator") 35 | } 36 | s := (*b)[:i] 37 | *b = (*b)[i+1:] 38 | return string(s) 39 | } 40 | 41 | func (b *readBuf) next(n int) (v []byte) { 42 | v = (*b)[:n] 43 | *b = (*b)[n:] 44 | return 45 | } 46 | 47 | func (b *readBuf) byte() byte { 48 | return b.next(1)[0] 49 | } 50 | 51 | type writeBuf struct { 52 | buf []byte 53 | pos int 54 | } 55 | 56 | func (b *writeBuf) int32(n int) { 57 | x := make([]byte, 4) 58 | binary.BigEndian.PutUint32(x, uint32(n)) 59 | b.buf = append(b.buf, x...) 60 | } 61 | 62 | func (b *writeBuf) int16(n int) { 63 | x := make([]byte, 2) 64 | binary.BigEndian.PutUint16(x, uint16(n)) 65 | b.buf = append(b.buf, x...) 66 | } 67 | 68 | func (b *writeBuf) string(s string) { 69 | b.buf = append(append(b.buf, s...), '\000') 70 | } 71 | 72 | func (b *writeBuf) byte(c byte) { 73 | b.buf = append(b.buf, c) 74 | } 75 | 76 | func (b *writeBuf) bytes(v []byte) { 77 | b.buf = append(b.buf, v...) 78 | } 79 | 80 | func (b *writeBuf) wrap() []byte { 81 | p := b.buf[b.pos:] 82 | binary.BigEndian.PutUint32(p, uint32(len(p))) 83 | return b.buf 84 | } 85 | 86 | func (b *writeBuf) next(c byte) { 87 | p := b.buf[b.pos:] 88 | binary.BigEndian.PutUint32(p, uint32(len(p))) 89 | b.pos = len(b.buf) + 1 90 | b.buf = append(b.buf, c, 0, 0, 0, 0) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lib/pq 2 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/oid/doc.go: -------------------------------------------------------------------------------- 1 | // Package oid contains OID constants 2 | // as defined by the Postgres server. 3 | package oid 4 | 5 | // Oid is a Postgres Object ID. 6 | type Oid uint32 7 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/ssl_permissions.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pq 4 | 5 | import "os" 6 | 7 | // sslKeyPermissions checks the permissions on user-supplied ssl key files. 8 | // The key file should have very little access. 9 | // 10 | // libpq does not check key file permissions on Windows. 11 | func sslKeyPermissions(sslkey string) error { 12 | info, err := os.Stat(sslkey) 13 | if err != nil { 14 | return err 15 | } 16 | if info.Mode().Perm()&0077 != 0 { 17 | return ErrSSLKeyHasWorldPermissions 18 | } 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/ssl_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package pq 4 | 5 | // sslKeyPermissions checks the permissions on user-supplied ssl key files. 6 | // The key file should have very little access. 7 | // 8 | // libpq does not check key file permissions on Windows. 9 | func sslKeyPermissions(string) error { return nil } 10 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/url.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | nurl "net/url" 7 | "sort" 8 | "strings" 9 | ) 10 | 11 | // ParseURL no longer needs to be used by clients of this library since supplying a URL as a 12 | // connection string to sql.Open() is now supported: 13 | // 14 | // sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full") 15 | // 16 | // It remains exported here for backwards-compatibility. 17 | // 18 | // ParseURL converts a url to a connection string for driver.Open. 19 | // Example: 20 | // 21 | // "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full" 22 | // 23 | // converts to: 24 | // 25 | // "user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full" 26 | // 27 | // A minimal example: 28 | // 29 | // "postgres://" 30 | // 31 | // This will be blank, causing driver.Open to use all of the defaults 32 | func ParseURL(url string) (string, error) { 33 | u, err := nurl.Parse(url) 34 | if err != nil { 35 | return "", err 36 | } 37 | 38 | if u.Scheme != "postgres" && u.Scheme != "postgresql" { 39 | return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme) 40 | } 41 | 42 | var kvs []string 43 | escaper := strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`) 44 | accrue := func(k, v string) { 45 | if v != "" { 46 | kvs = append(kvs, k+"="+escaper.Replace(v)) 47 | } 48 | } 49 | 50 | if u.User != nil { 51 | v := u.User.Username() 52 | accrue("user", v) 53 | 54 | v, _ = u.User.Password() 55 | accrue("password", v) 56 | } 57 | 58 | if host, port, err := net.SplitHostPort(u.Host); err != nil { 59 | accrue("host", u.Host) 60 | } else { 61 | accrue("host", host) 62 | accrue("port", port) 63 | } 64 | 65 | if u.Path != "" { 66 | accrue("dbname", u.Path[1:]) 67 | } 68 | 69 | q := u.Query() 70 | for k := range q { 71 | accrue(k, q.Get(k)) 72 | } 73 | 74 | sort.Strings(kvs) // Makes testing easier (not a performance concern) 75 | return strings.Join(kvs, " "), nil 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/user_posix.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | 3 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris rumprun 4 | 5 | package pq 6 | 7 | import ( 8 | "os" 9 | "os/user" 10 | ) 11 | 12 | func userCurrent() (string, error) { 13 | u, err := user.Current() 14 | if err == nil { 15 | return u.Username, nil 16 | } 17 | 18 | name := os.Getenv("USER") 19 | if name != "" { 20 | return name, nil 21 | } 22 | 23 | return "", ErrCouldNotDetectUsername 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/user_windows.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | package pq 3 | 4 | import ( 5 | "path/filepath" 6 | "syscall" 7 | ) 8 | 9 | // Perform Windows user name lookup identically to libpq. 10 | // 11 | // The PostgreSQL code makes use of the legacy Win32 function 12 | // GetUserName, and that function has not been imported into stock Go. 13 | // GetUserNameEx is available though, the difference being that a 14 | // wider range of names are available. To get the output to be the 15 | // same as GetUserName, only the base (or last) component of the 16 | // result is returned. 17 | func userCurrent() (string, error) { 18 | pw_name := make([]uint16, 128) 19 | pwname_size := uint32(len(pw_name)) - 1 20 | err := syscall.GetUserNameEx(syscall.NameSamCompatible, &pw_name[0], &pwname_size) 21 | if err != nil { 22 | return "", ErrCouldNotDetectUsername 23 | } 24 | s := syscall.UTF16ToString(pw_name) 25 | u := filepath.Base(s) 26 | return u, nil 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/uuid.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "encoding/hex" 5 | "fmt" 6 | ) 7 | 8 | // decodeUUIDBinary interprets the binary format of a uuid, returning it in text format. 9 | func decodeUUIDBinary(src []byte) ([]byte, error) { 10 | if len(src) != 16 { 11 | return nil, fmt.Errorf("pq: unable to decode uuid; bad length: %d", len(src)) 12 | } 13 | 14 | dst := make([]byte, 36) 15 | dst[8], dst[13], dst[18], dst[23] = '-', '-', '-', '-' 16 | hex.Encode(dst[0:], src[0:4]) 17 | hex.Encode(dst[9:], src[4:6]) 18 | hex.Encode(dst[14:], src[6:8]) 19 | hex.Encode(dst[19:], src[8:10]) 20 | hex.Encode(dst[24:], src[10:16]) 21 | 22 | return dst, nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Matt T. Proud (matt.proud@gmail.com) 2 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | cover: 4 | go test -cover -v -coverprofile=cover.dat ./... 5 | go tool cover -func cover.dat 6 | 7 | .PHONY: cover 8 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Matt T. Proud 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package pbutil provides record length-delimited Protocol Buffer streaming. 16 | package pbutil 17 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/encode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Matt T. Proud 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package pbutil 16 | 17 | import ( 18 | "encoding/binary" 19 | "io" 20 | 21 | "github.com/golang/protobuf/proto" 22 | ) 23 | 24 | // WriteDelimited encodes and dumps a message to the provided writer prefixed 25 | // with a 32-bit varint indicating the length of the encoded message, producing 26 | // a length-delimited record stream, which can be used to chain together 27 | // encoded messages of the same type together in a file. It returns the total 28 | // number of bytes written and any applicable error. This is roughly 29 | // equivalent to the companion Java API's MessageLite#writeDelimitedTo. 30 | func WriteDelimited(w io.Writer, m proto.Message) (n int, err error) { 31 | buffer, err := proto.Marshal(m) 32 | if err != nil { 33 | return 0, err 34 | } 35 | 36 | var buf [binary.MaxVarintLen32]byte 37 | encodedLength := binary.PutUvarint(buf[:], uint64(len(buffer))) 38 | 39 | sync, err := w.Write(buf[:encodedLength]) 40 | if err != nil { 41 | return sync, err 42 | } 43 | 44 | n, err = w.Write(buffer) 45 | return n + sync, err 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/NOTICE: -------------------------------------------------------------------------------- 1 | Prometheus instrumentation library for Go applications 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | 7 | 8 | The following components are included in this product: 9 | 10 | perks - a fork of https://github.com/bmizerany/perks 11 | https://github.com/beorn7/perks 12 | Copyright 2013-2015 Blake Mizerany, Björn Rabenstein 13 | See https://github.com/beorn7/perks/blob/master/README.md for license details. 14 | 15 | Go support for Protocol Buffers - Google's data interchange format 16 | http://github.com/golang/protobuf/ 17 | Copyright 2010 The Go Authors 18 | See source code for license details. 19 | 20 | Support for streaming Protocol Buffer messages for the Go language (golang). 21 | https://github.com/matttproud/golang_protobuf_extensions 22 | Copyright 2013 Matt T. Proud 23 | Licensed under the Apache License, Version 2.0 24 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/README.md: -------------------------------------------------------------------------------- 1 | See [![go-doc](https://godoc.org/github.com/prometheus/client_golang/prometheus?status.svg)](https://godoc.org/github.com/prometheus/client_golang/prometheus). 2 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/build_info.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // +build go1.12 15 | 16 | package prometheus 17 | 18 | import "runtime/debug" 19 | 20 | // readBuildInfo is a wrapper around debug.ReadBuildInfo for Go 1.12+. 21 | func readBuildInfo() (path, version, sum string) { 22 | path, version, sum = "unknown", "unknown", "unknown" 23 | if bi, ok := debug.ReadBuildInfo(); ok { 24 | path = bi.Main.Path 25 | version = bi.Main.Version 26 | sum = bi.Main.Sum 27 | } 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/build_info_pre_1.12.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // +build !go1.12 15 | 16 | package prometheus 17 | 18 | // readBuildInfo is a wrapper around debug.ReadBuildInfo for Go versions before 19 | // 1.12. Remove this whole file once the minimum supported Go version is 1.12. 20 | func readBuildInfo() (path, version, sum string) { 21 | return "unknown", "unknown", "unknown" 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/fnv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package prometheus 15 | 16 | // Inline and byte-free variant of hash/fnv's fnv64a. 17 | 18 | const ( 19 | offset64 = 14695981039346656037 20 | prime64 = 1099511628211 21 | ) 22 | 23 | // hashNew initializies a new fnv64a hash value. 24 | func hashNew() uint64 { 25 | return offset64 26 | } 27 | 28 | // hashAdd adds a string to a fnv64a hash value, returning the updated hash. 29 | func hashAdd(h uint64, s string) uint64 { 30 | for i := 0; i < len(s); i++ { 31 | h ^= uint64(s[i]) 32 | h *= prime64 33 | } 34 | return h 35 | } 36 | 37 | // hashAddByte adds a byte to a fnv64a hash value, returning the updated hash. 38 | func hashAddByte(h uint64, b byte) uint64 { 39 | h ^= uint64(b) 40 | h *= prime64 41 | return h 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/observer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package prometheus 15 | 16 | // Observer is the interface that wraps the Observe method, which is used by 17 | // Histogram and Summary to add observations. 18 | type Observer interface { 19 | Observe(float64) 20 | } 21 | 22 | // The ObserverFunc type is an adapter to allow the use of ordinary 23 | // functions as Observers. If f is a function with the appropriate 24 | // signature, ObserverFunc(f) is an Observer that calls f. 25 | // 26 | // This adapter is usually used in connection with the Timer type, and there are 27 | // two general use cases: 28 | // 29 | // The most common one is to use a Gauge as the Observer for a Timer. 30 | // See the "Gauge" Timer example. 31 | // 32 | // The more advanced use case is to create a function that dynamically decides 33 | // which Observer to use for observing the duration. See the "Complex" Timer 34 | // example. 35 | type ObserverFunc func(float64) 36 | 37 | // Observe calls f(value). It implements Observer. 38 | func (f ObserverFunc) Observe(value float64) { 39 | f(value) 40 | } 41 | 42 | // ObserverVec is an interface implemented by `HistogramVec` and `SummaryVec`. 43 | type ObserverVec interface { 44 | GetMetricWith(Labels) (Observer, error) 45 | GetMetricWithLabelValues(lvs ...string) (Observer, error) 46 | With(Labels) Observer 47 | WithLabelValues(...string) Observer 48 | CurryWith(Labels) (ObserverVec, error) 49 | MustCurryWith(Labels) ObserverVec 50 | 51 | Collector 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // +build !windows 15 | 16 | package prometheus 17 | 18 | import ( 19 | "github.com/prometheus/procfs" 20 | ) 21 | 22 | func canCollectProcess() bool { 23 | _, err := procfs.NewDefaultFS() 24 | return err == nil 25 | } 26 | 27 | func (c *processCollector) processCollect(ch chan<- Metric) { 28 | pid, err := c.pidFn() 29 | if err != nil { 30 | c.reportError(ch, nil, err) 31 | return 32 | } 33 | 34 | p, err := procfs.NewProc(pid) 35 | if err != nil { 36 | c.reportError(ch, nil, err) 37 | return 38 | } 39 | 40 | if stat, err := p.Stat(); err == nil { 41 | ch <- MustNewConstMetric(c.cpuTotal, CounterValue, stat.CPUTime()) 42 | ch <- MustNewConstMetric(c.vsize, GaugeValue, float64(stat.VirtualMemory())) 43 | ch <- MustNewConstMetric(c.rss, GaugeValue, float64(stat.ResidentMemory())) 44 | if startTime, err := stat.StartTime(); err == nil { 45 | ch <- MustNewConstMetric(c.startTime, GaugeValue, startTime) 46 | } else { 47 | c.reportError(ch, c.startTime, err) 48 | } 49 | } else { 50 | c.reportError(ch, nil, err) 51 | } 52 | 53 | if fds, err := p.FileDescriptorsLen(); err == nil { 54 | ch <- MustNewConstMetric(c.openFDs, GaugeValue, float64(fds)) 55 | } else { 56 | c.reportError(ch, c.openFDs, err) 57 | } 58 | 59 | if limits, err := p.Limits(); err == nil { 60 | ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(limits.OpenFiles)) 61 | ch <- MustNewConstMetric(c.maxVsize, GaugeValue, float64(limits.AddressSpace)) 62 | } else { 63 | c.reportError(ch, nil, err) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/timer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package prometheus 15 | 16 | import "time" 17 | 18 | // Timer is a helper type to time functions. Use NewTimer to create new 19 | // instances. 20 | type Timer struct { 21 | begin time.Time 22 | observer Observer 23 | } 24 | 25 | // NewTimer creates a new Timer. The provided Observer is used to observe a 26 | // duration in seconds. Timer is usually used to time a function call in the 27 | // following way: 28 | // func TimeMe() { 29 | // timer := NewTimer(myHistogram) 30 | // defer timer.ObserveDuration() 31 | // // Do actual work. 32 | // } 33 | func NewTimer(o Observer) *Timer { 34 | return &Timer{ 35 | begin: time.Now(), 36 | observer: o, 37 | } 38 | } 39 | 40 | // ObserveDuration records the duration passed since the Timer was created with 41 | // NewTimer. It calls the Observe method of the Observer provided during 42 | // construction with the duration in seconds as an argument. The observed 43 | // duration is also returned. ObserveDuration is usually called with a defer 44 | // statement. 45 | // 46 | // Note that this method is only guaranteed to never observe negative durations 47 | // if used with Go1.9+. 48 | func (t *Timer) ObserveDuration() time.Duration { 49 | d := time.Since(t.begin) 50 | if t.observer != nil { 51 | t.observer.Observe(d.Seconds()) 52 | } 53 | return d 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/untyped.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package prometheus 15 | 16 | // UntypedOpts is an alias for Opts. See there for doc comments. 17 | type UntypedOpts Opts 18 | 19 | // UntypedFunc works like GaugeFunc but the collected metric is of type 20 | // "Untyped". UntypedFunc is useful to mirror an external metric of unknown 21 | // type. 22 | // 23 | // To create UntypedFunc instances, use NewUntypedFunc. 24 | type UntypedFunc interface { 25 | Metric 26 | Collector 27 | } 28 | 29 | // NewUntypedFunc creates a new UntypedFunc based on the provided 30 | // UntypedOpts. The value reported is determined by calling the given function 31 | // from within the Write method. Take into account that metric collection may 32 | // happen concurrently. If that results in concurrent calls to Write, like in 33 | // the case where an UntypedFunc is directly registered with Prometheus, the 34 | // provided function must be concurrency-safe. 35 | func NewUntypedFunc(opts UntypedOpts, function func() float64) UntypedFunc { 36 | return newValueFunc(NewDesc( 37 | BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), 38 | opts.Help, 39 | nil, 40 | opts.ConstLabels, 41 | ), UntypedValue, function) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_model/NOTICE: -------------------------------------------------------------------------------- 1 | Data model artifacts for Prometheus. 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/NOTICE: -------------------------------------------------------------------------------- 1 | Common libraries shared by Prometheus Go components. 2 | Copyright 2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/expfmt/expfmt.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package expfmt contains tools for reading and writing Prometheus metrics. 15 | package expfmt 16 | 17 | // Format specifies the HTTP content type of the different wire protocols. 18 | type Format string 19 | 20 | // Constants to assemble the Content-Type values for the different wire protocols. 21 | const ( 22 | TextVersion = "0.0.4" 23 | ProtoType = `application/vnd.google.protobuf` 24 | ProtoProtocol = `io.prometheus.client.MetricFamily` 25 | ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" 26 | 27 | // The Content-Type values for the different wire protocols. 28 | FmtUnknown Format = `` 29 | FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8` 30 | FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` 31 | FmtProtoText Format = ProtoFmt + ` encoding=text` 32 | FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` 33 | ) 34 | 35 | const ( 36 | hdrContentType = "Content-Type" 37 | hdrAccept = "Accept" 38 | ) 39 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/expfmt/fuzz.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Build only when actually fuzzing 15 | // +build gofuzz 16 | 17 | package expfmt 18 | 19 | import "bytes" 20 | 21 | // Fuzz text metric parser with with github.com/dvyukov/go-fuzz: 22 | // 23 | // go-fuzz-build github.com/prometheus/common/expfmt 24 | // go-fuzz -bin expfmt-fuzz.zip -workdir fuzz 25 | // 26 | // Further input samples should go in the folder fuzz/corpus. 27 | func Fuzz(in []byte) int { 28 | parser := TextParser{} 29 | _, err := parser.TextToMetricFamilies(bytes.NewReader(in)) 30 | 31 | if err != nil { 32 | return 0 33 | } 34 | 35 | return 1 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/README.txt: -------------------------------------------------------------------------------- 1 | PACKAGE 2 | 3 | package goautoneg 4 | import "bitbucket.org/ww/goautoneg" 5 | 6 | HTTP Content-Type Autonegotiation. 7 | 8 | The functions in this package implement the behaviour specified in 9 | http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 10 | 11 | Copyright (c) 2011, Open Knowledge Foundation Ltd. 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are 16 | met: 17 | 18 | Redistributions of source code must retain the above copyright 19 | notice, this list of conditions and the following disclaimer. 20 | 21 | Redistributions in binary form must reproduce the above copyright 22 | notice, this list of conditions and the following disclaimer in 23 | the documentation and/or other materials provided with the 24 | distribution. 25 | 26 | Neither the name of the Open Knowledge Foundation Ltd. nor the 27 | names of its contributors may be used to endorse or promote 28 | products derived from this software without specific prior written 29 | permission. 30 | 31 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 34 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 36 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 37 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 38 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 39 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 40 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | 43 | 44 | FUNCTIONS 45 | 46 | func Negotiate(header string, alternatives []string) (content_type string) 47 | Negotiate the most appropriate content_type given the accept header 48 | and a list of alternatives. 49 | 50 | func ParseAccept(header string) (accept []Accept) 51 | Parse an Accept Header string returning a sorted list 52 | of clauses 53 | 54 | 55 | TYPES 56 | 57 | type Accept struct { 58 | Type, SubType string 59 | Q float32 60 | Params map[string]string 61 | } 62 | Structure to represent a clause in an HTTP Accept Header 63 | 64 | 65 | SUBDIRECTORIES 66 | 67 | .hg 68 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/model/fnv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | // Inline and byte-free variant of hash/fnv's fnv64a. 17 | 18 | const ( 19 | offset64 = 14695981039346656037 20 | prime64 = 1099511628211 21 | ) 22 | 23 | // hashNew initializies a new fnv64a hash value. 24 | func hashNew() uint64 { 25 | return offset64 26 | } 27 | 28 | // hashAdd adds a string to a fnv64a hash value, returning the updated hash. 29 | func hashAdd(h uint64, s string) uint64 { 30 | for i := 0; i < len(s); i++ { 31 | h ^= uint64(s[i]) 32 | h *= prime64 33 | } 34 | return h 35 | } 36 | 37 | // hashAddByte adds a byte to a fnv64a hash value, returning the updated hash. 38 | func hashAddByte(h uint64, b byte) uint64 { 39 | h ^= uint64(b) 40 | h *= prime64 41 | return h 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/model/model.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package model contains common data structures that are shared across 15 | // Prometheus components and libraries. 16 | package model 17 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | * Johannes 'fish' Ziemke @discordianfish 2 | * Paul Gier @pgier 3 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Prometheus Authors 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | 14 | include Makefile.common 15 | 16 | %/.unpacked: %.ttar 17 | @echo ">> extracting fixtures" 18 | ./ttar -C $(dir $*) -x -f $*.ttar 19 | touch $@ 20 | 21 | update_fixtures: 22 | rm -vf fixtures/.unpacked 23 | ./ttar -c -f fixtures.ttar fixtures/ 24 | 25 | .PHONY: build 26 | build: 27 | 28 | .PHONY: test 29 | test: fixtures/.unpacked common-test 30 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/NOTICE: -------------------------------------------------------------------------------- 1 | procfs provides functions to retrieve system, kernel and process 2 | metrics from the pseudo-filesystem proc. 3 | 4 | Copyright 2014-2015 The Prometheus Authors 5 | 6 | This product includes software developed at 7 | SoundCloud Ltd. (http://soundcloud.com/). 8 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/arp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package procfs 15 | 16 | import ( 17 | "fmt" 18 | "io/ioutil" 19 | "net" 20 | "strings" 21 | ) 22 | 23 | // ARPEntry contains a single row of the columnar data represented in 24 | // /proc/net/arp. 25 | type ARPEntry struct { 26 | // IP address 27 | IPAddr net.IP 28 | // MAC address 29 | HWAddr net.HardwareAddr 30 | // Name of the device 31 | Device string 32 | } 33 | 34 | // GatherARPEntries retrieves all the ARP entries, parse the relevant columns, 35 | // and then return a slice of ARPEntry's. 36 | func (fs FS) GatherARPEntries() ([]ARPEntry, error) { 37 | data, err := ioutil.ReadFile(fs.proc.Path("net/arp")) 38 | if err != nil { 39 | return nil, fmt.Errorf("error reading arp %s: %s", fs.proc.Path("net/arp"), err) 40 | } 41 | 42 | return parseARPEntries(data) 43 | } 44 | 45 | func parseARPEntries(data []byte) ([]ARPEntry, error) { 46 | lines := strings.Split(string(data), "\n") 47 | entries := make([]ARPEntry, 0) 48 | var err error 49 | const ( 50 | expectedDataWidth = 6 51 | expectedHeaderWidth = 9 52 | ) 53 | for _, line := range lines { 54 | columns := strings.Fields(line) 55 | width := len(columns) 56 | 57 | if width == expectedHeaderWidth || width == 0 { 58 | continue 59 | } else if width == expectedDataWidth { 60 | entry, err := parseARPEntry(columns) 61 | if err != nil { 62 | return []ARPEntry{}, fmt.Errorf("failed to parse ARP entry: %s", err) 63 | } 64 | entries = append(entries, entry) 65 | } else { 66 | return []ARPEntry{}, fmt.Errorf("%d columns were detected, but %d were expected", width, expectedDataWidth) 67 | } 68 | 69 | } 70 | 71 | return entries, err 72 | } 73 | 74 | func parseARPEntry(columns []string) (ARPEntry, error) { 75 | ip := net.ParseIP(columns[0]) 76 | mac := net.HardwareAddr(columns[3]) 77 | 78 | entry := ARPEntry{ 79 | IPAddr: ip, 80 | HWAddr: mac, 81 | Device: columns[5], 82 | } 83 | 84 | return entry, nil 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/buddyinfo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package procfs 15 | 16 | import ( 17 | "bufio" 18 | "fmt" 19 | "io" 20 | "os" 21 | "strconv" 22 | "strings" 23 | ) 24 | 25 | // A BuddyInfo is the details parsed from /proc/buddyinfo. 26 | // The data is comprised of an array of free fragments of each size. 27 | // The sizes are 2^n*PAGE_SIZE, where n is the array index. 28 | type BuddyInfo struct { 29 | Node string 30 | Zone string 31 | Sizes []float64 32 | } 33 | 34 | // BuddyInfo reads the buddyinfo statistics from the specified `proc` filesystem. 35 | func (fs FS) BuddyInfo() ([]BuddyInfo, error) { 36 | file, err := os.Open(fs.proc.Path("buddyinfo")) 37 | if err != nil { 38 | return nil, err 39 | } 40 | defer file.Close() 41 | 42 | return parseBuddyInfo(file) 43 | } 44 | 45 | func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { 46 | var ( 47 | buddyInfo = []BuddyInfo{} 48 | scanner = bufio.NewScanner(r) 49 | bucketCount = -1 50 | ) 51 | 52 | for scanner.Scan() { 53 | var err error 54 | line := scanner.Text() 55 | parts := strings.Fields(line) 56 | 57 | if len(parts) < 4 { 58 | return nil, fmt.Errorf("invalid number of fields when parsing buddyinfo") 59 | } 60 | 61 | node := strings.TrimRight(parts[1], ",") 62 | zone := strings.TrimRight(parts[3], ",") 63 | arraySize := len(parts[4:]) 64 | 65 | if bucketCount == -1 { 66 | bucketCount = arraySize 67 | } else { 68 | if bucketCount != arraySize { 69 | return nil, fmt.Errorf("mismatch in number of buddyinfo buckets, previous count %d, new count %d", bucketCount, arraySize) 70 | } 71 | } 72 | 73 | sizes := make([]float64, arraySize) 74 | for i := 0; i < arraySize; i++ { 75 | sizes[i], err = strconv.ParseFloat(parts[i+4], 64) 76 | if err != nil { 77 | return nil, fmt.Errorf("invalid value in buddyinfo: %s", err) 78 | } 79 | } 80 | 81 | buddyInfo = append(buddyInfo, BuddyInfo{node, zone, sizes}) 82 | } 83 | 84 | return buddyInfo, scanner.Err() 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Prometheus Team 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package procfs provides functions to retrieve system, kernel and process 15 | // metrics from the pseudo-filesystem proc. 16 | // 17 | // Example: 18 | // 19 | // package main 20 | // 21 | // import ( 22 | // "fmt" 23 | // "log" 24 | // 25 | // "github.com/prometheus/procfs" 26 | // ) 27 | // 28 | // func main() { 29 | // p, err := procfs.Self() 30 | // if err != nil { 31 | // log.Fatalf("could not get process: %s", err) 32 | // } 33 | // 34 | // stat, err := p.NewStat() 35 | // if err != nil { 36 | // log.Fatalf("could not get process stat: %s", err) 37 | // } 38 | // 39 | // fmt.Printf("command: %s\n", stat.Comm) 40 | // fmt.Printf("cpu time: %fs\n", stat.CPUTime()) 41 | // fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) 42 | // fmt.Printf("rss: %dB\n", stat.ResidentMemory()) 43 | // } 44 | // 45 | package procfs 46 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/fs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package procfs 15 | 16 | import ( 17 | "github.com/prometheus/procfs/internal/fs" 18 | ) 19 | 20 | // FS represents the pseudo-filesystem sys, which provides an interface to 21 | // kernel data structures. 22 | type FS struct { 23 | proc fs.FS 24 | } 25 | 26 | // DefaultMountPoint is the common mount point of the proc filesystem. 27 | const DefaultMountPoint = fs.DefaultProcMountPoint 28 | 29 | // NewDefaultFS returns a new proc FS mounted under the default proc mountPoint. 30 | // It will error if the mount point directory can't be read or is a file. 31 | func NewDefaultFS() (FS, error) { 32 | return NewFS(DefaultMountPoint) 33 | } 34 | 35 | // NewFS returns a new proc FS mounted under the given proc mountPoint. It will error 36 | // if the mount point directory can't be read or is a file. 37 | func NewFS(mountPoint string) (FS, error) { 38 | fs, err := fs.NewFS(mountPoint) 39 | if err != nil { 40 | return FS{}, err 41 | } 42 | return FS{fs}, nil 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/prometheus/procfs 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/google/go-cmp v0.3.1 7 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e 8 | ) 9 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= 2 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 3 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= 4 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 5 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/fs/fs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package fs 15 | 16 | import ( 17 | "fmt" 18 | "os" 19 | "path/filepath" 20 | ) 21 | 22 | const ( 23 | // DefaultProcMountPoint is the common mount point of the proc filesystem. 24 | DefaultProcMountPoint = "/proc" 25 | 26 | // DefaultSysMountPoint is the common mount point of the sys filesystem. 27 | DefaultSysMountPoint = "/sys" 28 | 29 | // DefaultConfigfsMountPoint is the common mount point of the configfs 30 | DefaultConfigfsMountPoint = "/sys/kernel/config" 31 | ) 32 | 33 | // FS represents a pseudo-filesystem, normally /proc or /sys, which provides an 34 | // interface to kernel data structures. 35 | type FS string 36 | 37 | // NewFS returns a new FS mounted under the given mountPoint. It will error 38 | // if the mount point can't be read. 39 | func NewFS(mountPoint string) (FS, error) { 40 | info, err := os.Stat(mountPoint) 41 | if err != nil { 42 | return "", fmt.Errorf("could not read %s: %s", mountPoint, err) 43 | } 44 | if !info.IsDir() { 45 | return "", fmt.Errorf("mount point %s is not a directory", mountPoint) 46 | } 47 | 48 | return FS(mountPoint), nil 49 | } 50 | 51 | // Path appends the given path elements to the filesystem path, adding separators 52 | // as necessary. 53 | func (fs FS) Path(p ...string) string { 54 | return filepath.Join(append([]string{string(fs)}, p...)...) 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/util/parse.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package util 15 | 16 | import ( 17 | "io/ioutil" 18 | "strconv" 19 | "strings" 20 | ) 21 | 22 | // ParseUint32s parses a slice of strings into a slice of uint32s. 23 | func ParseUint32s(ss []string) ([]uint32, error) { 24 | us := make([]uint32, 0, len(ss)) 25 | for _, s := range ss { 26 | u, err := strconv.ParseUint(s, 10, 32) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | us = append(us, uint32(u)) 32 | } 33 | 34 | return us, nil 35 | } 36 | 37 | // ParseUint64s parses a slice of strings into a slice of uint64s. 38 | func ParseUint64s(ss []string) ([]uint64, error) { 39 | us := make([]uint64, 0, len(ss)) 40 | for _, s := range ss { 41 | u, err := strconv.ParseUint(s, 10, 64) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | us = append(us, u) 47 | } 48 | 49 | return us, nil 50 | } 51 | 52 | // ParsePInt64s parses a slice of strings into a slice of int64 pointers. 53 | func ParsePInt64s(ss []string) ([]*int64, error) { 54 | us := make([]*int64, 0, len(ss)) 55 | for _, s := range ss { 56 | u, err := strconv.ParseInt(s, 10, 64) 57 | if err != nil { 58 | return nil, err 59 | } 60 | 61 | us = append(us, &u) 62 | } 63 | 64 | return us, nil 65 | } 66 | 67 | // ReadUintFromFile reads a file and attempts to parse a uint64 from it. 68 | func ReadUintFromFile(path string) (uint64, error) { 69 | data, err := ioutil.ReadFile(path) 70 | if err != nil { 71 | return 0, err 72 | } 73 | return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64) 74 | } 75 | 76 | // ParseBool parses a string into a boolean pointer. 77 | func ParseBool(b string) *bool { 78 | var truth bool 79 | switch b { 80 | case "enabled": 81 | truth = true 82 | case "disabled": 83 | truth = false 84 | default: 85 | return nil 86 | } 87 | return &truth 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/util/readfile.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package util 15 | 16 | import ( 17 | "io" 18 | "io/ioutil" 19 | "os" 20 | ) 21 | 22 | // ReadFileNoStat uses ioutil.ReadAll to read contents of entire file. 23 | // This is similar to ioutil.ReadFile but without the call to os.Stat, because 24 | // many files in /proc and /sys report incorrect file sizes (either 0 or 4096). 25 | // Reads a max file size of 512kB. For files larger than this, a scanner 26 | // should be used. 27 | func ReadFileNoStat(filename string) ([]byte, error) { 28 | const maxBufferSize = 1024 * 512 29 | 30 | f, err := os.Open(filename) 31 | if err != nil { 32 | return nil, err 33 | } 34 | defer f.Close() 35 | 36 | reader := io.LimitReader(f, maxBufferSize) 37 | return ioutil.ReadAll(reader) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/util/sysreadfile.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // +build linux,!appengine 15 | 16 | package util 17 | 18 | import ( 19 | "bytes" 20 | "os" 21 | "syscall" 22 | ) 23 | 24 | // SysReadFile is a simplified ioutil.ReadFile that invokes syscall.Read directly. 25 | // https://github.com/prometheus/node_exporter/pull/728/files 26 | // 27 | // Note that this function will not read files larger than 128 bytes. 28 | func SysReadFile(file string) (string, error) { 29 | f, err := os.Open(file) 30 | if err != nil { 31 | return "", err 32 | } 33 | defer f.Close() 34 | 35 | // On some machines, hwmon drivers are broken and return EAGAIN. This causes 36 | // Go's ioutil.ReadFile implementation to poll forever. 37 | // 38 | // Since we either want to read data or bail immediately, do the simplest 39 | // possible read using syscall directly. 40 | const sysFileBufferSize = 128 41 | b := make([]byte, sysFileBufferSize) 42 | n, err := syscall.Read(int(f.Fd()), b) 43 | if err != nil { 44 | return "", err 45 | } 46 | 47 | return string(bytes.TrimSpace(b[:n])), nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/util/sysreadfile_compat.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // +build linux,appengine !linux 15 | 16 | package util 17 | 18 | import ( 19 | "fmt" 20 | ) 21 | 22 | // SysReadFile is here implemented as a noop for builds that do not support 23 | // the read syscall. For example Windows, or Linux on Google App Engine. 24 | func SysReadFile(file string) (string, error) { 25 | return "", fmt.Errorf("not supported on this platform") 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/internal/util/valueparser.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package util 15 | 16 | import ( 17 | "strconv" 18 | ) 19 | 20 | // TODO(mdlayher): util packages are an anti-pattern and this should be moved 21 | // somewhere else that is more focused in the future. 22 | 23 | // A ValueParser enables parsing a single string into a variety of data types 24 | // in a concise and safe way. The Err method must be invoked after invoking 25 | // any other methods to ensure a value was successfully parsed. 26 | type ValueParser struct { 27 | v string 28 | err error 29 | } 30 | 31 | // NewValueParser creates a ValueParser using the input string. 32 | func NewValueParser(v string) *ValueParser { 33 | return &ValueParser{v: v} 34 | } 35 | 36 | // PInt64 interprets the underlying value as an int64 and returns a pointer to 37 | // that value. 38 | func (vp *ValueParser) PInt64() *int64 { 39 | if vp.err != nil { 40 | return nil 41 | } 42 | 43 | // A base value of zero makes ParseInt infer the correct base using the 44 | // string's prefix, if any. 45 | const base = 0 46 | v, err := strconv.ParseInt(vp.v, base, 64) 47 | if err != nil { 48 | vp.err = err 49 | return nil 50 | } 51 | 52 | return &v 53 | } 54 | 55 | // PUInt64 interprets the underlying value as an uint64 and returns a pointer to 56 | // that value. 57 | func (vp *ValueParser) PUInt64() *uint64 { 58 | if vp.err != nil { 59 | return nil 60 | } 61 | 62 | // A base value of zero makes ParseInt infer the correct base using the 63 | // string's prefix, if any. 64 | const base = 0 65 | v, err := strconv.ParseUint(vp.v, base, 64) 66 | if err != nil { 67 | vp.err = err 68 | return nil 69 | } 70 | 71 | return &v 72 | } 73 | 74 | // Err returns the last error, if any, encountered by the ValueParser. 75 | func (vp *ValueParser) Err() error { 76 | return vp.err 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/proc_environ.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package procfs 15 | 16 | import ( 17 | "strings" 18 | 19 | "github.com/prometheus/procfs/internal/util" 20 | ) 21 | 22 | // Environ reads process environments from /proc//environ 23 | func (p Proc) Environ() ([]string, error) { 24 | environments := make([]string, 0) 25 | 26 | data, err := util.ReadFileNoStat(p.path("environ")) 27 | if err != nil { 28 | return environments, err 29 | } 30 | 31 | environments = strings.Split(string(data), "\000") 32 | if len(environments) > 0 { 33 | environments = environments[:len(environments)-1] 34 | } 35 | 36 | return environments, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/proc_io.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package procfs 15 | 16 | import ( 17 | "fmt" 18 | 19 | "github.com/prometheus/procfs/internal/util" 20 | ) 21 | 22 | // ProcIO models the content of /proc//io. 23 | type ProcIO struct { 24 | // Chars read. 25 | RChar uint64 26 | // Chars written. 27 | WChar uint64 28 | // Read syscalls. 29 | SyscR uint64 30 | // Write syscalls. 31 | SyscW uint64 32 | // Bytes read. 33 | ReadBytes uint64 34 | // Bytes written. 35 | WriteBytes uint64 36 | // Bytes written, but taking into account truncation. See 37 | // Documentation/filesystems/proc.txt in the kernel sources for 38 | // detailed explanation. 39 | CancelledWriteBytes int64 40 | } 41 | 42 | // IO creates a new ProcIO instance from a given Proc instance. 43 | func (p Proc) IO() (ProcIO, error) { 44 | pio := ProcIO{} 45 | 46 | data, err := util.ReadFileNoStat(p.path("io")) 47 | if err != nil { 48 | return pio, err 49 | } 50 | 51 | ioFormat := "rchar: %d\nwchar: %d\nsyscr: %d\nsyscw: %d\n" + 52 | "read_bytes: %d\nwrite_bytes: %d\n" + 53 | "cancelled_write_bytes: %d\n" 54 | 55 | _, err = fmt.Sscanf(string(data), ioFormat, &pio.RChar, &pio.WChar, &pio.SyscR, 56 | &pio.SyscW, &pio.ReadBytes, &pio.WriteBytes, &pio.CancelledWriteBytes) 57 | 58 | return pio, err 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/proc_ns.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package procfs 15 | 16 | import ( 17 | "fmt" 18 | "os" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | // Namespace represents a single namespace of a process. 24 | type Namespace struct { 25 | Type string // Namespace type. 26 | Inode uint32 // Inode number of the namespace. If two processes are in the same namespace their inodes will match. 27 | } 28 | 29 | // Namespaces contains all of the namespaces that the process is contained in. 30 | type Namespaces map[string]Namespace 31 | 32 | // Namespaces reads from /proc//ns/* to get the namespaces of which the 33 | // process is a member. 34 | func (p Proc) Namespaces() (Namespaces, error) { 35 | d, err := os.Open(p.path("ns")) 36 | if err != nil { 37 | return nil, err 38 | } 39 | defer d.Close() 40 | 41 | names, err := d.Readdirnames(-1) 42 | if err != nil { 43 | return nil, fmt.Errorf("failed to read contents of ns dir: %v", err) 44 | } 45 | 46 | ns := make(Namespaces, len(names)) 47 | for _, name := range names { 48 | target, err := os.Readlink(p.path("ns", name)) 49 | if err != nil { 50 | return nil, err 51 | } 52 | 53 | fields := strings.SplitN(target, ":", 2) 54 | if len(fields) != 2 { 55 | return nil, fmt.Errorf("failed to parse namespace type and inode from '%v'", target) 56 | } 57 | 58 | typ := fields[0] 59 | inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32) 60 | if err != nil { 61 | return nil, fmt.Errorf("failed to parse inode from '%v': %v", fields[1], err) 62 | } 63 | 64 | ns[name] = Namespace{typ, uint32(inode)} 65 | } 66 | 67 | return ns, nil 68 | } 69 | -------------------------------------------------------------------------------- /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/crypto/md4/md4block.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 | // MD4 block step. 6 | // In its own file so that a faster assembly or C version 7 | // can be substituted easily. 8 | 9 | package md4 10 | 11 | var shift1 = []uint{3, 7, 11, 19} 12 | var shift2 = []uint{3, 5, 9, 13} 13 | var shift3 = []uint{3, 9, 11, 15} 14 | 15 | var xIndex2 = []uint{0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15} 16 | var xIndex3 = []uint{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15} 17 | 18 | func _Block(dig *digest, p []byte) int { 19 | a := dig.s[0] 20 | b := dig.s[1] 21 | c := dig.s[2] 22 | d := dig.s[3] 23 | n := 0 24 | var X [16]uint32 25 | for len(p) >= _Chunk { 26 | aa, bb, cc, dd := a, b, c, d 27 | 28 | j := 0 29 | for i := 0; i < 16; i++ { 30 | X[i] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24 31 | j += 4 32 | } 33 | 34 | // If this needs to be made faster in the future, 35 | // the usual trick is to unroll each of these 36 | // loops by a factor of 4; that lets you replace 37 | // the shift[] lookups with constants and, 38 | // with suitable variable renaming in each 39 | // unrolled body, delete the a, b, c, d = d, a, b, c 40 | // (or you can let the optimizer do the renaming). 41 | // 42 | // The index variables are uint so that % by a power 43 | // of two can be optimized easily by a compiler. 44 | 45 | // Round 1. 46 | for i := uint(0); i < 16; i++ { 47 | x := i 48 | s := shift1[i%4] 49 | f := ((c ^ d) & b) ^ d 50 | a += f + X[x] 51 | a = a<>(32-s) 52 | a, b, c, d = d, a, b, c 53 | } 54 | 55 | // Round 2. 56 | for i := uint(0); i < 16; i++ { 57 | x := xIndex2[i] 58 | s := shift2[i%4] 59 | g := (b & c) | (b & d) | (c & d) 60 | a += g + X[x] + 0x5a827999 61 | a = a<>(32-s) 62 | a, b, c, d = d, a, b, c 63 | } 64 | 65 | // Round 3. 66 | for i := uint(0); i < 16; i++ { 67 | x := xIndex3[i] 68 | s := shift3[i%4] 69 | h := b ^ c ^ d 70 | a += h + X[x] + 0x6ed9eba1 71 | a = a<>(32-s) 72 | a, b, c, d = d, a, b, c 73 | } 74 | 75 | a += aa 76 | b += bb 77 | c += cc 78 | d += dd 79 | 80 | p = p[_Chunk:] 81 | n += _Chunk 82 | } 83 | 84 | dig.s[0] = a 85 | dig.s[1] = b 86 | dig.s[2] = c 87 | dig.s[3] = d 88 | return n 89 | } 90 | -------------------------------------------------------------------------------- /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/windows/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 windows 6 | // +build go1.9 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | type Errno = syscall.Errno 13 | type SysProcAttr = syscall.SysProcAttr 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/empty.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.12 6 | 7 | // This file is here to allow bodyless functions with go:linkname for Go 1.11 8 | // and earlier (see https://golang.org/issue/23311). 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_windows.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 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import ( 10 | "syscall" 11 | "unicode/utf16" 12 | "unsafe" 13 | ) 14 | 15 | func Getenv(key string) (value string, found bool) { 16 | return syscall.Getenv(key) 17 | } 18 | 19 | func Setenv(key, value string) error { 20 | return syscall.Setenv(key, value) 21 | } 22 | 23 | func Clearenv() { 24 | syscall.Clearenv() 25 | } 26 | 27 | func Environ() []string { 28 | return syscall.Environ() 29 | } 30 | 31 | // Returns a default environment associated with the token, rather than the current 32 | // process. If inheritExisting is true, then this environment also inherits the 33 | // environment of the current process. 34 | func (token Token) Environ(inheritExisting bool) (env []string, err error) { 35 | var block *uint16 36 | err = CreateEnvironmentBlock(&block, token, inheritExisting) 37 | if err != nil { 38 | return nil, err 39 | } 40 | defer DestroyEnvironmentBlock(block) 41 | blockp := uintptr(unsafe.Pointer(block)) 42 | for { 43 | entry := (*[(1 << 30) - 1]uint16)(unsafe.Pointer(blockp))[:] 44 | for i, v := range entry { 45 | if v == 0 { 46 | entry = entry[:i] 47 | break 48 | } 49 | } 50 | if len(entry) == 0 { 51 | break 52 | } 53 | env = append(env, string(utf16.Decode(entry))) 54 | blockp += 2 * (uintptr(len(entry)) + 1) 55 | } 56 | return env, nil 57 | } 58 | 59 | func Unsetenv(key string) error { 60 | return syscall.Unsetenv(key) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/eventlog.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 windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/exec_windows.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 | // Fork, exec, wait, etc. 6 | 7 | package windows 8 | 9 | // EscapeArg rewrites command line argument s as prescribed 10 | // in http://msdn.microsoft.com/en-us/library/ms880421. 11 | // This function returns "" (2 double quotes) if s is empty. 12 | // Alternatively, these transformations are done: 13 | // - every back slash (\) is doubled, but only if immediately 14 | // followed by double quote ("); 15 | // - every double quote (") is escaped by back slash (\); 16 | // - finally, s is wrapped with double quotes (arg -> "arg"), 17 | // but only if there is space or tab inside s. 18 | func EscapeArg(s string) string { 19 | if len(s) == 0 { 20 | return "\"\"" 21 | } 22 | n := len(s) 23 | hasSpace := false 24 | for i := 0; i < len(s); i++ { 25 | switch s[i] { 26 | case '"', '\\': 27 | n++ 28 | case ' ', '\t': 29 | hasSpace = true 30 | } 31 | } 32 | if hasSpace { 33 | n += 2 34 | } 35 | if n == len(s) { 36 | return s 37 | } 38 | 39 | qs := make([]byte, n) 40 | j := 0 41 | if hasSpace { 42 | qs[j] = '"' 43 | j++ 44 | } 45 | slashes := 0 46 | for i := 0; i < len(s); i++ { 47 | switch s[i] { 48 | default: 49 | slashes = 0 50 | qs[j] = s[i] 51 | case '\\': 52 | slashes++ 53 | qs[j] = s[i] 54 | case '"': 55 | for ; slashes > 0; slashes-- { 56 | qs[j] = '\\' 57 | j++ 58 | } 59 | qs[j] = '\\' 60 | j++ 61 | qs[j] = s[i] 62 | } 63 | j++ 64 | } 65 | if hasSpace { 66 | for ; slashes > 0; slashes-- { 67 | qs[j] = '\\' 68 | j++ 69 | } 70 | qs[j] = '"' 71 | j++ 72 | } 73 | return string(qs[:j]) 74 | } 75 | 76 | func CloseOnExec(fd Handle) { 77 | SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) 78 | } 79 | 80 | // FullPath retrieves the full path of the specified file. 81 | func FullPath(name string) (path string, err error) { 82 | p, err := UTF16PtrFromString(name) 83 | if err != nil { 84 | return "", err 85 | } 86 | n := uint32(100) 87 | for { 88 | buf := make([]uint16, n) 89 | n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) 90 | if err != nil { 91 | return "", err 92 | } 93 | if n <= uint32(len(buf)) { 94 | return UTF16ToString(buf[:n]), nil 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/memory_windows.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 | package windows 6 | 7 | const ( 8 | MEM_COMMIT = 0x00001000 9 | MEM_RESERVE = 0x00002000 10 | MEM_DECOMMIT = 0x00004000 11 | MEM_RELEASE = 0x00008000 12 | MEM_RESET = 0x00080000 13 | MEM_TOP_DOWN = 0x00100000 14 | MEM_WRITE_WATCH = 0x00200000 15 | MEM_PHYSICAL = 0x00400000 16 | MEM_RESET_UNDO = 0x01000000 17 | MEM_LARGE_PAGES = 0x20000000 18 | 19 | PAGE_NOACCESS = 0x01 20 | PAGE_READONLY = 0x02 21 | PAGE_READWRITE = 0x04 22 | PAGE_WRITECOPY = 0x08 23 | PAGE_EXECUTE_READ = 0x20 24 | PAGE_EXECUTE_READWRITE = 0x40 25 | PAGE_EXECUTE_WRITECOPY = 0x80 26 | ) 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mkerrors.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 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 | set -e 8 | shopt -s nullglob 9 | 10 | winerror="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/shared/winerror.h | sort -Vr | head -n 1)" 11 | [[ -n $winerror ]] || { echo "Unable to find winerror.h" >&2; exit 1; } 12 | 13 | declare -A errors 14 | 15 | { 16 | echo "// Code generated by 'mkerrors.bash'; DO NOT EDIT." 17 | echo 18 | echo "package windows" 19 | echo "import \"syscall\"" 20 | echo "const (" 21 | 22 | while read -r line; do 23 | unset vtype 24 | if [[ $line =~ ^#define\ +([A-Z0-9_]+k?)\ +([A-Z0-9_]+\()?([A-Z][A-Z0-9_]+k?)\)? ]]; then 25 | key="${BASH_REMATCH[1]}" 26 | value="${BASH_REMATCH[3]}" 27 | elif [[ $line =~ ^#define\ +([A-Z0-9_]+k?)\ +([A-Z0-9_]+\()?((0x)?[0-9A-Fa-f]+)L?\)? ]]; then 28 | key="${BASH_REMATCH[1]}" 29 | value="${BASH_REMATCH[3]}" 30 | vtype="${BASH_REMATCH[2]}" 31 | elif [[ $line =~ ^#define\ +([A-Z0-9_]+k?)\ +\(\(([A-Z]+)\)((0x)?[0-9A-Fa-f]+)L?\) ]]; then 32 | key="${BASH_REMATCH[1]}" 33 | value="${BASH_REMATCH[3]}" 34 | vtype="${BASH_REMATCH[2]}" 35 | else 36 | continue 37 | fi 38 | [[ -n $key && -n $value ]] || continue 39 | [[ -z ${errors["$key"]} ]] || continue 40 | errors["$key"]="$value" 41 | if [[ -v vtype ]]; then 42 | if [[ $key == FACILITY_* || $key == NO_ERROR ]]; then 43 | vtype="" 44 | elif [[ $vtype == *HANDLE* || $vtype == *HRESULT* ]]; then 45 | vtype="Handle" 46 | else 47 | vtype="syscall.Errno" 48 | fi 49 | last_vtype="$vtype" 50 | else 51 | vtype="" 52 | if [[ $last_vtype == Handle && $value == NO_ERROR ]]; then 53 | value="S_OK" 54 | elif [[ $last_vtype == syscall.Errno && $value == NO_ERROR ]]; then 55 | value="ERROR_SUCCESS" 56 | fi 57 | fi 58 | 59 | echo "$key $vtype = $value" 60 | done < "$winerror" 61 | 62 | echo ")" 63 | } | gofmt > "zerrors_windows.go" 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mkknownfolderids.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 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 | set -e 8 | shopt -s nullglob 9 | 10 | knownfolders="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/um/KnownFolders.h | sort -Vr | head -n 1)" 11 | [[ -n $knownfolders ]] || { echo "Unable to find KnownFolders.h" >&2; exit 1; } 12 | 13 | { 14 | echo "// Code generated by 'mkknownfolderids.bash'; DO NOT EDIT." 15 | echo 16 | echo "package windows" 17 | echo "type KNOWNFOLDERID GUID" 18 | echo "var (" 19 | while read -r line; do 20 | [[ $line =~ DEFINE_KNOWN_FOLDER\((FOLDERID_[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+)\) ]] || continue 21 | printf "%s = &KNOWNFOLDERID{0x%08x, 0x%04x, 0x%04x, [8]byte{0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x}}\n" \ 22 | "${BASH_REMATCH[1]}" $(( "${BASH_REMATCH[2]}" )) $(( "${BASH_REMATCH[3]}" )) $(( "${BASH_REMATCH[4]}" )) \ 23 | $(( "${BASH_REMATCH[5]}" )) $(( "${BASH_REMATCH[6]}" )) $(( "${BASH_REMATCH[7]}" )) $(( "${BASH_REMATCH[8]}" )) \ 24 | $(( "${BASH_REMATCH[9]}" )) $(( "${BASH_REMATCH[10]}" )) $(( "${BASH_REMATCH[11]}" )) $(( "${BASH_REMATCH[12]}" )) 25 | done < "$knownfolders" 26 | echo ")" 27 | } | gofmt > "zknownfolderids_windows.go" 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mksyscall.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 generate 6 | 7 | package windows 8 | 9 | //go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,race 6 | 7 | package windows 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,!race 6 | 7 | package windows 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/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 windows 6 | 7 | // Package windows 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 the OS-specific documentation for the current 10 | // system. If you want godoc to display syscall 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 windows // import "golang.org/x/sys/windows" 26 | 27 | import ( 28 | "syscall" 29 | ) 30 | 31 | // ByteSliceFromString returns a NUL-terminated slice of bytes 32 | // containing the text of s. If s contains a NUL byte at any 33 | // location, it returns (nil, syscall.EINVAL). 34 | func ByteSliceFromString(s string) ([]byte, error) { 35 | for i := 0; i < len(s); i++ { 36 | if s[i] == 0 { 37 | return nil, syscall.EINVAL 38 | } 39 | } 40 | a := make([]byte, len(s)+1) 41 | copy(a, s) 42 | return a, nil 43 | } 44 | 45 | // BytePtrFromString returns a pointer to a NUL-terminated array of 46 | // bytes containing the text of s. If s contains a NUL byte at any 47 | // location, it returns (nil, syscall.EINVAL). 48 | func BytePtrFromString(s string) (*byte, error) { 49 | a, err := ByteSliceFromString(s) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return &a[0], nil 54 | } 55 | 56 | // Single-word zero for use when we need a valid pointer to 0 bytes. 57 | // See mksyscall.pl. 58 | var _zero uintptr 59 | 60 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 61 | return int64(ts.Sec), int64(ts.Nsec) 62 | } 63 | 64 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 65 | return int64(tv.Sec), int64(tv.Usec) * 1000 66 | } 67 | 68 | func (ts *Timespec) Nano() int64 { 69 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 70 | } 71 | 72 | func (tv *Timeval) Nano() int64 { 73 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_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 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/go.mod: -------------------------------------------------------------------------------- 1 | module "gopkg.in/yaml.v2" 2 | 3 | require ( 4 | "gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405 5 | ) 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 22 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 23 | } 24 | emitter.buffer_pos = 0 25 | return true 26 | } 27 | --------------------------------------------------------------------------------