├── .github └── workflows │ └── push.yaml ├── Dockerfile ├── LICENSE ├── README.md ├── cmd └── proj │ └── main.go ├── cproj ├── cgo_helpers.go ├── cgo_helpers.h ├── const.go ├── cproj.go ├── doc.go └── types.go ├── go.mod ├── go.sum ├── proj ├── coord.go ├── coord_test.go ├── crs.go ├── crs_test.go ├── proj.yaml ├── transform.go ├── transform_test.go └── unsafe.go ├── tools.go └── vendor ├── github.com ├── davecgh │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ ├── bypass.go │ │ ├── bypasssafe.go │ │ ├── common.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── dump.go │ │ ├── format.go │ │ └── spew.go ├── golang │ └── geo │ │ ├── LICENSE │ │ ├── r1 │ │ ├── doc.go │ │ └── interval.go │ │ ├── r2 │ │ ├── doc.go │ │ └── rect.go │ │ ├── r3 │ │ ├── doc.go │ │ ├── precisevector.go │ │ └── vector.go │ │ ├── s1 │ │ ├── angle.go │ │ ├── chordangle.go │ │ ├── doc.go │ │ └── interval.go │ │ └── s2 │ │ ├── bits_go18.go │ │ ├── bits_go19.go │ │ ├── cap.go │ │ ├── cell.go │ │ ├── cell_index.go │ │ ├── cellid.go │ │ ├── cellunion.go │ │ ├── centroids.go │ │ ├── contains_point_query.go │ │ ├── contains_vertex_query.go │ │ ├── convex_hull_query.go │ │ ├── crossing_edge_query.go │ │ ├── distance_target.go │ │ ├── doc.go │ │ ├── edge_clipping.go │ │ ├── edge_crosser.go │ │ ├── edge_crossings.go │ │ ├── edge_distances.go │ │ ├── edge_query.go │ │ ├── edge_tessellator.go │ │ ├── encode.go │ │ ├── interleave.go │ │ ├── latlng.go │ │ ├── lexicon.go │ │ ├── loop.go │ │ ├── matrix3x3.go │ │ ├── max_distance_targets.go │ │ ├── metric.go │ │ ├── min_distance_targets.go │ │ ├── nthderivative.go │ │ ├── paddedcell.go │ │ ├── point.go │ │ ├── point_measures.go │ │ ├── point_vector.go │ │ ├── pointcompression.go │ │ ├── polygon.go │ │ ├── polyline.go │ │ ├── polyline_measures.go │ │ ├── predicates.go │ │ ├── projections.go │ │ ├── query_entry.go │ │ ├── query_options.go │ │ ├── rect.go │ │ ├── rect_bounder.go │ │ ├── region.go │ │ ├── regioncoverer.go │ │ ├── regionunion.go │ │ ├── shape.go │ │ ├── shapeindex.go │ │ ├── shapeutil.go │ │ ├── shapeutil_edge_iterator.go │ │ ├── stuv.go │ │ ├── util.go │ │ └── wedge_relations.go ├── pmezard │ └── go-difflib │ │ ├── LICENSE │ │ └── difflib │ │ └── difflib.go ├── remyoudompheng │ └── bigfft │ │ ├── LICENSE │ │ ├── README │ │ ├── arith_386.s │ │ ├── arith_amd64.s │ │ ├── arith_arm.s │ │ ├── arith_arm64.s │ │ ├── arith_decl.go │ │ ├── arith_mips64x.s │ │ ├── arith_mipsx.s │ │ ├── arith_ppc64x.s │ │ ├── arith_s390x.s │ │ ├── fermat.go │ │ ├── fft.go │ │ ├── go.mod │ │ └── scan.go ├── stretchr │ └── testify │ │ ├── LICENSE │ │ ├── assert │ │ ├── assertion_compare.go │ │ ├── assertion_format.go │ │ ├── assertion_format.go.tmpl │ │ ├── assertion_forward.go │ │ ├── assertion_forward.go.tmpl │ │ ├── assertion_order.go │ │ ├── assertions.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── forward_assertions.go │ │ └── http_assertions.go │ │ └── require │ │ ├── doc.go │ │ ├── forward_requirements.go │ │ ├── require.go │ │ ├── require.go.tmpl │ │ ├── require_forward.go │ │ ├── require_forward.go.tmpl │ │ └── requirements.go ├── tj │ └── go-spin │ │ ├── Readme.md │ │ ├── go-spin.gif │ │ └── spin.go └── xlab │ ├── c-for-go │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── generator │ │ ├── Makefile │ │ ├── gen_bindings.go │ │ ├── gen_callbacks.go │ │ ├── gen_common.go │ │ ├── gen_const.go │ │ ├── gen_declares.go │ │ ├── gen_files.go │ │ ├── gen_struct_helpers.go │ │ ├── gen_typedef.go │ │ ├── gen_union.go │ │ └── generator.go │ ├── go.mod │ ├── go.sum │ ├── main.go │ ├── parser │ │ ├── parser.go │ │ └── predefined.go │ ├── process.go │ └── translator │ │ ├── array_spec.go │ │ ├── ast_walker.go │ │ ├── helpers.go │ │ ├── model_declaration.go │ │ ├── model_enum.go │ │ ├── model_function.go │ │ ├── model_go_type.go │ │ ├── model_struct_union.go │ │ ├── model_type.go │ │ ├── rules.go │ │ ├── translator.go │ │ └── type_mapping.go │ └── pkgconfig │ └── pkg │ ├── pkg.go │ └── system_path.go ├── golang.org └── x │ ├── mod │ ├── LICENSE │ ├── PATENTS │ ├── internal │ │ └── lazyregexp │ │ │ └── lazyre.go │ ├── module │ │ ├── module.go │ │ └── pseudo.go │ └── semver │ │ └── semver.go │ ├── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── execabs │ │ └── execabs.go │ ├── tools │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── go │ │ └── ast │ │ │ └── astutil │ │ │ ├── enclosing.go │ │ │ ├── imports.go │ │ │ ├── rewrite.go │ │ │ └── util.go │ ├── imports │ │ └── forward.go │ └── internal │ │ ├── event │ │ ├── core │ │ │ ├── event.go │ │ │ ├── export.go │ │ │ └── fast.go │ │ ├── doc.go │ │ ├── event.go │ │ ├── keys │ │ │ ├── keys.go │ │ │ └── standard.go │ │ └── label │ │ │ └── label.go │ │ ├── fastwalk │ │ ├── fastwalk.go │ │ ├── fastwalk_dirent_fileno.go │ │ ├── fastwalk_dirent_ino.go │ │ ├── fastwalk_dirent_namlen_bsd.go │ │ ├── fastwalk_dirent_namlen_linux.go │ │ ├── fastwalk_portable.go │ │ └── fastwalk_unix.go │ │ ├── gocommand │ │ ├── invoke.go │ │ ├── vendor.go │ │ └── version.go │ │ ├── gopathwalk │ │ └── walk.go │ │ ├── imports │ │ ├── fix.go │ │ ├── imports.go │ │ ├── mod.go │ │ ├── mod_cache.go │ │ ├── sortimports.go │ │ └── zstdlib.go │ │ └── typeparams │ │ ├── common.go │ │ ├── enabled_go117.go │ │ ├── enabled_go118.go │ │ ├── normalize.go │ │ ├── termlist.go │ │ ├── typeparams_go117.go │ │ ├── typeparams_go118.go │ │ └── typeterm.go │ └── xerrors │ ├── LICENSE │ ├── PATENTS │ ├── README │ ├── adaptor.go │ ├── codereview.cfg │ ├── doc.go │ ├── errors.go │ ├── fmt.go │ ├── format.go │ ├── frame.go │ ├── go.mod │ ├── internal │ └── internal.go │ └── wrap.go ├── gopkg.in ├── yaml.v2 │ ├── .travis.yml │ ├── 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 └── yaml.v3 │ ├── LICENSE │ ├── 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 ├── modernc.org ├── cc │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── ast.go │ ├── ast2.go │ ├── cc.go │ ├── cpp.go │ ├── encoding.go │ ├── etc.go │ ├── global.go │ ├── go.mod │ ├── go.sum │ ├── kind_string.go │ ├── lexer.go │ ├── linkage_string.go │ ├── model.go │ ├── namespace_string.go │ ├── parser.go │ ├── parser.y │ ├── parser.yy │ ├── scanner.go │ ├── scanner.l │ ├── scope_string.go │ ├── trigraphs.go │ ├── trigraphs.l │ ├── ucn32.go │ ├── ucn64.go │ └── xerrors ├── golex │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ └── lex │ │ ├── Makefile │ │ ├── api.go │ │ ├── dfa │ │ ├── doc.go │ │ └── example.l ├── mathutil │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── Makefile │ ├── README │ ├── binarylog.go │ ├── bits.go │ ├── envelope.go │ ├── go.mod │ ├── go.sum │ ├── int.go │ ├── mathutil.go │ ├── nist-sts-2-1-1-report │ ├── permute.go │ ├── poly.go │ ├── primes.go │ ├── rat.go │ ├── rnd.go │ ├── sqr.go │ ├── sqr_std.go │ ├── tables.go │ └── test_deps.go ├── strutil │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── Makefile │ ├── README │ ├── go.mod │ ├── go.sum │ └── strutil.go └── xc │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── db.go │ ├── dict.go │ ├── global.go │ └── lexer.go └── modules.txt /.github/workflows/push.yaml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | branches: 5 | - "**" 6 | jobs: 7 | test: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - run: docker build --pull . 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:latest AS proj 2 | 3 | ARG PROJ_VERSION=8.2.0 4 | 5 | RUN apt-get -y update 6 | 7 | RUN apt-get install -y automake libtool sqlite3 libsqlite3-dev unzip libtiff-dev libcurl4-openssl-dev 8 | 9 | RUN git clone --branch ${PROJ_VERSION} https://github.com/OSGeo/PROJ.git 10 | 11 | WORKDIR /go/PROJ 12 | 13 | RUN ./autogen.sh 14 | 15 | RUN ./configure 16 | 17 | RUN make 18 | 19 | RUN make install 20 | 21 | RUN make check 22 | 23 | ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib 24 | 25 | 26 | FROM proj 27 | 28 | WORKDIR /usr/src/go-proj 29 | 30 | COPY . . 31 | 32 | RUN go test ./... -v -count 1 33 | -------------------------------------------------------------------------------- /cmd/proj/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/everystreet/go-proj/v8/proj" 11 | ) 12 | 13 | func main() { 14 | var source, target string 15 | to := false 16 | for _, arg := range os.Args[1:] { 17 | switch { 18 | case arg == "+to": 19 | to = true 20 | case to: 21 | target += " " + arg 22 | default: 23 | source += " " + arg 24 | } 25 | } 26 | 27 | source = strings.TrimSpace(source) 28 | target = strings.TrimSpace(target) 29 | 30 | for { 31 | r := bufio.NewReader(os.Stdin) 32 | str, _ := r.ReadString('\n') 33 | if str == "" { 34 | return 35 | } 36 | 37 | fields := strings.Fields(str) 38 | 39 | getFloat := func(i int) float64 { 40 | if len(fields) <= i { 41 | return 0 42 | } 43 | 44 | f, err := strconv.ParseFloat(fields[i], 10) 45 | if err != nil { 46 | os.Exit(1) 47 | } 48 | return f 49 | } 50 | 51 | coord := proj.XYZ{ 52 | X: getFloat(0), 53 | Y: getFloat(1), 54 | Z: getFloat(2), 55 | } 56 | 57 | if err := proj.CRSToCRS(source, target, func(pj proj.Projection) { 58 | proj.TransformForward(pj, &coord) 59 | }); err != nil { 60 | fmt.Fprintln(os.Stderr, err) 61 | os.Exit(1) 62 | } 63 | fmt.Printf("%.2f\t%.2f\t%.2f\n", coord.X, coord.Y, coord.Z) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /cproj/cgo_helpers.h: -------------------------------------------------------------------------------- 1 | // WARNING: This file has automatically been generated on Sat, 11 Dec 2021 12:35:48 UTC. 2 | // Code generated by https://git.io/c-for-go. DO NOT EDIT. 3 | 4 | #include "proj.h" 5 | #include 6 | #pragma once 7 | 8 | #define __CGOGEN 1 9 | 10 | -------------------------------------------------------------------------------- /cproj/const.go: -------------------------------------------------------------------------------- 1 | // WARNING: This file has automatically been generated on Sat, 11 Dec 2021 12:35:48 UTC. 2 | // Code generated by https://git.io/c-for-go. DO NOT EDIT. 3 | 4 | package cproj 5 | 6 | /* 7 | #cgo LDFLAGS: -lproj 8 | #include "proj.h" 9 | #include 10 | #include "cgo_helpers.h" 11 | */ 12 | import "C" 13 | 14 | // PJ_DIRECTION as declared in include/proj.h:580 15 | type PJ_DIRECTION int32 16 | 17 | // PJ_DIRECTION enumeration from include/proj.h:580 18 | const () 19 | -------------------------------------------------------------------------------- /cproj/doc.go: -------------------------------------------------------------------------------- 1 | // WARNING: This file has automatically been generated on Sat, 11 Dec 2021 12:35:48 UTC. 2 | // Code generated by https://git.io/c-for-go. DO NOT EDIT. 3 | 4 | /* 5 | Package cproj provides Go bindings for PROJ - a library for performing conversions 6 | between cartographic projections, maintained by the OSGeo organization. 7 | See https://proj.org for information. 8 | These bindings are generated by "c-for-go" (see https://c.for-go.com). 9 | */ 10 | package cproj 11 | -------------------------------------------------------------------------------- /cproj/types.go: -------------------------------------------------------------------------------- 1 | // WARNING: This file has automatically been generated on Sat, 11 Dec 2021 12:35:48 UTC. 2 | // Code generated by https://git.io/c-for-go. DO NOT EDIT. 3 | 4 | package cproj 5 | 6 | /* 7 | #cgo LDFLAGS: -lproj 8 | #include "proj.h" 9 | #include 10 | #include "cgo_helpers.h" 11 | */ 12 | import "C" 13 | import "unsafe" 14 | 15 | // PJ_COORD as declared in include/proj.h:197 16 | const sizeofPJ_COORD = unsafe.Sizeof(C.PJ_COORD{}) 17 | 18 | type PJ_COORD [sizeofPJ_COORD]byte 19 | 20 | // PJ_AREA as declared in include/proj.h:200 21 | type PJ_AREA C.PJ_AREA 22 | 23 | // PJ as declared in include/proj.h:221 24 | type PJ C.PJ 25 | 26 | // PJ_CONTEXT as declared in include/proj.h:359 27 | type PJ_CONTEXT C.PJ_CONTEXT 28 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/everystreet/go-proj/v8 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/davecgh/go-spew v1.1.1 // indirect 7 | github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 8 | github.com/kr/pretty v0.3.0 // indirect 9 | github.com/rogpeppe/go-internal v1.8.0 // indirect 10 | github.com/stretchr/testify v1.7.0 11 | github.com/xlab/c-for-go v0.0.0-20201223145653-3ba5db515dcb 12 | golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect 13 | golang.org/x/tools v0.1.8 // indirect 14 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 15 | gopkg.in/yaml.v2 v2.4.0 // indirect 16 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect 17 | modernc.org/cc v1.0.1 // indirect 18 | modernc.org/golex v1.0.1 // indirect 19 | modernc.org/mathutil v1.4.1 // indirect 20 | modernc.org/strutil v1.1.1 // indirect 21 | ) 22 | -------------------------------------------------------------------------------- /proj/coord_test.go: -------------------------------------------------------------------------------- 1 | package proj_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/everystreet/go-proj/v8/cproj" 7 | "github.com/everystreet/go-proj/v8/proj" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | func TestXY(t *testing.T) { 12 | coord := proj.XY{ 13 | X: 2.52, 14 | Y: 49.78, 15 | } 16 | 17 | var cCoord cproj.PJ_COORD 18 | coord.PutCoordinate(&cCoord) 19 | 20 | var newCoord proj.XY 21 | newCoord.FromCoordinate(cCoord) 22 | require.Equal(t, coord, newCoord) 23 | } 24 | 25 | func TestXYZ(t *testing.T) { 26 | coord := proj.XYZ{ 27 | X: 2.52, 28 | Y: 49.78, 29 | Z: 10.00, 30 | } 31 | 32 | var cCoord cproj.PJ_COORD 33 | coord.PutCoordinate(&cCoord) 34 | 35 | var newCoord proj.XYZ 36 | newCoord.FromCoordinate(cCoord) 37 | require.Equal(t, coord, newCoord) 38 | } 39 | 40 | func TestXYZT(t *testing.T) { 41 | coord := proj.XYZT{ 42 | XYZ: proj.XYZ{ 43 | X: 2.52, 44 | Y: 49.78, 45 | Z: 10.00, 46 | }, 47 | T: 120.60, 48 | } 49 | 50 | var cCoord cproj.PJ_COORD 51 | coord.PutCoordinate(&cCoord) 52 | 53 | var newCoord proj.XYZT 54 | newCoord.FromCoordinate(cCoord) 55 | require.Equal(t, coord, newCoord) 56 | } 57 | 58 | func TestLP(t *testing.T) { 59 | coord := proj.LP{ 60 | Lng: 0.78, 61 | Lat: 2.57, 62 | } 63 | 64 | var cCoord cproj.PJ_COORD 65 | coord.PutCoordinate(&cCoord) 66 | 67 | var newCoord proj.LP 68 | newCoord.FromCoordinate(cCoord) 69 | require.Equal(t, coord, newCoord) 70 | } 71 | 72 | func TestLPZ(t *testing.T) { 73 | coord := proj.LPZ{ 74 | LP: proj.LP{ 75 | Lng: 0.78, 76 | Lat: 2.57, 77 | }, 78 | Z: 10.00, 79 | } 80 | 81 | var cCoord cproj.PJ_COORD 82 | coord.PutCoordinate(&cCoord) 83 | 84 | var newCoord proj.LPZ 85 | newCoord.FromCoordinate(cCoord) 86 | require.Equal(t, coord, newCoord) 87 | } 88 | 89 | func TestLPZT(t *testing.T) { 90 | coord := proj.LPZT{ 91 | LPZ: proj.LPZ{ 92 | LP: proj.LP{ 93 | Lng: 0.78, 94 | Lat: 2.57, 95 | }, 96 | Z: 10.00, 97 | }, 98 | T: 120.60, 99 | } 100 | 101 | var cCoord cproj.PJ_COORD 102 | coord.PutCoordinate(&cCoord) 103 | 104 | var newCoord proj.LPZT 105 | newCoord.FromCoordinate(cCoord) 106 | require.Equal(t, coord, newCoord) 107 | } 108 | -------------------------------------------------------------------------------- /proj/crs.go: -------------------------------------------------------------------------------- 1 | package proj 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | 7 | "github.com/everystreet/go-proj/v8/cproj" 8 | "github.com/golang/geo/s2" 9 | ) 10 | 11 | // CRS is a coordinate reference system definition. 12 | type CRS string 13 | 14 | // Area returns the area of use for the CRS, or false if no such area is defined. 15 | func (c CRS) Area() (*Area, bool, error) { 16 | ctx := cproj.Context_create() 17 | defer cproj.Context_destroy(ctx) 18 | 19 | pj, err := c.instantiate(ctx) 20 | if err != nil { 21 | return nil, false, fmt.Errorf("invalid source '%v': %w", c, err) 22 | } 23 | defer cproj.Destroy(pj) 24 | 25 | var north, east, south, west float64 26 | if cproj.Get_area_of_use(ctx, pj, &west, &south, &east, &north, nil) != 1 { 27 | return nil, false, nil 28 | } 29 | 30 | if north == -1000 || east == -1000 || south == -1000 || west == -1000 { 31 | return nil, false, nil 32 | } 33 | 34 | return &Area{ 35 | BottomLeft: s2.LatLngFromDegrees(south, west), 36 | TopRight: s2.LatLngFromDegrees(north, east), 37 | }, true, nil 38 | } 39 | 40 | // Area of use for a particular CRS. 41 | type Area struct { 42 | BottomLeft s2.LatLng 43 | TopRight s2.LatLng 44 | } 45 | 46 | // String returns the lower-cased CRS definition. 47 | // If the definition is a proj-string, the "+type=crs" option if appended if not present. 48 | func (c CRS) String() string { 49 | str := strings.ToLower(string(c)) 50 | if strings.HasPrefix(str, "proj=") || strings.HasPrefix(str, "+proj=") || 51 | strings.HasPrefix(str, "+init=") || strings.HasPrefix(str, "+title=") && 52 | !strings.Contains(str, "type=crs") { 53 | str += " +type=crs" 54 | } 55 | return str 56 | } 57 | 58 | func (c CRS) instantiate(ctx *cproj.PJ_CONTEXT) (*cproj.PJ, error) { 59 | pj := cproj.Create(ctx, c.String()) 60 | if pj == nil { 61 | return nil, fmt.Errorf("failed to create CRS") 62 | } 63 | return pj, nil 64 | } 65 | -------------------------------------------------------------------------------- /proj/crs_test.go: -------------------------------------------------------------------------------- 1 | package proj_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/everystreet/go-proj/v8/proj" 7 | "github.com/golang/geo/s2" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | func TestCRSString(t *testing.T) { 12 | crs := proj.CRS("proj=merc") 13 | require.Equal(t, "proj=merc +type=crs", crs.String()) 14 | } 15 | 16 | func TestCRSArea(t *testing.T) { 17 | crs := proj.CRS("EPSG:3857") 18 | 19 | area, ok, err := crs.Area() 20 | require.NoError(t, err) 21 | require.True(t, ok) 22 | require.Equal(t, proj.Area{ 23 | BottomLeft: s2.LatLngFromDegrees(-85.06, -180), 24 | TopRight: s2.LatLngFromDegrees(85.06, 180), 25 | }, *area) 26 | } 27 | -------------------------------------------------------------------------------- /proj/proj.yaml: -------------------------------------------------------------------------------- 1 | GENERATOR: 2 | PackageName: cproj 3 | PackageDescription: "Package cproj provides Go bindings for PROJ - a library for performing conversions\nbetween cartographic projections, maintained by the OSGeo organization.\nSee https://proj.org for information.\nThese bindings are generated by \"c-for-go\" (see https://c.for-go.com)." 4 | FlagGroups: 5 | - {name: LDFLAGS, flags: [-lproj]} 6 | Includes: ["proj.h"] 7 | Options: 8 | SafeStrings: true 9 | PARSER: 10 | IncludePaths: ["/usr/local/include"] 11 | SourcesPaths: ["proj.h"] 12 | TRANSLATOR: 13 | ConstRules: 14 | defines: eval 15 | enum: eval 16 | Rules: 17 | type: 18 | - {action: accept, from: "^PJ$"} 19 | - {action: accept, from: "^PJ_AREA$"} 20 | - {action: accept, from: "^PJ_CONTEXT$"} 21 | - {action: accept, from: "^PJ_COORD$"} 22 | function: 23 | - {transform: lower} 24 | - {action: accept, from: "^proj_context_create$"} 25 | - {action: accept, from: "^proj_context_destroy$"} 26 | - {action: accept, from: "^proj_create$"} 27 | - {action: accept, from: "^proj_create_crs_to_crs_from_pj$"} 28 | - {action: accept, from: "^proj_destroy$"} 29 | - {action: accept, from: "^proj_get_area_of_use$"} 30 | - {action: accept, from: "^proj_normalize_for_visualization$"} 31 | - {action: accept, from: "^proj_trans$"} 32 | - {action: replace, from: "^proj_"} 33 | - {transform: export} 34 | PtrTips: 35 | function: 36 | - {target: "^proj_context_destroy$", tips: [sref]} 37 | - {target: "^proj_create$", tips: [sref, 0]} 38 | - {target: "^proj_create_crs_to_crs_from_pj$", tips: [sref, sref, sref, sref, 0]} 39 | - {target: "^proj_destroy$", tips: [sref]} 40 | - {target: "^proj_get_area_of_use$", tips: [sref, sref, sref, sref, sref, sref, 0]} 41 | - {target: "^proj_normalize_for_visualization$", tips: [sref, sref]} 42 | - {target: "^proj_trans$", tips: [sref, 0, 0]} 43 | -------------------------------------------------------------------------------- /proj/transform.go: -------------------------------------------------------------------------------- 1 | package proj 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/everystreet/go-proj/v8/cproj" 7 | ) 8 | 9 | // Projection context. 10 | type Projection *cproj.PJ 11 | 12 | // CRSToCRS facilitates transformations between two coordinate reference systems. 13 | func CRSToCRS(source, target string, transform func(Projection)) error { 14 | ctx := cproj.Context_create() 15 | defer cproj.Context_destroy(ctx) 16 | 17 | src, err := CRS(source).instantiate(ctx) 18 | if err != nil { 19 | return fmt.Errorf("invalid source '%v': %w", source, err) 20 | } 21 | defer cproj.Destroy(src) 22 | 23 | dst, err := CRS(target).instantiate(ctx) 24 | if err != nil { 25 | return fmt.Errorf("invalud target '%v': %w", target, err) 26 | } 27 | defer cproj.Destroy(dst) 28 | 29 | pj := cproj.Create_crs_to_crs_from_pj(ctx, src, dst, nil, nil) 30 | if pj == nil { 31 | return fmt.Errorf("invalid source or target CRS") 32 | } 33 | defer cproj.Destroy(pj) 34 | 35 | normalized := cproj.Normalize_for_visualization(ctx, pj) 36 | if normalized == nil { 37 | return fmt.Errorf("failed to normalize") 38 | } 39 | defer cproj.Destroy(normalized) 40 | 41 | transform(normalized) 42 | return nil 43 | } 44 | 45 | // Coordinate wraps functions that allow communication with the cproj package. 46 | type Coordinate interface { 47 | PutCoordinate(*cproj.PJ_COORD) 48 | FromCoordinate(cproj.PJ_COORD) 49 | } 50 | 51 | // TransformForward performs a forward transformation of the supplied coordinate. 52 | func TransformForward(pj Projection, coord Coordinate) { 53 | transform(pj, forward, coord) 54 | } 55 | 56 | // TransformInverse performs an inverse transformation of the supplied coordinate. 57 | func TransformInverse(pj Projection, coord Coordinate) { 58 | transform(pj, inverse, coord) 59 | } 60 | 61 | const ( 62 | forward cproj.PJ_DIRECTION = 1 63 | inverse cproj.PJ_DIRECTION = -1 64 | ) 65 | 66 | func transform(pj *cproj.PJ, direction cproj.PJ_DIRECTION, coord Coordinate) { 67 | var in cproj.PJ_COORD 68 | coord.PutCoordinate(&in) 69 | 70 | out := cproj.Trans(pj, direction, in) 71 | coord.FromCoordinate(out) 72 | } 73 | -------------------------------------------------------------------------------- /proj/transform_test.go: -------------------------------------------------------------------------------- 1 | package proj_test 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/everystreet/go-proj/v8/proj" 7 | ) 8 | 9 | func ExampleCRSToCRS() { 10 | coord := proj.XYZ{ 11 | X: 2, 12 | Y: 49, 13 | Z: 10, 14 | } 15 | 16 | if err := proj.CRSToCRS("+proj=latlong", "EPSG:3857", func(pj proj.Projection) { 17 | proj.TransformForward(pj, &coord) 18 | // transform more coordinates 19 | }); err != nil { 20 | panic(err) 21 | } 22 | 23 | fmt.Printf("%.2f %.2f %.2f", coord.X, coord.Y, coord.Z) 24 | // Output: 222638.98 6274861.39 10.00 25 | } 26 | -------------------------------------------------------------------------------- /proj/unsafe.go: -------------------------------------------------------------------------------- 1 | package proj 2 | 3 | import "C" 4 | import ( 5 | "unsafe" 6 | ) 7 | 8 | func float64ToDoubleBytes(f float64) [8]byte { 9 | d := C.double(f) 10 | return *(*[8]byte)(unsafe.Pointer(&d)) 11 | } 12 | 13 | func doubleBytesToFloat64(d []byte) float64 { 14 | var arr [8]byte 15 | copy(arr[:], d[:8]) 16 | return float64(*(*C.double)(unsafe.Pointer(uintptr(unsafe.Pointer(&arr))))) 17 | } 18 | -------------------------------------------------------------------------------- /tools.go: -------------------------------------------------------------------------------- 1 | // +build tools 2 | 3 | package tools 4 | 5 | import ( 6 | _ "github.com/xlab/c-for-go" 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2016 Dave Collins 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe !go1.4 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/r1/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /* 16 | Package r1 implements types and functions for working with geometry in ℝ¹. 17 | 18 | See ../s2 for a more detailed overview. 19 | */ 20 | package r1 21 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/r2/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /* 16 | Package r2 implements types and functions for working with geometry in ℝ². 17 | 18 | See package s2 for a more detailed overview. 19 | */ 20 | package r2 21 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/r3/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /* 16 | Package r3 implements types and functions for working with geometry in ℝ³. 17 | 18 | See ../s2 for a more detailed overview. 19 | */ 20 | package r3 21 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s1/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /* 16 | Package s1 implements types and functions for working with geometry in S¹ (circular geometry). 17 | 18 | See ../s2 for a more detailed overview. 19 | */ 20 | package s1 21 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/bits_go18.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google Inc. All rights reserved. 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 | // +build !go1.9 16 | 17 | package s2 18 | 19 | // This file is for the bit manipulation code pre-Go 1.9. 20 | 21 | // findMSBSetNonZero64 returns the index (between 0 and 63) of the most 22 | // significant set bit. Passing zero to this function returns zero. 23 | func findMSBSetNonZero64(x uint64) int { 24 | val := []uint64{0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000, 0xFFFFFFFF00000000} 25 | shift := []uint64{1, 2, 4, 8, 16, 32} 26 | var msbPos uint64 27 | for i := 5; i >= 0; i-- { 28 | if x&val[i] != 0 { 29 | x >>= shift[i] 30 | msbPos |= shift[i] 31 | } 32 | } 33 | return int(msbPos) 34 | } 35 | 36 | const deBruijn64 = 0x03f79d71b4ca8b09 37 | const digitMask = uint64(1<<64 - 1) 38 | 39 | var deBruijn64Lookup = []byte{ 40 | 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 41 | 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 42 | 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, 43 | 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6, 44 | } 45 | 46 | // findLSBSetNonZero64 returns the index (between 0 and 63) of the least 47 | // significant set bit. Passing zero to this function returns zero. 48 | // 49 | // This code comes from trailingZeroBits in https://golang.org/src/math/big/nat.go 50 | // which references (Knuth, volume 4, section 7.3.1). 51 | func findLSBSetNonZero64(x uint64) int { 52 | return int(deBruijn64Lookup[((x&-x)*(deBruijn64&digitMask))>>58]) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/bits_go19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google Inc. All rights reserved. 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 | // +build go1.9 16 | 17 | package s2 18 | 19 | // This file is for the bit manipulation code post-Go 1.9. 20 | 21 | import "math/bits" 22 | 23 | // findMSBSetNonZero64 returns the index (between 0 and 63) of the most 24 | // significant set bit. Passing zero to this function return zero. 25 | func findMSBSetNonZero64(x uint64) int { 26 | if x == 0 { 27 | return 0 28 | } 29 | return 63 - bits.LeadingZeros64(x) 30 | } 31 | 32 | // findLSBSetNonZero64 returns the index (between 0 and 63) of the least 33 | // significant set bit. Passing zero to this function return zero. 34 | func findLSBSetNonZero64(x uint64) int { 35 | if x == 0 { 36 | return 0 37 | } 38 | return bits.TrailingZeros64(x) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/contains_vertex_query.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. All rights reserved. 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 s2 16 | 17 | // ContainsVertexQuery is used to track the edges entering and leaving the 18 | // given vertex of a Polygon in order to be able to determine if the point is 19 | // contained by the Polygon. 20 | // 21 | // Point containment is defined according to the semi-open boundary model 22 | // which means that if several polygons tile the region around a vertex, 23 | // then exactly one of those polygons contains that vertex. 24 | type ContainsVertexQuery struct { 25 | target Point 26 | edgeMap map[Point]int 27 | } 28 | 29 | // NewContainsVertexQuery returns a new query for the given vertex whose 30 | // containment will be determined. 31 | func NewContainsVertexQuery(target Point) *ContainsVertexQuery { 32 | return &ContainsVertexQuery{ 33 | target: target, 34 | edgeMap: make(map[Point]int), 35 | } 36 | } 37 | 38 | // AddEdge adds the edge between target and v with the given direction. 39 | // (+1 = outgoing, -1 = incoming, 0 = degenerate). 40 | func (q *ContainsVertexQuery) AddEdge(v Point, direction int) { 41 | q.edgeMap[v] += direction 42 | } 43 | 44 | // ContainsVertex reports a +1 if the target vertex is contained, -1 if it is 45 | // not contained, and 0 if the incident edges consisted of matched sibling pairs. 46 | func (q *ContainsVertexQuery) ContainsVertex() int { 47 | // Find the unmatched edge that is immediately clockwise from Ortho(P). 48 | referenceDir := Point{q.target.Ortho()} 49 | 50 | bestPoint := referenceDir 51 | bestDir := 0 52 | 53 | for k, v := range q.edgeMap { 54 | if v == 0 { 55 | continue // This is a "matched" edge. 56 | } 57 | if OrderedCCW(referenceDir, bestPoint, k, q.target) { 58 | bestPoint = k 59 | bestDir = v 60 | } 61 | } 62 | return bestDir 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /* 16 | Package s2 is a library for working with geometry in S² (spherical geometry). 17 | 18 | Its related packages, parallel to this one, are s1 (operates on S¹), r1 (operates on ℝ¹), 19 | r2 (operates on ℝ²) and r3 (operates on ℝ³). 20 | 21 | This package provides types and functions for the S2 cell hierarchy and coordinate systems. 22 | The S2 cell hierarchy is a hierarchical decomposition of the surface of a unit sphere (S²) 23 | into ``cells''; it is highly efficient, scales from continental size to under 1 cm² 24 | and preserves spatial locality (nearby cells have close IDs). 25 | 26 | More information including an in-depth introduction to S2 can be found on the 27 | S2 website https://s2geometry.io/ 28 | */ 29 | package s2 30 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/nthderivative.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. All rights reserved. 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 s2 16 | 17 | // nthDerivativeCoder provides Nth Derivative Coding. 18 | // (In signal processing disciplines, this is known as N-th Delta Coding.) 19 | // 20 | // Good for varint coding integer sequences with polynomial trends. 21 | // 22 | // Instead of coding a sequence of values directly, code its nth-order discrete 23 | // derivative. Overflow in integer addition and subtraction makes this a 24 | // lossless transform. 25 | // 26 | // constant linear quadratic 27 | // trend trend trend 28 | // / \ / \ / \_ 29 | // input |0 0 0 0 1 2 3 4 9 16 25 36 30 | // 0th derivative(identity) |0 0 0 0 1 2 3 4 9 16 25 36 31 | // 1st derivative(delta coding) | 0 0 0 1 1 1 1 5 7 9 11 32 | // 2nd derivative(linear prediction) | 0 0 1 0 0 0 4 2 2 2 33 | // ------------------------------------- 34 | // 0 1 2 3 4 5 6 7 8 9 10 11 35 | // n in sequence 36 | // 37 | // Higher-order codings can break even or be detrimental on other sequences. 38 | // 39 | // random oscillating 40 | // / \ / \_ 41 | // input |5 9 6 1 8 8 2 -2 4 -4 6 -6 42 | // 0th derivative(identity) |5 9 6 1 8 8 2 -2 4 -4 6 -6 43 | // 1st derivative(delta coding) | 4 -3 -5 7 0 -6 -4 6 -8 10 -12 44 | // 2nd derivative(linear prediction) | -7 -2 12 -7 -6 2 10 -14 18 -22 45 | // --------------------------------------- 46 | // 0 1 2 3 4 5 6 7 8 9 10 11 47 | // n in sequence 48 | // 49 | // Note that the nth derivative isn't available until sequence item n. Earlier 50 | // values are coded at lower order. For the above table, read 5 4 -7 -2 12 ... 51 | type nthDerivativeCoder struct { 52 | n, m int 53 | memory [10]int32 54 | } 55 | 56 | // newNthDerivativeCoder returns a new coder, where n is the derivative order of the encoder (the N in NthDerivative). 57 | // n must be within [0,10]. 58 | func newNthDerivativeCoder(n int) *nthDerivativeCoder { 59 | c := &nthDerivativeCoder{n: n} 60 | if n < 0 || n > len(c.memory) { 61 | panic("unsupported n. Must be within [0,10].") 62 | } 63 | return c 64 | } 65 | 66 | func (c *nthDerivativeCoder) encode(k int32) int32 { 67 | for i := 0; i < c.m; i++ { 68 | delta := k - c.memory[i] 69 | c.memory[i] = k 70 | k = delta 71 | } 72 | if c.m < c.n { 73 | c.memory[c.m] = k 74 | c.m++ 75 | } 76 | return k 77 | } 78 | 79 | func (c *nthDerivativeCoder) decode(k int32) int32 { 80 | if c.m < c.n { 81 | c.m++ 82 | } 83 | for i := c.m - 1; i >= 0; i-- { 84 | c.memory[i] += k 85 | k = c.memory[i] 86 | } 87 | return k 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/point_vector.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. All rights reserved. 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 s2 16 | 17 | // Shape interface enforcement 18 | var ( 19 | _ Shape = (*PointVector)(nil) 20 | ) 21 | 22 | // PointVector is a Shape representing a set of Points. Each point 23 | // is represented as a degenerate edge with the same starting and ending 24 | // vertices. 25 | // 26 | // This type is useful for adding a collection of points to an ShapeIndex. 27 | // 28 | // Its methods are on *PointVector due to implementation details of ShapeIndex. 29 | type PointVector []Point 30 | 31 | func (p *PointVector) NumEdges() int { return len(*p) } 32 | func (p *PointVector) Edge(i int) Edge { return Edge{(*p)[i], (*p)[i]} } 33 | func (p *PointVector) ReferencePoint() ReferencePoint { return OriginReferencePoint(false) } 34 | func (p *PointVector) NumChains() int { return len(*p) } 35 | func (p *PointVector) Chain(i int) Chain { return Chain{i, 1} } 36 | func (p *PointVector) ChainEdge(i, j int) Edge { return Edge{(*p)[i], (*p)[j]} } 37 | func (p *PointVector) ChainPosition(e int) ChainPosition { return ChainPosition{e, 0} } 38 | func (p *PointVector) Dimension() int { return 0 } 39 | func (p *PointVector) IsEmpty() bool { return defaultShapeIsEmpty(p) } 40 | func (p *PointVector) IsFull() bool { return defaultShapeIsFull(p) } 41 | func (p *PointVector) typeTag() typeTag { return typeTagPointVector } 42 | func (p *PointVector) privateInterface() {} 43 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/polyline_measures.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google Inc. All rights reserved. 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 s2 16 | 17 | // This file defines various measures for polylines on the sphere. These are 18 | // low-level methods that work directly with arrays of Points. They are used to 19 | // implement the methods in various other measures files. 20 | 21 | import ( 22 | "github.com/golang/geo/r3" 23 | "github.com/golang/geo/s1" 24 | ) 25 | 26 | // polylineLength returns the length of the given Polyline. 27 | // It returns 0 for polylines with fewer than two vertices. 28 | func polylineLength(p []Point) s1.Angle { 29 | var length s1.Angle 30 | 31 | for i := 1; i < len(p); i++ { 32 | length += p[i-1].Distance(p[i]) 33 | } 34 | return length 35 | } 36 | 37 | // polylineCentroid returns the true centroid of the polyline multiplied by the 38 | // length of the polyline. The result is not unit length, so you may wish to 39 | // normalize it. 40 | // 41 | // Scaling by the Polyline length makes it easy to compute the centroid 42 | // of several Polylines (by simply adding up their centroids). 43 | // 44 | // Note that for degenerate Polylines (e.g., AA) this returns Point(0, 0, 0). 45 | // (This answer is correct; the result of this function is a line integral over 46 | // the polyline, whose value is always zero if the polyline is degenerate.) 47 | func polylineCentroid(p []Point) Point { 48 | var centroid r3.Vector 49 | for i := 1; i < len(p); i++ { 50 | centroid = centroid.Add(EdgeTrueCentroid(p[i-1], p[i]).Vector) 51 | } 52 | return Point{centroid} 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/query_entry.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google Inc. All rights reserved. 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 s2 16 | 17 | import "container/heap" 18 | 19 | // A queryQueueEntry stores CellIDs and distance from a target. It is used by the 20 | // different S2 Query types to efficiently build their internal priority queue 21 | // in the optimized algorithm implementations. 22 | type queryQueueEntry struct { 23 | // A lower bound on the distance from the target to ID. This is the key 24 | // of the priority queue. 25 | distance distance 26 | 27 | // The cell being queued. 28 | id CellID 29 | 30 | // If the CellID belongs to a ShapeIndex, this field stores the 31 | // corresponding ShapeIndexCell. Otherwise ID is a proper ancestor of 32 | // one or more ShapeIndexCells and this field stores is nil. 33 | indexCell *ShapeIndexCell 34 | } 35 | 36 | // queryQueue is used by the optimized algorithm to maintain a priority queue of 37 | // unprocessed CellIDs, sorted in increasing order of distance from the target. 38 | type queryQueue struct { 39 | queue queryPQ 40 | } 41 | 42 | // newQueryQueue returns a new initialized queryQueue. 43 | func newQueryQueue() *queryQueue { 44 | q := &queryQueue{ 45 | queue: make(queryPQ, 0), 46 | } 47 | heap.Init(&q.queue) 48 | return q 49 | } 50 | 51 | // push adds the given entry to the top of this queue. 52 | func (q *queryQueue) push(e *queryQueueEntry) { 53 | heap.Push(&q.queue, e) 54 | } 55 | 56 | // pop returns the top element of this queue. 57 | func (q *queryQueue) pop() *queryQueueEntry { 58 | return heap.Pop(&q.queue).(*queryQueueEntry) 59 | } 60 | 61 | func (q *queryQueue) size() int { 62 | return q.queue.Len() 63 | } 64 | 65 | func (q *queryQueue) reset() { 66 | q.queue = q.queue[:0] 67 | } 68 | 69 | // queryPQ is a priority queue that implements the heap interface. 70 | type queryPQ []*queryQueueEntry 71 | 72 | func (q queryPQ) Len() int { return len(q) } 73 | func (q queryPQ) Less(i, j int) bool { 74 | return q[i].distance.less(q[j].distance) 75 | } 76 | 77 | // Swap swaps the two entries. 78 | func (q queryPQ) Swap(i, j int) { 79 | q[i], q[j] = q[j], q[i] 80 | } 81 | 82 | // Push adds the given entry to the queue. 83 | func (q *queryPQ) Push(x interface{}) { 84 | item := x.(*queryQueueEntry) 85 | *q = append(*q, item) 86 | } 87 | 88 | // Pop returns the top element of the queue. 89 | func (q *queryPQ) Pop() interface{} { 90 | item := (*q)[len(*q)-1] 91 | *q = (*q)[:len(*q)-1] 92 | return item 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/region.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 s2 16 | 17 | // A Region represents a two-dimensional region on the unit sphere. 18 | // 19 | // The purpose of this interface is to allow complex regions to be 20 | // approximated as simpler regions. The interface is restricted to methods 21 | // that are useful for computing approximations. 22 | type Region interface { 23 | // CapBound returns a bounding spherical cap. This is not guaranteed to be exact. 24 | CapBound() Cap 25 | 26 | // RectBound returns a bounding latitude-longitude rectangle that contains 27 | // the region. The bounds are not guaranteed to be tight. 28 | RectBound() Rect 29 | 30 | // ContainsCell reports whether the region completely contains the given region. 31 | // It returns false if containment could not be determined. 32 | ContainsCell(c Cell) bool 33 | 34 | // IntersectsCell reports whether the region intersects the given cell or 35 | // if intersection could not be determined. It returns false if the region 36 | // does not intersect. 37 | IntersectsCell(c Cell) bool 38 | 39 | // ContainsPoint reports whether the region contains the given point or not. 40 | // The point should be unit length, although some implementations may relax 41 | // this restriction. 42 | ContainsPoint(p Point) bool 43 | 44 | // CellUnionBound returns a small collection of CellIDs whose union covers 45 | // the region. The cells are not sorted, may have redundancies (such as cells 46 | // that contain other cells), and may cover much more area than necessary. 47 | // 48 | // This method is not intended for direct use by client code. Clients 49 | // should typically use Covering, which has options to control the size and 50 | // accuracy of the covering. Alternatively, if you want a fast covering and 51 | // don't care about accuracy, consider calling FastCovering (which returns a 52 | // cleaned-up version of the covering computed by this method). 53 | // 54 | // CellUnionBound implementations should attempt to return a small 55 | // covering (ideally 4 cells or fewer) that covers the region and can be 56 | // computed quickly. The result is used by RegionCoverer as a starting 57 | // point for further refinement. 58 | CellUnionBound() []CellID 59 | } 60 | 61 | // Enforce Region interface satisfaction. 62 | var ( 63 | _ Region = Cap{} 64 | _ Region = Cell{} 65 | _ Region = (*CellUnion)(nil) 66 | _ Region = (*Loop)(nil) 67 | _ Region = Point{} 68 | _ Region = (*Polygon)(nil) 69 | _ Region = (*Polyline)(nil) 70 | _ Region = Rect{} 71 | ) 72 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/regionunion.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google Inc. All rights reserved. 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 s2 16 | 17 | // A RegionUnion represents a union of possibly overlapping regions. 18 | // It is convenient for computing a covering of a set of regions. 19 | type RegionUnion []Region 20 | 21 | // CapBound returns a bounding cap for this RegionUnion. 22 | func (ru RegionUnion) CapBound() Cap { return ru.RectBound().CapBound() } 23 | 24 | // RectBound returns a bounding latitude-longitude rectangle for this RegionUnion. 25 | func (ru RegionUnion) RectBound() Rect { 26 | ret := EmptyRect() 27 | for _, reg := range ru { 28 | ret = ret.Union(reg.RectBound()) 29 | } 30 | return ret 31 | } 32 | 33 | // ContainsCell reports whether the given Cell is contained by this RegionUnion. 34 | func (ru RegionUnion) ContainsCell(c Cell) bool { 35 | for _, reg := range ru { 36 | if reg.ContainsCell(c) { 37 | return true 38 | } 39 | } 40 | return false 41 | } 42 | 43 | // IntersectsCell reports whether this RegionUnion intersects the given cell. 44 | func (ru RegionUnion) IntersectsCell(c Cell) bool { 45 | for _, reg := range ru { 46 | if reg.IntersectsCell(c) { 47 | return true 48 | } 49 | } 50 | return false 51 | } 52 | 53 | // ContainsPoint reports whether this RegionUnion contains the Point. 54 | func (ru RegionUnion) ContainsPoint(p Point) bool { 55 | for _, reg := range ru { 56 | if reg.ContainsPoint(p) { 57 | return true 58 | } 59 | } 60 | return false 61 | } 62 | 63 | // CellUnionBound computes a covering of the RegionUnion. 64 | func (ru RegionUnion) CellUnionBound() []CellID { 65 | return ru.CapBound().CellUnionBound() 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/shapeutil_edge_iterator.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google Inc. All rights reserved. 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 s2 16 | 17 | // EdgeIterator is an iterator that advances through all edges in an ShapeIndex. 18 | // This is different to the ShapeIndexIterator, which advances through the cells in the 19 | // ShapeIndex. 20 | type EdgeIterator struct { 21 | index *ShapeIndex 22 | shapeID int32 23 | numEdges int32 24 | edgeID int32 25 | } 26 | 27 | // NewEdgeIterator creates a new edge iterator for the given index. 28 | func NewEdgeIterator(index *ShapeIndex) *EdgeIterator { 29 | e := &EdgeIterator{ 30 | index: index, 31 | shapeID: -1, 32 | edgeID: -1, 33 | } 34 | 35 | e.Next() 36 | return e 37 | } 38 | 39 | // ShapeID returns the current shape ID. 40 | func (e *EdgeIterator) ShapeID() int32 { return e.shapeID } 41 | 42 | // EdgeID returns the current edge ID. 43 | func (e *EdgeIterator) EdgeID() int32 { return e.edgeID } 44 | 45 | // ShapeEdgeID returns the current (shapeID, edgeID). 46 | func (e *EdgeIterator) ShapeEdgeID() ShapeEdgeID { return ShapeEdgeID{e.shapeID, e.edgeID} } 47 | 48 | // Edge returns the current edge. 49 | func (e *EdgeIterator) Edge() Edge { 50 | return e.index.Shape(e.shapeID).Edge(int(e.edgeID)) 51 | } 52 | 53 | // Done reports if the iterator is positioned at or after the last index edge. 54 | func (e *EdgeIterator) Done() bool { return e.shapeID >= int32(len(e.index.shapes)) } 55 | 56 | // Next positions the iterator at the next index edge. 57 | func (e *EdgeIterator) Next() { 58 | e.edgeID++ 59 | for ; e.edgeID >= e.numEdges; e.edgeID++ { 60 | e.shapeID++ 61 | if e.shapeID >= int32(len(e.index.shapes)) { 62 | break 63 | } 64 | shape := e.index.Shape(e.shapeID) 65 | if shape == nil { 66 | e.numEdges = 0 67 | } else { 68 | e.numEdges = int32(shape.NumEdges()) 69 | } 70 | e.edgeID = -1 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/golang/geo/s2/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. All rights reserved. 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 s2 16 | 17 | import "github.com/golang/geo/s1" 18 | 19 | // roundAngle returns the value rounded to nearest as an int32. 20 | // This does not match C++ exactly for the case of x.5. 21 | func roundAngle(val s1.Angle) int32 { 22 | if val < 0 { 23 | return int32(val - 0.5) 24 | } 25 | return int32(val + 0.5) 26 | } 27 | 28 | // minAngle returns the smallest of the given values. 29 | func minAngle(x s1.Angle, others ...s1.Angle) s1.Angle { 30 | min := x 31 | for _, y := range others { 32 | if y < min { 33 | min = y 34 | } 35 | } 36 | return min 37 | } 38 | 39 | // maxAngle returns the largest of the given values. 40 | func maxAngle(x s1.Angle, others ...s1.Angle) s1.Angle { 41 | max := x 42 | for _, y := range others { 43 | if y > max { 44 | max = y 45 | } 46 | } 47 | return max 48 | } 49 | 50 | // minChordAngle returns the smallest of the given values. 51 | func minChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle { 52 | min := x 53 | for _, y := range others { 54 | if y < min { 55 | min = y 56 | } 57 | } 58 | return min 59 | } 60 | 61 | // maxChordAngle returns the largest of the given values. 62 | func maxChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle { 63 | max := x 64 | for _, y := range others { 65 | if y > max { 66 | max = y 67 | } 68 | } 69 | return max 70 | } 71 | 72 | // minFloat64 returns the smallest of the given values. 73 | func minFloat64(x float64, others ...float64) float64 { 74 | min := x 75 | for _, y := range others { 76 | if y < min { 77 | min = y 78 | } 79 | } 80 | return min 81 | } 82 | 83 | // maxFloat64 returns the largest of the given values. 84 | func maxFloat64(x float64, others ...float64) float64 { 85 | max := x 86 | for _, y := range others { 87 | if y > max { 88 | max = y 89 | } 90 | } 91 | return max 92 | } 93 | 94 | // minInt returns the smallest of the given values. 95 | func minInt(x int, others ...int) int { 96 | min := x 97 | for _, y := range others { 98 | if y < min { 99 | min = y 100 | } 101 | } 102 | return min 103 | } 104 | 105 | // maxInt returns the largest of the given values. 106 | func maxInt(x int, others ...int) int { 107 | max := x 108 | for _, y := range others { 109 | if y > max { 110 | max = y 111 | } 112 | } 113 | return max 114 | } 115 | 116 | // clampInt returns the number closest to x within the range min..max. 117 | func clampInt(x, min, max int) int { 118 | if x < min { 119 | return min 120 | } 121 | if x > max { 122 | return max 123 | } 124 | return x 125 | } 126 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | 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/remyoudompheng/bigfft/LICENSE: -------------------------------------------------------------------------------- 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/remyoudompheng/bigfft/README: -------------------------------------------------------------------------------- 1 | Benchmarking math/big vs. bigfft 2 | 3 | Number size old ns/op new ns/op delta 4 | 1kb 1599 1640 +2.56% 5 | 10kb 61533 62170 +1.04% 6 | 50kb 833693 831051 -0.32% 7 | 100kb 2567995 2693864 +4.90% 8 | 1Mb 105237800 28446400 -72.97% 9 | 5Mb 1272947000 168554600 -86.76% 10 | 10Mb 3834354000 405120200 -89.43% 11 | 20Mb 11514488000 845081600 -92.66% 12 | 50Mb 49199945000 2893950000 -94.12% 13 | 100Mb 147599836000 5921594000 -95.99% 14 | 15 | Benchmarking GMP vs bigfft 16 | 17 | Number size GMP ns/op Go ns/op delta 18 | 1kb 536 1500 +179.85% 19 | 10kb 26669 50777 +90.40% 20 | 50kb 252270 658534 +161.04% 21 | 100kb 686813 2127534 +209.77% 22 | 1Mb 12100000 22391830 +85.06% 23 | 5Mb 111731843 133550600 +19.53% 24 | 10Mb 212314000 318595800 +50.06% 25 | 20Mb 490196000 671512800 +36.99% 26 | 50Mb 1280000000 2451476000 +91.52% 27 | 100Mb 2673000000 5228991000 +95.62% 28 | 29 | Benchmarks were run on a Core 2 Quad Q8200 (2.33GHz). 30 | FFT is enabled when input numbers are over 200kbits. 31 | 32 | Scanning large decimal number from strings. 33 | (math/big [n^2 complexity] vs bigfft [n^1.6 complexity], Core i5-4590) 34 | 35 | Digits old ns/op new ns/op delta 36 | 1e3 9995 10876 +8.81% 37 | 1e4 175356 243806 +39.03% 38 | 1e5 9427422 6780545 -28.08% 39 | 1e6 1776707489 144867502 -91.85% 40 | 2e6 6865499995 346540778 -94.95% 41 | 5e6 42641034189 1069878799 -97.49% 42 | 10e6 151975273589 2693328580 -98.23% 43 | 44 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_386.s: -------------------------------------------------------------------------------- 1 | // Trampolines to math/big assembly implementations. 2 | 3 | #include "textflag.h" 4 | 5 | // func addVV(z, x, y []Word) (c Word) 6 | TEXT ·addVV(SB),NOSPLIT,$0 7 | JMP math∕big·addVV(SB) 8 | 9 | // func subVV(z, x, y []Word) (c Word) 10 | TEXT ·subVV(SB),NOSPLIT,$0 11 | JMP math∕big·subVV(SB) 12 | 13 | // func addVW(z, x []Word, y Word) (c Word) 14 | TEXT ·addVW(SB),NOSPLIT,$0 15 | JMP math∕big·addVW(SB) 16 | 17 | // func subVW(z, x []Word, y Word) (c Word) 18 | TEXT ·subVW(SB),NOSPLIT,$0 19 | JMP math∕big·subVW(SB) 20 | 21 | // func shlVU(z, x []Word, s uint) (c Word) 22 | TEXT ·shlVU(SB),NOSPLIT,$0 23 | JMP math∕big·shlVU(SB) 24 | 25 | // func shrVU(z, x []Word, s uint) (c Word) 26 | TEXT ·shrVU(SB),NOSPLIT,$0 27 | JMP math∕big·shrVU(SB) 28 | 29 | // func mulAddVWW(z, x []Word, y, r Word) (c Word) 30 | TEXT ·mulAddVWW(SB),NOSPLIT,$0 31 | JMP math∕big·mulAddVWW(SB) 32 | 33 | // func addMulVVW(z, x []Word, y Word) (c Word) 34 | TEXT ·addMulVVW(SB),NOSPLIT,$0 35 | JMP math∕big·addMulVVW(SB) 36 | 37 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_amd64.s: -------------------------------------------------------------------------------- 1 | // Trampolines to math/big assembly implementations. 2 | 3 | #include "textflag.h" 4 | 5 | // func addVV(z, x, y []Word) (c Word) 6 | TEXT ·addVV(SB),NOSPLIT,$0 7 | JMP math∕big·addVV(SB) 8 | 9 | // func subVV(z, x, y []Word) (c Word) 10 | // (same as addVV except for SBBQ instead of ADCQ and label names) 11 | TEXT ·subVV(SB),NOSPLIT,$0 12 | JMP math∕big·subVV(SB) 13 | 14 | // func addVW(z, x []Word, y Word) (c Word) 15 | TEXT ·addVW(SB),NOSPLIT,$0 16 | JMP math∕big·addVW(SB) 17 | 18 | // func subVW(z, x []Word, y Word) (c Word) 19 | // (same as addVW except for SUBQ/SBBQ instead of ADDQ/ADCQ and label names) 20 | TEXT ·subVW(SB),NOSPLIT,$0 21 | JMP math∕big·subVW(SB) 22 | 23 | // func shlVU(z, x []Word, s uint) (c Word) 24 | TEXT ·shlVU(SB),NOSPLIT,$0 25 | JMP math∕big·shlVU(SB) 26 | 27 | // func shrVU(z, x []Word, s uint) (c Word) 28 | TEXT ·shrVU(SB),NOSPLIT,$0 29 | JMP math∕big·shrVU(SB) 30 | 31 | // func mulAddVWW(z, x []Word, y, r Word) (c Word) 32 | TEXT ·mulAddVWW(SB),NOSPLIT,$0 33 | JMP math∕big·mulAddVWW(SB) 34 | 35 | // func addMulVVW(z, x []Word, y Word) (c Word) 36 | TEXT ·addMulVVW(SB),NOSPLIT,$0 37 | JMP math∕big·addMulVVW(SB) 38 | 39 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_arm.s: -------------------------------------------------------------------------------- 1 | // Trampolines to math/big assembly implementations. 2 | 3 | #include "textflag.h" 4 | 5 | // func addVV(z, x, y []Word) (c Word) 6 | TEXT ·addVV(SB),NOSPLIT,$0 7 | B math∕big·addVV(SB) 8 | 9 | // func subVV(z, x, y []Word) (c Word) 10 | TEXT ·subVV(SB),NOSPLIT,$0 11 | B math∕big·subVV(SB) 12 | 13 | // func addVW(z, x []Word, y Word) (c Word) 14 | TEXT ·addVW(SB),NOSPLIT,$0 15 | B math∕big·addVW(SB) 16 | 17 | // func subVW(z, x []Word, y Word) (c Word) 18 | TEXT ·subVW(SB),NOSPLIT,$0 19 | B math∕big·subVW(SB) 20 | 21 | // func shlVU(z, x []Word, s uint) (c Word) 22 | TEXT ·shlVU(SB),NOSPLIT,$0 23 | B math∕big·shlVU(SB) 24 | 25 | // func shrVU(z, x []Word, s uint) (c Word) 26 | TEXT ·shrVU(SB),NOSPLIT,$0 27 | B math∕big·shrVU(SB) 28 | 29 | // func mulAddVWW(z, x []Word, y, r Word) (c Word) 30 | TEXT ·mulAddVWW(SB),NOSPLIT,$0 31 | B math∕big·mulAddVWW(SB) 32 | 33 | // func addMulVVW(z, x []Word, y Word) (c Word) 34 | TEXT ·addMulVVW(SB),NOSPLIT,$0 35 | B math∕big·addMulVVW(SB) 36 | 37 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_arm64.s: -------------------------------------------------------------------------------- 1 | // Trampolines to math/big assembly implementations. 2 | 3 | #include "textflag.h" 4 | 5 | // func addVV(z, x, y []Word) (c Word) 6 | TEXT ·addVV(SB),NOSPLIT,$0 7 | B math∕big·addVV(SB) 8 | 9 | // func subVV(z, x, y []Word) (c Word) 10 | TEXT ·subVV(SB),NOSPLIT,$0 11 | B math∕big·subVV(SB) 12 | 13 | // func addVW(z, x []Word, y Word) (c Word) 14 | TEXT ·addVW(SB),NOSPLIT,$0 15 | B math∕big·addVW(SB) 16 | 17 | // func subVW(z, x []Word, y Word) (c Word) 18 | TEXT ·subVW(SB),NOSPLIT,$0 19 | B math∕big·subVW(SB) 20 | 21 | // func shlVU(z, x []Word, s uint) (c Word) 22 | TEXT ·shlVU(SB),NOSPLIT,$0 23 | B math∕big·shlVU(SB) 24 | 25 | // func shrVU(z, x []Word, s uint) (c Word) 26 | TEXT ·shrVU(SB),NOSPLIT,$0 27 | B math∕big·shrVU(SB) 28 | 29 | // func mulAddVWW(z, x []Word, y, r Word) (c Word) 30 | TEXT ·mulAddVWW(SB),NOSPLIT,$0 31 | B math∕big·mulAddVWW(SB) 32 | 33 | // func addMulVVW(z, x []Word, y Word) (c Word) 34 | TEXT ·addMulVVW(SB),NOSPLIT,$0 35 | B math∕big·addMulVVW(SB) 36 | 37 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_decl.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 | package bigfft 6 | 7 | import . "math/big" 8 | 9 | // implemented in arith_$GOARCH.s 10 | func addVV(z, x, y []Word) (c Word) 11 | func subVV(z, x, y []Word) (c Word) 12 | func addVW(z, x []Word, y Word) (c Word) 13 | func subVW(z, x []Word, y Word) (c Word) 14 | func shlVU(z, x []Word, s uint) (c Word) 15 | func mulAddVWW(z, x []Word, y, r Word) (c Word) 16 | func addMulVVW(z, x []Word, y Word) (c Word) 17 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_mips64x.s: -------------------------------------------------------------------------------- 1 | // Trampolines to math/big assembly implementations. 2 | 3 | // +build mips64 mips64le 4 | 5 | #include "textflag.h" 6 | 7 | // func addVV(z, x, y []Word) (c Word) 8 | TEXT ·addVV(SB),NOSPLIT,$0 9 | JMP math∕big·addVV(SB) 10 | 11 | // func subVV(z, x, y []Word) (c Word) 12 | // (same as addVV except for SBBQ instead of ADCQ and label names) 13 | TEXT ·subVV(SB),NOSPLIT,$0 14 | JMP math∕big·subVV(SB) 15 | 16 | // func addVW(z, x []Word, y Word) (c Word) 17 | TEXT ·addVW(SB),NOSPLIT,$0 18 | JMP math∕big·addVW(SB) 19 | 20 | // func subVW(z, x []Word, y Word) (c Word) 21 | // (same as addVW except for SUBQ/SBBQ instead of ADDQ/ADCQ and label names) 22 | TEXT ·subVW(SB),NOSPLIT,$0 23 | JMP math∕big·subVW(SB) 24 | 25 | // func shlVU(z, x []Word, s uint) (c Word) 26 | TEXT ·shlVU(SB),NOSPLIT,$0 27 | JMP math∕big·shlVU(SB) 28 | 29 | // func shrVU(z, x []Word, s uint) (c Word) 30 | TEXT ·shrVU(SB),NOSPLIT,$0 31 | JMP math∕big·shrVU(SB) 32 | 33 | // func mulAddVWW(z, x []Word, y, r Word) (c Word) 34 | TEXT ·mulAddVWW(SB),NOSPLIT,$0 35 | JMP math∕big·mulAddVWW(SB) 36 | 37 | // func addMulVVW(z, x []Word, y Word) (c Word) 38 | TEXT ·addMulVVW(SB),NOSPLIT,$0 39 | JMP math∕big·addMulVVW(SB) 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_mipsx.s: -------------------------------------------------------------------------------- 1 | // Trampolines to math/big assembly implementations. 2 | 3 | // +build mips mipsle 4 | 5 | #include "textflag.h" 6 | 7 | // func addVV(z, x, y []Word) (c Word) 8 | TEXT ·addVV(SB),NOSPLIT,$0 9 | JMP math∕big·addVV(SB) 10 | 11 | // func subVV(z, x, y []Word) (c Word) 12 | // (same as addVV except for SBBQ instead of ADCQ and label names) 13 | TEXT ·subVV(SB),NOSPLIT,$0 14 | JMP math∕big·subVV(SB) 15 | 16 | // func addVW(z, x []Word, y Word) (c Word) 17 | TEXT ·addVW(SB),NOSPLIT,$0 18 | JMP math∕big·addVW(SB) 19 | 20 | // func subVW(z, x []Word, y Word) (c Word) 21 | // (same as addVW except for SUBQ/SBBQ instead of ADDQ/ADCQ and label names) 22 | TEXT ·subVW(SB),NOSPLIT,$0 23 | JMP math∕big·subVW(SB) 24 | 25 | // func shlVU(z, x []Word, s uint) (c Word) 26 | TEXT ·shlVU(SB),NOSPLIT,$0 27 | JMP math∕big·shlVU(SB) 28 | 29 | // func shrVU(z, x []Word, s uint) (c Word) 30 | TEXT ·shrVU(SB),NOSPLIT,$0 31 | JMP math∕big·shrVU(SB) 32 | 33 | // func mulAddVWW(z, x []Word, y, r Word) (c Word) 34 | TEXT ·mulAddVWW(SB),NOSPLIT,$0 35 | JMP math∕big·mulAddVWW(SB) 36 | 37 | // func addMulVVW(z, x []Word, y Word) (c Word) 38 | TEXT ·addMulVVW(SB),NOSPLIT,$0 39 | JMP math∕big·addMulVVW(SB) 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Trampolines to math/big assembly implementations. 2 | 3 | // +build ppc64 ppc64le 4 | 5 | #include "textflag.h" 6 | 7 | // func addVV(z, x, y []Word) (c Word) 8 | TEXT ·addVV(SB),NOSPLIT,$0 9 | BR math∕big·addVV(SB) 10 | 11 | // func subVV(z, x, y []Word) (c Word) 12 | TEXT ·subVV(SB),NOSPLIT,$0 13 | BR math∕big·subVV(SB) 14 | 15 | // func addVW(z, x []Word, y Word) (c Word) 16 | TEXT ·addVW(SB),NOSPLIT,$0 17 | BR math∕big·addVW(SB) 18 | 19 | // func subVW(z, x []Word, y Word) (c Word) 20 | TEXT ·subVW(SB),NOSPLIT,$0 21 | BR math∕big·subVW(SB) 22 | 23 | // func shlVU(z, x []Word, s uint) (c Word) 24 | TEXT ·shlVU(SB),NOSPLIT,$0 25 | BR math∕big·shlVU(SB) 26 | 27 | // func shrVU(z, x []Word, s uint) (c Word) 28 | TEXT ·shrVU(SB),NOSPLIT,$0 29 | BR math∕big·shrVU(SB) 30 | 31 | // func mulAddVWW(z, x []Word, y, r Word) (c Word) 32 | TEXT ·mulAddVWW(SB),NOSPLIT,$0 33 | BR math∕big·mulAddVWW(SB) 34 | 35 | // func addMulVVW(z, x []Word, y Word) (c Word) 36 | TEXT ·addMulVVW(SB),NOSPLIT,$0 37 | BR math∕big·addMulVVW(SB) 38 | 39 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/arith_s390x.s: -------------------------------------------------------------------------------- 1 | 2 | // Trampolines to math/big assembly implementations. 3 | 4 | #include "textflag.h" 5 | 6 | // func addVV(z, x, y []Word) (c Word) 7 | TEXT ·addVV(SB),NOSPLIT,$0 8 | BR math∕big·addVV(SB) 9 | 10 | // func subVV(z, x, y []Word) (c Word) 11 | TEXT ·subVV(SB),NOSPLIT,$0 12 | BR math∕big·subVV(SB) 13 | 14 | // func addVW(z, x []Word, y Word) (c Word) 15 | TEXT ·addVW(SB),NOSPLIT,$0 16 | BR math∕big·addVW(SB) 17 | 18 | // func subVW(z, x []Word, y Word) (c Word) 19 | TEXT ·subVW(SB),NOSPLIT,$0 20 | BR math∕big·subVW(SB) 21 | 22 | // func shlVU(z, x []Word, s uint) (c Word) 23 | TEXT ·shlVU(SB),NOSPLIT,$0 24 | BR math∕big·shlVU(SB) 25 | 26 | // func shrVU(z, x []Word, s uint) (c Word) 27 | TEXT ·shrVU(SB),NOSPLIT,$0 28 | BR math∕big·shrVU(SB) 29 | 30 | // func mulAddVWW(z, x []Word, y, r Word) (c Word) 31 | TEXT ·mulAddVWW(SB),NOSPLIT,$0 32 | BR math∕big·mulAddVWW(SB) 33 | 34 | // func addMulVVW(z, x []Word, y Word) (c Word) 35 | TEXT ·addMulVVW(SB),NOSPLIT,$0 36 | BR math∕big·addMulVVW(SB) 37 | 38 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/remyoudompheng/bigfft 2 | 3 | go 1.12 4 | -------------------------------------------------------------------------------- /vendor/github.com/remyoudompheng/bigfft/scan.go: -------------------------------------------------------------------------------- 1 | package bigfft 2 | 3 | import ( 4 | "math/big" 5 | ) 6 | 7 | // FromDecimalString converts the base 10 string 8 | // representation of a natural (non-negative) number 9 | // into a *big.Int. 10 | // Its asymptotic complexity is less than quadratic. 11 | func FromDecimalString(s string) *big.Int { 12 | var sc scanner 13 | z := new(big.Int) 14 | sc.scan(z, s) 15 | return z 16 | } 17 | 18 | type scanner struct { 19 | // powers[i] is 10^(2^i * quadraticScanThreshold). 20 | powers []*big.Int 21 | } 22 | 23 | func (s *scanner) chunkSize(size int) (int, *big.Int) { 24 | if size <= quadraticScanThreshold { 25 | panic("size < quadraticScanThreshold") 26 | } 27 | pow := uint(0) 28 | for n := size; n > quadraticScanThreshold; n /= 2 { 29 | pow++ 30 | } 31 | // threshold * 2^(pow-1) <= size < threshold * 2^pow 32 | return quadraticScanThreshold << (pow - 1), s.power(pow - 1) 33 | } 34 | 35 | func (s *scanner) power(k uint) *big.Int { 36 | for i := len(s.powers); i <= int(k); i++ { 37 | z := new(big.Int) 38 | if i == 0 { 39 | if quadraticScanThreshold%14 != 0 { 40 | panic("quadraticScanThreshold % 14 != 0") 41 | } 42 | z.Exp(big.NewInt(1e14), big.NewInt(quadraticScanThreshold/14), nil) 43 | } else { 44 | z.Mul(s.powers[i-1], s.powers[i-1]) 45 | } 46 | s.powers = append(s.powers, z) 47 | } 48 | return s.powers[k] 49 | } 50 | 51 | func (s *scanner) scan(z *big.Int, str string) { 52 | if len(str) <= quadraticScanThreshold { 53 | z.SetString(str, 10) 54 | return 55 | } 56 | sz, pow := s.chunkSize(len(str)) 57 | // Scan the left half. 58 | s.scan(z, str[:len(str)-sz]) 59 | // FIXME: reuse temporaries. 60 | left := Mul(z, pow) 61 | // Scan the right half 62 | s.scan(z, str[len(str)-sz:]) 63 | z.Add(z, left) 64 | } 65 | 66 | // quadraticScanThreshold is the number of digits 67 | // below which big.Int.SetString is more efficient 68 | // than subquadratic algorithms. 69 | // 1232 digits fit in 4096 bits. 70 | const quadraticScanThreshold = 1232 71 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors. 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/stretchr/testify/assert/assertion_format.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentFormat}} 2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_order.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | // isOrdered checks that collection contains orderable elements. 9 | func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool { 10 | objKind := reflect.TypeOf(object).Kind() 11 | if objKind != reflect.Slice && objKind != reflect.Array { 12 | return false 13 | } 14 | 15 | objValue := reflect.ValueOf(object) 16 | objLen := objValue.Len() 17 | 18 | if objLen <= 1 { 19 | return true 20 | } 21 | 22 | value := objValue.Index(0) 23 | valueInterface := value.Interface() 24 | firstValueKind := value.Kind() 25 | 26 | for i := 1; i < objLen; i++ { 27 | prevValue := value 28 | prevValueInterface := valueInterface 29 | 30 | value = objValue.Index(i) 31 | valueInterface = value.Interface() 32 | 33 | compareResult, isComparable := compare(prevValueInterface, valueInterface, firstValueKind) 34 | 35 | if !isComparable { 36 | return Fail(t, fmt.Sprintf("Can not compare type \"%s\" and \"%s\"", reflect.TypeOf(value), reflect.TypeOf(prevValue)), msgAndArgs...) 37 | } 38 | 39 | if !containsValue(allowedComparesResults, compareResult) { 40 | return Fail(t, fmt.Sprintf(failMessage, prevValue, value), msgAndArgs...) 41 | } 42 | } 43 | 44 | return true 45 | } 46 | 47 | // IsIncreasing asserts that the collection is increasing 48 | // 49 | // assert.IsIncreasing(t, []int{1, 2, 3}) 50 | // assert.IsIncreasing(t, []float{1, 2}) 51 | // assert.IsIncreasing(t, []string{"a", "b"}) 52 | func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { 53 | return isOrdered(t, object, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs) 54 | } 55 | 56 | // IsNonIncreasing asserts that the collection is not increasing 57 | // 58 | // assert.IsNonIncreasing(t, []int{2, 1, 1}) 59 | // assert.IsNonIncreasing(t, []float{2, 1}) 60 | // assert.IsNonIncreasing(t, []string{"b", "a"}) 61 | func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { 62 | return isOrdered(t, object, []CompareType{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs) 63 | } 64 | 65 | // IsDecreasing asserts that the collection is decreasing 66 | // 67 | // assert.IsDecreasing(t, []int{2, 1, 0}) 68 | // assert.IsDecreasing(t, []float{2, 1}) 69 | // assert.IsDecreasing(t, []string{"b", "a"}) 70 | func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { 71 | return isOrdered(t, object, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs) 72 | } 73 | 74 | // IsNonDecreasing asserts that the collection is not decreasing 75 | // 76 | // assert.IsNonDecreasing(t, []int{1, 1, 2}) 77 | // assert.IsNonDecreasing(t, []float{1, 2}) 78 | // assert.IsNonDecreasing(t, []string{"a", "b"}) 79 | func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { 80 | return isOrdered(t, object, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs" 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Package require implements the same assertions as the `assert` package but 2 | // stops test execution when a test fails. 3 | // 4 | // Example Usage 5 | // 6 | // The following is a complete example using require in a standard test function: 7 | // import ( 8 | // "testing" 9 | // "github.com/stretchr/testify/require" 10 | // ) 11 | // 12 | // func TestSomething(t *testing.T) { 13 | // 14 | // var a string = "Hello" 15 | // var b string = "Hello" 16 | // 17 | // require.Equal(t, a, b, "The two words should be the same.") 18 | // 19 | // } 20 | // 21 | // Assertions 22 | // 23 | // The `require` package have same global functions as in the `assert` package, 24 | // but instead of returning a boolean result they call `t.FailNow()`. 25 | // 26 | // Every assertion function also takes an optional string message as the final argument, 27 | // allowing custom error messages to be appended to the message the assertion method outputs. 28 | package require 29 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require_forward.go.tmpl -include-format-funcs" 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Comment}} 2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return } 5 | t.FailNow() 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // TestingT is an interface wrapper around *testing.T 4 | type TestingT interface { 5 | Errorf(format string, args ...interface{}) 6 | FailNow() 7 | } 8 | 9 | type tHelper interface { 10 | Helper() 11 | } 12 | 13 | // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful 14 | // for table driven tests. 15 | type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) 16 | 17 | // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful 18 | // for table driven tests. 19 | type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) 20 | 21 | // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful 22 | // for table driven tests. 23 | type BoolAssertionFunc func(TestingT, bool, ...interface{}) 24 | 25 | // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful 26 | // for table driven tests. 27 | type ErrorAssertionFunc func(TestingT, error, ...interface{}) 28 | 29 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs" 30 | -------------------------------------------------------------------------------- /vendor/github.com/tj/go-spin/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # go-spin 3 | 4 | Little terminal spinner lib. 5 | 6 | View the [docs](http://godoc.org/github.com/tj/go-spin). 7 | 8 | ## Installation 9 | 10 | ``` 11 | $ go get github.com/tj/go-spin 12 | ``` 13 | 14 | ## Example 15 | 16 | ```go 17 | s := spin.New() 18 | for i := 0; i < 30; i++ { 19 | fmt.Printf("\r \033[36mcomputing\033[m %s ", s.Next()) 20 | time.Sleep(100 * time.Millisecond) 21 | } 22 | ``` 23 | ## GIF FTW 24 | ![](./go-spin.gif) 25 | 26 | # License 27 | 28 | MIT -------------------------------------------------------------------------------- /vendor/github.com/tj/go-spin/go-spin.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everystreet/go-proj/a359594b845fd8e5b79b43dc9e33169bab5676d6/vendor/github.com/tj/go-spin/go-spin.gif -------------------------------------------------------------------------------- /vendor/github.com/tj/go-spin/spin.go: -------------------------------------------------------------------------------- 1 | package spin 2 | 3 | import "sync" 4 | 5 | // Spinner types. 6 | var ( 7 | Box1 = `⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏` 8 | Box2 = `⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓` 9 | Box3 = `⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆` 10 | Box4 = `⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋` 11 | Box5 = `⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁` 12 | Box6 = `⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈` 13 | Box7 = `⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈` 14 | Spin1 = `|/-\` 15 | Spin2 = `◴◷◶◵` 16 | Spin3 = `◰◳◲◱` 17 | Spin4 = `◐◓◑◒` 18 | Spin5 = `▉▊▋▌▍▎▏▎▍▌▋▊▉` 19 | Spin6 = `▌▄▐▀` 20 | Spin7 = `╫╪` 21 | Spin8 = `■□▪▫` 22 | Spin9 = `←↑→↓` 23 | Default = Box1 24 | ) 25 | 26 | // Spinner is exactly what you think it is. 27 | type Spinner struct { 28 | mu sync.Mutex 29 | frames []rune 30 | length int 31 | pos int 32 | } 33 | 34 | // New returns a spinner initialized with Default frames. 35 | func New() *Spinner { 36 | s := &Spinner{} 37 | s.Set(Default) 38 | return s 39 | } 40 | 41 | // Set frames to the given string which must not use spaces. 42 | func (s *Spinner) Set(frames string) { 43 | s.mu.Lock() 44 | defer s.mu.Unlock() 45 | s.frames = []rune(frames) 46 | s.length = len(s.frames) 47 | } 48 | 49 | // Current returns the current rune in the sequence. 50 | func (s *Spinner) Current() string { 51 | s.mu.Lock() 52 | defer s.mu.Unlock() 53 | r := s.frames[s.pos%s.length] 54 | return string(r) 55 | } 56 | 57 | // Next returns the next rune in the sequence. 58 | func (s *Spinner) Next() string { 59 | s.mu.Lock() 60 | defer s.mu.Unlock() 61 | r := s.frames[s.pos%s.length] 62 | s.pos++ 63 | return string(r) 64 | } 65 | 66 | // Reset the spinner to its initial frame. 67 | func (s *Spinner) Reset() { 68 | s.mu.Lock() 69 | defer s.mu.Unlock() 70 | s.pos = 0 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /tmp/ 3 | c-for-go 4 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright © 2015-2017 Maxim Kupriianov 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the “Software”), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/README.md: -------------------------------------------------------------------------------- 1 | # c-for-go [![Go Report Card](https://goreportcard.com/badge/github.com/xlab/c-for-go)](https://goreportcard.com/report/github.com/xlab/c-for-go) 2 | _Automatic C-Go Bindings Generator for Go Programming Language_ 3 | 4 | This project allows to reuse existing C/C++ libraries in your Go applications, by automatically creating [c-go bindings](https://golang.org/cmd/cgo/) for a given set of C headers and the manifest file. We believe in component-based software engineering and think that reusing C/C++ code in Go applications could bring a huge boost to developer's productivity and system's performance. Read more about the motivation: [top reasons to use bindings](https://github.com/xlab/c-for-go/wiki/Top-5-reasons-to-use-bindings). 5 | 6 | ### Process overview 7 | 8 |

9 | c-for-go process overview 10 |

11 | 12 | The only component required to produce a Go package that will wrap the source C/C++ code is the YAML manifest file that defines parsing, translation and generation rules. The manifest can have just a few lines, however in order to match Go's naming conventions and provide enough tips for type conversions it usually contains about 100 lines, which is still better than producing tens of thousands lines of Go code by hand. 13 | 14 | The resulting bindings are as low-level as C code, i.e. it would require knowledge of memory management to carefully use the resulting code, however no more C code is needed to make things done. Eventually some functions can be replaced manually with pure-Go analogs. Also usually a high-level wrapper is created by hand, to introduce Object Oriented Design into API, manage inner state and memory, thus making things safe and lifting the mental overhead. 15 | 16 | Full documentation is available at https://github.com/xlab/c-for-go/wiki 17 | 18 | ### Installation 19 | 20 | ```bash 21 | $ go get github.com/xlab/c-for-go 22 | ``` 23 | 24 | A simple [Makefile template](https://github.com/xlab/c-for-go/wiki/Makefile-template). 25 | 26 | ### In action 27 | 28 | * https://github.com/xlab/android-go 🌟 29 | * https://github.com/vulkan-go/vulkan 🌟 30 | * https://github.com/golang-ui/nuklear 31 | * https://github.com/xlab/pocketsphinx-go 32 | * https://github.com/xlab/libvpx-go 33 | * https://github.com/xlab/portaudio-go 34 | * https://github.com/xlab/portmidi 35 | * https://github.com/xlab/alac-go 36 | * https://github.com/xlab/vorbis-go 37 | * https://github.com/xlab/opus-go 38 | * https://github.com/xlab/libpd-go 39 | * https://github.com/zenhotels/lmdb-go 40 | * https://github.com/zenhotels/libpostal-go 41 | * https://github.com/xlab/hamlib-go 42 | * https://github.com/5k3105/nidaq 43 | * https://github.com/SphereSoftware/pdf-go 44 | * ... 45 | * [Request yours](max@kc.vc) 46 | 47 | ### Credits 48 | 49 | * [Jan Mercl](https://github.com/cznic) for his [cznic/cc](https://gitlab.com/cznic/cc) C99 compiler front end package. 50 | 51 | ### License 52 | 53 | MIT 54 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/generator/Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | rm -f test/foo.go test/cgo_helpers.go test/cgo_helpers.c test/cgo_helpers.h 3 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/generator/gen_union.go: -------------------------------------------------------------------------------- 1 | package generator 2 | 3 | import "io" 4 | 5 | func (gen *Generator) WriteUnions(wr io.Writer) int { 6 | return 0 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/xlab/c-for-go 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/stretchr/testify v1.6.1 // indirect 7 | github.com/tj/go-spin v1.1.0 8 | github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245 9 | golang.org/x/tools v0.0.0-20200711155855-7342f9734a7d 10 | gopkg.in/yaml.v2 v2.3.0 11 | modernc.org/cc v1.0.0 12 | modernc.org/golex v1.0.0 // indirect 13 | modernc.org/mathutil v1.1.1 // indirect 14 | modernc.org/strutil v1.1.0 // indirect 15 | modernc.org/xc v1.0.0 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | "os" 8 | "path/filepath" 9 | "sync" 10 | "time" 11 | 12 | "github.com/tj/go-spin" 13 | ) 14 | 15 | var ( 16 | outputPath = flag.String("out", "", "Specify a `dir` for the output.") 17 | noCGO = flag.Bool("nocgo", false, "Do not include a cgo-specific header in resulting files.") 18 | ccDefs = flag.Bool("ccdefs", false, "Use built-in defines from a hosted C-compiler.") 19 | ccIncl = flag.Bool("ccincl", false, "Use built-in sys include paths from a hosted C-compiler.") 20 | maxMem = flag.String("maxmem", "0x7fffffff", "Specifies platform's memory cap the generated code.") 21 | fancy = flag.Bool("fancy", true, "Enable fancy output in the term.") 22 | nostamp = flag.Bool("nostamp", false, "Disable printing timestamps in the output files.") 23 | debug = flag.Bool("debug", false, "Enable some debug info.") 24 | ) 25 | 26 | const logo = `Copyright (c) 2015-2017 Maxim Kupriianov 27 | Based on a C99 compiler front end by Jan Mercl <0xjnml@gmail.com> 28 | ` 29 | 30 | func init() { 31 | if *debug { 32 | log.SetFlags(log.Lshortfile) 33 | } else { 34 | log.SetFlags(0) 35 | } 36 | flag.Usage = func() { 37 | fmt.Println(logo) 38 | fmt.Printf("Usage: %s package1.yml [package2.yml] ...\n", os.Args[0]) 39 | fmt.Printf("See https://github.com/xlab/c-for-go for examples and documentation.\n\n") 40 | fmt.Println("Options:") 41 | flag.PrintDefaults() 42 | } 43 | flag.Parse() 44 | if len(flag.Args()) == 0 { 45 | flag.Usage() 46 | fmt.Println() 47 | log.Fatalln("[ERR] no package configuration files have been provided.") 48 | } 49 | } 50 | 51 | func main() { 52 | s := spin.New() 53 | 54 | var wg sync.WaitGroup 55 | doneChan := make(chan struct{}) 56 | for _, cfgPath := range getConfigPaths() { 57 | if *fancy { 58 | wg.Add(1) 59 | go func() { 60 | for { 61 | select { 62 | case <-doneChan: 63 | doneChan = make(chan struct{}) 64 | fmt.Printf("\r \033[36mprocessing %s\033[m done.\n", cfgPath) 65 | wg.Done() 66 | return 67 | default: 68 | fmt.Printf("\r \033[36mprocessing %s\033[m %s", cfgPath, s.Next()) 69 | time.Sleep(100 * time.Millisecond) 70 | } 71 | } 72 | }() 73 | } 74 | 75 | var t0 time.Time 76 | if *debug { 77 | t0 = time.Now() 78 | } 79 | process, err := NewProcess(cfgPath, *outputPath) 80 | if err != nil { 81 | log.Fatalln("[ERR]", err) 82 | } 83 | process.Generate(*noCGO) 84 | if err := process.Flush(*noCGO); err != nil { 85 | log.Fatalln("[ERR]", err) 86 | } 87 | if *debug { 88 | fmt.Printf("done in %v\n", time.Now().Sub(t0)) 89 | } 90 | if *fancy { 91 | close(doneChan) 92 | wg.Wait() 93 | } 94 | } 95 | } 96 | 97 | func getConfigPaths() (paths []string) { 98 | for _, path := range flag.Args() { 99 | if info, err := os.Stat(path); err != nil { 100 | log.Fatalln("[ERR] cannot locate the specified path:", path) 101 | } else if info.IsDir() { 102 | if path, ok := configFromDir(path); ok { 103 | paths = append(paths, path) 104 | continue 105 | } 106 | log.Fatalln("[ERR] cannot find any config file in:", path) 107 | } 108 | paths = append(paths, path) 109 | } 110 | return 111 | } 112 | 113 | func configFromDir(path string) (string, bool) { 114 | possibleNames := []string{"c-for-go.yaml", "c-for-go.yml"} 115 | if base := filepath.Base(path); len(base) > 0 { 116 | possibleNames = append(possibleNames, 117 | fmt.Sprintf("%s.yaml", base), fmt.Sprintf("%s.yml", base)) 118 | } 119 | for _, name := range possibleNames { 120 | path := filepath.Join(path, name) 121 | if info, err := os.Stat(path); err == nil && !info.IsDir() { 122 | return path, true 123 | } 124 | } 125 | return "", false 126 | } 127 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/translator/array_spec.go: -------------------------------------------------------------------------------- 1 | package translator 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | type ArraySpec string 10 | 11 | func (a ArraySpec) String() string { 12 | return string(a) 13 | } 14 | 15 | func (a *ArraySpec) AddSized(size uint64) { 16 | *a = ArraySpec(fmt.Sprintf("%s[%d]", a, size)) 17 | } 18 | 19 | func (a *ArraySpec) Prepend(spec ArraySpec) { 20 | *a = spec + *a 21 | } 22 | 23 | type ArraySizeSpec struct { 24 | N uint64 25 | Str string 26 | } 27 | 28 | func (a ArraySpec) Sizes() (sizes []ArraySizeSpec) { 29 | if len(a) == 0 { 30 | return 31 | } 32 | arr := string(a) 33 | for len(arr) > 0 { 34 | // get "n" from "[k][l][m][n]" 35 | p1 := strings.LastIndexByte(arr, '[') 36 | p2 := strings.LastIndexByte(arr, ']') 37 | part := arr[p1+1 : p2] 38 | // and try to convert uint64 39 | if u, err := strconv.ParseUint(part, 10, 64); err != nil || u == 0 { 40 | // use size spec as-is (i.e. unsafe.Sizeof(x)) 41 | sizes = append(sizes, ArraySizeSpec{Str: part}) 42 | } else { 43 | sizes = append(sizes, ArraySizeSpec{N: u}) 44 | } 45 | arr = arr[:p1] 46 | } 47 | return sizes 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/translator/model_declaration.go: -------------------------------------------------------------------------------- 1 | package translator 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "go/token" 7 | ) 8 | 9 | type CTypeKind int 10 | 11 | const ( 12 | TypeKind CTypeKind = iota 13 | PlainTypeKind 14 | StructKind 15 | OpaqueStructKind 16 | UnionKind 17 | FunctionKind 18 | EnumKind 19 | ) 20 | 21 | type CType interface { 22 | GetBase() string 23 | GetTag() string 24 | SetRaw(x string) 25 | CGoName() string 26 | GetPointers() uint8 27 | SetPointers(uint8) 28 | AddOuterArr(uint64) 29 | AddInnerArr(uint64) 30 | OuterArrays() ArraySpec 31 | InnerArrays() ArraySpec 32 | OuterArraySizes() []ArraySizeSpec 33 | InnerArraySizes() []ArraySizeSpec 34 | // 35 | IsConst() bool 36 | IsOpaque() bool 37 | IsComplete() bool 38 | Kind() CTypeKind 39 | String() string 40 | Copy() CType 41 | AtLevel(level int) CType 42 | } 43 | 44 | type ( 45 | Value interface{} 46 | ) 47 | 48 | type CDecl struct { 49 | Spec CType 50 | Name string 51 | Value Value 52 | Expression string 53 | IsStatic bool 54 | IsTypedef bool 55 | IsDefine bool 56 | Pos token.Pos 57 | Src string 58 | } 59 | 60 | func (c CDecl) String() string { 61 | buf := new(bytes.Buffer) 62 | switch { 63 | case len(c.Name) > 0: 64 | fmt.Fprintf(buf, "%s %s", c.Spec, c.Name) 65 | default: 66 | buf.WriteString(c.Spec.String()) 67 | } 68 | if len(c.Expression) > 0 { 69 | fmt.Fprintf(buf, " = %s", string(c.Expression)) 70 | } 71 | return buf.String() 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/translator/model_function.go: -------------------------------------------------------------------------------- 1 | package translator 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type CFunctionSpec struct { 9 | Raw string 10 | Typedef string 11 | Return CType 12 | Params []*CDecl 13 | Pointers uint8 14 | } 15 | 16 | func (c CFunctionSpec) String() string { 17 | if len(c.Raw) > 0 { 18 | return c.Raw 19 | } 20 | var params []string 21 | for i, param := range c.Params { 22 | if len(param.Name) == 0 { 23 | params = append(params, fmt.Sprintf("arg%d", i)) 24 | continue 25 | } 26 | params = append(params, param.String()) 27 | } 28 | paramList := strings.Join(params, ", ") 29 | if c.Return != nil { 30 | return fmt.Sprintf("%s (%s)", c.Return, paramList) 31 | } 32 | return fmt.Sprintf("void (%s)", paramList) 33 | } 34 | 35 | func (c *CFunctionSpec) SetPointers(n uint8) { 36 | c.Pointers = n 37 | } 38 | 39 | func (c *CFunctionSpec) Kind() CTypeKind { 40 | return FunctionKind 41 | } 42 | 43 | func (c *CFunctionSpec) IsComplete() bool { 44 | return true 45 | } 46 | 47 | func (c *CFunctionSpec) IsOpaque() bool { 48 | return len(c.Params) == 0 49 | } 50 | 51 | func (c CFunctionSpec) Copy() CType { 52 | return &c 53 | } 54 | 55 | func (c *CFunctionSpec) GetBase() string { 56 | return "" 57 | } 58 | 59 | func (c *CFunctionSpec) GetTag() string { 60 | return c.Raw 61 | } 62 | 63 | func (c *CFunctionSpec) CGoName() string { 64 | return c.Raw 65 | } 66 | 67 | func (c *CFunctionSpec) SetRaw(x string) { 68 | c.Raw = x 69 | } 70 | 71 | func (c *CFunctionSpec) AddOuterArr(uint64) {} 72 | func (c *CFunctionSpec) AddInnerArr(uint64) {} 73 | func (c *CFunctionSpec) OuterArraySizes() []ArraySizeSpec { 74 | return nil 75 | } 76 | func (c *CFunctionSpec) InnerArraySizes() []ArraySizeSpec { 77 | return nil 78 | } 79 | func (c *CFunctionSpec) OuterArrays() ArraySpec { 80 | return "" 81 | } 82 | func (c *CFunctionSpec) InnerArrays() ArraySpec { 83 | return "" 84 | } 85 | 86 | func (c *CFunctionSpec) GetPointers() uint8 { 87 | return c.Pointers 88 | } 89 | 90 | func (c *CFunctionSpec) IsConst() bool { 91 | return false 92 | } 93 | 94 | func (c CFunctionSpec) AtLevel(level int) CType { 95 | return &c 96 | } 97 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/translator/model_struct_union.go: -------------------------------------------------------------------------------- 1 | package translator 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "strings" 7 | ) 8 | 9 | type CStructSpec struct { 10 | Tag string 11 | Typedef string 12 | IsUnion bool 13 | Members []*CDecl 14 | Pointers uint8 15 | InnerArr ArraySpec 16 | OuterArr ArraySpec 17 | } 18 | 19 | func (spec CStructSpec) String() string { 20 | buf := new(bytes.Buffer) 21 | writePrefix := func() { 22 | if spec.IsUnion { 23 | buf.WriteString("union ") 24 | } else { 25 | buf.WriteString("struct ") 26 | } 27 | } 28 | 29 | switch { 30 | case len(spec.Typedef) > 0: 31 | buf.WriteString(spec.Typedef) 32 | case len(spec.Tag) > 0: 33 | writePrefix() 34 | buf.WriteString(spec.Tag) 35 | case len(spec.Members) > 0: 36 | var members []string 37 | for _, m := range spec.Members { 38 | members = append(members, m.String()) 39 | } 40 | membersColumn := strings.Join(members, ",\n") 41 | writePrefix() 42 | fmt.Fprintf(buf, " {%s}", membersColumn) 43 | default: 44 | writePrefix() 45 | } 46 | 47 | buf.WriteString(arrs(spec.OuterArr)) 48 | buf.WriteString(ptrs(spec.Pointers)) 49 | buf.WriteString(arrs(spec.InnerArr)) 50 | return buf.String() 51 | } 52 | 53 | func (c *CStructSpec) SetPointers(n uint8) { 54 | c.Pointers = n 55 | } 56 | 57 | func (c *CStructSpec) Kind() CTypeKind { 58 | switch { 59 | case c.IsUnion: 60 | return UnionKind 61 | case len(c.Members) == 0: 62 | return OpaqueStructKind 63 | default: 64 | return StructKind 65 | } 66 | } 67 | 68 | func (c *CStructSpec) IsComplete() bool { 69 | return len(c.Members) > 0 70 | } 71 | 72 | func (c *CStructSpec) IsOpaque() bool { 73 | return len(c.Members) == 0 74 | } 75 | 76 | func (c CStructSpec) Copy() CType { 77 | return &c 78 | } 79 | 80 | func (c *CStructSpec) GetBase() string { 81 | if len(c.Typedef) > 0 { 82 | return c.Typedef 83 | } 84 | return c.Tag 85 | } 86 | 87 | func (c *CStructSpec) GetTag() string { 88 | return c.Tag 89 | } 90 | 91 | func (c *CStructSpec) SetRaw(x string) { 92 | c.Typedef = x 93 | } 94 | 95 | func (c *CStructSpec) CGoName() string { 96 | if len(c.Typedef) > 0 { 97 | return c.Typedef 98 | } 99 | if c.IsUnion { 100 | return "union_" + c.Tag 101 | } 102 | return "struct_" + c.Tag 103 | } 104 | 105 | func (c *CStructSpec) AddOuterArr(size uint64) { 106 | c.OuterArr.AddSized(size) 107 | } 108 | 109 | func (c *CStructSpec) AddInnerArr(size uint64) { 110 | c.InnerArr.AddSized(size) 111 | } 112 | 113 | func (c *CStructSpec) OuterArraySizes() []ArraySizeSpec { 114 | return c.OuterArr.Sizes() 115 | } 116 | 117 | func (c *CStructSpec) InnerArraySizes() []ArraySizeSpec { 118 | return c.InnerArr.Sizes() 119 | } 120 | 121 | func (c *CStructSpec) OuterArrays() ArraySpec { 122 | return c.OuterArr 123 | } 124 | 125 | func (c *CStructSpec) InnerArrays() ArraySpec { 126 | return c.InnerArr 127 | } 128 | 129 | func (c *CStructSpec) GetPointers() uint8 { 130 | return c.Pointers 131 | } 132 | 133 | func (c *CStructSpec) IsConst() bool { 134 | return false 135 | } 136 | 137 | func (c CStructSpec) AtLevel(level int) CType { 138 | spec := c 139 | var outerArrSpec ArraySpec 140 | for i, size := range spec.OuterArr.Sizes() { 141 | if i < int(level) { 142 | continue 143 | } else if i == 0 { 144 | spec.Pointers = 1 145 | continue 146 | } 147 | outerArrSpec.AddSized(size.N) 148 | } 149 | if int(level) > len(spec.OuterArr) { 150 | if delta := int(spec.Pointers) + len(spec.OuterArr.Sizes()) - int(level); delta > 0 { 151 | spec.Pointers = uint8(delta) 152 | } 153 | } 154 | spec.OuterArr = outerArrSpec 155 | spec.InnerArr = ArraySpec("") 156 | return &spec 157 | } 158 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/c-for-go/translator/model_type.go: -------------------------------------------------------------------------------- 1 | package translator 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | ) 7 | 8 | type CTypeSpec struct { 9 | Raw string 10 | Base string 11 | Const bool 12 | Signed bool 13 | Unsigned bool 14 | Short bool 15 | Long bool 16 | Complex bool 17 | Opaque bool 18 | Pointers uint8 19 | InnerArr ArraySpec 20 | OuterArr ArraySpec 21 | } 22 | 23 | func (spec CTypeSpec) String() string { 24 | buf := new(bytes.Buffer) 25 | if spec.Unsigned { 26 | buf.WriteString("unsigned ") 27 | } else if spec.Signed { 28 | buf.WriteString("signed ") 29 | } 30 | switch { 31 | case spec.Long: 32 | buf.WriteString("long ") 33 | case spec.Short: 34 | buf.WriteString("short ") 35 | case spec.Complex: 36 | buf.WriteString("complex ") 37 | } 38 | fmt.Fprint(buf, spec.Base) 39 | 40 | var unsafePointer uint8 41 | if spec.Base == "unsafe.Pointer" { 42 | unsafePointer = 1 43 | } 44 | 45 | buf.WriteString(arrs(spec.InnerArr)) 46 | buf.WriteString(ptrs(spec.Pointers - unsafePointer)) 47 | buf.WriteString(arrs(spec.OuterArr)) 48 | return buf.String() 49 | } 50 | 51 | func (c *CTypeSpec) SetPointers(n uint8) { 52 | c.Pointers = n 53 | } 54 | 55 | func (c *CTypeSpec) IsComplete() bool { 56 | return true 57 | } 58 | 59 | func (c *CTypeSpec) IsOpaque() bool { 60 | return c.Opaque 61 | } 62 | 63 | func (c *CTypeSpec) Kind() CTypeKind { 64 | return TypeKind 65 | } 66 | 67 | func (c CTypeSpec) Copy() CType { 68 | return &c 69 | } 70 | 71 | func (c *CTypeSpec) GetBase() string { 72 | return c.Base 73 | } 74 | 75 | func (c *CTypeSpec) GetTag() string { 76 | return "" 77 | } 78 | 79 | func (c *CTypeSpec) SetRaw(x string) { 80 | c.Raw = x 81 | } 82 | 83 | func (c *CTypeSpec) CGoName() (name string) { 84 | if len(c.Raw) > 0 { 85 | return c.Raw 86 | } 87 | switch c.Base { 88 | case "int", "short", "long", "char": 89 | if c.Unsigned { 90 | name += "u" 91 | } else if c.Signed { 92 | name += "s" 93 | } 94 | switch { 95 | case c.Long: 96 | name += "long" 97 | if c.Base == "long" { 98 | name += "long" 99 | } 100 | case c.Short: 101 | name += "short" 102 | default: 103 | name += c.Base 104 | } 105 | default: 106 | name = c.Base 107 | } 108 | return 109 | } 110 | 111 | func (c *CTypeSpec) AddOuterArr(size uint64) { 112 | c.OuterArr.AddSized(size) 113 | } 114 | 115 | func (c *CTypeSpec) AddInnerArr(size uint64) { 116 | c.InnerArr.AddSized(size) 117 | } 118 | 119 | func (c *CTypeSpec) OuterArraySizes() []ArraySizeSpec { 120 | return c.OuterArr.Sizes() 121 | } 122 | 123 | func (c *CTypeSpec) InnerArraySizes() []ArraySizeSpec { 124 | return c.InnerArr.Sizes() 125 | } 126 | 127 | func (c *CTypeSpec) OuterArrays() ArraySpec { 128 | return c.OuterArr 129 | } 130 | 131 | func (c *CTypeSpec) InnerArrays() ArraySpec { 132 | return c.InnerArr 133 | } 134 | 135 | func (c *CTypeSpec) GetPointers() uint8 { 136 | return c.Pointers 137 | } 138 | 139 | func (c *CTypeSpec) IsConst() bool { 140 | return c.Const 141 | } 142 | 143 | func (c CTypeSpec) AtLevel(level int) CType { 144 | spec := c 145 | var outerArrSpec ArraySpec 146 | for i, size := range spec.OuterArr.Sizes() { 147 | if i < int(level) { 148 | continue 149 | } else if i == 0 { 150 | spec.Pointers = 1 151 | continue 152 | } 153 | outerArrSpec.AddSized(size.N) 154 | } 155 | if int(level) > len(spec.OuterArr) { 156 | if delta := int(spec.Pointers) + len(spec.OuterArr.Sizes()) - int(level); delta > 0 { 157 | spec.Pointers = uint8(delta) 158 | } 159 | } 160 | spec.OuterArr = outerArrSpec 161 | spec.InnerArr = ArraySpec("") 162 | return &spec 163 | } 164 | -------------------------------------------------------------------------------- /vendor/github.com/xlab/pkgconfig/pkg/system_path.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "os/exec" 4 | 5 | // getSystemPath returns the installed pkg-config's default PKG_CONFIG_PATH, if 6 | // it is available, otherwise it returns an empty string. 7 | func getSystemPath() string { 8 | cmd := exec.Command("pkg-config", "--variable=pc_path", "pkg-config") 9 | out, err := cmd.Output() 10 | if err != nil { 11 | return "" 12 | } 13 | return string(out) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/mod/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/mod/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/mod/internal/lazyregexp/lazyre.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 lazyregexp is a thin wrapper over regexp, allowing the use of global 6 | // regexp variables without forcing them to be compiled at init. 7 | package lazyregexp 8 | 9 | import ( 10 | "os" 11 | "regexp" 12 | "strings" 13 | "sync" 14 | ) 15 | 16 | // Regexp is a wrapper around regexp.Regexp, where the underlying regexp will be 17 | // compiled the first time it is needed. 18 | type Regexp struct { 19 | str string 20 | once sync.Once 21 | rx *regexp.Regexp 22 | } 23 | 24 | func (r *Regexp) re() *regexp.Regexp { 25 | r.once.Do(r.build) 26 | return r.rx 27 | } 28 | 29 | func (r *Regexp) build() { 30 | r.rx = regexp.MustCompile(r.str) 31 | r.str = "" 32 | } 33 | 34 | func (r *Regexp) FindSubmatch(s []byte) [][]byte { 35 | return r.re().FindSubmatch(s) 36 | } 37 | 38 | func (r *Regexp) FindStringSubmatch(s string) []string { 39 | return r.re().FindStringSubmatch(s) 40 | } 41 | 42 | func (r *Regexp) FindStringSubmatchIndex(s string) []int { 43 | return r.re().FindStringSubmatchIndex(s) 44 | } 45 | 46 | func (r *Regexp) ReplaceAllString(src, repl string) string { 47 | return r.re().ReplaceAllString(src, repl) 48 | } 49 | 50 | func (r *Regexp) FindString(s string) string { 51 | return r.re().FindString(s) 52 | } 53 | 54 | func (r *Regexp) FindAllString(s string, n int) []string { 55 | return r.re().FindAllString(s, n) 56 | } 57 | 58 | func (r *Regexp) MatchString(s string) bool { 59 | return r.re().MatchString(s) 60 | } 61 | 62 | func (r *Regexp) SubexpNames() []string { 63 | return r.re().SubexpNames() 64 | } 65 | 66 | var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") 67 | 68 | // New creates a new lazy regexp, delaying the compiling work until it is first 69 | // needed. If the code is being run as part of tests, the regexp compiling will 70 | // happen immediately. 71 | func New(str string) *Regexp { 72 | lr := &Regexp{str: str} 73 | if inTest { 74 | // In tests, always compile the regexps early. 75 | lr.re() 76 | } 77 | return lr 78 | } 79 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/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/tools/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/tools/go/ast/astutil/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package astutil 6 | 7 | import "go/ast" 8 | 9 | // Unparen returns e with any enclosing parentheses stripped. 10 | func Unparen(e ast.Expr) ast.Expr { 11 | for { 12 | p, ok := e.(*ast.ParenExpr) 13 | if !ok { 14 | return e 15 | } 16 | e = p.X 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/imports/forward.go: -------------------------------------------------------------------------------- 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 | // Package imports implements a Go pretty-printer (like package "go/format") 6 | // that also adds or removes import statements as necessary. 7 | package imports // import "golang.org/x/tools/imports" 8 | 9 | import ( 10 | "io/ioutil" 11 | "log" 12 | 13 | "golang.org/x/tools/internal/gocommand" 14 | intimp "golang.org/x/tools/internal/imports" 15 | ) 16 | 17 | // Options specifies options for processing files. 18 | type Options struct { 19 | Fragment bool // Accept fragment of a source file (no package statement) 20 | AllErrors bool // Report all errors (not just the first 10 on different lines) 21 | 22 | Comments bool // Print comments (true if nil *Options provided) 23 | TabIndent bool // Use tabs for indent (true if nil *Options provided) 24 | TabWidth int // Tab width (8 if nil *Options provided) 25 | 26 | FormatOnly bool // Disable the insertion and deletion of imports 27 | } 28 | 29 | // Debug controls verbose logging. 30 | var Debug = false 31 | 32 | // LocalPrefix is a comma-separated string of import path prefixes, which, if 33 | // set, instructs Process to sort the import paths with the given prefixes 34 | // into another group after 3rd-party packages. 35 | var LocalPrefix string 36 | 37 | // Process formats and adjusts imports for the provided file. 38 | // If opt is nil the defaults are used, and if src is nil the source 39 | // is read from the filesystem. 40 | // 41 | // Note that filename's directory influences which imports can be chosen, 42 | // so it is important that filename be accurate. 43 | // To process data ``as if'' it were in filename, pass the data as a non-nil src. 44 | func Process(filename string, src []byte, opt *Options) ([]byte, error) { 45 | var err error 46 | if src == nil { 47 | src, err = ioutil.ReadFile(filename) 48 | if err != nil { 49 | return nil, err 50 | } 51 | } 52 | if opt == nil { 53 | opt = &Options{Comments: true, TabIndent: true, TabWidth: 8} 54 | } 55 | intopt := &intimp.Options{ 56 | Env: &intimp.ProcessEnv{ 57 | GocmdRunner: &gocommand.Runner{}, 58 | }, 59 | LocalPrefix: LocalPrefix, 60 | AllErrors: opt.AllErrors, 61 | Comments: opt.Comments, 62 | FormatOnly: opt.FormatOnly, 63 | Fragment: opt.Fragment, 64 | TabIndent: opt.TabIndent, 65 | TabWidth: opt.TabWidth, 66 | } 67 | if Debug { 68 | intopt.Env.Logf = log.Printf 69 | } 70 | return intimp.Process(filename, src, intopt) 71 | } 72 | 73 | // VendorlessPath returns the devendorized version of the import path ipath. 74 | // For example, VendorlessPath("foo/bar/vendor/a/b") returns "a/b". 75 | func VendorlessPath(ipath string) string { 76 | return intimp.VendorlessPath(ipath) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/event/core/event.go: -------------------------------------------------------------------------------- 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 | // Package core provides support for event based telemetry. 6 | package core 7 | 8 | import ( 9 | "fmt" 10 | "time" 11 | 12 | "golang.org/x/tools/internal/event/label" 13 | ) 14 | 15 | // Event holds the information about an event of note that occurred. 16 | type Event struct { 17 | at time.Time 18 | 19 | // As events are often on the stack, storing the first few labels directly 20 | // in the event can avoid an allocation at all for the very common cases of 21 | // simple events. 22 | // The length needs to be large enough to cope with the majority of events 23 | // but no so large as to cause undue stack pressure. 24 | // A log message with two values will use 3 labels (one for each value and 25 | // one for the message itself). 26 | 27 | static [3]label.Label // inline storage for the first few labels 28 | dynamic []label.Label // dynamically sized storage for remaining labels 29 | } 30 | 31 | // eventLabelMap implements label.Map for a the labels of an Event. 32 | type eventLabelMap struct { 33 | event Event 34 | } 35 | 36 | func (ev Event) At() time.Time { return ev.at } 37 | 38 | func (ev Event) Format(f fmt.State, r rune) { 39 | if !ev.at.IsZero() { 40 | fmt.Fprint(f, ev.at.Format("2006/01/02 15:04:05 ")) 41 | } 42 | for index := 0; ev.Valid(index); index++ { 43 | if l := ev.Label(index); l.Valid() { 44 | fmt.Fprintf(f, "\n\t%v", l) 45 | } 46 | } 47 | } 48 | 49 | func (ev Event) Valid(index int) bool { 50 | return index >= 0 && index < len(ev.static)+len(ev.dynamic) 51 | } 52 | 53 | func (ev Event) Label(index int) label.Label { 54 | if index < len(ev.static) { 55 | return ev.static[index] 56 | } 57 | return ev.dynamic[index-len(ev.static)] 58 | } 59 | 60 | func (ev Event) Find(key label.Key) label.Label { 61 | for _, l := range ev.static { 62 | if l.Key() == key { 63 | return l 64 | } 65 | } 66 | for _, l := range ev.dynamic { 67 | if l.Key() == key { 68 | return l 69 | } 70 | } 71 | return label.Label{} 72 | } 73 | 74 | func MakeEvent(static [3]label.Label, labels []label.Label) Event { 75 | return Event{ 76 | static: static, 77 | dynamic: labels, 78 | } 79 | } 80 | 81 | // CloneEvent event returns a copy of the event with the time adjusted to at. 82 | func CloneEvent(ev Event, at time.Time) Event { 83 | ev.at = at 84 | return ev 85 | } 86 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/event/core/export.go: -------------------------------------------------------------------------------- 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 | package core 6 | 7 | import ( 8 | "context" 9 | "sync/atomic" 10 | "time" 11 | "unsafe" 12 | 13 | "golang.org/x/tools/internal/event/label" 14 | ) 15 | 16 | // Exporter is a function that handles events. 17 | // It may return a modified context and event. 18 | type Exporter func(context.Context, Event, label.Map) context.Context 19 | 20 | var ( 21 | exporter unsafe.Pointer 22 | ) 23 | 24 | // SetExporter sets the global exporter function that handles all events. 25 | // The exporter is called synchronously from the event call site, so it should 26 | // return quickly so as not to hold up user code. 27 | func SetExporter(e Exporter) { 28 | p := unsafe.Pointer(&e) 29 | if e == nil { 30 | // &e is always valid, and so p is always valid, but for the early abort 31 | // of ProcessEvent to be efficient it needs to make the nil check on the 32 | // pointer without having to dereference it, so we make the nil function 33 | // also a nil pointer 34 | p = nil 35 | } 36 | atomic.StorePointer(&exporter, p) 37 | } 38 | 39 | // deliver is called to deliver an event to the supplied exporter. 40 | // it will fill in the time. 41 | func deliver(ctx context.Context, exporter Exporter, ev Event) context.Context { 42 | // add the current time to the event 43 | ev.at = time.Now() 44 | // hand the event off to the current exporter 45 | return exporter(ctx, ev, ev) 46 | } 47 | 48 | // Export is called to deliver an event to the global exporter if set. 49 | func Export(ctx context.Context, ev Event) context.Context { 50 | // get the global exporter and abort early if there is not one 51 | exporterPtr := (*Exporter)(atomic.LoadPointer(&exporter)) 52 | if exporterPtr == nil { 53 | return ctx 54 | } 55 | return deliver(ctx, *exporterPtr, ev) 56 | } 57 | 58 | // ExportPair is called to deliver a start event to the supplied exporter. 59 | // It also returns a function that will deliver the end event to the same 60 | // exporter. 61 | // It will fill in the time. 62 | func ExportPair(ctx context.Context, begin, end Event) (context.Context, func()) { 63 | // get the global exporter and abort early if there is not one 64 | exporterPtr := (*Exporter)(atomic.LoadPointer(&exporter)) 65 | if exporterPtr == nil { 66 | return ctx, func() {} 67 | } 68 | ctx = deliver(ctx, *exporterPtr, begin) 69 | return ctx, func() { deliver(ctx, *exporterPtr, end) } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/event/core/fast.go: -------------------------------------------------------------------------------- 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 | package core 6 | 7 | import ( 8 | "context" 9 | 10 | "golang.org/x/tools/internal/event/keys" 11 | "golang.org/x/tools/internal/event/label" 12 | ) 13 | 14 | // Log1 takes a message and one label delivers a log event to the exporter. 15 | // It is a customized version of Print that is faster and does no allocation. 16 | func Log1(ctx context.Context, message string, t1 label.Label) { 17 | Export(ctx, MakeEvent([3]label.Label{ 18 | keys.Msg.Of(message), 19 | t1, 20 | }, nil)) 21 | } 22 | 23 | // Log2 takes a message and two labels and delivers a log event to the exporter. 24 | // It is a customized version of Print that is faster and does no allocation. 25 | func Log2(ctx context.Context, message string, t1 label.Label, t2 label.Label) { 26 | Export(ctx, MakeEvent([3]label.Label{ 27 | keys.Msg.Of(message), 28 | t1, 29 | t2, 30 | }, nil)) 31 | } 32 | 33 | // Metric1 sends a label event to the exporter with the supplied labels. 34 | func Metric1(ctx context.Context, t1 label.Label) context.Context { 35 | return Export(ctx, MakeEvent([3]label.Label{ 36 | keys.Metric.New(), 37 | t1, 38 | }, nil)) 39 | } 40 | 41 | // Metric2 sends a label event to the exporter with the supplied labels. 42 | func Metric2(ctx context.Context, t1, t2 label.Label) context.Context { 43 | return Export(ctx, MakeEvent([3]label.Label{ 44 | keys.Metric.New(), 45 | t1, 46 | t2, 47 | }, nil)) 48 | } 49 | 50 | // Start1 sends a span start event with the supplied label list to the exporter. 51 | // It also returns a function that will end the span, which should normally be 52 | // deferred. 53 | func Start1(ctx context.Context, name string, t1 label.Label) (context.Context, func()) { 54 | return ExportPair(ctx, 55 | MakeEvent([3]label.Label{ 56 | keys.Start.Of(name), 57 | t1, 58 | }, nil), 59 | MakeEvent([3]label.Label{ 60 | keys.End.New(), 61 | }, nil)) 62 | } 63 | 64 | // Start2 sends a span start event with the supplied label list to the exporter. 65 | // It also returns a function that will end the span, which should normally be 66 | // deferred. 67 | func Start2(ctx context.Context, name string, t1, t2 label.Label) (context.Context, func()) { 68 | return ExportPair(ctx, 69 | MakeEvent([3]label.Label{ 70 | keys.Start.Of(name), 71 | t1, 72 | t2, 73 | }, nil), 74 | MakeEvent([3]label.Label{ 75 | keys.End.New(), 76 | }, nil)) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/event/doc.go: -------------------------------------------------------------------------------- 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 | // Package event provides a set of packages that cover the main 6 | // concepts of telemetry in an implementation agnostic way. 7 | package event 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/event/keys/standard.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 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 keys 6 | 7 | var ( 8 | // Msg is a key used to add message strings to label lists. 9 | Msg = NewString("message", "a readable message") 10 | // Label is a key used to indicate an event adds labels to the context. 11 | Label = NewTag("label", "a label context marker") 12 | // Start is used for things like traces that have a name. 13 | Start = NewString("start", "span start") 14 | // Metric is a key used to indicate an event records metrics. 15 | End = NewTag("end", "a span end marker") 16 | // Metric is a key used to indicate an event records metrics. 17 | Detach = NewTag("detach", "a span detach marker") 18 | // Err is a key used to add error values to label lists. 19 | Err = NewError("error", "an error that occurred") 20 | // Metric is a key used to indicate an event records metrics. 21 | Metric = NewTag("metric", "a metric event marker") 22 | ) 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_fileno.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build freebsd || openbsd || netbsd 6 | // +build freebsd openbsd netbsd 7 | 8 | package fastwalk 9 | 10 | import "syscall" 11 | 12 | func direntInode(dirent *syscall.Dirent) uint64 { 13 | return uint64(dirent.Fileno) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_ino.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (linux || darwin) && !appengine 6 | // +build linux darwin 7 | // +build !appengine 8 | 9 | package fastwalk 10 | 11 | import "syscall" 12 | 13 | func direntInode(dirent *syscall.Dirent) uint64 { 14 | return uint64(dirent.Ino) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_namlen_bsd.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 | //go:build darwin || freebsd || openbsd || netbsd 6 | // +build darwin freebsd openbsd netbsd 7 | 8 | package fastwalk 9 | 10 | import "syscall" 11 | 12 | func direntNamlen(dirent *syscall.Dirent) uint64 { 13 | return uint64(dirent.Namlen) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_namlen_linux.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 | //go:build linux && !appengine 6 | // +build linux,!appengine 7 | 8 | package fastwalk 9 | 10 | import ( 11 | "bytes" 12 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | func direntNamlen(dirent *syscall.Dirent) uint64 { 17 | const fixedHdr = uint16(unsafe.Offsetof(syscall.Dirent{}.Name)) 18 | nameBuf := (*[unsafe.Sizeof(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0])) 19 | const nameBufLen = uint16(len(nameBuf)) 20 | limit := dirent.Reclen - fixedHdr 21 | if limit > nameBufLen { 22 | limit = nameBufLen 23 | } 24 | nameLen := bytes.IndexByte(nameBuf[:limit], 0) 25 | if nameLen < 0 { 26 | panic("failed to find terminating 0 byte in dirent") 27 | } 28 | return uint64(nameLen) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/fastwalk/fastwalk_portable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build appengine || (!linux && !darwin && !freebsd && !openbsd && !netbsd) 6 | // +build appengine !linux,!darwin,!freebsd,!openbsd,!netbsd 7 | 8 | package fastwalk 9 | 10 | import ( 11 | "io/ioutil" 12 | "os" 13 | ) 14 | 15 | // readDir calls fn for each directory entry in dirName. 16 | // It does not descend into directories or follow symlinks. 17 | // If fn returns a non-nil error, readDir returns with that error 18 | // immediately. 19 | func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) error) error { 20 | fis, err := ioutil.ReadDir(dirName) 21 | if err != nil { 22 | return err 23 | } 24 | skipFiles := false 25 | for _, fi := range fis { 26 | if fi.Mode().IsRegular() && skipFiles { 27 | continue 28 | } 29 | if err := fn(dirName, fi.Name(), fi.Mode()&os.ModeType); err != nil { 30 | if err == ErrSkipFiles { 31 | skipFiles = true 32 | continue 33 | } 34 | return err 35 | } 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/gocommand/version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 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 gocommand 6 | 7 | import ( 8 | "context" 9 | "fmt" 10 | "strings" 11 | ) 12 | 13 | // GoVersion checks the go version by running "go list" with modules off. 14 | // It returns the X in Go 1.X. 15 | func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) { 16 | inv.Verb = "list" 17 | inv.Args = []string{"-e", "-f", `{{context.ReleaseTags}}`, `--`, `unsafe`} 18 | inv.Env = append(append([]string{}, inv.Env...), "GO111MODULE=off") 19 | // Unset any unneeded flags, and remove them from BuildFlags, if they're 20 | // present. 21 | inv.ModFile = "" 22 | inv.ModFlag = "" 23 | var buildFlags []string 24 | for _, flag := range inv.BuildFlags { 25 | // Flags can be prefixed by one or two dashes. 26 | f := strings.TrimPrefix(strings.TrimPrefix(flag, "-"), "-") 27 | if strings.HasPrefix(f, "mod=") || strings.HasPrefix(f, "modfile=") { 28 | continue 29 | } 30 | buildFlags = append(buildFlags, flag) 31 | } 32 | inv.BuildFlags = buildFlags 33 | stdoutBytes, err := r.Run(ctx, inv) 34 | if err != nil { 35 | return 0, err 36 | } 37 | stdout := stdoutBytes.String() 38 | if len(stdout) < 3 { 39 | return 0, fmt.Errorf("bad ReleaseTags output: %q", stdout) 40 | } 41 | // Split up "[go1.1 go1.15]" 42 | tags := strings.Fields(stdout[1 : len(stdout)-2]) 43 | for i := len(tags) - 1; i >= 0; i-- { 44 | var version int 45 | if _, err := fmt.Sscanf(tags[i], "go1.%d", &version); err != nil { 46 | continue 47 | } 48 | return version, nil 49 | } 50 | return 0, fmt.Errorf("no parseable ReleaseTags in %v", tags) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/typeparams/common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 typeparams provides functions to work indirectly with type parameter 6 | // data stored in go/ast and go/types objects, while these API are guarded by a 7 | // build constraint. 8 | // 9 | // This package exists to make it easier for tools to work with generic code, 10 | // while also compiling against older Go versions. 11 | package typeparams 12 | 13 | import ( 14 | "go/ast" 15 | "go/token" 16 | "go/types" 17 | ) 18 | 19 | // A IndexExprData holds data from both ast.IndexExpr and the new 20 | // ast.MultiIndexExpr, which was introduced in Go 1.18. 21 | type IndexExprData struct { 22 | X ast.Expr // expression 23 | Lbrack token.Pos // position of "[" 24 | Indices []ast.Expr // index expressions 25 | Rbrack token.Pos // position of "]" 26 | } 27 | 28 | // IsTypeParam reports whether t is a type parameter. 29 | func IsTypeParam(t types.Type) bool { 30 | _, ok := t.(*TypeParam) 31 | return ok 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/typeparams/enabled_go117.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !go1.18 6 | // +build !go1.18 7 | 8 | package typeparams 9 | 10 | // Enabled reports whether type parameters are enabled in the current build 11 | // environment. 12 | const Enabled = false 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/tools/internal/typeparams/enabled_go118.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build go1.18 6 | // +build go1.18 7 | 8 | package typeparams 9 | 10 | // Note: this constant is in a separate file as this is the only acceptable 11 | // diff between the <1.18 API of this package and the 1.18 API. 12 | 13 | // Enabled reports whether type parameters are enabled in the current build 14 | // environment. 15 | const Enabled = true 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 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/xerrors/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/xerrors/README: -------------------------------------------------------------------------------- 1 | This repository holds the transition packages for the new Go 1.13 error values. 2 | See golang.org/design/29934-error-values. 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/doc.go: -------------------------------------------------------------------------------- 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 | // Package xerrors implements functions to manipulate errors. 6 | // 7 | // This package is based on the Go 2 proposal for error values: 8 | // https://golang.org/design/29934-error-values 9 | // 10 | // These functions were incorporated into the standard library's errors package 11 | // in Go 1.13: 12 | // - Is 13 | // - As 14 | // - Unwrap 15 | // 16 | // Also, Errorf's %w verb was incorporated into fmt.Errorf. 17 | // 18 | // Use this package to get equivalent behavior in all supported Go versions. 19 | // 20 | // No other features of this package were included in Go 1.13, and at present 21 | // there are no plans to include any of them. 22 | package xerrors // import "golang.org/x/xerrors" 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/errors.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 xerrors 6 | 7 | import "fmt" 8 | 9 | // errorString is a trivial implementation of error. 10 | type errorString struct { 11 | s string 12 | frame Frame 13 | } 14 | 15 | // New returns an error that formats as the given text. 16 | // 17 | // The returned error contains a Frame set to the caller's location and 18 | // implements Formatter to show this information when printed with details. 19 | func New(text string) error { 20 | return &errorString{text, Caller(1)} 21 | } 22 | 23 | func (e *errorString) Error() string { 24 | return e.s 25 | } 26 | 27 | func (e *errorString) Format(s fmt.State, v rune) { FormatError(e, s, v) } 28 | 29 | func (e *errorString) FormatError(p Printer) (next error) { 30 | p.Print(e.s) 31 | e.frame.Format(p) 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/format.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 xerrors 6 | 7 | // A Formatter formats error messages. 8 | type Formatter interface { 9 | error 10 | 11 | // FormatError prints the receiver's first error and returns the next error in 12 | // the error chain, if any. 13 | FormatError(p Printer) (next error) 14 | } 15 | 16 | // A Printer formats error messages. 17 | // 18 | // The most common implementation of Printer is the one provided by package fmt 19 | // during Printf (as of Go 1.13). Localization packages such as golang.org/x/text/message 20 | // typically provide their own implementations. 21 | type Printer interface { 22 | // Print appends args to the message output. 23 | Print(args ...interface{}) 24 | 25 | // Printf writes a formatted string. 26 | Printf(format string, args ...interface{}) 27 | 28 | // Detail reports whether error detail is requested. 29 | // After the first call to Detail, all text written to the Printer 30 | // is formatted as additional detail, or ignored when 31 | // detail has not been requested. 32 | // If Detail returns false, the caller can avoid printing the detail at all. 33 | Detail() bool 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/frame.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 xerrors 6 | 7 | import ( 8 | "runtime" 9 | ) 10 | 11 | // A Frame contains part of a call stack. 12 | type Frame struct { 13 | // Make room for three PCs: the one we were asked for, what it called, 14 | // and possibly a PC for skipPleaseUseCallersFrames. See: 15 | // https://go.googlesource.com/go/+/032678e0fb/src/runtime/extern.go#169 16 | frames [3]uintptr 17 | } 18 | 19 | // Caller returns a Frame that describes a frame on the caller's stack. 20 | // The argument skip is the number of frames to skip over. 21 | // Caller(0) returns the frame for the caller of Caller. 22 | func Caller(skip int) Frame { 23 | var s Frame 24 | runtime.Callers(skip+1, s.frames[:]) 25 | return s 26 | } 27 | 28 | // location reports the file, line, and function of a frame. 29 | // 30 | // The returned function may be "" even if file and line are not. 31 | func (f Frame) location() (function, file string, line int) { 32 | frames := runtime.CallersFrames(f.frames[:]) 33 | if _, ok := frames.Next(); !ok { 34 | return "", "", 0 35 | } 36 | fr, ok := frames.Next() 37 | if !ok { 38 | return "", "", 0 39 | } 40 | return fr.Function, fr.File, fr.Line 41 | } 42 | 43 | // Format prints the stack as error detail. 44 | // It should be called from an error's Format implementation 45 | // after printing any other error detail. 46 | func (f Frame) Format(p Printer) { 47 | if p.Detail() { 48 | function, file, line := f.location() 49 | if function != "" { 50 | p.Printf("%s\n ", function) 51 | } 52 | if file != "" { 53 | p.Printf("%s:%d\n", file, line) 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/go.mod: -------------------------------------------------------------------------------- 1 | module golang.org/x/xerrors 2 | 3 | go 1.11 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/internal/internal.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 internal 6 | 7 | // EnableTrace indicates whether stack information should be recorded in errors. 8 | var EnableTrace = true 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/xerrors/wrap.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 xerrors 6 | 7 | import ( 8 | "reflect" 9 | ) 10 | 11 | // A Wrapper provides context around another error. 12 | type Wrapper interface { 13 | // Unwrap returns the next error in the error chain. 14 | // If there is no next error, Unwrap returns nil. 15 | Unwrap() error 16 | } 17 | 18 | // Opaque returns an error with the same error formatting as err 19 | // but that does not match err and cannot be unwrapped. 20 | func Opaque(err error) error { 21 | return noWrapper{err} 22 | } 23 | 24 | type noWrapper struct { 25 | error 26 | } 27 | 28 | func (e noWrapper) FormatError(p Printer) (next error) { 29 | if f, ok := e.error.(Formatter); ok { 30 | return f.FormatError(p) 31 | } 32 | p.Print(e.error) 33 | return nil 34 | } 35 | 36 | // Unwrap returns the result of calling the Unwrap method on err, if err implements 37 | // Unwrap. Otherwise, Unwrap returns nil. 38 | func Unwrap(err error) error { 39 | u, ok := err.(Wrapper) 40 | if !ok { 41 | return nil 42 | } 43 | return u.Unwrap() 44 | } 45 | 46 | // Is reports whether any error in err's chain matches target. 47 | // 48 | // An error is considered to match a target if it is equal to that target or if 49 | // it implements a method Is(error) bool such that Is(target) returns true. 50 | func Is(err, target error) bool { 51 | if target == nil { 52 | return err == target 53 | } 54 | 55 | isComparable := reflect.TypeOf(target).Comparable() 56 | for { 57 | if isComparable && err == target { 58 | return true 59 | } 60 | if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(target) { 61 | return true 62 | } 63 | // TODO: consider supporing target.Is(err). This would allow 64 | // user-definable predicates, but also may allow for coping with sloppy 65 | // APIs, thereby making it easier to get away with them. 66 | if err = Unwrap(err); err == nil { 67 | return false 68 | } 69 | } 70 | } 71 | 72 | // As finds the first error in err's chain that matches the type to which target 73 | // points, and if so, sets the target to its value and returns true. An error 74 | // matches a type if it is assignable to the target type, or if it has a method 75 | // As(interface{}) bool such that As(target) returns true. As will panic if target 76 | // is not a non-nil pointer to a type which implements error or is of interface type. 77 | // 78 | // The As method should set the target to its value and return true if err 79 | // matches the type to which target points. 80 | func As(err error, target interface{}) bool { 81 | if target == nil { 82 | panic("errors: target cannot be nil") 83 | } 84 | val := reflect.ValueOf(target) 85 | typ := val.Type() 86 | if typ.Kind() != reflect.Ptr || val.IsNil() { 87 | panic("errors: target must be a non-nil pointer") 88 | } 89 | if e := typ.Elem(); e.Kind() != reflect.Interface && !e.Implements(errorType) { 90 | panic("errors: *target must be interface or implement error") 91 | } 92 | targetType := typ.Elem() 93 | for err != nil { 94 | if reflect.TypeOf(err).AssignableTo(targetType) { 95 | val.Elem().Set(reflect.ValueOf(err)) 96 | return true 97 | } 98 | if x, ok := err.(interface{ As(interface{}) bool }); ok && x.As(target) { 99 | return true 100 | } 101 | err = Unwrap(err) 102 | } 103 | return false 104 | } 105 | 106 | var errorType = reflect.TypeOf((*error)(nil)).Elem() 107 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - "1.4.x" 5 | - "1.5.x" 6 | - "1.6.x" 7 | - "1.7.x" 8 | - "1.8.x" 9 | - "1.9.x" 10 | - "1.10.x" 11 | - "1.11.x" 12 | - "1.12.x" 13 | - "1.13.x" 14 | - "1.14.x" 15 | - "tip" 16 | 17 | go_import_path: gopkg.in/yaml.v2 18 | -------------------------------------------------------------------------------- /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/README.md: -------------------------------------------------------------------------------- 1 | # YAML support for the Go language 2 | 3 | Introduction 4 | ------------ 5 | 6 | The yaml package enables Go programs to comfortably encode and decode YAML 7 | values. It was developed within [Canonical](https://www.canonical.com) as 8 | part of the [juju](https://juju.ubuntu.com) project, and is based on a 9 | pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) 10 | C library to parse and generate YAML data quickly and reliably. 11 | 12 | Compatibility 13 | ------------- 14 | 15 | The yaml package supports most of YAML 1.1 and 1.2, including support for 16 | anchors, tags, map merging, etc. Multi-document unmarshalling is not yet 17 | implemented, and base-60 floats from YAML 1.1 are purposefully not 18 | supported since they're a poor design and are gone in YAML 1.2. 19 | 20 | Installation and usage 21 | ---------------------- 22 | 23 | The import path for the package is *gopkg.in/yaml.v2*. 24 | 25 | To install it, run: 26 | 27 | go get gopkg.in/yaml.v2 28 | 29 | API documentation 30 | ----------------- 31 | 32 | If opened in a browser, the import path itself leads to the API documentation: 33 | 34 | * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) 35 | 36 | API stability 37 | ------------- 38 | 39 | The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in). 40 | 41 | 42 | License 43 | ------- 44 | 45 | The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details. 46 | 47 | 48 | Example 49 | ------- 50 | 51 | ```Go 52 | package main 53 | 54 | import ( 55 | "fmt" 56 | "log" 57 | 58 | "gopkg.in/yaml.v2" 59 | ) 60 | 61 | var data = ` 62 | a: Easy! 63 | b: 64 | c: 2 65 | d: [3, 4] 66 | ` 67 | 68 | // Note: struct fields must be public in order for unmarshal to 69 | // correctly populate the data. 70 | type T struct { 71 | A string 72 | B struct { 73 | RenamedC int `yaml:"c"` 74 | D []int `yaml:",flow"` 75 | } 76 | } 77 | 78 | func main() { 79 | t := T{} 80 | 81 | err := yaml.Unmarshal([]byte(data), &t) 82 | if err != nil { 83 | log.Fatalf("error: %v", err) 84 | } 85 | fmt.Printf("--- t:\n%v\n\n", t) 86 | 87 | d, err := yaml.Marshal(&t) 88 | if err != nil { 89 | log.Fatalf("error: %v", err) 90 | } 91 | fmt.Printf("--- t dump:\n%s\n\n", string(d)) 92 | 93 | m := make(map[interface{}]interface{}) 94 | 95 | err = yaml.Unmarshal([]byte(data), &m) 96 | if err != nil { 97 | log.Fatalf("error: %v", err) 98 | } 99 | fmt.Printf("--- m:\n%v\n\n", m) 100 | 101 | d, err = yaml.Marshal(&m) 102 | if err != nil { 103 | log.Fatalf("error: %v", err) 104 | } 105 | fmt.Printf("--- m dump:\n%s\n\n", string(d)) 106 | } 107 | ``` 108 | 109 | This example will generate the following output: 110 | 111 | ``` 112 | --- t: 113 | {Easy! {2 [3 4]}} 114 | 115 | --- t dump: 116 | a: Easy! 117 | b: 118 | c: 2 119 | d: [3, 4] 120 | 121 | 122 | --- m: 123 | map[a:Easy! b:map[c:2 d:[3 4]]] 124 | 125 | --- m dump: 126 | a: Easy! 127 | b: 128 | c: 2 129 | d: 130 | - 3 131 | - 4 132 | ``` 133 | 134 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/go.mod: -------------------------------------------------------------------------------- 1 | module gopkg.in/yaml.v2 2 | 3 | go 1.15 4 | 5 | require gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/sorter.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "reflect" 5 | "unicode" 6 | ) 7 | 8 | type keyList []reflect.Value 9 | 10 | func (l keyList) Len() int { return len(l) } 11 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } 12 | func (l keyList) Less(i, j int) bool { 13 | a := l[i] 14 | b := l[j] 15 | ak := a.Kind() 16 | bk := b.Kind() 17 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { 18 | a = a.Elem() 19 | ak = a.Kind() 20 | } 21 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { 22 | b = b.Elem() 23 | bk = b.Kind() 24 | } 25 | af, aok := keyFloat(a) 26 | bf, bok := keyFloat(b) 27 | if aok && bok { 28 | if af != bf { 29 | return af < bf 30 | } 31 | if ak != bk { 32 | return ak < bk 33 | } 34 | return numLess(a, b) 35 | } 36 | if ak != reflect.String || bk != reflect.String { 37 | return ak < bk 38 | } 39 | ar, br := []rune(a.String()), []rune(b.String()) 40 | for i := 0; i < len(ar) && i < len(br); i++ { 41 | if ar[i] == br[i] { 42 | continue 43 | } 44 | al := unicode.IsLetter(ar[i]) 45 | bl := unicode.IsLetter(br[i]) 46 | if al && bl { 47 | return ar[i] < br[i] 48 | } 49 | if al || bl { 50 | return bl 51 | } 52 | var ai, bi int 53 | var an, bn int64 54 | if ar[i] == '0' || br[i] == '0' { 55 | for j := i-1; j >= 0 && unicode.IsDigit(ar[j]); j-- { 56 | if ar[j] != '0' { 57 | an = 1 58 | bn = 1 59 | break 60 | } 61 | } 62 | } 63 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { 64 | an = an*10 + int64(ar[ai]-'0') 65 | } 66 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { 67 | bn = bn*10 + int64(br[bi]-'0') 68 | } 69 | if an != bn { 70 | return an < bn 71 | } 72 | if ai != bi { 73 | return ai < bi 74 | } 75 | return ar[i] < br[i] 76 | } 77 | return len(ar) < len(br) 78 | } 79 | 80 | // keyFloat returns a float value for v if it is a number/bool 81 | // and whether it is a number/bool or not. 82 | func keyFloat(v reflect.Value) (f float64, ok bool) { 83 | switch v.Kind() { 84 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 85 | return float64(v.Int()), true 86 | case reflect.Float32, reflect.Float64: 87 | return v.Float(), true 88 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 89 | return float64(v.Uint()), true 90 | case reflect.Bool: 91 | if v.Bool() { 92 | return 1, true 93 | } 94 | return 0, true 95 | } 96 | return 0, false 97 | } 98 | 99 | // numLess returns whether a < b. 100 | // a and b must necessarily have the same kind. 101 | func numLess(a, b reflect.Value) bool { 102 | switch a.Kind() { 103 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 104 | return a.Int() < b.Int() 105 | case reflect.Float32, reflect.Float64: 106 | return a.Float() < b.Float() 107 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 108 | return a.Uint() < b.Uint() 109 | case reflect.Bool: 110 | return !a.Bool() && b.Bool() 111 | } 112 | panic("not a number") 113 | } 114 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | This project is covered by two different licenses: MIT and Apache. 3 | 4 | #### MIT License #### 5 | 6 | The following files were ported to Go from C files of libyaml, and thus 7 | are still covered by their original MIT license, with the additional 8 | copyright staring in 2011 when the project was ported over: 9 | 10 | apic.go emitterc.go parserc.go readerc.go scannerc.go 11 | writerc.go yamlh.go yamlprivateh.go 12 | 13 | Copyright (c) 2006-2010 Kirill Simonov 14 | Copyright (c) 2006-2011 Kirill Simonov 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy of 17 | this software and associated documentation files (the "Software"), to deal in 18 | the Software without restriction, including without limitation the rights to 19 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 20 | of the Software, and to permit persons to whom the Software is furnished to do 21 | so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in all 24 | copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 | SOFTWARE. 33 | 34 | ### Apache License ### 35 | 36 | All the remaining project files are covered by the Apache license: 37 | 38 | Copyright (c) 2011-2019 Canonical Ltd 39 | 40 | Licensed under the Apache License, Version 2.0 (the "License"); 41 | you may not use this file except in compliance with the License. 42 | You may obtain a copy of the License at 43 | 44 | http://www.apache.org/licenses/LICENSE-2.0 45 | 46 | Unless required by applicable law or agreed to in writing, software 47 | distributed under the License is distributed on an "AS IS" BASIS, 48 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 49 | See the License for the specific language governing permissions and 50 | limitations under the License. 51 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/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.v3/go.mod: -------------------------------------------------------------------------------- 1 | module "gopkg.in/yaml.v3" 2 | 3 | require ( 4 | "gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405 5 | ) 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/writerc.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2019 Canonical Ltd 3 | // Copyright (c) 2006-2010 Kirill Simonov 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files (the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | // of the Software, and to permit persons to whom the Software is furnished to do 10 | // so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | package yaml 24 | 25 | // Set the writer error and return false. 26 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 27 | emitter.error = yaml_WRITER_ERROR 28 | emitter.problem = problem 29 | return false 30 | } 31 | 32 | // Flush the output buffer. 33 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 34 | if emitter.write_handler == nil { 35 | panic("write handler not set") 36 | } 37 | 38 | // Check if the buffer is empty. 39 | if emitter.buffer_pos == 0 { 40 | return true 41 | } 42 | 43 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 44 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 45 | } 46 | emitter.buffer_pos = 0 47 | return true 48 | } 49 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists authors for copyright purposes. This file is distinct from 2 | # the CONTRIBUTORS files. See the latter for an explanation. 3 | # 4 | # Names should be added to this file as: 5 | # Name or Organization 6 | # 7 | # The email address is not required for organizations. 8 | # 9 | # Please keep the list sorted. 10 | 11 | Dan Kortschak 12 | Jan Mercl <0xjnml@gmail.com> 13 | Maxim Kupriianov 14 | Peter Waller 15 | Steffen Butzer 16 | Yasuhiro Matsumoto 17 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file lists people who contributed code to this repository. The AUTHORS 2 | # file lists the copyright holders; this file lists people. 3 | # 4 | # Names should be added to this file like so: 5 | # Name 6 | # 7 | # Please keep the list sorted. 8 | 9 | Dan Kortschak 10 | Jan Mercl <0xjnml@gmail.com> 11 | Maxim Kupriianov 12 | Peter Waller 13 | Steffen Butzer 14 | Zvi Effron 15 | Yasuhiro Matsumoto 16 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 The CC 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 names of the authors nor the names of the 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/modernc.org/cc/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The CC 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 | .PHONY: all clean cover cpu edit editor internalError later mem nuke todo 6 | 7 | grep=--include=*.go --include=*.l --include=*.y 8 | 9 | all: editor 10 | rm -f log-*.c log-*.h 11 | go vet || true 12 | golint || true 13 | make todo 14 | unused . || true 15 | maligned 16 | unconvert -apply 17 | 18 | clean: 19 | rm -f log-*.c log-*.h *~ cpu.test mem.test /tmp/cc-test-* log*.c 20 | go clean 21 | 22 | cover: 23 | t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t 24 | 25 | cpu: 26 | go test -c -o cpu.test 27 | ./cpu.test -noerr -test.cpuprofile cpu.out 28 | go tool pprof --lines cpu.test cpu.out 29 | 30 | edit: 31 | gvim -p Makefile trigraphs.l scanner.l parser.yy all_test.go ast2.go cc.go cpp.go encoding.go etc.go lexer.go model.go & 32 | 33 | editor: parser.go scanner.go trigraphs.go 34 | rm -f log-*.c log-*.h 35 | gofmt -l -s -w *.go 36 | rm -f log-*.c log-*.h 37 | go test -i 38 | go test 2>&1 | tee log 39 | go install 40 | 41 | internalError: 42 | egrep -ho '"internal error.*"' *.go | sort | cat -n 43 | 44 | later: 45 | @grep -n $(grep) LATER * || true 46 | @grep -n $(grep) MAYBE * || true 47 | 48 | mem: 49 | go test -c -o mem.test 50 | ./mem.test -test.bench . -test.memprofile mem.out 51 | go tool pprof --lines --web --alloc_space mem.test mem.out 52 | 53 | nuke: clean 54 | go clean -i 55 | 56 | parser.go scanner.go trigraphs.go: parser.yy trigraphs.l scanner.l 57 | rm -f log-*.c log-*.h 58 | go test -i 59 | go generate 60 | 61 | todo: 62 | @grep -n $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true 63 | @grep -n $(grep) TODO * || true 64 | @grep -n $(grep) BUG * || true 65 | @grep -n $(grep) [^[:alpha:]]println * || true 66 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/README.md: -------------------------------------------------------------------------------- 1 | # cc 2 | 3 | ---- 4 | 5 | 2020-07-13 This package is no longer maintained. Please see the v3 version at 6 | 7 | [https://modernc.org/cc/v3](https://modernc.org/cc/v3) 8 | 9 | ---- 10 | 11 | Package CC is a C99 compiler front end. 12 | 13 | Installation 14 | 15 | $ go get modernc.org/cc 16 | 17 | 18 | Documentation: [godoc.org/modernc.org/cc](http://godoc.org/modernc.org/cc) 19 | 20 | 21 | Building with `make` requires indent(1) and the following Go packages 22 | 23 | * github.com/golang/lint/golint 24 | * github.com/mdempsky/maligned 25 | * github.com/mdempsky/unconvert 26 | * honnef.co/go/tools/cmd/unused 27 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/global.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The CC 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 cc // import "modernc.org/cc" 6 | 7 | import ( 8 | "reflect" 9 | "strconv" 10 | "strings" 11 | 12 | "modernc.org/golex/lex" 13 | "modernc.org/strutil" 14 | "modernc.org/xc" 15 | ) 16 | 17 | const ( 18 | commentNotClosed = "comment not closed" 19 | ) 20 | 21 | var ( 22 | debugIncludes bool 23 | debugMacros bool 24 | dict = xc.Dict 25 | fset = xc.FileSet 26 | isGenerating bool // go generate hook. 27 | isTesting bool // Test hook. 28 | printHooks = strutil.PrettyPrintHooks{} 29 | ) 30 | 31 | func init() { 32 | for k, v := range xc.PrintHooks { 33 | printHooks[k] = v 34 | } 35 | lcRT := reflect.TypeOf(lex.Char{}) 36 | lcH := func(f strutil.Formatter, v interface{}, prefix, suffix string) { 37 | c := v.(lex.Char) 38 | r := c.Rune 39 | s := yySymName(int(r)) 40 | if x := s[0]; x >= '0' && x <= '9' { 41 | s = strconv.QuoteRune(r) 42 | } 43 | f.Format("%s%v: %s"+suffix, prefix, fset.Position(c.Pos()), s) 44 | } 45 | 46 | printHooks[lcRT] = lcH 47 | printHooks[reflect.TypeOf(xc.Token{})] = func(f strutil.Formatter, v interface{}, prefix, suffix string) { 48 | t := v.(xc.Token) 49 | if (t == xc.Token{}) { 50 | return 51 | } 52 | 53 | lcH(f, t.Char, prefix, "") 54 | if s := t.S(); len(s) != 0 { 55 | f.Format(" %q", s) 56 | } 57 | f.Format(suffix) 58 | } 59 | 60 | printHooks[reflect.TypeOf(PPTokenList(0))] = func(f strutil.Formatter, v interface{}, prefix, suffix string) { 61 | x := v.(PPTokenList) 62 | if x == 0 { 63 | return 64 | } 65 | 66 | a := strings.Split(prefix+PrettyString(decodeTokens(x, nil, true))+",", "\n") 67 | for _, v := range a { 68 | f.Format("%s\n", v) 69 | } 70 | 71 | } 72 | 73 | printHooks[reflect.TypeOf((*ctype)(nil))] = func(f strutil.Formatter, v interface{}, prefix, suffix string) { 74 | f.Format(prefix) 75 | f.Format("%v", v.(Type).String()) 76 | f.Format(suffix) 77 | } 78 | 79 | printHooks[reflect.TypeOf(Kind(0))] = func(f strutil.Formatter, v interface{}, prefix, suffix string) { 80 | f.Format(prefix) 81 | f.Format("%v", v.(Kind)) 82 | f.Format(suffix) 83 | } 84 | 85 | printHooks[reflect.TypeOf(Linkage(0))] = func(f strutil.Formatter, v interface{}, prefix, suffix string) { 86 | f.Format(prefix) 87 | f.Format("%v", v.(Linkage)) 88 | f.Format(suffix) 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/go.mod: -------------------------------------------------------------------------------- 1 | module modernc.org/cc 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/dustin/go-humanize v1.0.0 7 | github.com/google/go-cmp v0.5.3 8 | github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 // indirect 9 | modernc.org/golex v1.0.0 10 | modernc.org/internal v1.0.0 // indirect 11 | modernc.org/ir v1.0.0 12 | modernc.org/mathutil v1.0.0 13 | modernc.org/strutil v1.1.0 14 | modernc.org/token v1.0.0 15 | modernc.org/xc v1.0.0 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/go.sum: -------------------------------------------------------------------------------- 1 | github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= 2 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 3 | github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo= 4 | github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 5 | github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 h1:/NRJ5vAYoqz+7sG51ubIDHXeWO8DlTSrToPu6q11ziA= 6 | github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= 7 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 8 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 9 | modernc.org/golex v1.0.0 h1:wWpDlbK8ejRfSyi0frMyhilD3JBvtcx2AdGDnU+JtsE= 10 | modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= 11 | modernc.org/internal v1.0.0 h1:XMDsFDcBDsibbBnHB2xzljZ+B1yrOVLEFkKL2u15Glw= 12 | modernc.org/internal v1.0.0/go.mod h1:VUD/+JAkhCpvkUitlEOnhpVxCgsBI90oTzSCRcqQVSM= 13 | modernc.org/ir v1.0.0 h1:5S08NkggW1cm/422E1oq9+DsywE5qxHzEC3QumMWuxw= 14 | modernc.org/ir v1.0.0/go.mod h1:wxK1nK3PS04CASoUY+HJr+FQywv4+D38y2sRrd71y7s= 15 | modernc.org/mathutil v1.0.0 h1:93vKjrJopTPrtTNpZ8XIovER7iCIH1QU7wNbOQXC60I= 16 | modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= 17 | modernc.org/strutil v1.0.0 h1:XVFtQwFVwc02Wk+0L/Z/zDDXO81r5Lhe6iMKmGX3KhE= 18 | modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= 19 | modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc= 20 | modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= 21 | modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= 22 | modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= 23 | modernc.org/xc v1.0.0 h1:7ccXrupWZIS3twbUGrtKmHS2DXY6xegFua+6O3xgAFU= 24 | modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= 25 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/kind_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type Kind"; DO NOT EDIT. 2 | 3 | package cc // import "modernc.org/cc" 4 | 5 | import "fmt" 6 | 7 | const _Kind_name = "UndefinedVoidPtrUintPtrCharSCharUCharShortUShortIntUIntLongULongLongLongULongLongFloatDoubleLongDoubleBoolFloatComplexDoubleComplexLongDoubleComplexStructUnionEnumTypedefNameFunctionArraytypeofkindMax" 8 | 9 | var _Kind_index = [...]uint8{0, 9, 13, 16, 23, 27, 32, 37, 42, 48, 51, 55, 59, 64, 72, 81, 86, 92, 102, 106, 118, 131, 148, 154, 159, 163, 174, 182, 187, 193, 200} 10 | 11 | func (i Kind) String() string { 12 | if i < 0 || i >= Kind(len(_Kind_index)-1) { 13 | return fmt.Sprintf("Kind(%d)", i) 14 | } 15 | return _Kind_name[_Kind_index[i]:_Kind_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/linkage_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type Linkage"; DO NOT EDIT. 2 | 3 | package cc // import "modernc.org/cc" 4 | 5 | import "fmt" 6 | 7 | const _Linkage_name = "NoneInternalExternal" 8 | 9 | var _Linkage_index = [...]uint8{0, 4, 12, 20} 10 | 11 | func (i Linkage) String() string { 12 | if i < 0 || i >= Linkage(len(_Linkage_index)-1) { 13 | return fmt.Sprintf("Linkage(%d)", i) 14 | } 15 | return _Linkage_name[_Linkage_index[i]:_Linkage_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/namespace_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type Namespace"; DO NOT EDIT. 2 | 3 | package cc // import "modernc.org/cc" 4 | 5 | import "fmt" 6 | 7 | const _Namespace_name = "NSIdentifiersNSTags" 8 | 9 | var _Namespace_index = [...]uint8{0, 13, 19} 10 | 11 | func (i Namespace) String() string { 12 | if i < 0 || i >= Namespace(len(_Namespace_index)-1) { 13 | return fmt.Sprintf("Namespace(%d)", i) 14 | } 15 | return _Namespace_name[_Namespace_index[i]:_Namespace_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/scope_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type Scope"; DO NOT EDIT. 2 | 3 | package cc // import "modernc.org/cc" 4 | 5 | import "fmt" 6 | 7 | const _Scope_name = "ScopeFileScopeBlockScopeMembersScopeParams" 8 | 9 | var _Scope_index = [...]uint8{0, 9, 19, 31, 42} 10 | 11 | func (i Scope) String() string { 12 | if i < 0 || i >= Scope(len(_Scope_index)-1) { 13 | return fmt.Sprintf("Scope(%d)", i) 14 | } 15 | return _Scope_name[_Scope_index[i]:_Scope_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/trigraphs.l: -------------------------------------------------------------------------------- 1 | %{ 2 | // Copyright 2016 The CC Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // Based on [0], 6.4. 7 | // 8 | 9 | // Implements translation phases 1 and 2 of [0], 5.1.1.2. 10 | %} 11 | 12 | %yyc c 13 | %yyn c = t.Next() 14 | %yym t.Mark() 15 | %yyt t.sc 16 | 17 | %s TRIGRAPHS 18 | 19 | %{ 20 | package cc 21 | 22 | import ( 23 | "fmt" 24 | ) 25 | 26 | const ( 27 | _ = iota 28 | scTRIGRAPHS 29 | ) 30 | 31 | func (t *trigraphsReader) scan() (r int) { 32 | c := t.Enter() 33 | %} 34 | 35 | %% 36 | c = t.Rule0() 37 | 38 | "??!" return '|' 39 | "??'" return '^' 40 | "??(" return '[' 41 | "??)" return ']' 42 | "??-" return '~' 43 | "??/" return '\\' 44 | "??<" return '{' 45 | "??=" return '#' 46 | "??>" return '}' 47 | 48 | \\\r?\n|\r | 49 | "??/"\r?\n 50 | 51 | %% 52 | if c, ok := t.Abort(); ok { 53 | return c 54 | } 55 | 56 | goto yyAction 57 | } 58 | -------------------------------------------------------------------------------- /vendor/modernc.org/cc/xerrors: -------------------------------------------------------------------------------- 1 | //TODO Revisit: PPIF PPOTHER '\n' '\n' "unterminated #if" 2 | 3 | CONSTANT_EXPRESSION | 4 | PREPROCESSING_FILE | 5 | TRANSLATION_UNIT "unexpected EOF" 6 | -------------------------------------------------------------------------------- /vendor/modernc.org/golex/AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists authors for copyright purposes. This file is distinct from 2 | # the CONTRIBUTORS files. See the latter for an explanation. 3 | # 4 | # Names should be added to this file as: 5 | # Name or Organization 6 | # 7 | # The email address is not required for organizations. 8 | # 9 | # Please keep the list sorted. 10 | 11 | CZ.NIC z.s.p.o. 12 | Jan Mercl <0xjnml@gmail.com> 13 | -------------------------------------------------------------------------------- /vendor/modernc.org/golex/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file lists people who contributed code to this repository. The AUTHORS 2 | # file lists the copyright holders; this file lists people. 3 | # 4 | # Names should be added to this file like so: 5 | # Name 6 | # 7 | # Please keep the list sorted. 8 | 9 | Alexey Neyhdanov 10 | Bill Thiede 11 | Jan Mercl <0xjnml@gmail.com> 12 | Jesse Szwedko 13 | Robert-André Mauchin -------------------------------------------------------------------------------- /vendor/modernc.org/golex/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 The golex 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 names of the authors nor the names of the 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/modernc.org/golex/lex/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015 The golex 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 | .PHONY: all clean cover cpu editor internalError later mem nuke todo 6 | 7 | grep=--include=*.go --include=*.l --include=*.y 8 | 9 | all: editor 10 | go vet || true 11 | golint || true 12 | make todo 13 | 14 | clean: 15 | go clean 16 | rm -f *~ cpu.test mem.test 17 | 18 | cover: 19 | t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t 20 | 21 | cpu: 22 | go test -c -o cpu.test 23 | ./cpu.test -noerr -test.cpuprofile cpu.out 24 | go tool pprof --lines cpu.test cpu.out 25 | 26 | editor: example_test.go 27 | gofmt -l -s -w *.go 28 | go test 29 | go install 30 | 31 | example_test.go: example.l 32 | golex -o $@ $< 33 | 34 | internalError: 35 | egrep -ho '"internal error.*"' *.go | sort | cat -n 36 | 37 | later: 38 | @grep -n $(grep) LATER * || true 39 | @grep -n $(grep) MAYBE * || true 40 | 41 | mem: 42 | go test -c -o mem.test 43 | ./mem.test -test.bench . -test.memprofile mem.out 44 | go tool pprof --lines --web --alloc_space mem.test mem.out 45 | 46 | nuke: clean 47 | go clean -i 48 | 49 | todo: 50 | @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true 51 | @grep -nr $(grep) TODO * || true 52 | @grep -nr $(grep) BUG * || true 53 | @grep -nr $(grep) [^[:alpha:]]println * || true 54 | -------------------------------------------------------------------------------- /vendor/modernc.org/golex/lex/dfa: -------------------------------------------------------------------------------- 1 | $ golex -DFA example.l 2 | StartConditions: 3 | INITIAL, scId:0, stateId:1 4 | DFA: 5 | [1] 6 | "\t"..."\n", "\r", " ", --> 2 7 | "0"..."9", --> 3 8 | "A"..."Z", "_", "a"..."e", "g"..."z", "\u0080", --> 4 9 | "f"--> 5 10 | [2] 11 | "\t"..."\n", "\r", " ", --> 2 12 | [3] 13 | "0"..."9", --> 3 14 | [4] 15 | "0"..."9", "A"..."Z", "_", "a"..."z", "\u0080"..."\u0081", --> 4 16 | [5] 17 | "0"..."9", "A"..."Z", "_", "a"..."t", "v"..."z", "\u0080"..."\u0081", --> 4 18 | "u"--> 6 19 | [6] 20 | "0"..."9", "A"..."Z", "_", "a"..."m", "o"..."z", "\u0080"..."\u0081", --> 4 21 | "n"--> 7 22 | [7] 23 | "0"..."9", "A"..."Z", "_", "a"..."b", "d"..."z", "\u0080"..."\u0081", --> 4 24 | "c"--> 8 25 | [8] 26 | "0"..."9", "A"..."Z", "_", "a"..."z", "\u0080"..."\u0081", --> 4 27 | state 2 accepts rule 1 28 | state 3 accepts rule 4 29 | state 4 accepts rule 3 30 | state 5 accepts rule 3 31 | state 6 accepts rule 3 32 | state 7 accepts rule 3 33 | state 8 accepts rule 2 34 | 35 | $ 36 | -------------------------------------------------------------------------------- /vendor/modernc.org/golex/lex/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 The golex 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 lex is a Unicode-friendly run time library for golex[0] generated 6 | // lexical analyzers[1]. 7 | // 8 | // Changelog 9 | // 10 | // 2015-04-08: Initial release. 11 | // 12 | // Character classes 13 | // 14 | // Golex internally handles only 8 bit "characters". Many Unicode-aware 15 | // tokenizers do not actually need to recognize every Unicode rune, but only 16 | // some particular partitions/subsets. Like, for example, a particular Unicode 17 | // category, say upper case letters: Lu. 18 | // 19 | // The idea is to convert all runes in a particular set as a single 8 bit 20 | // character allocated outside the ASCII range of codes. The token value, a 21 | // string of runes and their exact positions is collected as usual (see the 22 | // Token and TokenBytes method), but the tokenizer DFA is simpler (and thus 23 | // smaller and perhaps also faster) when this technique is used. In the example 24 | // program (see below), recognizing (and skipping) white space, integer 25 | // literals, one keyword and Go identifiers requires only an 8 state DFA[5]. 26 | // 27 | // To provide the conversion from runes to character classes, "install" your 28 | // converting function using the RuneClass option. 29 | // 30 | // References 31 | // 32 | // - 33 | // 34 | // [0]: http://godoc.org/modernc.org/golex 35 | // [1]: http://en.wikipedia.org/wiki/Lexical_analysis 36 | // [2]: http://golang.org/cmd/yacc/ 37 | // [3]: https://modernc.org/golex/blob/master/lex/example.l 38 | // [4]: http://golang.org/pkg/io/#RuneReader 39 | // [5]: https://modernc.org/golex/blob/master/lex/dfa 40 | package lex // import "modernc.org/golex/lex" 41 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists authors for copyright purposes. This file is distinct from 2 | # the CONTRIBUTORS files. See the latter for an explanation. 3 | # 4 | # Names should be added to this file as: 5 | # Name or Organization 6 | # 7 | # The email address is not required for organizations. 8 | # 9 | # Please keep the list sorted. 10 | 11 | CZ.NIC z.s.p.o. 12 | Edward Betts 13 | Jan Mercl <0xjnml@gmail.com> 14 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file lists people who contributed code to this repository. The AUTHORS 2 | # file lists the copyright holders; this file lists people. 3 | # 4 | # Names should be added to this file like so: 5 | # Name 6 | # 7 | # Please keep the list sorted. 8 | 9 | Bodecker DellaMaria 10 | Edward Betts 11 | Faiz Abbasi 12 | Gary Burd 13 | Jan Mercl <0xjnml@gmail.com> 14 | Muhammad Surya 15 | Santiago De la Cruz 16 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 The mathutil 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 names of the authors nor the names of the 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/modernc.org/mathutil/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The mathutil 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 | .PHONY: all clean cover cpu editor internalError later mem nuke todo edit 6 | 7 | grep=--include=*.go --include=*.l --include=*.y --include=*.yy 8 | ngrep='TODOOK\|parser\.go\|scanner\.go\|.*_string\.go' 9 | 10 | all: editor 11 | go vet 2>&1 | grep -v $(ngrep) || true 12 | golint 2>&1 | grep -v $(ngrep) || true 13 | make todo 14 | misspell *.go 15 | unconvert || true 16 | maligned || true 17 | staticcheck || true 18 | 19 | clean: 20 | go clean 21 | rm -f *~ *.test *.out 22 | 23 | cover: 24 | t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t 25 | 26 | cpu: clean 27 | go test -run @ -bench . -cpuprofile cpu.out 28 | go tool pprof -lines *.test cpu.out 29 | 30 | edit: 31 | @ 1>/dev/null 2>/dev/null gvim -p Makefile *.go & 32 | 33 | editor: 34 | gofmt -l -s -w *.go 35 | go test 36 | go build 37 | 38 | internalError: 39 | egrep -ho '"internal error.*"' *.go | sort | cat -n 40 | 41 | later: 42 | @grep -n $(grep) LATER * || true 43 | @grep -n $(grep) MAYBE * || true 44 | 45 | mem: clean 46 | go test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h 47 | go tool pprof -lines -web -alloc_space *.test mem.out 48 | 49 | nuke: clean 50 | go clean -i 51 | 52 | todo: 53 | @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true 54 | @grep -nr $(grep) TODO * | grep -v $(ngrep) || true 55 | @grep -nr $(grep) BUG * | grep -v $(ngrep) || true 56 | @grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true 57 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/README: -------------------------------------------------------------------------------- 1 | This is a goinstall-able mirror of modified code already published at: 2 | http://git.nic.cz/redmine/projects/gornd/repository 3 | 4 | Packages in this repository: 5 | 6 | Install: $ go get modernc.org/mathutil 7 | Godocs: http://godoc.org/modernc.org/mathutil 8 | 9 | Install: $ go get modernc.org/mathutil/mersenne 10 | Godocs: http://godoc.org/modernc.org/mathutil/mersenne 11 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/binarylog.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 The mathutil 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 mathutil // import "modernc.org/mathutil" 6 | 7 | import ( 8 | "math/big" 9 | ) 10 | 11 | type float struct { 12 | n *big.Int 13 | fracBits int 14 | maxFracBits int 15 | } 16 | 17 | func newFloat(n *big.Int, fracBits, maxFracBits int) float { 18 | f := float{n: n, fracBits: fracBits, maxFracBits: maxFracBits} 19 | f.normalize() 20 | return f 21 | } 22 | 23 | func (f *float) normalize() { 24 | n := f.n.BitLen() 25 | if n == 0 { 26 | return 27 | } 28 | 29 | if n := f.fracBits - f.maxFracBits; n > 0 { 30 | bit := f.n.Bit(n - 1) 31 | f.n.Rsh(f.n, uint(n)) 32 | if bit != 0 { 33 | f.n.Add(f.n, _1) 34 | } 35 | f.fracBits -= n 36 | } 37 | 38 | var i int 39 | for ; f.fracBits > 0 && i <= f.fracBits && f.n.Bit(i) == 0; i++ { 40 | f.fracBits-- 41 | } 42 | 43 | if i != 0 { 44 | f.n.Rsh(f.n, uint(i)) 45 | } 46 | } 47 | 48 | func (f *float) eq1() bool { return f.fracBits == 0 && f.n.BitLen() == 1 } 49 | func (f *float) ge2() bool { return f.n.BitLen() > f.fracBits+1 } 50 | 51 | func (f *float) div2() { 52 | f.fracBits++ 53 | f.normalize() 54 | } 55 | 56 | // BinaryLog computes the binary logarithm of n. The result consists of a 57 | // characteristic and a mantissa having precision mantissaBits. The value of 58 | // the binary logarithm is 59 | // 60 | // characteristic + mantissa*(2^-mantissaBits) 61 | // 62 | // BinaryLog panics for n <= 0 or mantissaBits < 0. 63 | func BinaryLog(n *big.Int, mantissaBits int) (characteristic int, mantissa *big.Int) { 64 | if n.Sign() <= 0 || mantissaBits < 0 { 65 | panic("invalid argument of BinaryLog") 66 | } 67 | 68 | characteristic = n.BitLen() - 1 69 | mantissa = big.NewInt(0) 70 | x := newFloat(n, characteristic, mantissaBits) 71 | for ; mantissaBits != 0 && !x.eq1(); mantissaBits-- { 72 | x.sqr() 73 | mantissa.Lsh(mantissa, 1) 74 | if x.ge2() { 75 | mantissa.SetBit(mantissa, 0, 1) 76 | x.div2() 77 | } 78 | } 79 | return characteristic, mantissa 80 | } 81 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/envelope.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 The mathutil 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 mathutil // import "modernc.org/mathutil" 6 | 7 | import ( 8 | "math" 9 | ) 10 | 11 | // Approximation type determines approximation methods used by e.g. Envelope. 12 | type Approximation int 13 | 14 | // Specific approximation method tags 15 | const ( 16 | _ Approximation = iota 17 | Linear // As named 18 | Sinusoidal // Smooth for all derivations 19 | ) 20 | 21 | // Envelope is an utility for defining simple curves using a small (usually) 22 | // set of data points. Envelope returns a value defined by x, points and 23 | // approximation. The value of x must be in [0,1) otherwise the result is 24 | // undefined or the function may panic. Points are interpreted as dividing the 25 | // [0,1) interval in len(points)-1 sections, so len(points) must be > 1 or the 26 | // function may panic. According to the left and right points closing/adjacent 27 | // to the section the resulting value is interpolated using the chosen 28 | // approximation method. Unsupported values of approximation are silently 29 | // interpreted as 'Linear'. 30 | func Envelope(x float64, points []float64, approximation Approximation) float64 { 31 | step := 1 / float64(len(points)-1) 32 | fslot := math.Floor(x / step) 33 | mod := x - fslot*step 34 | slot := int(fslot) 35 | l, r := points[slot], points[slot+1] 36 | rmod := mod / step 37 | switch approximation { 38 | case Sinusoidal: 39 | k := (math.Sin(math.Pi*(rmod-0.5)) + 1) / 2 40 | return l + (r-l)*k 41 | case Linear: 42 | fallthrough 43 | default: 44 | return l + (r-l)*rmod 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/go.mod: -------------------------------------------------------------------------------- 1 | module modernc.org/mathutil 2 | 3 | go 1.13 4 | 5 | require github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 6 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/go.sum: -------------------------------------------------------------------------------- 1 | github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= 2 | github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= 3 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/permute.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 The mathutil 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 mathutil // import "modernc.org/mathutil" 6 | 7 | import ( 8 | "sort" 9 | ) 10 | 11 | // PermutationFirst generates the first permutation of data. 12 | func PermutationFirst(data sort.Interface) { 13 | sort.Sort(data) 14 | } 15 | 16 | // PermutationNext generates the next permutation of data if possible and 17 | // return true. Return false if there is no more permutation left. Based on 18 | // the algorithm described here: 19 | // http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order 20 | func PermutationNext(data sort.Interface) bool { 21 | var k, l int 22 | for k = data.Len() - 2; ; k-- { // 1. 23 | if k < 0 { 24 | return false 25 | } 26 | 27 | if data.Less(k, k+1) { 28 | break 29 | } 30 | } 31 | for l = data.Len() - 1; !data.Less(k, l); l-- { // 2. 32 | } 33 | data.Swap(k, l) // 3. 34 | for i, j := k+1, data.Len()-1; i < j; i++ { // 4. 35 | data.Swap(i, j) 36 | j-- 37 | } 38 | return true 39 | } 40 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/rat.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 The mathutil 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 mathutil // import "modernc.org/mathutil" 6 | 7 | // QCmpUint32 compares a/b and c/d and returns: 8 | // 9 | // -1 if a/b < c/d 10 | // 0 if a/b == c/d 11 | // +1 if a/b > c/d 12 | // 13 | func QCmpUint32(a, b, c, d uint32) int { 14 | switch x, y := uint64(a)*uint64(d), uint64(b)*uint64(c); { 15 | case x < y: 16 | return -1 17 | case x == y: 18 | return 0 19 | default: // x > y 20 | return 1 21 | } 22 | } 23 | 24 | // QScaleUint32 returns a such that a/b >= c/d. 25 | func QScaleUint32(b, c, d uint32) (a uint64) { 26 | return 1 + (uint64(b)*uint64(c))/uint64(d) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/sqr.go: -------------------------------------------------------------------------------- 1 | // +build !riscv64 2 | 3 | package mathutil 4 | 5 | import "github.com/remyoudompheng/bigfft" 6 | 7 | func (f *float) sqr() { 8 | f.n = bigfft.Mul(f.n, f.n) 9 | f.fracBits *= 2 10 | f.normalize() 11 | } 12 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/sqr_std.go: -------------------------------------------------------------------------------- 1 | // +build riscv64 2 | 3 | package mathutil 4 | 5 | func (f *float) sqr() { 6 | f.n.Mul(f.n, f.n) 7 | f.fracBits *= 2 8 | f.normalize() 9 | } 10 | -------------------------------------------------------------------------------- /vendor/modernc.org/mathutil/test_deps.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 The mathutil 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 mathutil // import "modernc.org/mathutil" 6 | 7 | // Pull test dependencies too. 8 | // Enables easy 'go test X' after 'go get X' 9 | import ( 10 | // nothing yet 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/modernc.org/strutil/AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists authors for copyright purposes. This file is distinct from 2 | # the CONTRIBUTORS files. See the latter for an explanation. 3 | # 4 | # Names should be added to this file as: 5 | # Name or Organization 6 | # 7 | # The email address is not required for organizations. 8 | # 9 | # Please keep the list sorted. 10 | 11 | CZ.NIC z.s.p.o. 12 | Jan Mercl <0xjnml@gmail.com> 13 | -------------------------------------------------------------------------------- /vendor/modernc.org/strutil/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file lists people who contributed code to this repository. The AUTHORS 2 | # file lists the copyright holders; this file lists people. 3 | # 4 | # Names should be added to this file like so: 5 | # Name 6 | # 7 | # Please keep the list sorted. 8 | 9 | Jan Mercl <0xjnml@gmail.com> 10 | -------------------------------------------------------------------------------- /vendor/modernc.org/strutil/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 The strutil 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 names of the authors nor the names of the 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/modernc.org/strutil/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014 The sortutil 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 | .PHONY: all clean cover cpu editor internalError later mem nuke todo edit 6 | 7 | grep=--include=*.go --include=*.l --include=*.y --include=*.yy 8 | ngrep='TODOOK\|parser\.go\|scanner\.go\|.*_string\.go' 9 | 10 | all: editor 11 | go vet 2>&1 | grep -v $(ngrep) || true 12 | golint 2>&1 | grep -v $(ngrep) || true 13 | make todo 14 | unused . || true 15 | misspell *.go 16 | gosimple || true 17 | maligned || true 18 | unconvert -apply 19 | 20 | clean: 21 | go clean 22 | rm -f *~ *.test *.out 23 | 24 | cover: 25 | t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t 26 | 27 | cpu: clean 28 | go test -run @ -bench . -cpuprofile cpu.out 29 | go tool pprof -lines *.test cpu.out 30 | 31 | edit: 32 | @ 1>/dev/null 2>/dev/null gvim -p Makefile *.go 33 | 34 | editor: 35 | unconvert -apply || true 36 | gofmt -l -s -w *.go 37 | go test -i 38 | go test 2>&1 | tee log 39 | go install 40 | 41 | internalError: 42 | egrep -ho '"internal error.*"' *.go | sort | cat -n 43 | 44 | later: 45 | @grep -n $(grep) LATER * || true 46 | @grep -n $(grep) MAYBE * || true 47 | 48 | mem: clean 49 | go test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h 50 | go tool pprof -lines -web -alloc_space *.test mem.out 51 | 52 | nuke: clean 53 | go clean -i 54 | 55 | todo: 56 | @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true 57 | @grep -nr $(grep) TODO * | grep -v $(ngrep) || true 58 | @grep -nr $(grep) BUG * | grep -v $(ngrep) || true 59 | @grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true 60 | -------------------------------------------------------------------------------- /vendor/modernc.org/strutil/README: -------------------------------------------------------------------------------- 1 | modernc.orgall-able mirror of modified code already published at: 2 | http://git.nic.cz/redmine/projects/gostrutil/repository 3 | 4 | Online godoc documentation for this package (should be) available at: 5 | http://gopkgdoc.appspot.com/pkg/modernc.org/strutil 6 | 7 | Installation: 8 | $ go get modernc.org/strutil 9 | -------------------------------------------------------------------------------- /vendor/modernc.org/strutil/go.mod: -------------------------------------------------------------------------------- 1 | module modernc.org/strutil 2 | 3 | go 1.15 4 | 5 | require modernc.org/mathutil v1.2.2 6 | -------------------------------------------------------------------------------- /vendor/modernc.org/strutil/go.sum: -------------------------------------------------------------------------------- 1 | github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= 2 | github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= 3 | modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY= 4 | modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= 5 | -------------------------------------------------------------------------------- /vendor/modernc.org/xc/AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists authors for copyright purposes. This file is distinct from 2 | # the CONTRIBUTORS files. See the latter for an explanation. 3 | # 4 | # Names should be added to this file as: 5 | # Name or Organization 6 | # 7 | # The email address is not required for organizations. 8 | # 9 | # Please keep the list sorted. 10 | 11 | Jan Mercl <0xjnml@gmail.com> 12 | -------------------------------------------------------------------------------- /vendor/modernc.org/xc/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file lists people who contributed code to this repository. The AUTHORS 2 | # file lists the copyright holders; this file lists people. 3 | # 4 | # Names should be added to this file like so: 5 | # Name 6 | # 7 | # Please keep the list sorted. 8 | 9 | Jan Mercl <0xjnml@gmail.com> 10 | -------------------------------------------------------------------------------- /vendor/modernc.org/xc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 The XC 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 names of the authors nor the names of the 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/modernc.org/xc/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The XC 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 | .PHONY: all clean cover cpu editor internalError later mem nuke todo edit 6 | 7 | grep=--include=*.go --include=*.l --include=*.y --include=*.yy 8 | ngrep='TODOOK\|parser\.go\|scanner\.go\|.*_string\.go' 9 | 10 | all: editor 11 | go vet 2>&1 | grep -v $(ngrep) || true 12 | golint 2>&1 | grep -v $(ngrep) || true 13 | make todo 14 | unused . || true 15 | misspell *.go 16 | gosimple || true 17 | codesweep || true 18 | maligned || true 19 | unconvert -apply 20 | 21 | clean: 22 | go clean 23 | rm -f *~ *.test *.out 24 | 25 | cover: 26 | t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t 27 | 28 | cpu: clean 29 | go test -run @ -bench . -cpuprofile cpu.out 30 | go tool pprof -lines *.test cpu.out 31 | 32 | edit: 33 | @ 1>/dev/null 2>/dev/null gvim -p Makefile *.go 34 | 35 | editor: 36 | gofmt -l -s -w *.go 37 | go test -i 38 | go test 2>&1 | tee log 39 | go install 40 | 41 | internalError: 42 | egrep -ho '"internal error.*"' *.go | sort | cat -n 43 | 44 | later: 45 | @grep -n $(grep) LATER * || true 46 | @grep -n $(grep) MAYBE * || true 47 | 48 | mem: clean 49 | go test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h 50 | go tool pprof -lines -web -alloc_space *.test mem.out 51 | 52 | nuke: clean 53 | go clean -i 54 | 55 | todo: 56 | @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true 57 | @grep -nr $(grep) TODO * | grep -v $(ngrep) || true 58 | @grep -nr $(grep) BUG * | grep -v $(ngrep) || true 59 | @grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true 60 | -------------------------------------------------------------------------------- /vendor/modernc.org/xc/README.md: -------------------------------------------------------------------------------- 1 | # xc 2 | Package xc provides cross language compiler support/utility stuff. 3 | 4 | Installation 5 | 6 | $ go get modernc.org/xc 7 | 8 | Documentation: [godoc.org/modernc.org/xc](http://godoc.org/modernc.org/xc) 9 | -------------------------------------------------------------------------------- /vendor/modernc.org/xc/db.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The XC 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 xc // import "modernc.org/xc" 6 | 7 | import ( 8 | "encoding/binary" 9 | "sync" 10 | 11 | "modernc.org/mathutil" 12 | ) 13 | 14 | const ( 15 | maxUvarint = (64 + 7) / 7 16 | dbPageShift = 20 //TODO bench tune. 17 | dbPageSize = 1 << dbPageShift 18 | dbPageMask = dbPageSize - 1 19 | ) 20 | 21 | // MemDB stores data accessible using a numeric identifier. 22 | type MemDB struct { 23 | b256 [256]byte 24 | mu sync.RWMutex // Access guard. 25 | nextID int 26 | pages [][]byte 27 | } 28 | 29 | // NewMemDB returns a newly create *MemDB. 30 | func NewMemDB() *MemDB { 31 | d := &MemDB{} 32 | for i := 0; i < 256; i++ { 33 | d.b256[i] = byte(i) 34 | } 35 | return d 36 | } 37 | 38 | // Bytes returns the byte slice associated with id. Passing id not obtained by 39 | // PutBytes has undefined behavior. Bytes RLocks the DB to obtain the result. 40 | // 41 | // NOTE: The result refers to the DB backing storage directly without copying 42 | // and is thus strictly R/O. 43 | func (d *MemDB) Bytes(id int) []byte { 44 | if id == 0 { 45 | return nil 46 | } 47 | 48 | if id < 257 { 49 | return d.b256[id-1 : id : id] 50 | } 51 | 52 | id -= 257 53 | off := id & dbPageMask 54 | 55 | d.mu.RLock() // R+ 56 | 57 | page := d.pages[id>>dbPageShift] 58 | n, l := binary.Uvarint(page[off:]) 59 | off += l 60 | h := off + int(n) 61 | r := page[off:h:h] 62 | 63 | d.mu.RUnlock() // R- 64 | 65 | return r 66 | } 67 | 68 | // bytesUnlocked is like Bytes but it does not RLock the DB. 69 | func (d *MemDB) bytesUnlocked(id int) []byte { 70 | if id == 0 { 71 | return nil 72 | } 73 | 74 | if id < 257 { 75 | return d.b256[id-1 : id : id] 76 | } 77 | 78 | id -= 257 79 | off := id & dbPageMask 80 | 81 | page := d.pages[id>>dbPageShift] 82 | n, l := binary.Uvarint(page[off:]) 83 | off += l 84 | r := page[off : off+int(n)] 85 | 86 | return r 87 | } 88 | 89 | // Cap reports the current DB capacity. 90 | func (d *MemDB) Cap() int { 91 | d.mu.RLock() // R+ 92 | 93 | r := 0 94 | for _, v := range d.pages { 95 | r += cap(v) 96 | } 97 | 98 | d.mu.RUnlock() // R- 99 | 100 | return r 101 | } 102 | 103 | // Len reports the size of the DB used by data. 104 | func (d *MemDB) Len() int { 105 | d.mu.RLock() // R+ 106 | 107 | r := 0 108 | for _, v := range d.pages { 109 | r += len(v) 110 | } 111 | 112 | d.mu.RUnlock() // R- 113 | 114 | return r 115 | } 116 | 117 | // PutBytes stores b in the DB and returns its id. Zero length byte slices are 118 | // guaranteed to return zero ID. PutBytes Locks the DB before updating it. 119 | func (d *MemDB) PutBytes(b []byte) int { 120 | if len(b) == 0 { 121 | return 0 122 | } 123 | 124 | if len(b) == 1 { 125 | return int(b[0]) + 1 126 | } 127 | 128 | d.mu.Lock() // W+ 129 | 130 | id := d.nextID 131 | pi := id >> dbPageShift 132 | if pi < len(d.pages) { 133 | p := d.pages[pi] 134 | off := id & dbPageMask 135 | if n := cap(p) - off - maxUvarint; n >= len(b) { 136 | p = p[:cap(p)] 137 | l := binary.PutUvarint(p[off:], uint64(len(b))) 138 | copy(p[off+l:], b) 139 | n = l + len(b) 140 | d.pages[pi] = p[:off+n] 141 | d.nextID += n 142 | 143 | d.mu.Unlock() // W- 144 | 145 | return id + 257 146 | } 147 | 148 | pi++ 149 | } 150 | 151 | p := make([]byte, mathutil.Max(dbPageSize, maxUvarint+len(b))) 152 | p = p[:binary.PutUvarint(p, uint64(len(b)))] 153 | p = append(p, b...) 154 | d.pages = append(d.pages, p) 155 | id = pi << dbPageShift 156 | d.nextID = id + mathutil.Min(dbPageSize, len(p)) 157 | 158 | d.mu.Unlock() // W- 159 | 160 | return id + 257 161 | } 162 | -------------------------------------------------------------------------------- /vendor/modernc.org/xc/lexer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The XC 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 xc // import "modernc.org/xc" 6 | 7 | import ( 8 | "go/token" 9 | 10 | "modernc.org/golex/lex" 11 | "modernc.org/strutil" 12 | ) 13 | 14 | // Token describes a token. 15 | type Token struct { 16 | lex.Char // Token rune and position. 17 | Val int // ID of token value in the global Dict variable. 18 | } 19 | 20 | // S returns a R/O value of t, ie. Dict.S(t.Val). 21 | func (t Token) S() []byte { return Dict.S(t.Val) } 22 | 23 | // String implements fmt.Stringer. 24 | func (t Token) String() string { return strutil.PrettyString(t, "", "", PrintHooks) } 25 | 26 | // Position returns position of t. 27 | func (t *Token) Position() token.Position { return FileSet.Position(t.Pos()) } 28 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/davecgh/go-spew v1.1.1 2 | github.com/davecgh/go-spew/spew 3 | # github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 4 | github.com/golang/geo/r1 5 | github.com/golang/geo/r2 6 | github.com/golang/geo/r3 7 | github.com/golang/geo/s1 8 | github.com/golang/geo/s2 9 | # github.com/pmezard/go-difflib v1.0.0 10 | github.com/pmezard/go-difflib/difflib 11 | # github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 12 | github.com/remyoudompheng/bigfft 13 | # github.com/stretchr/testify v1.7.0 14 | github.com/stretchr/testify/assert 15 | github.com/stretchr/testify/require 16 | # github.com/tj/go-spin v1.1.0 17 | github.com/tj/go-spin 18 | # github.com/xlab/c-for-go v0.0.0-20201223145653-3ba5db515dcb 19 | github.com/xlab/c-for-go 20 | github.com/xlab/c-for-go/generator 21 | github.com/xlab/c-for-go/parser 22 | github.com/xlab/c-for-go/translator 23 | # github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245 24 | github.com/xlab/pkgconfig/pkg 25 | # golang.org/x/mod v0.5.1 26 | golang.org/x/mod/internal/lazyregexp 27 | golang.org/x/mod/module 28 | golang.org/x/mod/semver 29 | # golang.org/x/sys v0.0.0-20211210111614-af8b64212486 30 | golang.org/x/sys/execabs 31 | # golang.org/x/tools v0.1.8 32 | golang.org/x/tools/go/ast/astutil 33 | golang.org/x/tools/imports 34 | golang.org/x/tools/internal/event 35 | golang.org/x/tools/internal/event/core 36 | golang.org/x/tools/internal/event/keys 37 | golang.org/x/tools/internal/event/label 38 | golang.org/x/tools/internal/fastwalk 39 | golang.org/x/tools/internal/gocommand 40 | golang.org/x/tools/internal/gopathwalk 41 | golang.org/x/tools/internal/imports 42 | golang.org/x/tools/internal/typeparams 43 | # golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 44 | golang.org/x/xerrors 45 | golang.org/x/xerrors/internal 46 | # gopkg.in/yaml.v2 v2.4.0 47 | gopkg.in/yaml.v2 48 | # gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b 49 | gopkg.in/yaml.v3 50 | # modernc.org/cc v1.0.1 51 | modernc.org/cc 52 | # modernc.org/golex v1.0.1 53 | modernc.org/golex/lex 54 | # modernc.org/mathutil v1.4.1 55 | modernc.org/mathutil 56 | # modernc.org/strutil v1.1.1 57 | modernc.org/strutil 58 | # modernc.org/xc v1.0.0 59 | modernc.org/xc 60 | --------------------------------------------------------------------------------