@@ -22,11 +22,8 @@ require ( | |||
github.com/alecthomas/chroma v0.8.2 | |||
github.com/andybalholm/brotli v1.0.1 // indirect | |||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect | |||
github.com/blevesearch/bleve v1.0.13 | |||
github.com/blevesearch/bleve v1.0.14 | |||
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect | |||
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d // indirect | |||
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect | |||
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537 // indirect | |||
github.com/denisenkom/go-mssqldb v0.9.0 | |||
github.com/dgrijalva/jwt-go v3.2.0+incompatible | |||
github.com/dlclark/regexp2 v1.4.0 // indirect | |||
@@ -34,9 +31,6 @@ require ( | |||
github.com/editorconfig/editorconfig-core-go/v2 v2.3.9 | |||
github.com/emirpasic/gods v1.12.0 | |||
github.com/ethantkoenig/rupture v0.0.0-20181029165146-c3b3b810dc77 | |||
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 // indirect | |||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect | |||
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect | |||
github.com/gliderlabs/ssh v0.3.1 | |||
github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a // indirect | |||
github.com/go-chi/chi v1.5.0 | |||
@@ -61,7 +55,6 @@ require ( | |||
github.com/issue9/assert v1.3.2 // indirect | |||
github.com/issue9/identicon v1.0.1 | |||
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 | |||
github.com/jmhodges/levigo v1.0.0 // indirect | |||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 | |||
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4 | |||
github.com/klauspost/compress v1.11.3 | |||
@@ -87,13 +80,11 @@ require ( | |||
github.com/olivere/elastic/v7 v7.0.21 | |||
github.com/onsi/ginkgo v1.13.0 // indirect | |||
github.com/pelletier/go-toml v1.8.1 | |||
github.com/philhofer/fwd v1.1.0 // indirect | |||
github.com/pierrec/lz4/v4 v4.1.1 // indirect | |||
github.com/pkg/errors v0.9.1 | |||
github.com/pquerna/otp v1.2.0 | |||
github.com/prometheus/client_golang v1.8.0 | |||
github.com/quasoft/websspi v1.0.0 | |||
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 // indirect | |||
github.com/sergi/go-diff v1.1.0 | |||
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect | |||
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 | |||
@@ -101,8 +92,7 @@ require ( | |||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect | |||
github.com/stretchr/testify v1.6.1 | |||
github.com/syndtr/goleveldb v1.0.0 | |||
github.com/tecbot/gorocksdb v0.0.0-20181010114359-8752a9433481 // indirect | |||
github.com/tinylib/msgp v1.1.2 // indirect | |||
github.com/tinylib/msgp v1.1.5 // indirect | |||
github.com/tstranex/u2f v1.0.0 | |||
github.com/ulikunitz/xz v0.5.8 // indirect | |||
github.com/unknwon/com v1.0.1 | |||
@@ -120,10 +110,10 @@ require ( | |||
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 | |||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 | |||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 | |||
golang.org/x/sys v0.0.0-20201106081118-db71ae66460a | |||
golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f | |||
golang.org/x/text v0.3.4 | |||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect | |||
golang.org/x/tools v0.0.0-20200929161345-d7fc70abf50f | |||
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9 | |||
google.golang.org/appengine v1.6.7 // indirect | |||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect | |||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df |
@@ -162,10 +162,11 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r | |||
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= | |||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= | |||
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= | |||
github.com/blevesearch/bleve v1.0.13 h1:NtqdA+2UL715y2/9Epg9Ie9uspNcilGMYNM+tT+HfAo= | |||
github.com/blevesearch/bleve v1.0.13/go.mod h1:3y+16vR4Cwtis/bOGCt7r+CHKB2/ewizEqKBUycXomA= | |||
github.com/blevesearch/blevex v0.0.0-20190916190636-152f0fe5c040 h1:SjYVcfJVZoCfBlg+fkaq2eoZHTf5HaJfaTeTkOtyfHQ= | |||
github.com/blevesearch/blevex v0.0.0-20190916190636-152f0fe5c040/go.mod h1:WH+MU2F4T0VmSdaPX+Wu5GYoZBrYWdOZWSjzvYcDmqQ= | |||
github.com/blevesearch/bleve v1.0.14 h1:Q8r+fHTt35jtGXJUM0ULwM3Tzg+MRfyai4ZkWDy2xO4= | |||
github.com/blevesearch/bleve v1.0.14/go.mod h1:e/LJTr+E7EaoVdkQZTfoz7dt4KoDNvDbLb8MSKuNTLQ= | |||
github.com/blevesearch/blevex v1.0.0 h1:pnilj2Qi3YSEGdWgLj1Pn9Io7ukfXPoQcpAI1Bv8n/o= | |||
github.com/blevesearch/blevex v1.0.0/go.mod h1:2rNVqoG2BZI8t1/P1awgTKnGlx5MP9ZbtEciQaNhswc= | |||
github.com/blevesearch/cld2 v0.0.0-20200327141045-8b5f551d37f5/go.mod h1:PN0QNTLs9+j1bKy3d/GB/59wsNBFC4sWLWG3k69lWbc= | |||
github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo= | |||
github.com/blevesearch/go-porterstemmer v1.0.3/go.mod h1:angGc5Ht+k2xhJdZi511LtmxuEf0OVpvUUNrwmM1P7M= | |||
github.com/blevesearch/mmap-go v1.0.2 h1:JtMHb+FgQCTTYIhtMvimw15dJwu1Y5lrZDMOFXVWPk0= | |||
@@ -174,16 +175,16 @@ github.com/blevesearch/segment v0.9.0 h1:5lG7yBCx98or7gK2cHMKPukPZ/31Kag7nONpoBt | |||
github.com/blevesearch/segment v0.9.0/go.mod h1:9PfHYUdQCgHktBgvtUOF4x+pc4/l8rdH0u5spnW85UQ= | |||
github.com/blevesearch/snowballstem v0.9.0 h1:lMQ189YspGP6sXvZQ4WZ+MLawfV8wOmPoD/iWeNXm8s= | |||
github.com/blevesearch/snowballstem v0.9.0/go.mod h1:PivSj3JMc8WuaFkTSRDW2SlrulNWPl4ABg1tC/hlgLs= | |||
github.com/blevesearch/zap/v11 v11.0.13 h1:NDvmjAyeEQsBbPElubVPqrBtSDOftXYwxkHeZfflU4A= | |||
github.com/blevesearch/zap/v11 v11.0.13/go.mod h1:qKkNigeXbxZwym02wsxoQpbme1DgAwTvRlT/beIGfTM= | |||
github.com/blevesearch/zap/v12 v12.0.13 h1:05Ebdmv2tRTUytypG4DlOIHLLw995DtVV0Zl3YwwDew= | |||
github.com/blevesearch/zap/v12 v12.0.13/go.mod h1:0RTeU1uiLqsPoybUn6G/Zgy6ntyFySL3uWg89NgX3WU= | |||
github.com/blevesearch/zap/v13 v13.0.5 h1:+Gcwl95uei3MgBlJAddBFRv9gl+FMNcXpMa7BX3byJw= | |||
github.com/blevesearch/zap/v13 v13.0.5/go.mod h1:HTfWECmzBN7BbdBxdEigpUsD6MOPFOO84tZ0z/g3CnE= | |||
github.com/blevesearch/zap/v14 v14.0.4 h1:BnWWkdgmPhK50J9dkBlQrWB4UDa22OMPIUzn1oXcXfY= | |||
github.com/blevesearch/zap/v14 v14.0.4/go.mod h1:sTwuFoe1n/+VtaHNAjY3W5GzHZ5UxFkw1MZ82P/WKpA= | |||
github.com/blevesearch/zap/v15 v15.0.2 h1:7wV4ksnKzBibLaWBolzbxngxdVAUmF7HJ+gMOqkzsdQ= | |||
github.com/blevesearch/zap/v15 v15.0.2/go.mod h1:nfycXPgfbio8l+ZSkXUkhSNjTpp57jZ0/MKa6TigWvM= | |||
github.com/blevesearch/zap/v11 v11.0.14 h1:IrDAvtlzDylh6H2QCmS0OGcN9Hpf6mISJlfKjcwJs7k= | |||
github.com/blevesearch/zap/v11 v11.0.14/go.mod h1:MUEZh6VHGXv1PKx3WnCbdP404LGG2IZVa/L66pyFwnY= | |||
github.com/blevesearch/zap/v12 v12.0.14 h1:2o9iRtl1xaRjsJ1xcqTyLX414qPAwykHNV7wNVmbp3w= | |||
github.com/blevesearch/zap/v12 v12.0.14/go.mod h1:rOnuZOiMKPQj18AEKEHJxuI14236tTQ1ZJz4PAnWlUg= | |||
github.com/blevesearch/zap/v13 v13.0.6 h1:r+VNSVImi9cBhTNNR+Kfl5uiGy8kIbb0JMz/h8r6+O4= | |||
github.com/blevesearch/zap/v13 v13.0.6/go.mod h1:L89gsjdRKGyGrRN6nCpIScCvvkyxvmeDCwZRcjjPCrw= | |||
github.com/blevesearch/zap/v14 v14.0.5 h1:NdcT+81Nvmp2zL+NhwSvGSLh7xNgGL8QRVZ67njR0NU= | |||
github.com/blevesearch/zap/v14 v14.0.5/go.mod h1:bWe8S7tRrSBTIaZ6cLRbgNH4TUDaC9LZSpRGs85AsGY= | |||
github.com/blevesearch/zap/v15 v15.0.3 h1:Ylj8Oe+mo0P25tr9iLPp33lN6d4qcztGjaIsP51UxaY= | |||
github.com/blevesearch/zap/v15 v15.0.3/go.mod h1:iuwQrImsh1WjWJ0Ue2kBqY83a0rFtJTqfa9fp1rbVVU= | |||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI= | |||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= | |||
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668 h1:U/lr3Dgy4WK+hNk4tyD+nuGjpVLPEHuJSFXMw11/HPA= | |||
@@ -291,12 +292,12 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m | |||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= | |||
github.com/ethantkoenig/rupture v0.0.0-20181029165146-c3b3b810dc77 h1:ZLWiTTzTUBb0WEXUxobYI/RxULIzOoIP7pgfDd4p1cw= | |||
github.com/ethantkoenig/rupture v0.0.0-20181029165146-c3b3b810dc77/go.mod h1:MkKY/CB98aVE4VxO63X5vTQKUgcn+3XP15LMASe3lYs= | |||
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= | |||
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= | |||
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= | |||
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= | |||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= | |||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= | |||
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y= | |||
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= | |||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= | |||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= | |||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= | |||
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= | |||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= | |||
@@ -608,6 +609,7 @@ github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw | |||
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= | |||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= | |||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= | |||
github.com/ikawaha/kagome.ipadic v1.1.2/go.mod h1:DPSBbU0czaJhAb/5uKQZHMc9MTVRpDugJfX+HddPHHg= | |||
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg= | |||
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= | |||
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA= | |||
@@ -899,8 +901,8 @@ github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrap | |||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= | |||
github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= | |||
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= | |||
github.com/philhofer/fwd v1.1.0 h1:PAdZw9+/BCf4gc/kA2L/PbGPkFe72Kl2GLZXTG8HpU8= | |||
github.com/philhofer/fwd v1.1.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= | |||
github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ= | |||
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= | |||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= | |||
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= | |||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= | |||
@@ -957,8 +959,8 @@ github.com/quasoft/websspi v1.0.0 h1:5nDgdM5xSur9s+B5w2xQ5kxf5nUGqgFgU4W0aDLZ8Mw | |||
github.com/quasoft/websspi v1.0.0/go.mod h1:HmVdl939dQ0WIXZhyik+ARdI03M6bQzaSEKcgpFmewk= | |||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= | |||
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= | |||
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 h1:YDeskXpkNDhPdWN3REluVa46HQOVuVkjkd2sWnrABNQ= | |||
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= | |||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= | |||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= | |||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= | |||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= | |||
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= | |||
@@ -1055,19 +1057,21 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s | |||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= | |||
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= | |||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= | |||
github.com/tecbot/gorocksdb v0.0.0-20181010114359-8752a9433481 h1:HOxvxvnntLiPn123Fk+twfUhCQdMDaqmb0cclArW0T0= | |||
github.com/tecbot/gorocksdb v0.0.0-20181010114359-8752a9433481/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= | |||
github.com/tebeka/snowball v0.4.2/go.mod h1:4IfL14h1lvwZcp1sfXuuc7/7yCsvVffTWxWxCLfFpYg= | |||
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= | |||
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= | |||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= | |||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= | |||
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= | |||
github.com/tinylib/msgp v1.1.2 h1:gWmO7n0Ys2RBEb7GPYB9Ujq8Mk5p2U08lRnmMcGy6BQ= | |||
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= | |||
github.com/tinylib/msgp v1.1.5 h1:2gXmtWueD2HefZHQe1QOy9HVzmFrLOVvsXwXBQ0ayy0= | |||
github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= | |||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= | |||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= | |||
github.com/toqueteos/webbrowser v1.2.0 h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ= | |||
github.com/toqueteos/webbrowser v1.2.0/go.mod h1:XWoZq4cyp9WeUeak7w7LXRUQf1F1ATJMir8RTqb4ayM= | |||
github.com/tstranex/u2f v1.0.0 h1:HhJkSzDDlVSVIVt7pDJwCHQj67k7A5EeBgPmeD+pVsQ= | |||
github.com/tstranex/u2f v1.0.0/go.mod h1:eahSLaqAS0zsIEv80+vXT7WanXs7MQQDg3j3wGBSayo= | |||
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= | |||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= | |||
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8= | |||
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= | |||
@@ -1252,6 +1256,7 @@ golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81R | |||
golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 h1:YfxMZzv3PjGonQYNUaeU2+DhAdqOxerQ30JFB6WgAXo= | |||
golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | |||
golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | |||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | |||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 h1:42cLlJJdEh+ySyeUUbEQ5bsTiq8voBeTuweGVkY6Puw= | |||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | |||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | |||
@@ -1272,6 +1277,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ | |||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | |||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | |||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | |||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | |||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |||
@@ -1340,8 +1346,8 @@ golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7w | |||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88= | |||
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
golang.org/x/sys v0.0.0-20201106081118-db71ae66460a h1:ALUFBKlIyeY7y5ZgPJmblk/vKz+zBQSnNiPkt41sgeg= | |||
golang.org/x/sys v0.0.0-20201106081118-db71ae66460a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f h1:QdHQnPce6K4XQewki9WNbG5KOROuDzqO3NaYjI1cXJ0= | |||
golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |||
@@ -1430,6 +1436,8 @@ golang.org/x/tools v0.0.0-20200921210052-fa0125251cc4/go.mod h1:z6u4i615ZeAfBE4X | |||
golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= | |||
golang.org/x/tools v0.0.0-20200929161345-d7fc70abf50f h1:18s2P7JILnVhIF2+ZtGJQ9czV5bvTsb13/UGtNPDbjA= | |||
golang.org/x/tools v0.0.0-20200929161345-d7fc70abf50f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= | |||
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9 h1:sEvmEcJVKBNUvgCUClbUQeHOAa9U0I2Ce1BooMvVCY4= | |||
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | |||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
@@ -4,15 +4,15 @@ go 1.13 | |||
require ( | |||
github.com/RoaringBitmap/roaring v0.4.23 | |||
github.com/blevesearch/blevex v0.0.0-20190916190636-152f0fe5c040 | |||
github.com/blevesearch/blevex v1.0.0 | |||
github.com/blevesearch/go-porterstemmer v1.0.3 | |||
github.com/blevesearch/segment v0.9.0 | |||
github.com/blevesearch/snowballstem v0.9.0 | |||
github.com/blevesearch/zap/v11 v11.0.13 | |||
github.com/blevesearch/zap/v12 v12.0.13 | |||
github.com/blevesearch/zap/v13 v13.0.5 | |||
github.com/blevesearch/zap/v14 v14.0.4 | |||
github.com/blevesearch/zap/v15 v15.0.2 | |||
github.com/blevesearch/zap/v11 v11.0.14 | |||
github.com/blevesearch/zap/v12 v12.0.14 | |||
github.com/blevesearch/zap/v13 v13.0.6 | |||
github.com/blevesearch/zap/v14 v14.0.5 | |||
github.com/blevesearch/zap/v15 v15.0.3 | |||
github.com/couchbase/moss v0.1.0 | |||
github.com/couchbase/vellum v1.0.2 | |||
github.com/golang/protobuf v1.3.2 |
@@ -4,7 +4,7 @@ go 1.12 | |||
require ( | |||
github.com/RoaringBitmap/roaring v0.4.23 | |||
github.com/blevesearch/bleve v1.0.13 | |||
github.com/blevesearch/bleve v1.0.14 | |||
github.com/blevesearch/mmap-go v1.0.2 | |||
github.com/couchbase/vellum v1.0.2 | |||
github.com/golang/snappy v0.0.1 |
@@ -4,7 +4,7 @@ go 1.12 | |||
require ( | |||
github.com/RoaringBitmap/roaring v0.4.23 | |||
github.com/blevesearch/bleve v1.0.13 | |||
github.com/blevesearch/bleve v1.0.14 | |||
github.com/blevesearch/mmap-go v1.0.2 | |||
github.com/couchbase/vellum v1.0.2 | |||
github.com/golang/snappy v0.0.1 |
@@ -4,7 +4,7 @@ go 1.12 | |||
require ( | |||
github.com/RoaringBitmap/roaring v0.4.23 | |||
github.com/blevesearch/bleve v1.0.13 | |||
github.com/blevesearch/bleve v1.0.14 | |||
github.com/blevesearch/mmap-go v1.0.2 | |||
github.com/couchbase/vellum v1.0.2 | |||
github.com/golang/snappy v0.0.1 |
@@ -4,7 +4,7 @@ go 1.12 | |||
require ( | |||
github.com/RoaringBitmap/roaring v0.4.23 | |||
github.com/blevesearch/bleve v1.0.13 | |||
github.com/blevesearch/bleve v1.0.14 | |||
github.com/blevesearch/mmap-go v1.0.2 | |||
github.com/couchbase/vellum v1.0.2 | |||
github.com/golang/snappy v0.0.1 |
@@ -4,7 +4,7 @@ go 1.12 | |||
require ( | |||
github.com/RoaringBitmap/roaring v0.4.23 | |||
github.com/blevesearch/bleve v1.0.13 | |||
github.com/blevesearch/bleve v1.0.14 | |||
github.com/blevesearch/mmap-go v1.0.2 | |||
github.com/couchbase/vellum v1.0.2 | |||
github.com/golang/snappy v0.0.1 |
@@ -34,7 +34,10 @@ | |||
// | |||
package fwd | |||
import "io" | |||
import ( | |||
"io" | |||
"os" | |||
) | |||
const ( | |||
// DefaultReaderSize is the default size of the read buffer | |||
@@ -187,6 +190,19 @@ func (r *Reader) Peek(n int) ([]byte, error) { | |||
return r.data[r.n : r.n+n], nil | |||
} | |||
// discard(n) discards up to 'n' buffered bytes, and | |||
// and returns the number of bytes discarded | |||
func (r *Reader) discard(n int) int { | |||
inbuf := r.buffered() | |||
if inbuf <= n { | |||
r.n = 0 | |||
r.data = r.data[:0] | |||
return inbuf | |||
} | |||
r.n += n | |||
return n | |||
} | |||
// Skip moves the reader forward 'n' bytes. | |||
// Returns the number of bytes skipped and any | |||
// errors encountered. It is analogous to Seek(n, 1). | |||
@@ -201,33 +217,25 @@ func (r *Reader) Peek(n int) ([]byte, error) { | |||
// will not return `io.EOF` until the next call | |||
// to Read.) | |||
func (r *Reader) Skip(n int) (int, error) { | |||
// fast path | |||
if r.buffered() >= n { | |||
r.n += n | |||
return n, nil | |||
if n < 0 { | |||
return 0, os.ErrInvalid | |||
} | |||
// use seeker implementation | |||
// if we can | |||
if r.rs != nil { | |||
return r.skipSeek(n) | |||
} | |||
// discard some or all of the current buffer | |||
skipped := r.discard(n) | |||
// loop on filling | |||
// and then erasing | |||
o := n | |||
for r.buffered() < n && r.state == nil { | |||
// if we can Seek() through the remaining bytes, do that | |||
if n > skipped && r.rs != nil { | |||
nn, err := r.rs.Seek(int64(n-skipped), 1) | |||
return int(nn) + skipped, err | |||
} | |||
// otherwise, keep filling the buffer | |||
// and discarding it up to 'n' | |||
for skipped < n && r.state == nil { | |||
r.more() | |||
// we can skip forward | |||
// up to r.buffered() bytes | |||
step := min(r.buffered(), n) | |||
r.n += step | |||
n -= step | |||
skipped += r.discard(n - skipped) | |||
} | |||
// at this point, n should be | |||
// 0 if everything went smoothly | |||
return o - n, r.noEOF() | |||
return skipped, r.noEOF() | |||
} | |||
// Next returns the next 'n' bytes in the stream. | |||
@@ -262,20 +270,6 @@ func (r *Reader) Next(n int) ([]byte, error) { | |||
return out, nil | |||
} | |||
// skipSeek uses the io.Seeker to seek forward. | |||
// only call this function when n > r.buffered() | |||
func (r *Reader) skipSeek(n int) (int, error) { | |||
o := r.buffered() | |||
// first, clear buffer | |||
n -= o | |||
r.n = 0 | |||
r.data = r.data[:0] | |||
// then seek forward remaning bytes | |||
i, err := r.rs.Seek(int64(n), 1) | |||
return int(i) + o, err | |||
} | |||
// Read implements `io.Reader` | |||
func (r *Reader) Read(b []byte) (int, error) { | |||
// if we have data in the buffer, just | |||
@@ -381,13 +375,6 @@ func (r *Reader) WriteTo(w io.Writer) (int64, error) { | |||
return i, nil | |||
} | |||
func min(a int, b int) int { | |||
if a < b { | |||
return a | |||
} | |||
return b | |||
} | |||
func max(a int, b int) int { | |||
if a < b { | |||
return b |
@@ -123,6 +123,9 @@ func (e errWrapped) Resumable() bool { | |||
return resumableDefault | |||
} | |||
// Unwrap returns the cause. | |||
func (e errWrapped) Unwrap() error { return e.cause } | |||
type errShort struct{} | |||
func (e errShort) Error() string { return "msgp: too few bytes left to read object" } |
@@ -206,7 +206,7 @@ func rwFloat32(dst jsWriter, src *Reader) (int, error) { | |||
if err != nil { | |||
return 0, err | |||
} | |||
src.scratch = strconv.AppendFloat(src.scratch[:0], float64(f), 'f', -1, 64) | |||
src.scratch = strconv.AppendFloat(src.scratch[:0], float64(f), 'f', -1, 32) | |||
return dst.Write(src.scratch) | |||
} | |||
@@ -215,7 +215,7 @@ func rwFloat64(dst jsWriter, src *Reader) (int, error) { | |||
if err != nil { | |||
return 0, err | |||
} | |||
src.scratch = strconv.AppendFloat(src.scratch[:0], f, 'f', -1, 32) | |||
src.scratch = strconv.AppendFloat(src.scratch[:0], f, 'f', -1, 64) | |||
return dst.Write(src.scratch) | |||
} | |||
@@ -126,6 +126,11 @@ func NewReaderSize(r io.Reader, sz int) *Reader { | |||
return &Reader{R: fwd.NewReaderSize(r, sz)} | |||
} | |||
// NewReaderBuf returns a *Reader with a provided buffer. | |||
func NewReaderBuf(r io.Reader, buf []byte) *Reader { | |||
return &Reader{R: fwd.NewReaderBuf(r, buf)} | |||
} | |||
// Reader wraps an io.Reader and provides | |||
// methods to read MessagePack-encoded values | |||
// from it. Readers are buffered. |
@@ -3,7 +3,6 @@ | |||
package msgp | |||
import ( | |||
"reflect" | |||
"unsafe" | |||
) | |||
@@ -24,18 +23,14 @@ const ( | |||
// THIS IS EVIL CODE. | |||
// YOU HAVE BEEN WARNED. | |||
func UnsafeString(b []byte) string { | |||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) | |||
return *(*string)(unsafe.Pointer(&reflect.StringHeader{Data: sh.Data, Len: sh.Len})) | |||
return *(*string)(unsafe.Pointer(&b)) | |||
} | |||
// UnsafeBytes returns the string as a byte slice | |||
// THIS SHOULD ONLY BE USED BY THE CODE GENERATOR. | |||
// THIS IS EVIL CODE. | |||
// YOU HAVE BEEN WARNED. | |||
// | |||
// Deprecated: | |||
// Since this code is no longer used by the code generator, | |||
// UnsafeBytes(s) is precisely equivalent to []byte(s) | |||
func UnsafeBytes(s string) []byte { | |||
return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ | |||
Len: len(s), | |||
Cap: len(s), | |||
Data: (*(*reflect.StringHeader)(unsafe.Pointer(&s))).Data, | |||
})) | |||
return []byte(s) | |||
} |
@@ -10,6 +10,11 @@ import ( | |||
"time" | |||
) | |||
const ( | |||
// min buffer size for the writer | |||
minWriterSize = 18 | |||
) | |||
// Sizer is an interface implemented | |||
// by types that can estimate their | |||
// size when MessagePack encoded. | |||
@@ -120,16 +125,27 @@ func NewWriter(w io.Writer) *Writer { | |||
// NewWriterSize returns a writer with a custom buffer size. | |||
func NewWriterSize(w io.Writer, sz int) *Writer { | |||
// we must be able to require() 18 | |||
// we must be able to require() 'minWriterSize' | |||
// contiguous bytes, so that is the | |||
// practical minimum buffer size | |||
if sz < 18 { | |||
sz = 18 | |||
if sz < minWriterSize { | |||
sz = minWriterSize | |||
} | |||
buf := make([]byte, sz) | |||
return NewWriterBuf(w, buf) | |||
} | |||
// NewWriterBuf returns a writer with a provided buffer. | |||
// 'buf' is not used when the capacity is smaller than 18, | |||
// custom buffer is allocated instead. | |||
func NewWriterBuf(w io.Writer, buf []byte) *Writer { | |||
if cap(buf) < minWriterSize { | |||
buf = make([]byte, minWriterSize) | |||
} | |||
buf = buf[:cap(buf)] | |||
return &Writer{ | |||
w: w, | |||
buf: make([]byte, sz), | |||
buf: buf, | |||
} | |||
} | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
package cpu | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
package cpu | |||
@@ -3,7 +3,7 @@ | |||
// license that can be found in the LICENSE file. | |||
// +build 386 amd64 amd64p32 | |||
// +build !gccgo | |||
// +build gc | |||
package cpu | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -3,7 +3,7 @@ | |||
// license that can be found in the LICENSE file. | |||
// +build 386 amd64 amd64p32 | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -7,7 +7,7 @@ | |||
// (See golang.org/issue/32102) | |||
// +build aix,ppc64 | |||
// +build !gccgo | |||
// +build gc | |||
package cpu | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
// +build arm,darwin | |||
#include "textflag.h" |
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
// +build arm64,darwin | |||
#include "textflag.h" |
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -4,7 +4,7 @@ | |||
// +build linux | |||
// +build arm64 | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -4,7 +4,7 @@ | |||
// +build linux | |||
// +build mips64 mips64le | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -4,7 +4,7 @@ | |||
// +build linux | |||
// +build mips mipsle | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -4,7 +4,7 @@ | |||
// +build linux | |||
// +build ppc64 ppc64le | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build riscv64,!gccgo | |||
// +build riscv64,gc | |||
#include "textflag.h" | |||
@@ -4,7 +4,7 @@ | |||
// +build s390x | |||
// +build linux | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
// +build gc | |||
#include "textflag.h" | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// | |||
// +build ppc64 s390x mips mips64 | |||
// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64 | |||
package unix | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// | |||
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le riscv64 | |||
// +build 386 amd64 amd64p32 alpha arm arm64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh | |||
package unix | |||
@@ -225,6 +225,7 @@ struct ltchars { | |||
#include <linux/kexec.h> | |||
#include <linux/keyctl.h> | |||
#include <linux/loop.h> | |||
#include <linux/lwtunnel.h> | |||
#include <linux/magic.h> | |||
#include <linux/memfd.h> | |||
#include <linux/module.h> | |||
@@ -561,6 +562,7 @@ ccflags="$@" | |||
$2 ~ /^CRYPTO_/ || | |||
$2 ~ /^TIPC_/ || | |||
$2 ~ /^DEVLINK_/ || | |||
$2 ~ /^LWTUNNEL_IP/ || | |||
$2 !~ "WMESGLEN" && | |||
$2 ~ /^W[A-Z0-9]+$/ || | |||
$2 ~/^PPPIOC/ || |
@@ -26,7 +26,6 @@ func fdopendir(fd int) (dir uintptr, err error) { | |||
func libc_fdopendir_trampoline() | |||
//go:linkname libc_fdopendir libc_fdopendir | |||
//go:cgo_import_dynamic libc_fdopendir fdopendir "/usr/lib/libSystem.B.dylib" | |||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { |
@@ -105,6 +105,19 @@ func Pipe(p []int) (err error) { | |||
return | |||
} | |||
//sysnb pipe2(p *[2]_C_int, flags int) (err error) | |||
func Pipe2(p []int, flags int) error { | |||
if len(p) != 2 { | |||
return EINVAL | |||
} | |||
var pp [2]_C_int | |||
err := pipe2(&pp, flags) | |||
p[0] = int(pp[0]) | |||
p[1] = int(pp[1]) | |||
return err | |||
} | |||
//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error) | |||
func Pread(fd int, p []byte, offset int64) (n int, err error) { | |||
return extpread(fd, p, 0, offset) |
@@ -641,6 +641,36 @@ func (sa *SockaddrCAN) sockaddr() (unsafe.Pointer, _Socklen, error) { | |||
return unsafe.Pointer(&sa.raw), SizeofSockaddrCAN, nil | |||
} | |||
// SockaddrCANJ1939 implements the Sockaddr interface for AF_CAN using J1939 | |||
// protocol (https://en.wikipedia.org/wiki/SAE_J1939). For more information | |||
// on the purposes of the fields, check the official linux kernel documentation | |||
// available here: https://www.kernel.org/doc/Documentation/networking/j1939.rst | |||
type SockaddrCANJ1939 struct { | |||
Ifindex int | |||
Name uint64 | |||
PGN uint32 | |||
Addr uint8 | |||
raw RawSockaddrCAN | |||
} | |||
func (sa *SockaddrCANJ1939) sockaddr() (unsafe.Pointer, _Socklen, error) { | |||
if sa.Ifindex < 0 || sa.Ifindex > 0x7fffffff { | |||
return nil, 0, EINVAL | |||
} | |||
sa.raw.Family = AF_CAN | |||
sa.raw.Ifindex = int32(sa.Ifindex) | |||
n := (*[8]byte)(unsafe.Pointer(&sa.Name)) | |||
for i := 0; i < 8; i++ { | |||
sa.raw.Addr[i] = n[i] | |||
} | |||
p := (*[4]byte)(unsafe.Pointer(&sa.PGN)) | |||
for i := 0; i < 4; i++ { | |||
sa.raw.Addr[i+8] = p[i] | |||
} | |||
sa.raw.Addr[12] = sa.Addr | |||
return unsafe.Pointer(&sa.raw), SizeofSockaddrCAN, nil | |||
} | |||
// SockaddrALG implements the Sockaddr interface for AF_ALG type sockets. | |||
// SockaddrALG enables userspace access to the Linux kernel's cryptography | |||
// subsystem. The Type and Name fields specify which type of hash or cipher | |||
@@ -952,6 +982,10 @@ func (sa *SockaddrIUCV) sockaddr() (unsafe.Pointer, _Socklen, error) { | |||
return unsafe.Pointer(&sa.raw), SizeofSockaddrIUCV, nil | |||
} | |||
var socketProtocol = func(fd int) (int, error) { | |||
return GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL) | |||
} | |||
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
switch rsa.Addr.Family { | |||
case AF_NETLINK: | |||
@@ -1002,7 +1036,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
return sa, nil | |||
case AF_INET: | |||
proto, err := GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL) | |||
proto, err := socketProtocol(fd) | |||
if err != nil { | |||
return nil, err | |||
} | |||
@@ -1028,7 +1062,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
} | |||
case AF_INET6: | |||
proto, err := GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL) | |||
proto, err := socketProtocol(fd) | |||
if err != nil { | |||
return nil, err | |||
} | |||
@@ -1063,7 +1097,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
} | |||
return sa, nil | |||
case AF_BLUETOOTH: | |||
proto, err := GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL) | |||
proto, err := socketProtocol(fd) | |||
if err != nil { | |||
return nil, err | |||
} | |||
@@ -1150,20 +1184,43 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
return sa, nil | |||
case AF_CAN: | |||
pp := (*RawSockaddrCAN)(unsafe.Pointer(rsa)) | |||
sa := &SockaddrCAN{ | |||
Ifindex: int(pp.Ifindex), | |||
} | |||
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID)) | |||
for i := 0; i < 4; i++ { | |||
rx[i] = pp.Addr[i] | |||
} | |||
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID)) | |||
for i := 0; i < 4; i++ { | |||
tx[i] = pp.Addr[i+4] | |||
proto, err := socketProtocol(fd) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return sa, nil | |||
pp := (*RawSockaddrCAN)(unsafe.Pointer(rsa)) | |||
switch proto { | |||
case CAN_J1939: | |||
sa := &SockaddrCANJ1939{ | |||
Ifindex: int(pp.Ifindex), | |||
} | |||
name := (*[8]byte)(unsafe.Pointer(&sa.Name)) | |||
for i := 0; i < 8; i++ { | |||
name[i] = pp.Addr[i] | |||
} | |||
pgn := (*[4]byte)(unsafe.Pointer(&sa.PGN)) | |||
for i := 0; i < 4; i++ { | |||
pgn[i] = pp.Addr[i+8] | |||
} | |||
addr := (*[1]byte)(unsafe.Pointer(&sa.Addr)) | |||
addr[0] = pp.Addr[12] | |||
return sa, nil | |||
default: | |||
sa := &SockaddrCAN{ | |||
Ifindex: int(pp.Ifindex), | |||
} | |||
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID)) | |||
for i := 0; i < 4; i++ { | |||
rx[i] = pp.Addr[i] | |||
} | |||
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID)) | |||
for i := 0; i < 4; i++ { | |||
tx[i] = pp.Addr[i+4] | |||
} | |||
return sa, nil | |||
} | |||
} | |||
return nil, EAFNOSUPPORT | |||
} |
@@ -3,7 +3,7 @@ | |||
// license that can be found in the LICENSE file. | |||
// +build amd64,linux | |||
// +build !gccgo | |||
// +build gc | |||
package unix | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build linux,!gccgo | |||
// +build linux,gc | |||
package unix | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build linux,!gccgo,386 | |||
// +build linux,gc,386 | |||
package unix | |||
@@ -2,7 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build arm,!gccgo,linux | |||
// +build arm,gc,linux | |||
package unix | |||
@@ -3,7 +3,7 @@ | |||
// license that can be found in the LICENSE file. | |||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | |||
// +build !gccgo,!ppc64le,!ppc64 | |||
// +build gc,!ppc64le,!ppc64 | |||
package unix | |||
@@ -4,7 +4,7 @@ | |||
// +build linux | |||
// +build ppc64le ppc64 | |||
// +build !gccgo | |||
// +build gc | |||
package unix | |||
@@ -1217,6 +1217,12 @@ const ( | |||
LOOP_SET_STATUS_SETTABLE_FLAGS = 0xc | |||
LO_KEY_SIZE = 0x20 | |||
LO_NAME_SIZE = 0x40 | |||
LWTUNNEL_IP6_MAX = 0x8 | |||
LWTUNNEL_IP_MAX = 0x8 | |||
LWTUNNEL_IP_OPTS_MAX = 0x3 | |||
LWTUNNEL_IP_OPT_ERSPAN_MAX = 0x4 | |||
LWTUNNEL_IP_OPT_GENEVE_MAX = 0x3 | |||
LWTUNNEL_IP_OPT_VXLAN_MAX = 0x1 | |||
MADV_COLD = 0x14 | |||
MADV_DODUMP = 0x11 | |||
MADV_DOFORK = 0xb |
@@ -2,7 +2,7 @@ | |||
// Code generated by the command above; see README.md. DO NOT EDIT. | |||
// +build aix,ppc64 | |||
// +build !gccgo | |||
// +build gc | |||
package unix | |||
@@ -24,7 +24,6 @@ func closedir(dir uintptr) (err error) { | |||
func libc_closedir_trampoline() | |||
//go:linkname libc_closedir libc_closedir | |||
//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
@@ -37,5 +36,4 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { | |||
func libc_readdir_r_trampoline() | |||
//go:linkname libc_readdir_r libc_readdir_r | |||
//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" |
@@ -24,7 +24,6 @@ func closedir(dir uintptr) (err error) { | |||
func libc_closedir_trampoline() | |||
//go:linkname libc_closedir libc_closedir | |||
//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
@@ -37,5 +36,4 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { | |||
func libc_readdir_r_trampoline() | |||
//go:linkname libc_readdir_r libc_readdir_r | |||
//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" |
@@ -24,7 +24,6 @@ func closedir(dir uintptr) (err error) { | |||
func libc_closedir_trampoline() | |||
//go:linkname libc_closedir libc_closedir | |||
//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
@@ -37,5 +36,4 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { | |||
func libc_readdir_r_trampoline() | |||
//go:linkname libc_readdir_r libc_readdir_r | |||
//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" |
@@ -24,7 +24,6 @@ func closedir(dir uintptr) (err error) { | |||
func libc_closedir_trampoline() | |||
//go:linkname libc_closedir libc_closedir | |||
//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
@@ -37,5 +36,4 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { | |||
func libc_readdir_r_trampoline() | |||
//go:linkname libc_readdir_r libc_readdir_r | |||
//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" |
@@ -362,6 +362,16 @@ func pipe() (r int, w int, err error) { | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func pipe2(p *[2]_C_int, flags int) (err error) { | |||
_, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func extpread(fd int, p []byte, flags int, offset int64) (n int, err error) { | |||
var _p0 unsafe.Pointer | |||
if len(p) > 0 { |
@@ -269,6 +269,7 @@ const ( | |||
SizeofSockaddrDatalink = 0x14 | |||
SizeofSockaddrCtl = 0x20 | |||
SizeofLinger = 0x8 | |||
SizeofIovec = 0x8 | |||
SizeofIPMreq = 0x8 | |||
SizeofIPv6Mreq = 0x14 | |||
SizeofMsghdr = 0x1c |
@@ -274,6 +274,7 @@ const ( | |||
SizeofSockaddrDatalink = 0x14 | |||
SizeofSockaddrCtl = 0x20 | |||
SizeofLinger = 0x8 | |||
SizeofIovec = 0x10 | |||
SizeofIPMreq = 0x8 | |||
SizeofIPv6Mreq = 0x14 | |||
SizeofMsghdr = 0x30 |
@@ -269,6 +269,7 @@ const ( | |||
SizeofSockaddrDatalink = 0x14 | |||
SizeofSockaddrCtl = 0x20 | |||
SizeofLinger = 0x8 | |||
SizeofIovec = 0x8 | |||
SizeofIPMreq = 0x8 | |||
SizeofIPv6Mreq = 0x14 | |||
SizeofMsghdr = 0x1c |
@@ -274,6 +274,7 @@ const ( | |||
SizeofSockaddrDatalink = 0x14 | |||
SizeofSockaddrCtl = 0x20 | |||
SizeofLinger = 0x8 | |||
SizeofIovec = 0x10 | |||
SizeofIPMreq = 0x8 | |||
SizeofIPv6Mreq = 0x14 | |||
SizeofMsghdr = 0x30 |
@@ -2981,3 +2981,21 @@ type PPSKTime struct { | |||
Nsec int32 | |||
Flags uint32 | |||
} | |||
const ( | |||
LWTUNNEL_ENCAP_NONE = 0x0 | |||
LWTUNNEL_ENCAP_MPLS = 0x1 | |||
LWTUNNEL_ENCAP_IP = 0x2 | |||
LWTUNNEL_ENCAP_ILA = 0x3 | |||
LWTUNNEL_ENCAP_IP6 = 0x4 | |||
LWTUNNEL_ENCAP_SEG6 = 0x5 | |||
LWTUNNEL_ENCAP_BPF = 0x6 | |||
LWTUNNEL_ENCAP_SEG6_LOCAL = 0x7 | |||
LWTUNNEL_ENCAP_RPL = 0x8 | |||
LWTUNNEL_ENCAP_MAX = 0x8 | |||
MPLS_IPTUNNEL_UNSPEC = 0x0 | |||
MPLS_IPTUNNEL_DST = 0x1 | |||
MPLS_IPTUNNEL_TTL = 0x2 | |||
MPLS_IPTUNNEL_MAX = 0x2 | |||
) |
@@ -32,6 +32,8 @@ type DLLError struct { | |||
func (e *DLLError) Error() string { return e.Msg } | |||
func (e *DLLError) Unwrap() error { return e.Err } | |||
// A DLL implements access to a single DLL. | |||
type DLL struct { | |||
Name string | |||
@@ -389,7 +391,6 @@ func loadLibraryEx(name string, system bool) (*DLL, error) { | |||
var flags uintptr | |||
if system { | |||
if canDoSearchSystem32() { | |||
const LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800 | |||
flags = LOAD_LIBRARY_SEARCH_SYSTEM32 | |||
} else if isBaseName(name) { | |||
// WindowsXP or unpatched Windows machine |
@@ -16,13 +16,19 @@ const ( | |||
MEM_RESET_UNDO = 0x01000000 | |||
MEM_LARGE_PAGES = 0x20000000 | |||
PAGE_NOACCESS = 0x01 | |||
PAGE_READONLY = 0x02 | |||
PAGE_READWRITE = 0x04 | |||
PAGE_WRITECOPY = 0x08 | |||
PAGE_EXECUTE_READ = 0x20 | |||
PAGE_EXECUTE_READWRITE = 0x40 | |||
PAGE_EXECUTE_WRITECOPY = 0x80 | |||
PAGE_NOACCESS = 0x00000001 | |||
PAGE_READONLY = 0x00000002 | |||
PAGE_READWRITE = 0x00000004 | |||
PAGE_WRITECOPY = 0x00000008 | |||
PAGE_EXECUTE = 0x00000010 | |||
PAGE_EXECUTE_READ = 0x00000020 | |||
PAGE_EXECUTE_READWRITE = 0x00000040 | |||
PAGE_EXECUTE_WRITECOPY = 0x00000080 | |||
PAGE_GUARD = 0x00000100 | |||
PAGE_NOCACHE = 0x00000200 | |||
PAGE_WRITECOMBINE = 0x00000400 | |||
PAGE_TARGETS_INVALID = 0x40000000 | |||
PAGE_TARGETS_NO_UPDATE = 0x40000000 | |||
QUOTA_LIMITS_HARDWS_MIN_DISABLE = 0x00000002 | |||
QUOTA_LIMITS_HARDWS_MIN_ENABLE = 0x00000001 |
@@ -624,6 +624,7 @@ func (tml *Tokenmandatorylabel) Size() uint32 { | |||
// Authorization Functions | |||
//sys checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) = advapi32.CheckTokenMembership | |||
//sys isTokenRestricted(tokenHandle Token) (ret bool, err error) [!failretval] = advapi32.IsTokenRestricted | |||
//sys OpenProcessToken(process Handle, access uint32, token *Token) (err error) = advapi32.OpenProcessToken | |||
//sys OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) = advapi32.OpenThreadToken | |||
//sys ImpersonateSelf(impersonationlevel uint32) (err error) = advapi32.ImpersonateSelf | |||
@@ -837,6 +838,16 @@ func (t Token) IsMember(sid *SID) (bool, error) { | |||
return b != 0, nil | |||
} | |||
// IsRestricted reports whether the access token t is a restricted token. | |||
func (t Token) IsRestricted() (isRestricted bool, err error) { | |||
isRestricted, err = isTokenRestricted(t) | |||
if !isRestricted && err == syscall.EINVAL { | |||
// If err is EINVAL, this returned ERROR_SUCCESS indicating a non-restricted token. | |||
err = nil | |||
} | |||
return | |||
} | |||
const ( | |||
WTS_CONSOLE_CONNECT = 0x1 | |||
WTS_CONSOLE_DISCONNECT = 0x2 | |||
@@ -1103,9 +1114,10 @@ type OBJECTS_AND_NAME struct { | |||
} | |||
//sys getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) = advapi32.GetSecurityInfo | |||
//sys SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) = advapi32.SetSecurityInfo | |||
//sys SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) = advapi32.SetSecurityInfo | |||
//sys getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) = advapi32.GetNamedSecurityInfoW | |||
//sys SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) = advapi32.SetNamedSecurityInfoW | |||
//sys SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) = advapi32.SetKernelObjectSecurity | |||
//sys buildSecurityDescriptor(owner *TRUSTEE, group *TRUSTEE, countAccessEntries uint32, accessEntries *EXPLICIT_ACCESS, countAuditEntries uint32, auditEntries *EXPLICIT_ACCESS, oldSecurityDescriptor *SECURITY_DESCRIPTOR, sizeNewSecurityDescriptor *uint32, newSecurityDescriptor **SECURITY_DESCRIPTOR) (ret error) = advapi32.BuildSecurityDescriptorW | |||
//sys initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) = advapi32.InitializeSecurityDescriptor |
@@ -128,6 +128,10 @@ const ( | |||
SERVICE_NOTIFY_CREATED = 0x00000080 | |||
SERVICE_NOTIFY_DELETED = 0x00000100 | |||
SERVICE_NOTIFY_DELETE_PENDING = 0x00000200 | |||
SC_EVENT_DATABASE_CHANGE = 0 | |||
SC_EVENT_PROPERTY_CHANGE = 1 | |||
SC_EVENT_STATUS_CHANGE = 2 | |||
) | |||
type SERVICE_STATUS struct { | |||
@@ -229,3 +233,5 @@ type QUERY_SERVICE_LOCK_STATUS struct { | |||
//sys EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) = advapi32.EnumServicesStatusExW | |||
//sys QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceStatusEx | |||
//sys NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) = advapi32.NotifyServiceStatusChangeW | |||
//sys SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) = sechost.SubscribeServiceChangeNotifications? | |||
//sys UnsubscribeServiceChangeNotifications(subscription uintptr) = sechost.UnsubscribeServiceChangeNotifications? |
@@ -0,0 +1,100 @@ | |||
// Copyright 2020 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
package windows | |||
import "syscall" | |||
const ( | |||
ERROR_EXPECTED_SECTION_NAME syscall.Errno = 0x20000000 | 0xC0000000 | 0 | |||
ERROR_BAD_SECTION_NAME_LINE syscall.Errno = 0x20000000 | 0xC0000000 | 1 | |||
ERROR_SECTION_NAME_TOO_LONG syscall.Errno = 0x20000000 | 0xC0000000 | 2 | |||
ERROR_GENERAL_SYNTAX syscall.Errno = 0x20000000 | 0xC0000000 | 3 | |||
ERROR_WRONG_INF_STYLE syscall.Errno = 0x20000000 | 0xC0000000 | 0x100 | |||
ERROR_SECTION_NOT_FOUND syscall.Errno = 0x20000000 | 0xC0000000 | 0x101 | |||
ERROR_LINE_NOT_FOUND syscall.Errno = 0x20000000 | 0xC0000000 | 0x102 | |||
ERROR_NO_BACKUP syscall.Errno = 0x20000000 | 0xC0000000 | 0x103 | |||
ERROR_NO_ASSOCIATED_CLASS syscall.Errno = 0x20000000 | 0xC0000000 | 0x200 | |||
ERROR_CLASS_MISMATCH syscall.Errno = 0x20000000 | 0xC0000000 | 0x201 | |||
ERROR_DUPLICATE_FOUND syscall.Errno = 0x20000000 | 0xC0000000 | 0x202 | |||
ERROR_NO_DRIVER_SELECTED syscall.Errno = 0x20000000 | 0xC0000000 | 0x203 | |||
ERROR_KEY_DOES_NOT_EXIST syscall.Errno = 0x20000000 | 0xC0000000 | 0x204 | |||
ERROR_INVALID_DEVINST_NAME syscall.Errno = 0x20000000 | 0xC0000000 | 0x205 | |||
ERROR_INVALID_CLASS syscall.Errno = 0x20000000 | 0xC0000000 | 0x206 | |||
ERROR_DEVINST_ALREADY_EXISTS syscall.Errno = 0x20000000 | 0xC0000000 | 0x207 | |||
ERROR_DEVINFO_NOT_REGISTERED syscall.Errno = 0x20000000 | 0xC0000000 | 0x208 | |||
ERROR_INVALID_REG_PROPERTY syscall.Errno = 0x20000000 | 0xC0000000 | 0x209 | |||
ERROR_NO_INF syscall.Errno = 0x20000000 | 0xC0000000 | 0x20A | |||
ERROR_NO_SUCH_DEVINST syscall.Errno = 0x20000000 | 0xC0000000 | 0x20B | |||
ERROR_CANT_LOAD_CLASS_ICON syscall.Errno = 0x20000000 | 0xC0000000 | 0x20C | |||
ERROR_INVALID_CLASS_INSTALLER syscall.Errno = 0x20000000 | 0xC0000000 | 0x20D | |||
ERROR_DI_DO_DEFAULT syscall.Errno = 0x20000000 | 0xC0000000 | 0x20E | |||
ERROR_DI_NOFILECOPY syscall.Errno = 0x20000000 | 0xC0000000 | 0x20F | |||
ERROR_INVALID_HWPROFILE syscall.Errno = 0x20000000 | 0xC0000000 | 0x210 | |||
ERROR_NO_DEVICE_SELECTED syscall.Errno = 0x20000000 | 0xC0000000 | 0x211 | |||
ERROR_DEVINFO_LIST_LOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x212 | |||
ERROR_DEVINFO_DATA_LOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x213 | |||
ERROR_DI_BAD_PATH syscall.Errno = 0x20000000 | 0xC0000000 | 0x214 | |||
ERROR_NO_CLASSINSTALL_PARAMS syscall.Errno = 0x20000000 | 0xC0000000 | 0x215 | |||
ERROR_FILEQUEUE_LOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x216 | |||
ERROR_BAD_SERVICE_INSTALLSECT syscall.Errno = 0x20000000 | 0xC0000000 | 0x217 | |||
ERROR_NO_CLASS_DRIVER_LIST syscall.Errno = 0x20000000 | 0xC0000000 | 0x218 | |||
ERROR_NO_ASSOCIATED_SERVICE syscall.Errno = 0x20000000 | 0xC0000000 | 0x219 | |||
ERROR_NO_DEFAULT_DEVICE_INTERFACE syscall.Errno = 0x20000000 | 0xC0000000 | 0x21A | |||
ERROR_DEVICE_INTERFACE_ACTIVE syscall.Errno = 0x20000000 | 0xC0000000 | 0x21B | |||
ERROR_DEVICE_INTERFACE_REMOVED syscall.Errno = 0x20000000 | 0xC0000000 | 0x21C | |||
ERROR_BAD_INTERFACE_INSTALLSECT syscall.Errno = 0x20000000 | 0xC0000000 | 0x21D | |||
ERROR_NO_SUCH_INTERFACE_CLASS syscall.Errno = 0x20000000 | 0xC0000000 | 0x21E | |||
ERROR_INVALID_REFERENCE_STRING syscall.Errno = 0x20000000 | 0xC0000000 | 0x21F | |||
ERROR_INVALID_MACHINENAME syscall.Errno = 0x20000000 | 0xC0000000 | 0x220 | |||
ERROR_REMOTE_COMM_FAILURE syscall.Errno = 0x20000000 | 0xC0000000 | 0x221 | |||
ERROR_MACHINE_UNAVAILABLE syscall.Errno = 0x20000000 | 0xC0000000 | 0x222 | |||
ERROR_NO_CONFIGMGR_SERVICES syscall.Errno = 0x20000000 | 0xC0000000 | 0x223 | |||
ERROR_INVALID_PROPPAGE_PROVIDER syscall.Errno = 0x20000000 | 0xC0000000 | 0x224 | |||
ERROR_NO_SUCH_DEVICE_INTERFACE syscall.Errno = 0x20000000 | 0xC0000000 | 0x225 | |||
ERROR_DI_POSTPROCESSING_REQUIRED syscall.Errno = 0x20000000 | 0xC0000000 | 0x226 | |||
ERROR_INVALID_COINSTALLER syscall.Errno = 0x20000000 | 0xC0000000 | 0x227 | |||
ERROR_NO_COMPAT_DRIVERS syscall.Errno = 0x20000000 | 0xC0000000 | 0x228 | |||
ERROR_NO_DEVICE_ICON syscall.Errno = 0x20000000 | 0xC0000000 | 0x229 | |||
ERROR_INVALID_INF_LOGCONFIG syscall.Errno = 0x20000000 | 0xC0000000 | 0x22A | |||
ERROR_DI_DONT_INSTALL syscall.Errno = 0x20000000 | 0xC0000000 | 0x22B | |||
ERROR_INVALID_FILTER_DRIVER syscall.Errno = 0x20000000 | 0xC0000000 | 0x22C | |||
ERROR_NON_WINDOWS_NT_DRIVER syscall.Errno = 0x20000000 | 0xC0000000 | 0x22D | |||
ERROR_NON_WINDOWS_DRIVER syscall.Errno = 0x20000000 | 0xC0000000 | 0x22E | |||
ERROR_NO_CATALOG_FOR_OEM_INF syscall.Errno = 0x20000000 | 0xC0000000 | 0x22F | |||
ERROR_DEVINSTALL_QUEUE_NONNATIVE syscall.Errno = 0x20000000 | 0xC0000000 | 0x230 | |||
ERROR_NOT_DISABLEABLE syscall.Errno = 0x20000000 | 0xC0000000 | 0x231 | |||
ERROR_CANT_REMOVE_DEVINST syscall.Errno = 0x20000000 | 0xC0000000 | 0x232 | |||
ERROR_INVALID_TARGET syscall.Errno = 0x20000000 | 0xC0000000 | 0x233 | |||
ERROR_DRIVER_NONNATIVE syscall.Errno = 0x20000000 | 0xC0000000 | 0x234 | |||
ERROR_IN_WOW64 syscall.Errno = 0x20000000 | 0xC0000000 | 0x235 | |||
ERROR_SET_SYSTEM_RESTORE_POINT syscall.Errno = 0x20000000 | 0xC0000000 | 0x236 | |||
ERROR_SCE_DISABLED syscall.Errno = 0x20000000 | 0xC0000000 | 0x238 | |||
ERROR_UNKNOWN_EXCEPTION syscall.Errno = 0x20000000 | 0xC0000000 | 0x239 | |||
ERROR_PNP_REGISTRY_ERROR syscall.Errno = 0x20000000 | 0xC0000000 | 0x23A | |||
ERROR_REMOTE_REQUEST_UNSUPPORTED syscall.Errno = 0x20000000 | 0xC0000000 | 0x23B | |||
ERROR_NOT_AN_INSTALLED_OEM_INF syscall.Errno = 0x20000000 | 0xC0000000 | 0x23C | |||
ERROR_INF_IN_USE_BY_DEVICES syscall.Errno = 0x20000000 | 0xC0000000 | 0x23D | |||
ERROR_DI_FUNCTION_OBSOLETE syscall.Errno = 0x20000000 | 0xC0000000 | 0x23E | |||
ERROR_NO_AUTHENTICODE_CATALOG syscall.Errno = 0x20000000 | 0xC0000000 | 0x23F | |||
ERROR_AUTHENTICODE_DISALLOWED syscall.Errno = 0x20000000 | 0xC0000000 | 0x240 | |||
ERROR_AUTHENTICODE_TRUSTED_PUBLISHER syscall.Errno = 0x20000000 | 0xC0000000 | 0x241 | |||
ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED syscall.Errno = 0x20000000 | 0xC0000000 | 0x242 | |||
ERROR_AUTHENTICODE_PUBLISHER_NOT_TRUSTED syscall.Errno = 0x20000000 | 0xC0000000 | 0x243 | |||
ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH syscall.Errno = 0x20000000 | 0xC0000000 | 0x244 | |||
ERROR_ONLY_VALIDATE_VIA_AUTHENTICODE syscall.Errno = 0x20000000 | 0xC0000000 | 0x245 | |||
ERROR_DEVICE_INSTALLER_NOT_READY syscall.Errno = 0x20000000 | 0xC0000000 | 0x246 | |||
ERROR_DRIVER_STORE_ADD_FAILED syscall.Errno = 0x20000000 | 0xC0000000 | 0x247 | |||
ERROR_DEVICE_INSTALL_BLOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x248 | |||
ERROR_DRIVER_INSTALL_BLOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x249 | |||
ERROR_WRONG_INF_TYPE syscall.Errno = 0x20000000 | 0xC0000000 | 0x24A | |||
ERROR_FILE_HASH_NOT_IN_CATALOG syscall.Errno = 0x20000000 | 0xC0000000 | 0x24B | |||
ERROR_DRIVER_STORE_DELETE_FAILED syscall.Errno = 0x20000000 | 0xC0000000 | 0x24C | |||
ERROR_UNRECOVERABLE_STACK_OVERFLOW syscall.Errno = 0x20000000 | 0xC0000000 | 0x300 | |||
EXCEPTION_SPAPI_UNRECOVERABLE_STACK_OVERFLOW syscall.Errno = ERROR_UNRECOVERABLE_STACK_OVERFLOW | |||
ERROR_NO_DEFAULT_INTERFACE_DEVICE syscall.Errno = ERROR_NO_DEFAULT_DEVICE_INTERFACE | |||
ERROR_INTERFACE_DEVICE_ACTIVE syscall.Errno = ERROR_DEVICE_INTERFACE_ACTIVE | |||
ERROR_INTERFACE_DEVICE_REMOVED syscall.Errno = ERROR_DEVICE_INTERFACE_REMOVED | |||
ERROR_NO_SUCH_INTERFACE_DEVICE syscall.Errno = ERROR_NO_SUCH_DEVICE_INTERFACE | |||
) |
@@ -71,11 +71,13 @@ const ( | |||
// Status combines State and Accepted commands to fully describe running service. | |||
type Status struct { | |||
State State | |||
Accepts Accepted | |||
CheckPoint uint32 // used to report progress during a lengthy operation | |||
WaitHint uint32 // estimated time required for a pending operation, in milliseconds | |||
ProcessId uint32 // if the service is running, the process identifier of it, and otherwise zero | |||
State State | |||
Accepts Accepted | |||
CheckPoint uint32 // used to report progress during a lengthy operation | |||
WaitHint uint32 // estimated time required for a pending operation, in milliseconds | |||
ProcessId uint32 // if the service is running, the process identifier of it, and otherwise zero | |||
Win32ExitCode uint32 // set if the service has exited with a win32 exit code | |||
ServiceSpecificExitCode uint32 // set if the service has exited with a service-specific exit code | |||
} | |||
// ChangeRequest is sent to the service Handler to request service status change. |
@@ -170,10 +170,13 @@ func NewCallbackCDecl(fn interface{}) uintptr { | |||
//sys GetProcAddress(module Handle, procname string) (proc uintptr, err error) | |||
//sys GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) = kernel32.GetModuleFileNameW | |||
//sys GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) = kernel32.GetModuleHandleExW | |||
//sys SetDefaultDllDirectories(directoryFlags uint32) (err error) | |||
//sys SetDllDirectory(path string) (err error) = kernel32.SetDllDirectoryW | |||
//sys GetVersion() (ver uint32, err error) | |||
//sys FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) = FormatMessageW | |||
//sys ExitProcess(exitcode uint32) | |||
//sys IsWow64Process(handle Handle, isWow64 *bool) (err error) = IsWow64Process | |||
//sys IsWow64Process2(handle Handle, processMachine *uint16, nativeMachine *uint16) (err error) = IsWow64Process2? | |||
//sys CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW | |||
//sys ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) | |||
//sys WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) | |||
@@ -187,6 +190,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { | |||
//sys FindClose(handle Handle) (err error) | |||
//sys GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) | |||
//sys GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) | |||
//sys SetFileInformationByHandle(handle Handle, class uint32, inBuffer *byte, inBufferLen uint32) (err error) | |||
//sys GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) = GetCurrentDirectoryW | |||
//sys SetCurrentDirectory(path *uint16) (err error) = SetCurrentDirectoryW | |||
//sys CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) = CreateDirectoryW | |||
@@ -243,6 +247,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { | |||
//sys GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) = kernel32.GetFullPathNameW | |||
//sys GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) = kernel32.GetLongPathNameW | |||
//sys GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) = kernel32.GetShortPathNameW | |||
//sys GetFinalPathNameByHandle(file Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) = kernel32.GetFinalPathNameByHandleW | |||
//sys CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) = kernel32.CreateFileMappingW | |||
//sys MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) | |||
//sys UnmapViewOfFile(addr uintptr) (err error) | |||
@@ -255,7 +260,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { | |||
//sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile | |||
//sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW | |||
//sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW | |||
//sys CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) [failretval==InvalidHandle] = crypt32.CertOpenStore | |||
//sys CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) = crypt32.CertOpenStore | |||
//sys CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) [failretval==nil] = crypt32.CertEnumCertificatesInStore | |||
//sys CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) = crypt32.CertAddCertificateContextToStore | |||
//sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore | |||
@@ -270,12 +275,13 @@ func NewCallbackCDecl(fn interface{}) uintptr { | |||
//sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW | |||
//sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegEnumKeyExW | |||
//sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW | |||
//sys RegNotifyChangeKeyValue(key Handle, watchSubtree bool, notifyFilter uint32, event Handle, asynchronous bool) (regerrno error) = advapi32.RegNotifyChangeKeyValue | |||
//sys GetCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId | |||
//sys ProcessIdToSessionId(pid uint32, sessionid *uint32) (err error) = kernel32.ProcessIdToSessionId | |||
//sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode | |||
//sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode | |||
//sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo | |||
//sys SetConsoleCursorPosition(console Handle, position Coord) (err error) = kernel32.SetConsoleCursorPosition | |||
//sys setConsoleCursorPosition(console Handle, position uint32) (err error) = kernel32.SetConsoleCursorPosition | |||
//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW | |||
//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW | |||
//sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot | |||
@@ -351,7 +357,6 @@ func NewCallbackCDecl(fn interface{}) uintptr { | |||
//sys getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetThreadPreferredUILanguages | |||
//sys getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetUserPreferredUILanguages | |||
//sys getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetSystemPreferredUILanguages | |||
//sys GetFinalPathNameByHandleW(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) = kernel32.GetFinalPathNameByHandleW | |||
// Process Status API (PSAPI) | |||
//sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses | |||
@@ -1480,3 +1485,7 @@ func getUILanguages(flags uint32, f func(flags uint32, numLanguages *uint32, buf | |||
return languages, nil | |||
} | |||
} | |||
func SetConsoleCursorPosition(console Handle, position Coord) error { | |||
return setConsoleCursorPosition(console, *((*uint32)(unsafe.Pointer(&position)))) | |||
} |
@@ -1772,3 +1772,69 @@ const ( | |||
MUI_LANGUAGE_INSTALLED = 0x20 | |||
MUI_LANGUAGE_LICENSED = 0x40 | |||
) | |||
// FILE_INFO_BY_HANDLE_CLASS constants for SetFileInformationByHandle/GetFileInformationByHandleEx | |||
const ( | |||
FileBasicInfo = 0 | |||
FileStandardInfo = 1 | |||
FileNameInfo = 2 | |||
FileRenameInfo = 3 | |||
FileDispositionInfo = 4 | |||
FileAllocationInfo = 5 | |||
FileEndOfFileInfo = 6 | |||
FileStreamInfo = 7 | |||
FileCompressionInfo = 8 | |||
FileAttributeTagInfo = 9 | |||
FileIdBothDirectoryInfo = 10 | |||
FileIdBothDirectoryRestartInfo = 11 | |||
FileIoPriorityHintInfo = 12 | |||
FileRemoteProtocolInfo = 13 | |||
FileFullDirectoryInfo = 14 | |||
FileFullDirectoryRestartInfo = 15 | |||
FileStorageInfo = 16 | |||
FileAlignmentInfo = 17 | |||
FileIdInfo = 18 | |||
FileIdExtdDirectoryInfo = 19 | |||
FileIdExtdDirectoryRestartInfo = 20 | |||
FileDispositionInfoEx = 21 | |||
FileRenameInfoEx = 22 | |||
FileCaseSensitiveInfo = 23 | |||
FileNormalizedNameInfo = 24 | |||
) | |||
// LoadLibrary flags for determining from where to search for a DLL | |||
const ( | |||
DONT_RESOLVE_DLL_REFERENCES = 0x1 | |||
LOAD_LIBRARY_AS_DATAFILE = 0x2 | |||
LOAD_WITH_ALTERED_SEARCH_PATH = 0x8 | |||
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x10 | |||
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x20 | |||
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x40 | |||
LOAD_LIBRARY_REQUIRE_SIGNED_TARGET = 0x80 | |||
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x100 | |||
LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x200 | |||
LOAD_LIBRARY_SEARCH_USER_DIRS = 0x400 | |||
LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x800 | |||
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x1000 | |||
LOAD_LIBRARY_SAFE_CURRENT_DIRS = 0x00002000 | |||
LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER = 0x00004000 | |||
LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY = 0x00008000 | |||
) | |||
// RegNotifyChangeKeyValue notifyFilter flags. | |||
const ( | |||
// REG_NOTIFY_CHANGE_NAME notifies the caller if a subkey is added or deleted. | |||
REG_NOTIFY_CHANGE_NAME = 0x00000001 | |||
// REG_NOTIFY_CHANGE_ATTRIBUTES notifies the caller of changes to the attributes of the key, such as the security descriptor information. | |||
REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002 | |||
// REG_NOTIFY_CHANGE_LAST_SET notifies the caller of changes to a value of the key. This can include adding or deleting a value, or changing an existing value. | |||
REG_NOTIFY_CHANGE_LAST_SET = 0x00000004 | |||
// REG_NOTIFY_CHANGE_SECURITY notifies the caller of changes to the security descriptor of the key. | |||
REG_NOTIFY_CHANGE_SECURITY = 0x00000008 | |||
// REG_NOTIFY_THREAD_AGNOSTIC indicates that the lifetime of the registration must not be tied to the lifetime of the thread issuing the RegNotifyChangeKeyValue call. Note: This flag value is only supported in Windows 8 and later. | |||
REG_NOTIFY_THREAD_AGNOSTIC = 0x10000000 | |||
) |
@@ -46,6 +46,7 @@ var ( | |||
modntdll = NewLazySystemDLL("ntdll.dll") | |||
modole32 = NewLazySystemDLL("ole32.dll") | |||
modpsapi = NewLazySystemDLL("psapi.dll") | |||
modsechost = NewLazySystemDLL("sechost.dll") | |||
modsecur32 = NewLazySystemDLL("secur32.dll") | |||
modshell32 = NewLazySystemDLL("shell32.dll") | |||
moduser32 = NewLazySystemDLL("user32.dll") | |||
@@ -95,6 +96,7 @@ var ( | |||
procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") | |||
procInitializeSecurityDescriptor = modadvapi32.NewProc("InitializeSecurityDescriptor") | |||
procInitiateSystemShutdownExW = modadvapi32.NewProc("InitiateSystemShutdownExW") | |||
procIsTokenRestricted = modadvapi32.NewProc("IsTokenRestricted") | |||
procIsValidSecurityDescriptor = modadvapi32.NewProc("IsValidSecurityDescriptor") | |||
procIsValidSid = modadvapi32.NewProc("IsValidSid") | |||
procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid") | |||
@@ -115,6 +117,7 @@ var ( | |||
procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx") | |||
procRegCloseKey = modadvapi32.NewProc("RegCloseKey") | |||
procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW") | |||
procRegNotifyChangeKeyValue = modadvapi32.NewProc("RegNotifyChangeKeyValue") | |||
procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW") | |||
procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW") | |||
procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW") | |||
@@ -122,6 +125,7 @@ var ( | |||
procReportEventW = modadvapi32.NewProc("ReportEventW") | |||
procRevertToSelf = modadvapi32.NewProc("RevertToSelf") | |||
procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW") | |||
procSetKernelObjectSecurity = modadvapi32.NewProc("SetKernelObjectSecurity") | |||
procSetNamedSecurityInfoW = modadvapi32.NewProc("SetNamedSecurityInfoW") | |||
procSetSecurityDescriptorControl = modadvapi32.NewProc("SetSecurityDescriptorControl") | |||
procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl") | |||
@@ -248,6 +252,7 @@ var ( | |||
procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW") | |||
procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW") | |||
procIsWow64Process = modkernel32.NewProc("IsWow64Process") | |||
procIsWow64Process2 = modkernel32.NewProc("IsWow64Process2") | |||
procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW") | |||
procLoadLibraryW = modkernel32.NewProc("LoadLibraryW") | |||
procLocalFree = modkernel32.NewProc("LocalFree") | |||
@@ -277,12 +282,15 @@ var ( | |||
procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition") | |||
procSetConsoleMode = modkernel32.NewProc("SetConsoleMode") | |||
procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") | |||
procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories") | |||
procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW") | |||
procSetEndOfFile = modkernel32.NewProc("SetEndOfFile") | |||
procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW") | |||
procSetErrorMode = modkernel32.NewProc("SetErrorMode") | |||
procSetEvent = modkernel32.NewProc("SetEvent") | |||
procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW") | |||
procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes") | |||
procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle") | |||
procSetFilePointer = modkernel32.NewProc("SetFilePointer") | |||
procSetFileTime = modkernel32.NewProc("SetFileTime") | |||
procSetHandleInformation = modkernel32.NewProc("SetHandleInformation") | |||
@@ -323,6 +331,8 @@ var ( | |||
procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") | |||
procStringFromGUID2 = modole32.NewProc("StringFromGUID2") | |||
procEnumProcesses = modpsapi.NewProc("EnumProcesses") | |||
procSubscribeServiceChangeNotifications = modsechost.NewProc("SubscribeServiceChangeNotifications") | |||
procUnsubscribeServiceChangeNotifications = modsechost.NewProc("UnsubscribeServiceChangeNotifications") | |||
procGetUserNameExW = modsecur32.NewProc("GetUserNameExW") | |||
procTranslateNameW = modsecur32.NewProc("TranslateNameW") | |||
procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW") | |||
@@ -753,6 +763,15 @@ func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint | |||
return | |||
} | |||
func isTokenRestricted(tokenHandle Token) (ret bool, err error) { | |||
r0, _, e1 := syscall.Syscall(procIsTokenRestricted.Addr(), 1, uintptr(tokenHandle), 0, 0) | |||
ret = r0 != 0 | |||
if !ret { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) { | |||
r0, _, _ := syscall.Syscall(procIsValidSecurityDescriptor.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0) | |||
isValid = r0 != 0 | |||
@@ -913,6 +932,22 @@ func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reser | |||
return | |||
} | |||
func RegNotifyChangeKeyValue(key Handle, watchSubtree bool, notifyFilter uint32, event Handle, asynchronous bool) (regerrno error) { | |||
var _p0 uint32 | |||
if watchSubtree { | |||
_p0 = 1 | |||
} | |||
var _p1 uint32 | |||
if asynchronous { | |||
_p1 = 1 | |||
} | |||
r0, _, _ := syscall.Syscall6(procRegNotifyChangeKeyValue.Addr(), 5, uintptr(key), uintptr(_p0), uintptr(notifyFilter), uintptr(event), uintptr(_p1), 0) | |||
if r0 != 0 { | |||
regerrno = syscall.Errno(r0) | |||
} | |||
return | |||
} | |||
func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) { | |||
r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0) | |||
if r0 != 0 { | |||
@@ -970,6 +1005,14 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE | |||
return | |||
} | |||
func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { | |||
r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) | |||
if r1 == 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) { | |||
var _p0 *uint16 | |||
_p0, ret = syscall.UTF16PtrFromString(objectName) | |||
@@ -1056,8 +1099,11 @@ func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl * | |||
return | |||
} | |||
func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) { | |||
syscall.Syscall9(procSetSecurityInfo.Addr(), 7, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0) | |||
func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) { | |||
r0, _, _ := syscall.Syscall9(procSetSecurityInfo.Addr(), 7, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0) | |||
if r0 != 0 { | |||
ret = syscall.Errno(r0) | |||
} | |||
return | |||
} | |||
@@ -1167,7 +1213,7 @@ func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, a | |||
func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) { | |||
r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0) | |||
handle = Handle(r0) | |||
if handle == InvalidHandle { | |||
if handle == 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
@@ -1727,7 +1773,7 @@ func GetFileType(filehandle Handle) (n uint32, err error) { | |||
return | |||
} | |||
func GetFinalPathNameByHandleW(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) { | |||
func GetFinalPathNameByHandle(file Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) { | |||
r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0) | |||
n = uint32(r0) | |||
if n == 0 { | |||
@@ -2055,6 +2101,18 @@ func IsWow64Process(handle Handle, isWow64 *bool) (err error) { | |||
return | |||
} | |||
func IsWow64Process2(handle Handle, processMachine *uint16, nativeMachine *uint16) (err error) { | |||
err = procIsWow64Process2.Find() | |||
if err != nil { | |||
return | |||
} | |||
r1, _, e1 := syscall.Syscall(procIsWow64Process2.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(processMachine)), uintptr(unsafe.Pointer(nativeMachine))) | |||
if r1 == 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) { | |||
var _p0 *uint16 | |||
_p0, err = syscall.UTF16PtrFromString(libname) | |||
@@ -2316,8 +2374,8 @@ func ResumeThread(thread Handle) (ret uint32, err error) { | |||
return | |||
} | |||
func SetConsoleCursorPosition(console Handle, position Coord) (err error) { | |||
r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(*((*uint32)(unsafe.Pointer(&position)))), 0) | |||
func setConsoleCursorPosition(console Handle, position uint32) (err error) { | |||
r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0) | |||
if r1 == 0 { | |||
err = errnoErr(e1) | |||
} | |||
@@ -2340,6 +2398,31 @@ func SetCurrentDirectory(path *uint16) (err error) { | |||
return | |||
} | |||
func SetDefaultDllDirectories(directoryFlags uint32) (err error) { | |||
r1, _, e1 := syscall.Syscall(procSetDefaultDllDirectories.Addr(), 1, uintptr(directoryFlags), 0, 0) | |||
if r1 == 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func SetDllDirectory(path string) (err error) { | |||
var _p0 *uint16 | |||
_p0, err = syscall.UTF16PtrFromString(path) | |||
if err != nil { | |||
return | |||
} | |||
return _SetDllDirectory(_p0) | |||
} | |||
func _SetDllDirectory(path *uint16) (err error) { | |||
r1, _, e1 := syscall.Syscall(procSetDllDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) | |||
if r1 == 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func SetEndOfFile(handle Handle) (err error) { | |||
r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0) | |||
if r1 == 0 { | |||
@@ -2386,6 +2469,14 @@ func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) | |||
return | |||
} | |||
func SetFileInformationByHandle(handle Handle, class uint32, inBuffer *byte, inBufferLen uint32) (err error) { | |||
r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferLen), 0, 0) | |||
if r1 == 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) { | |||
r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0) | |||
newlowoffset = uint32(r0) | |||
@@ -2718,6 +2809,27 @@ func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) { | |||
return | |||
} | |||
func SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) { | |||
ret = procSubscribeServiceChangeNotifications.Find() | |||
if ret != nil { | |||
return | |||
} | |||
r0, _, _ := syscall.Syscall6(procSubscribeServiceChangeNotifications.Addr(), 5, uintptr(service), uintptr(eventType), uintptr(callback), uintptr(callbackCtx), uintptr(unsafe.Pointer(subscription)), 0) | |||
if r0 != 0 { | |||
ret = syscall.Errno(r0) | |||
} | |||
return | |||
} | |||
func UnsubscribeServiceChangeNotifications(subscription uintptr) (err error) { | |||
err = procUnsubscribeServiceChangeNotifications.Find() | |||
if err != nil { | |||
return | |||
} | |||
syscall.Syscall(procUnsubscribeServiceChangeNotifications.Addr(), 1, uintptr(subscription), 0, 0) | |||
return | |||
} | |||
func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) { | |||
r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize))) | |||
if r1&0xff == 0 { |
@@ -95,12 +95,13 @@ type Pass struct { | |||
Analyzer *Analyzer // the identity of the current analyzer | |||
// syntax and type information | |||
Fset *token.FileSet // file position information | |||
Files []*ast.File // the abstract syntax tree of each file | |||
OtherFiles []string // names of non-Go files of this package | |||
Pkg *types.Package // type information about the package | |||
TypesInfo *types.Info // type information about the syntax trees | |||
TypesSizes types.Sizes // function for computing sizes of types | |||
Fset *token.FileSet // file position information | |||
Files []*ast.File // the abstract syntax tree of each file | |||
OtherFiles []string // names of non-Go files of this package | |||
IgnoredFiles []string // names of ignored source files in this package | |||
Pkg *types.Package // type information about the package | |||
TypesInfo *types.Info // type information about the syntax trees | |||
TypesSizes types.Sizes // function for computing sizes of types | |||
// Report reports a Diagnostic, a finding about a specific location | |||
// in the analyzed source code such as a potential mistake. |
@@ -121,13 +121,14 @@ package being analyzed, and provides operations to the Run function for | |||
reporting diagnostics and other information back to the driver. | |||
type Pass struct { | |||
Fset *token.FileSet | |||
Files []*ast.File | |||
OtherFiles []string | |||
Pkg *types.Package | |||
TypesInfo *types.Info | |||
ResultOf map[*Analyzer]interface{} | |||
Report func(Diagnostic) | |||
Fset *token.FileSet | |||
Files []*ast.File | |||
OtherFiles []string | |||
IgnoredFiles []string | |||
Pkg *types.Package | |||
TypesInfo *types.Info | |||
ResultOf map[*Analyzer]interface{} | |||
Report func(Diagnostic) | |||
... | |||
} | |||
@@ -139,6 +140,12 @@ files such as assembly that are part of this package. See the "asmdecl" | |||
or "buildtags" analyzers for examples of loading non-Go files and reporting | |||
diagnostics against them. | |||
The IgnoredFiles field provides the names, but not the contents, | |||
of ignored Go and non-Go source files that are not part of this package | |||
with the current build configuration but may be part of other build | |||
configurations. See the "buildtags" analyzer for an example of loading | |||
and checking IgnoredFiles. | |||
The ResultOf field provides the results computed by the analyzers | |||
required by this one, as expressed in its Analyzer.Requires field. The | |||
driver runs the required analyzers first and makes their results |
@@ -63,6 +63,7 @@ type Config struct { | |||
ImportPath string | |||
GoFiles []string | |||
NonGoFiles []string | |||
IgnoredFiles []string | |||
ImportMap map[string]string | |||
PackageFile map[string]string | |||
Standard map[string]bool | |||
@@ -333,6 +334,7 @@ func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]re | |||
Fset: fset, | |||
Files: files, | |||
OtherFiles: cfg.NonGoFiles, | |||
IgnoredFiles: cfg.IgnoredFiles, | |||
Pkg: pkg, | |||
TypesInfo: info, | |||
TypesSizes: tc.Sizes, |
@@ -39,7 +39,12 @@ func GetSizes(ctx context.Context, buildFlags, env []string, gocmdRunner *gocomm | |||
} | |||
if tool == "off" { | |||
return GetSizesGolist(ctx, buildFlags, env, gocmdRunner, dir) | |||
inv := gocommand.Invocation{ | |||
BuildFlags: buildFlags, | |||
Env: env, | |||
WorkingDir: dir, | |||
} | |||
return GetSizesGolist(ctx, inv, gocmdRunner) | |||
} | |||
req, err := json.Marshal(struct { | |||
@@ -75,26 +80,17 @@ func GetSizes(ctx context.Context, buildFlags, env []string, gocmdRunner *gocomm | |||
return response.Sizes, nil | |||
} | |||
func GetSizesGolist(ctx context.Context, buildFlags, env []string, gocmdRunner *gocommand.Runner, dir string) (types.Sizes, error) { | |||
inv := gocommand.Invocation{ | |||
Verb: "list", | |||
Args: []string{"-f", "{{context.GOARCH}} {{context.Compiler}}", "--", "unsafe"}, | |||
Env: env, | |||
BuildFlags: buildFlags, | |||
WorkingDir: dir, | |||
} | |||
func GetSizesGolist(ctx context.Context, inv gocommand.Invocation, gocmdRunner *gocommand.Runner) (types.Sizes, error) { | |||
inv.Verb = "list" | |||
inv.Args = []string{"-f", "{{context.GOARCH}} {{context.Compiler}}", "--", "unsafe"} | |||
stdout, stderr, friendlyErr, rawErr := gocmdRunner.RunRaw(ctx, inv) | |||
var goarch, compiler string | |||
if rawErr != nil { | |||
if strings.Contains(rawErr.Error(), "cannot find main module") { | |||
// User's running outside of a module. All bets are off. Get GOARCH and guess compiler is gc. | |||
// TODO(matloob): Is this a problem in practice? | |||
inv := gocommand.Invocation{ | |||
Verb: "env", | |||
Args: []string{"GOARCH"}, | |||
Env: env, | |||
WorkingDir: dir, | |||
} | |||
inv.Verb = "env" | |||
inv.Args = []string{"GOARCH"} | |||
envout, enverr := gocmdRunner.Run(ctx, inv) | |||
if enverr != nil { | |||
return nil, enverr |
@@ -91,7 +91,7 @@ type golistState struct { | |||
goVersionOnce sync.Once | |||
goVersionError error | |||
goVersion string // third field of 'go version' | |||
goVersion int // The X in Go 1.X. | |||
// vendorDirs caches the (non)existence of vendor directories. | |||
vendorDirs map[string]bool | |||
@@ -139,6 +139,12 @@ func goListDriver(cfg *Config, patterns ...string) (*driverResponse, error) { | |||
response := newDeduper() | |||
state := &golistState{ | |||
cfg: cfg, | |||
ctx: ctx, | |||
vendorDirs: map[string]bool{}, | |||
} | |||
// Fill in response.Sizes asynchronously if necessary. | |||
var sizeserr error | |||
var sizeswg sync.WaitGroup | |||
@@ -146,19 +152,13 @@ func goListDriver(cfg *Config, patterns ...string) (*driverResponse, error) { | |||
sizeswg.Add(1) | |||
go func() { | |||
var sizes types.Sizes | |||
sizes, sizeserr = packagesdriver.GetSizesGolist(ctx, cfg.BuildFlags, cfg.Env, cfg.gocmdRunner, cfg.Dir) | |||
sizes, sizeserr = packagesdriver.GetSizesGolist(ctx, state.cfgInvocation(), cfg.gocmdRunner) | |||
// types.SizesFor always returns nil or a *types.StdSizes. | |||
response.dr.Sizes, _ = sizes.(*types.StdSizes) | |||
sizeswg.Done() | |||
}() | |||
} | |||
state := &golistState{ | |||
cfg: cfg, | |||
ctx: ctx, | |||
vendorDirs: map[string]bool{}, | |||
} | |||
// Determine files requested in contains patterns | |||
var containFiles []string | |||
restPatterns := make([]string, 0, len(patterns)) | |||
@@ -381,32 +381,34 @@ func (state *golistState) adhocPackage(pattern, query string) (*driverResponse, | |||
// Fields must match go list; | |||
// see $GOROOT/src/cmd/go/internal/load/pkg.go. | |||
type jsonPackage struct { | |||
ImportPath string | |||
Dir string | |||
Name string | |||
Export string | |||
GoFiles []string | |||
CompiledGoFiles []string | |||
CFiles []string | |||
CgoFiles []string | |||
CXXFiles []string | |||
MFiles []string | |||
HFiles []string | |||
FFiles []string | |||
SFiles []string | |||
SwigFiles []string | |||
SwigCXXFiles []string | |||
SysoFiles []string | |||
Imports []string | |||
ImportMap map[string]string | |||
Deps []string | |||
Module *Module | |||
TestGoFiles []string | |||
TestImports []string | |||
XTestGoFiles []string | |||
XTestImports []string | |||
ForTest string // q in a "p [q.test]" package, else "" | |||
DepOnly bool | |||
ImportPath string | |||
Dir string | |||
Name string | |||
Export string | |||
GoFiles []string | |||
CompiledGoFiles []string | |||
IgnoredGoFiles []string | |||
IgnoredOtherFiles []string | |||
CFiles []string | |||
CgoFiles []string | |||
CXXFiles []string | |||
MFiles []string | |||
HFiles []string | |||
FFiles []string | |||
SFiles []string | |||
SwigFiles []string | |||
SwigCXXFiles []string | |||
SysoFiles []string | |||
Imports []string | |||
ImportMap map[string]string | |||
Deps []string | |||
Module *Module | |||
TestGoFiles []string | |||
TestImports []string | |||
XTestGoFiles []string | |||
XTestImports []string | |||
ForTest string // q in a "p [q.test]" package, else "" | |||
DepOnly bool | |||
Error *jsonPackageError | |||
} | |||
@@ -558,6 +560,7 @@ func (state *golistState) createDriverResponse(words ...string) (*driverResponse | |||
GoFiles: absJoin(p.Dir, p.GoFiles, p.CgoFiles), | |||
CompiledGoFiles: absJoin(p.Dir, p.CompiledGoFiles), | |||
OtherFiles: absJoin(p.Dir, otherFiles(p)...), | |||
IgnoredFiles: absJoin(p.Dir, p.IgnoredGoFiles, p.IgnoredOtherFiles), | |||
forTest: p.ForTest, | |||
Module: p.Module, | |||
} | |||
@@ -728,7 +731,7 @@ func (state *golistState) shouldAddFilenameFromError(p *jsonPackage) bool { | |||
// On Go 1.14 and earlier, only add filenames from errors if the import stack is empty. | |||
// The import stack behaves differently for these versions than newer Go versions. | |||
if strings.HasPrefix(goV, "go1.13") || strings.HasPrefix(goV, "go1.14") { | |||
if goV < 15 { | |||
return len(p.Error.ImportStack) == 0 | |||
} | |||
@@ -739,31 +742,9 @@ func (state *golistState) shouldAddFilenameFromError(p *jsonPackage) bool { | |||
return len(p.Error.ImportStack) == 0 || p.Error.ImportStack[len(p.Error.ImportStack)-1] == p.ImportPath | |||
} | |||
func (state *golistState) getGoVersion() (string, error) { | |||
func (state *golistState) getGoVersion() (int, error) { | |||
state.goVersionOnce.Do(func() { | |||
var b *bytes.Buffer | |||
// Invoke go version. Don't use invokeGo because it will supply build flags, and | |||
// go version doesn't expect build flags. | |||
inv := gocommand.Invocation{ | |||
Verb: "version", | |||
Env: state.cfg.Env, | |||
Logf: state.cfg.Logf, | |||
} | |||
gocmdRunner := state.cfg.gocmdRunner | |||
if gocmdRunner == nil { | |||
gocmdRunner = &gocommand.Runner{} | |||
} | |||
b, _, _, state.goVersionError = gocmdRunner.RunRaw(state.cfg.Context, inv) | |||
if state.goVersionError != nil { | |||
return | |||
} | |||
sp := strings.Split(b.String(), " ") | |||
if len(sp) < 3 { | |||
state.goVersionError = fmt.Errorf("go version output: expected 'go version <version>', got '%s'", b.String()) | |||
return | |||
} | |||
state.goVersion = sp[2] | |||
state.goVersion, state.goVersionError = gocommand.GoVersion(state.ctx, state.cfgInvocation(), state.cfg.gocmdRunner) | |||
}) | |||
return state.goVersion, state.goVersionError | |||
} | |||
@@ -836,18 +817,26 @@ func golistargs(cfg *Config, words []string) []string { | |||
return fullargs | |||
} | |||
// invokeGo returns the stdout of a go command invocation. | |||
func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer, error) { | |||
// cfgInvocation returns an Invocation that reflects cfg's settings. | |||
func (state *golistState) cfgInvocation() gocommand.Invocation { | |||
cfg := state.cfg | |||
inv := gocommand.Invocation{ | |||
Verb: verb, | |||
Args: args, | |||
return gocommand.Invocation{ | |||
BuildFlags: cfg.BuildFlags, | |||
ModFile: cfg.modFile, | |||
ModFlag: cfg.modFlag, | |||
Env: cfg.Env, | |||
Logf: cfg.Logf, | |||
WorkingDir: cfg.Dir, | |||
} | |||
} | |||
// invokeGo returns the stdout of a go command invocation. | |||
func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer, error) { | |||
cfg := state.cfg | |||
inv := state.cfgInvocation() | |||
inv.Verb = verb | |||
inv.Args = args | |||
gocmdRunner := cfg.gocmdRunner | |||
if gocmdRunner == nil { | |||
gocmdRunner = &gocommand.Runner{} |
@@ -1,3 +1,7 @@ | |||
// Copyright 2018 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
package packages | |||
import ( |
@@ -144,6 +144,12 @@ type Config struct { | |||
// the build system's query tool. | |||
BuildFlags []string | |||
// modFile will be used for -modfile in go command invocations. | |||
modFile string | |||
// modFlag will be used for -modfile in go command invocations. | |||
modFlag string | |||
// Fset provides source position information for syntax trees and types. | |||
// If Fset is nil, Load will use a new fileset, but preserve Fset's value. | |||
Fset *token.FileSet | |||
@@ -289,6 +295,11 @@ type Package struct { | |||
// including assembly, C, C++, Fortran, Objective-C, SWIG, and so on. | |||
OtherFiles []string | |||
// IgnoredFiles lists source files that are not part of the package | |||
// using the current build configuration but that might be part of | |||
// the package using other build configurations. | |||
IgnoredFiles []string | |||
// ExportFile is the absolute path to a file containing type | |||
// information for the package as provided by the build system. | |||
ExportFile string | |||
@@ -361,6 +372,12 @@ func init() { | |||
packagesinternal.SetGoCmdRunner = func(config interface{}, runner *gocommand.Runner) { | |||
config.(*Config).gocmdRunner = runner | |||
} | |||
packagesinternal.SetModFile = func(config interface{}, value string) { | |||
config.(*Config).modFile = value | |||
} | |||
packagesinternal.SetModFlag = func(config interface{}, value string) { | |||
config.(*Config).modFlag = value | |||
} | |||
packagesinternal.TypecheckCgo = int(typecheckCgo) | |||
} | |||
@@ -404,6 +421,7 @@ type flatPackage struct { | |||
GoFiles []string `json:",omitempty"` | |||
CompiledGoFiles []string `json:",omitempty"` | |||
OtherFiles []string `json:",omitempty"` | |||
IgnoredFiles []string `json:",omitempty"` | |||
ExportFile string `json:",omitempty"` | |||
Imports map[string]string `json:",omitempty"` | |||
} | |||
@@ -426,6 +444,7 @@ func (p *Package) MarshalJSON() ([]byte, error) { | |||
GoFiles: p.GoFiles, | |||
CompiledGoFiles: p.CompiledGoFiles, | |||
OtherFiles: p.OtherFiles, | |||
IgnoredFiles: p.IgnoredFiles, | |||
ExportFile: p.ExportFile, | |||
} | |||
if len(p.Imports) > 0 { | |||
@@ -712,7 +731,8 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) { | |||
result[i] = lpkg.Package | |||
} | |||
for i := range ld.pkgs { | |||
// Clear all unrequested fields, for extra de-Hyrum-ization. | |||
// Clear all unrequested fields, | |||
// to catch programs that use more than they request. | |||
if ld.requestedMode&NeedName == 0 { | |||
ld.pkgs[i].Name = "" | |||
ld.pkgs[i].PkgPath = "" | |||
@@ -720,6 +740,7 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) { | |||
if ld.requestedMode&NeedFiles == 0 { | |||
ld.pkgs[i].GoFiles = nil | |||
ld.pkgs[i].OtherFiles = nil | |||
ld.pkgs[i].IgnoredFiles = nil | |||
} | |||
if ld.requestedMode&NeedCompiledGoFiles == 0 { | |||
ld.pkgs[i].CompiledGoFiles = nil |
@@ -130,6 +130,8 @@ type Invocation struct { | |||
Verb string | |||
Args []string | |||
BuildFlags []string | |||
ModFlag string | |||
ModFile string | |||
Env []string | |||
WorkingDir string | |||
Logf func(format string, args ...interface{}) | |||
@@ -158,17 +160,35 @@ func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error { | |||
} | |||
goArgs := []string{i.Verb} | |||
appendModFile := func() { | |||
if i.ModFile != "" { | |||
goArgs = append(goArgs, "-modfile="+i.ModFile) | |||
} | |||
} | |||
appendModFlag := func() { | |||
if i.ModFlag != "" { | |||
goArgs = append(goArgs, "-mod="+i.ModFlag) | |||
} | |||
} | |||
switch i.Verb { | |||
case "env", "version": | |||
goArgs = append(goArgs, i.Args...) | |||
case "mod": | |||
// mod needs the sub-verb before build flags. | |||
// mod needs the sub-verb before flags. | |||
goArgs = append(goArgs, i.Args[0]) | |||
goArgs = append(goArgs, i.BuildFlags...) | |||
appendModFile() | |||
goArgs = append(goArgs, i.Args[1:]...) | |||
case "env": | |||
// env doesn't take build flags. | |||
case "get": | |||
goArgs = append(goArgs, i.BuildFlags...) | |||
appendModFile() | |||
goArgs = append(goArgs, i.Args...) | |||
default: | |||
default: // notably list and build. | |||
goArgs = append(goArgs, i.BuildFlags...) | |||
appendModFile() | |||
appendModFlag() | |||
goArgs = append(goArgs, i.Args...) | |||
} | |||
cmd := exec.Command("go", goArgs...) |
@@ -0,0 +1,40 @@ | |||
// Copyright 2020 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
package gocommand | |||
import ( | |||
"context" | |||
"fmt" | |||
"strings" | |||
) | |||
// GoVersion checks the go version by running "go list" with modules off. | |||
// It returns the X in Go 1.X. | |||
func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) { | |||
inv.Verb = "list" | |||
inv.Args = []string{"-e", "-f", `{{context.ReleaseTags}}`} | |||
inv.Env = append(append([]string{}, inv.Env...), "GO111MODULE=off") | |||
// Unset any unneeded flags. | |||
inv.ModFile = "" | |||
inv.ModFlag = "" | |||
stdoutBytes, err := r.Run(ctx, inv) | |||
if err != nil { | |||
return 0, err | |||
} | |||
stdout := stdoutBytes.String() | |||
if len(stdout) < 3 { | |||
return 0, fmt.Errorf("bad ReleaseTags output: %q", stdout) | |||
} | |||
// Split up "[go1.1 go1.15]" | |||
tags := strings.Fields(stdout[1 : len(stdout)-2]) | |||
for i := len(tags) - 1; i >= 0; i-- { | |||
var version int | |||
if _, err := fmt.Sscanf(tags[i], "go1.%d", &version); err != nil { | |||
continue | |||
} | |||
return version, nil | |||
} | |||
return 0, fmt.Errorf("no parseable ReleaseTags in %v", tags) | |||
} |
@@ -83,7 +83,7 @@ type ImportFix struct { | |||
IdentName string | |||
// FixType is the type of fix this is (AddImport, DeleteImport, SetImportName). | |||
FixType ImportFixType | |||
Relevance int // see pkg | |||
Relevance float64 // see pkg | |||
} | |||
// An ImportInfo represents a single import statement. | |||
@@ -592,9 +592,9 @@ func getFixes(fset *token.FileSet, f *ast.File, filename string, env *ProcessEnv | |||
return fixes, nil | |||
} | |||
// Highest relevance, used for the standard library. Chosen arbitrarily to | |||
// match pre-existing gopls code. | |||
const MaxRelevance = 7 | |||
// MaxRelevance is the highest relevance, used for the standard library. | |||
// Chosen arbitrarily to match pre-existing gopls code. | |||
const MaxRelevance = 7.0 | |||
// getCandidatePkgs works with the passed callback to find all acceptable packages. | |||
// It deduplicates by import path, and uses a cached stdlib rather than reading | |||
@@ -607,6 +607,10 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena | |||
if err != nil { | |||
return err | |||
} | |||
var mu sync.Mutex // to guard asynchronous access to dupCheck | |||
dupCheck := map[string]struct{}{} | |||
// Start off with the standard library. | |||
for importPath, exports := range stdlib { | |||
p := &pkg{ | |||
@@ -615,14 +619,12 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena | |||
packageName: path.Base(importPath), | |||
relevance: MaxRelevance, | |||
} | |||
dupCheck[importPath] = struct{}{} | |||
if notSelf(p) && wrappedCallback.dirFound(p) && wrappedCallback.packageNameLoaded(p) { | |||
wrappedCallback.exportsLoaded(p, exports) | |||
} | |||
} | |||
var mu sync.Mutex | |||
dupCheck := map[string]struct{}{} | |||
scanFilter := &scanCallback{ | |||
rootFound: func(root gopathwalk.Root) bool { | |||
// Exclude goroot results -- getting them is relatively expensive, not cached, | |||
@@ -658,8 +660,8 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena | |||
return resolver.scan(ctx, scanFilter) | |||
} | |||
func ScoreImportPaths(ctx context.Context, env *ProcessEnv, paths []string) (map[string]int, error) { | |||
result := make(map[string]int) | |||
func ScoreImportPaths(ctx context.Context, env *ProcessEnv, paths []string) (map[string]float64, error) { | |||
result := make(map[string]float64) | |||
resolver, err := env.GetResolver() | |||
if err != nil { | |||
return nil, err | |||
@@ -802,6 +804,8 @@ type ProcessEnv struct { | |||
GocmdRunner *gocommand.Runner | |||
BuildFlags []string | |||
ModFlag string | |||
ModFile string | |||
// Env overrides the OS environment, and can be used to specify | |||
// GOPROXY, GO111MODULE, etc. PATH cannot be set here, because | |||
@@ -995,7 +999,7 @@ type Resolver interface { | |||
// loadExports may be called concurrently. | |||
loadExports(ctx context.Context, pkg *pkg, includeTest bool) (string, []string, error) | |||
// scoreImportPath returns the relevance for an import path. | |||
scoreImportPath(ctx context.Context, path string) int | |||
scoreImportPath(ctx context.Context, path string) float64 | |||
ClearForNewScan() | |||
} | |||
@@ -1260,10 +1264,10 @@ func packageDirToName(dir string) (packageName string, err error) { | |||
} | |||
type pkg struct { | |||
dir string // absolute file path to pkg directory ("/usr/lib/go/src/net/http") | |||
importPathShort string // vendorless import path ("net/http", "a/b") | |||
packageName string // package name loaded from source if requested | |||
relevance int // a weakly-defined score of how relevant a package is. 0 is most relevant. | |||
dir string // absolute file path to pkg directory ("/usr/lib/go/src/net/http") | |||
importPathShort string // vendorless import path ("net/http", "a/b") | |||
packageName string // package name loaded from source if requested | |||
relevance float64 // a weakly-defined score of how relevant a package is. 0 is most relevant. | |||
} | |||
type pkgDistance struct { | |||
@@ -1389,7 +1393,7 @@ func (r *gopathResolver) scan(ctx context.Context, callback *scanCallback) error | |||
return nil | |||
} | |||
func (r *gopathResolver) scoreImportPath(ctx context.Context, path string) int { | |||
func (r *gopathResolver) scoreImportPath(ctx context.Context, path string) float64 { | |||
if _, ok := stdlib[path]; ok { | |||
return MaxRelevance | |||
} |
@@ -59,6 +59,8 @@ func (r *ModuleResolver) init() error { | |||
} | |||
inv := gocommand.Invocation{ | |||
BuildFlags: r.env.BuildFlags, | |||
ModFlag: r.env.ModFlag, | |||
ModFile: r.env.ModFile, | |||
Env: r.env.env(), | |||
Logf: r.env.Logf, | |||
WorkingDir: r.env.WorkingDir, | |||
@@ -487,7 +489,7 @@ func (r *ModuleResolver) scan(ctx context.Context, callback *scanCallback) error | |||
return nil | |||
} | |||
func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) int { | |||
func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) float64 { | |||
if _, ok := stdlib[path]; ok { | |||
return MaxRelevance | |||
} | |||
@@ -495,17 +497,31 @@ func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) int { | |||
return modRelevance(mod) | |||
} | |||
func modRelevance(mod *gocommand.ModuleJSON) int { | |||
func modRelevance(mod *gocommand.ModuleJSON) float64 { | |||
var relevance float64 | |||
switch { | |||
case mod == nil: // out of scope | |||
return MaxRelevance - 4 | |||
case mod.Indirect: | |||
return MaxRelevance - 3 | |||
relevance = MaxRelevance - 3 | |||
case !mod.Main: | |||
return MaxRelevance - 2 | |||
relevance = MaxRelevance - 2 | |||
default: | |||
return MaxRelevance - 1 // main module ties with stdlib | |||
relevance = MaxRelevance - 1 // main module ties with stdlib | |||
} | |||
_, versionString, ok := module.SplitPathVersion(mod.Path) | |||
if ok { | |||
index := strings.Index(versionString, "v") | |||
if index == -1 { | |||
return relevance | |||
} | |||
if versionNumber, err := strconv.ParseFloat(versionString[index+1:], 64); err == nil { | |||
relevance += versionNumber / 1000 | |||
} | |||
} | |||
return relevance | |||
} | |||
// canonicalize gets the result of canonicalizing the packages using the results |