- update vendor

master v1.0.79
李光春 1 year ago
parent cb86530fd4
commit 7c2e03cab2

@ -5,12 +5,12 @@ go 1.20
require (
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible
github.com/allegro/bigcache/v3 v3.1.0
github.com/baidubce/bce-sdk-go v0.9.141
github.com/baidubce/bce-sdk-go v0.9.142
github.com/basgys/goxml2json v1.1.0
github.com/gin-gonic/gin v1.8.2
github.com/go-playground/locales v0.14.1
github.com/go-playground/universal-translator v0.18.0
github.com/go-playground/validator/v10 v10.11.1
github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.11.2
github.com/go-sql-driver/mysql v1.7.0
github.com/lib/pq v1.10.7
github.com/mitchellh/mapstructure v1.5.0
@ -18,7 +18,7 @@ require (
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/oschwald/geoip2-golang v1.8.0
github.com/qiniu/go-sdk/v7 v7.14.0
github.com/redis/go-redis/v9 v9.0.0-rc.4
github.com/redis/go-redis/v9 v9.0.2
github.com/robfig/cron/v3 v3.0.1
github.com/saracen/go7z v0.0.0-20191010121135-9c09b6bd7fda
github.com/shirou/gopsutil v3.21.11+incompatible
@ -32,8 +32,8 @@ require (
gorm.io/datatypes v1.1.0
gorm.io/driver/mysql v1.4.5
gorm.io/driver/postgres v1.4.6
gorm.io/gen v0.3.19
gorm.io/gorm v1.24.3
gorm.io/gen v0.3.21
gorm.io/gorm v1.24.5
xorm.io/xorm v1.3.2
)
@ -42,7 +42,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/clbanning/mxj v1.8.4 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/goccy/go-json v0.10.0 // indirect
@ -71,7 +70,7 @@ require (
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/ugorji/go/codec v1.2.8 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
@ -83,7 +82,7 @@ require (
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.5.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
@ -91,6 +90,6 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/hints v1.1.1 // indirect
gorm.io/plugin/dbresolver v1.4.0 // indirect
gorm.io/plugin/dbresolver v1.4.1 // indirect
xorm.io/builder v0.3.12 // indirect
)

@ -29,8 +29,8 @@ github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6l
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/baidubce/bce-sdk-go v0.9.141 h1:EV5BH5lfymIGPSmYDo9xYdsVlvWAW6nFeiA6t929zBE=
github.com/baidubce/bce-sdk-go v0.9.141/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg=
github.com/baidubce/bce-sdk-go v0.9.142 h1:zWXZy8R1UN76zybzW208scQOfZC+O398kwwF1S+NJaY=
github.com/baidubce/bce-sdk-go v0.9.142/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg=
github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw=
github.com/basgys/goxml2json v1.1.0/go.mod h1:wH7a5Np/Q4QoECFIU8zTQlZwZkrilY0itPfecMw41Dw=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
@ -40,6 +40,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
github.com/bsm/ginkgo/v2 v2.5.0 h1:aOAnND1T40wEdAtkGSkvSICWeQ8L3UASX7YVCqQx+eQ=
github.com/bsm/gomega v1.20.0 h1:JhAwLmtRzXFTx2AkALSLa8ijZafntmhSoU63Ok18Uq8=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
@ -81,8 +83,6 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
@ -96,18 +96,19 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk=
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
@ -144,8 +145,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
@ -183,6 +184,7 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
@ -341,15 +343,14 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
@ -401,8 +402,8 @@ github.com/qiniu/go-sdk/v7 v7.14.0 h1:6icihMTKHoKMmeU1mqtIoHUv7c1LrLjYm8wTQaYDqm
github.com/qiniu/go-sdk/v7 v7.14.0/go.mod h1:btsaOc8CA3hdVloULfFdDgDc+g4f3TDZEFsDY0BLE+w=
github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.0.0-rc.4 h1:JUhsiZMTZknz3vn50zSVlkwcSeTGPd51lMO3IKUrWpY=
github.com/redis/go-redis/v9 v9.0.0-rc.4/go.mod h1:Vo3EsyWnicKnSKCA7HhgnvnyA74wOA69Cd2Meli5mmA=
github.com/redis/go-redis/v9 v9.0.2 h1:BA426Zqe/7r56kCcvxYLWe1mkaz71LKF77GwgFzSxfE=
github.com/redis/go-redis/v9 v9.0.2/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps=
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/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
@ -475,8 +476,8 @@ github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7Am
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0=
github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU=
github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
@ -542,7 +543,6 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
@ -626,19 +626,17 @@ golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -683,6 +681,7 @@ golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
@ -714,6 +713,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
@ -744,17 +744,18 @@ gorm.io/driver/postgres v1.4.6/go.mod h1:UJChCNLFKeBqQRE+HrkFUbKbq9idPXmTOk2u4Wo
gorm.io/driver/sqlite v1.4.2/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU=
gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0=
gorm.io/gen v0.3.19 h1:GX+KLUrycBzy6UsM1svLgC7wBoZVN1XSvbSCZDnuXEE=
gorm.io/gen v0.3.19/go.mod h1:aWgvoKdG9f8Des4TegSa0N5a+gwhGsFo0JJMaLwokvk=
gorm.io/gen v0.3.21 h1:t8329wT4tW1ZZWOm7vn4LV6OIrz8a5zCg+p78ezt+rA=
gorm.io/gen v0.3.21/go.mod h1:aWgvoKdG9f8Des4TegSa0N5a+gwhGsFo0JJMaLwokvk=
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.3 h1:WL2ifUmzR/SLp85CSURAfybcHnGZ+yLSGSxgYXlFBHg=
gorm.io/gorm v1.24.3/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE=
gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/hints v1.1.1 h1:NPampLxQujY+277452rt4yqtg6JmzNZ1jA2olk0eFXw=
gorm.io/hints v1.1.1/go.mod h1:zdwzfFqvBWGbpuKiAhLFOSGSpeD3/VsRgkXR9Y7Z3cs=
gorm.io/plugin/dbresolver v1.4.0 h1:MnT3JFDFpZ1lJ6MoGW5jOAHHuItL/jfBCwqmdVWMC+A=
gorm.io/plugin/dbresolver v1.4.0/go.mod h1:w0DKqg02frWKwbBMTQkJ7aVxeKnap2cShQcroOQaq8k=
gorm.io/plugin/dbresolver v1.4.1 h1:Ug4LcoPhrvqq71UhxtF346f+skTYoCa/nEsdjvHwEzk=
gorm.io/plugin/dbresolver v1.4.1/go.mod h1:CTbCtMWhsjXSiJqiW2R8POvJ2cq18RVOl4WGyT5nhNc=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

@ -1,5 +1,5 @@
package go_library
func Version() string {
return "1.0.78"
return "1.0.79"
}

@ -26,7 +26,7 @@ import (
// Constants and default values for the package bce
const (
SDK_VERSION = "0.9.141"
SDK_VERSION = "0.9.142"
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
DEFAULT_DOMAIN = "baidubce.com"
DEFAULT_PROTOCOL = "http"

@ -81,4 +81,5 @@ const (
BCE_FORBID_OVERWRITE = "x-bce-forbid-overwrite"
BCE_SYMLINK_TARGET = "x-bce-symlink-target"
BCE_TRAFFIC_LIMIT = "x-bce-traffic-limit"
BCE_BUCKET_TYPE = "x-bce-bucket-type"
)

@ -106,21 +106,22 @@ func ListObjects(cli bce.Client, bucket string,
// - bucket: the bucket name
// RETURNS:
// - error: nil if exists and have authority otherwise the specific error
func HeadBucket(cli bce.Client, bucket string) error {
func HeadBucket(cli bce.Client, bucket string) (error, *bce.BceResponse) {
req := &bce.BceRequest{}
req.SetUri(getBucketUri(bucket))
req.SetMethod(http.HEAD)
resp := &bce.BceResponse{}
if err := SendRequest(cli, req, resp); err != nil {
return err
return err, resp
}
if resp.IsFail() {
return resp.ServiceError()
return resp.ServiceError(), resp
}
defer func() { resp.Body().Close() }()
return nil
return nil, resp
}
// PutBucket - create a new bucket with the given name
//
// PARAMS:

@ -59,6 +59,8 @@ const (
FORBID_OVERWRITE_FALSE = "false"
FORBID_OVERWRITE_TRUE = "true"
NAMESPACE_BUCKET = "namespace"
)
var DEFAULT_CNAME_LIKE_LIST = []string{

@ -28,6 +28,7 @@ import (
"github.com/baidubce/bce-sdk-go/auth"
"github.com/baidubce/bce-sdk-go/bce"
sdk_http "github.com/baidubce/bce-sdk-go/http"
"github.com/baidubce/bce-sdk-go/services/bos/api"
"github.com/baidubce/bce-sdk-go/services/sts"
"github.com/baidubce/bce-sdk-go/util/log"
@ -183,7 +184,8 @@ func (c *Client) SimpleListObjects(bucket, prefix string, maxKeys int, marker,
// RETURNS:
// - error: nil if exists and have authority otherwise the specific error
func (c *Client) HeadBucket(bucket string) error {
return api.HeadBucket(c, bucket)
err, _ := api.HeadBucket(c, bucket)
return err
}
// DoesBucketExist - test the given bucket existed or not
@ -194,7 +196,7 @@ func (c *Client) HeadBucket(bucket string) error {
// - bool: true if exists and false if not exists or occurs error
// - error: nil if exists or not exist, otherwise the specific error
func (c *Client) DoesBucketExist(bucket string) (bool, error) {
err := api.HeadBucket(c, bucket)
err, _ := api.HeadBucket(c, bucket)
if err == nil {
return true, nil
}
@ -209,6 +211,21 @@ func (c *Client) DoesBucketExist(bucket string) (bool, error) {
return false, err
}
//IsNsBucket - test the given bucket is namespace bucket or not
func (c *Client) IsNsBucket(bucket string) bool {
err, resp := api.HeadBucket(c, bucket)
if err == nil && resp.Header(sdk_http.BCE_BUCKET_TYPE) == api.NAMESPACE_BUCKET {
return true
}
if realErr, ok := err.(*bce.BceServiceError); ok {
if realErr.StatusCode == http.StatusForbidden &&
resp.Header(sdk_http.BCE_BUCKET_TYPE) == api.NAMESPACE_BUCKET {
return true
}
}
return false
}
// PutBucket - create a new bucket
//
// PARAMS:

@ -1,11 +1,9 @@
## universal-translator
<img align="right" src="https://raw.githubusercontent.com/go-playground/universal-translator/master/logo.png">![Project status](https://img.shields.io/badge/version-0.18.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/universal-translator.svg?branch=master)](https://travis-ci.org/go-playground/universal-translator)
<img align="right" src="https://raw.githubusercontent.com/go-playground/universal-translator/master/logo.png">![Project status](https://img.shields.io/badge/version-0.18.1-green.svg)
[![Coverage Status](https://coveralls.io/repos/github/go-playground/universal-translator/badge.svg)](https://coveralls.io/github/go-playground/universal-translator)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/universal-translator)](https://goreportcard.com/report/github.com/go-playground/universal-translator)
[![GoDoc](https://godoc.org/github.com/go-playground/universal-translator?status.svg)](https://godoc.org/github.com/go-playground/universal-translator)
![License](https://img.shields.io/dub/l/vibe-d.svg)
[![Gitter](https://badges.gitter.im/go-playground/universal-translator.svg)](https://gitter.im/go-playground/universal-translator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
Universal Translator is an i18n Translator for Go/Golang using CLDR data + pluralization rules

@ -3,7 +3,6 @@ package ut
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
@ -41,7 +40,6 @@ const (
func (t *UniversalTranslator) Export(format ImportExportFormat, dirname string) error {
_, err := os.Stat(dirname)
fmt.Println(dirname, err, os.IsNotExist(err))
if err != nil {
if !os.IsNotExist(err) {
@ -138,7 +136,7 @@ func (t *UniversalTranslator) Export(format ImportExportFormat, dirname string)
return err
}
err = ioutil.WriteFile(filepath.Join(dirname, fmt.Sprintf("%s%s", locale.Locale(), ext)), b, 0644)
err = os.WriteFile(filepath.Join(dirname, fmt.Sprintf("%s%s", locale.Locale(), ext)), b, 0644)
if err != nil {
return err
}
@ -200,7 +198,7 @@ func (t *UniversalTranslator) Import(format ImportExportFormat, dirnameOrFilenam
// NOTE: generally used when assets have been embedded into the binary and are already in memory.
func (t *UniversalTranslator) ImportByReader(format ImportExportFormat, reader io.Reader) error {
b, err := ioutil.ReadAll(reader)
b, err := io.ReadAll(reader)
if err != nil {
return err
}

@ -28,3 +28,4 @@ _testmain.go
*.txt
cover.html
README.html
.idea

@ -1,7 +1,7 @@
Package validator
=================
<img align="right" src="https://raw.githubusercontent.com/go-playground/validator/v9/logo.png">[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Project status](https://img.shields.io/badge/version-10.11.1-green.svg)
![Project status](https://img.shields.io/badge/version-10.11.2-green.svg)
[![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator)
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)

@ -1266,6 +1266,11 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
translation: "{0} must contain a valid MAC address",
override: false,
},
{
tag: "fqdn",
translation: "{0} must be a valid FQDN",
override: false,
},
{
tag: "unique",
translation: "{0} must contain unique values",

@ -1,37 +1,13 @@
# [9.0.0-rc.4](https://github.com/redis/go-redis/compare/v9.0.0-rc.3...v9.0.0-rc.4) (2023-01-24)
# [9.0.0-rc.3](https://github.com/redis/go-redis/compare/v9.0.0-rc.2...v9.0.0-rc.3) (2023-01-24)
### Bug Fixes
* 386 platform test ([701b1d0](https://github.com/redis/go-redis/commit/701b1d0a8bc497c8dc55fb61bda05afde2dd073b))
* change serialize key "key" to "redis" ([913936b](https://github.com/redis/go-redis/commit/913936b4cd9ae131e4671d0960bf1f9e46e6b171))
* fix the withHook func ([0ed4a44](https://github.com/redis/go-redis/commit/0ed4a4420fddcbe897b3884ef637ece53ccc55b8))
* read cursor as uint64 ([b88bd93](https://github.com/redis/go-redis/commit/b88bd93662f55ff2d0b2353f5f79e7065464f982))
* **redisotel:** correct metrics.DialHook attrs ([#2331](https://github.com/redis/go-redis/issues/2331)) ([7c4b924](https://github.com/redis/go-redis/commit/7c4b92435024eef4429a30146fad28ec98085c5b))
* remove comment ([4ce9046](https://github.com/redis/go-redis/commit/4ce90461a5572395f0bffcf1e0eb5f17ae31ce11))
* remove mutex from pipeline ([6525bbb](https://github.com/redis/go-redis/commit/6525bbbaa157eaea40e363c462057a3ad29536a9))
* tags for structToMap "json" -> "key" ([07e15d2](https://github.com/redis/go-redis/commit/07e15d2876ccc88afcd0f344a3eed6a050ff1921))
* test code ([1fdcbf8](https://github.com/redis/go-redis/commit/1fdcbf86bbb390e4e689a35a391a4a4b3917216d))
## [9.0.2](https://github.com/redis/go-redis/compare/v9.0.1...v9.0.2) (2023-02-01)
### Features
* add ClientName option ([a872c35](https://github.com/redis/go-redis/commit/a872c35b1a9cbd19904010c105281ad15ab687ab))
* add SORT_RO command ([ca063fd](https://github.com/redis/go-redis/commit/ca063fd0adf0974504f4e9d7352e1b4d7b14cb61))
* add zintercard cmd ([bb65dcd](https://github.com/redis/go-redis/commit/bb65dcdf0903459ed341c87de34ad689632dceff))
* appendArgs adds to read the structure field and supplements the test ([0064199](https://github.com/redis/go-redis/commit/0064199323e408f0dafcd033460acb94a9ad9f4f))
* enable struct on HSet ([bf334e7](https://github.com/redis/go-redis/commit/bf334e773819574a898717f5a709e15cecaa43ff))
* hook mode is changed to FIFO ([97697f4](https://github.com/redis/go-redis/commit/97697f488fe5179542d07af72e031939fd854a99))
* **redisotel:** add code attributes ([3892986](https://github.com/redis/go-redis/commit/3892986f01959e1e71aee8710d9719400e0b1205))
* **scan:** add Scanner interface ([#2317](https://github.com/redis/go-redis/issues/2317)) ([a4336cb](https://github.com/redis/go-redis/commit/a4336cbd43a1e620cb8967bca27a678b9445bef8))
* upgrade OpenTelemetry, use the new metrics API. ([#2410](https://github.com/redis/go-redis/issues/2410)) ([e29e42c](https://github.com/redis/go-redis/commit/e29e42cde2755ab910d04185025dc43ce6f59c65))
## v9 UNRELEASED
## v9 2023-01-30
### Added

@ -1,11 +1,15 @@
PACKAGE_DIRS := $(shell find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; | sort)
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
test: testdeps
go test ./...
go test ./... -short -race
go test ./... -run=NONE -bench=. -benchmem
env GOOS=linux GOARCH=386 go test ./...
go vet
set -e; for dir in $(GO_MOD_DIRS); do \
echo "go test in $${dir}"; \
(cd "$${dir}" && \
go test && \
go test ./... -short -race && \
go test ./... -run=NONE -bench=. -benchmem && \
env GOOS=linux GOARCH=386 go test && \
go vet); \
done
cd internal/customvet && go build .
go vet -vettool ./internal/customvet/customvet
@ -28,7 +32,7 @@ fmt:
goimports -w -local github.com/redis/go-redis ./
go_mod_tidy:
set -e; for dir in $(PACKAGE_DIRS); do \
set -e; for dir in $(GO_MOD_DIRS); do \
echo "go mod tidy in $${dir}"; \
(cd "$${dir}" && \
go get -u ./... && \

@ -1287,9 +1287,13 @@ func (c *ClusterClient) processPipelineNode(
return err
}
err = c.processPipelineNodeConn(ctx, node, cn, cmds, failedCmds)
node.Client.releaseConn(ctx, cn, err)
return err
var processErr error
defer func() {
node.Client.releaseConn(ctx, cn, processErr)
}()
processErr = c.processPipelineNodeConn(ctx, node, cn, cmds, failedCmds)
return processErr
})
}
@ -1464,9 +1468,13 @@ func (c *ClusterClient) processTxPipelineNode(
return err
}
err = c.processTxPipelineNodeConn(ctx, node, cn, cmds, failedCmds)
node.Client.releaseConn(ctx, cn, err)
return err
var processErr error
defer func() {
node.Client.releaseConn(ctx, cn, processErr)
}()
processErr = c.processTxPipelineNodeConn(ctx, node, cn, cmds, failedCmds)
return processErr
})
}

@ -1,6 +1,6 @@
{
"name": "redis",
"version": "9.0.0-rc.4",
"version": "9.0.2",
"main": "index.js",
"repository": "git@github.com:redis/go-redis.git",
"author": "Vladimir Mihailenco <vladimir.webdev@gmail.com>",

@ -342,9 +342,14 @@ func (c *baseClient) withConn(
return err
}
err = fn(ctx, cn)
c.releaseConn(ctx, cn, err)
return err
var fnErr error
defer func() {
c.releaseConn(ctx, cn, fnErr)
}()
fnErr = fn(ctx, cn)
return fnErr
}
func (c *baseClient) dial(ctx context.Context, network, addr string) (net.Conn, error) {

@ -2,5 +2,5 @@ package redis
// Version is the current release version.
func Version() string {
return "9.0.0-rc.4"
return "9.0.2"
}

@ -247,7 +247,7 @@ caveats. See Encode documentation.
```go
const CborStreamBytes byte = 0x5f ...
const GenVersion = 25
const GenVersion = 26
var SelfExt = &extFailWrapper{}
var GoRpc goRpc
var MsgpackSpecRpc msgpackSpecRpc

@ -556,7 +556,10 @@ func (d *bincDecDriver) decUint() (v uint64) {
case 1:
v = uint64(bigen.Uint16(d.d.decRd.readn2()))
case 2:
v = uint64(bigen.Uint32(d.d.decRd.readn3()))
b3 := d.d.decRd.readn3()
var b [4]byte
copy(b[1:], b3[:])
v = uint64(bigen.Uint32(b))
case 3:
v = uint64(bigen.Uint32(d.d.decRd.readn4()))
case 4, 5, 6:

@ -16,9 +16,9 @@ import (
const msgBadDesc = "unrecognized descriptor byte"
const (
decDefMaxDepth = 1024 // maximum depth
decDefChanCap = 64 // should be large, as cap cannot be expanded
decScratchByteArrayLen = (8 + 2 + 2) * 8 // around cacheLineSize ie ~64, depending on Decoder size
decDefMaxDepth = 1024 // maximum depth
decDefChanCap = 64 // should be large, as cap cannot be expanded
decScratchByteArrayLen = (8 + 2 + 2 + 1) * 8 // around cacheLineSize ie ~64, depending on Decoder size
// MARKER: massage decScratchByteArrayLen to ensure xxxDecDriver structs fit within cacheLine*N
@ -150,13 +150,11 @@ type decDriver interface {
// If the format doesn't prefix the length, it returns containerLenUnknown.
// If the expected array was a nil in the stream, it returns containerLenNil.
ReadArrayStart() int
ReadArrayEnd()
// ReadMapStart will return the length of the array.
// If the format doesn't prefix the length, it returns containerLenUnknown.
// If the expected array was a nil in the stream, it returns containerLenNil.
ReadMapStart() int
ReadMapEnd()
reset()
@ -186,6 +184,8 @@ type decDriverContainerTracker interface {
ReadArrayElem()
ReadMapElemKey()
ReadMapElemValue()
ReadArrayEnd()
ReadMapEnd()
}
type decNegintPosintFloatNumber interface {
@ -202,11 +202,11 @@ func (x decDriverNoopNumberHelper) decFloat() (f float64, ok bool) { panic("decF
type decDriverNoopContainerReader struct{}
func (x decDriverNoopContainerReader) ReadArrayStart() (v int) { panic("ReadArrayStart unsupported") }
func (x decDriverNoopContainerReader) ReadArrayEnd() {}
func (x decDriverNoopContainerReader) ReadMapStart() (v int) { panic("ReadMapStart unsupported") }
func (x decDriverNoopContainerReader) ReadMapEnd() {}
func (x decDriverNoopContainerReader) CheckBreak() (v bool) { return }
// func (x decDriverNoopContainerReader) ReadArrayStart() (v int) { panic("ReadArrayStart unsupported") }
// func (x decDriverNoopContainerReader) ReadMapStart() (v int) { panic("ReadMapStart unsupported") }
func (x decDriverNoopContainerReader) ReadArrayEnd() {}
func (x decDriverNoopContainerReader) ReadMapEnd() {}
func (x decDriverNoopContainerReader) CheckBreak() (v bool) { return }
// DecodeOptions captures configuration options during decode.
type DecodeOptions struct {
@ -644,7 +644,7 @@ func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) {
// decode into it, and reset the interface to that new value.
if !canDecode {
rvn2 := d.oneShotAddrRV(rvType(rvn), rvn.Kind())
rvn2 := d.oneShotAddrRV(rvn.Type(), rvn.Kind())
rvSetDirect(rvn2, rvn)
rvn = rvn2
}
@ -729,38 +729,21 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) {
}
// Not much gain from doing it two ways for array.
// Arrays are not used as much for structs.
hasLen := containerLen >= 0
var checkbreak bool
tisfi := ti.sfi.source()
for j, si := range tisfi {
if hasLen {
if j == containerLen {
break
}
} else if d.checkBreak() {
checkbreak = true
break
}
hasLen := containerLen >= 0
// iterate all the items in the stream
// if mapped elem-wise to a field, handle it
// if more stream items than cap be mapped, error it
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.arrayElem()
d.kStructField(si, rv)
}
var proceed bool
if hasLen {
proceed = containerLen > len(tisfi)
} else {
proceed = !checkbreak
}
// if (hasLen && containerLen > len(tisfi)) || (!hasLen && !checkbreak) {
if proceed {
// read remaining values and throw away
for j := len(tisfi); ; j++ {
if !d.containerNext(j, containerLen, hasLen) {
break
}
d.arrayElem()
if j < len(tisfi) {
d.kStructField(tisfi[j], rv)
} else {
d.structFieldNotFound(j, "")
}
}
d.arrayEnd()
} else {
d.onerror(errNeedMapOrArrayDecodeToStruct)
@ -1231,7 +1214,7 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) {
d.decodeValue(rvk, keyFn)
// special case if interface wrapping a byte slice
if ktypeIsIntf {
if rvk2 := rvk.Elem(); rvk2.IsValid() && rvType(rvk2) == uint8SliceTyp {
if rvk2 := rvk.Elem(); rvk2.IsValid() && rvk2.Type() == uint8SliceTyp {
kstr2bs = rvGetBytes(rvk2)
rvSetIntf(rvk, rv4istr(fnRvk2()))
}
@ -1422,6 +1405,7 @@ func (d *Decoder) r() *decRd {
func (d *Decoder) init(h Handle) {
initHandle(h)
d.cbreak = d.js || d.cbor
d.bytes = true
d.err = errDecoderNotInitialized
d.h = h.getBasicHandle()
@ -1466,21 +1450,11 @@ func (d *Decoder) Reset(r io.Reader) {
r = &eofReader
}
d.bytes = false
if d.h.ReaderBufferSize > 0 {
if d.bi == nil {
d.bi = new(bufioDecReader)
}
d.bi.reset(r, d.h.ReaderBufferSize, &d.blist)
d.bufio = true
d.decReader = d.bi
} else {
if d.ri == nil {
d.ri = new(ioDecReader)
}
d.ri.reset(r, &d.blist)
d.bufio = false
d.decReader = d.ri
if d.ri == nil {
d.ri = new(ioDecReader)
}
d.ri.reset(r, d.h.ReaderBufferSize, &d.blist)
d.decReader = d.ri
d.resetCommon()
}
@ -1490,7 +1464,6 @@ func (d *Decoder) ResetBytes(in []byte) {
if in == nil {
in = []byte{}
}
d.bufio = false
d.bytes = true
d.decReader = &d.rb
d.rb.reset(in)
@ -1832,7 +1805,7 @@ PTR:
if rv.Kind() == reflect.Ptr {
rvpValid = true
if rvIsNil(rv) {
rvSetDirect(rv, reflect.New(rvType(rv).Elem()))
rvSetDirect(rv, reflect.New(rv.Type().Elem()))
}
rvp = rv
rv = rv.Elem()
@ -1840,7 +1813,7 @@ PTR:
}
if fn == nil {
fn = d.h.fn(rvType(rv))
fn = d.h.fn(rv.Type())
}
if fn.i.addrD {
if rvpValid {
@ -1926,9 +1899,9 @@ func (d *Decoder) rawBytes() (v []byte) {
// i.e. if necessary, make new copy always.
v = d.d.nextValueBytes([]byte{})
if d.bytes && !d.h.ZeroCopy {
v0 := v
v = make([]byte, len(v))
copy(v, v0)
vv := make([]byte, len(v))
copy(vv, v) // using copy here triggers make+copy optimization eliding memclr
v = vv
}
return
}
@ -1959,7 +1932,34 @@ func (d *Decoder) decodeFloat32() float32 {
// MARKER: do not call mapEnd if mapStart returns containerLenNil.
// MARKER: optimize decoding since all formats do not truly support all decDriver'ish operations.
// - Read(Map|Array)Start is only supported by all formats.
// - CheckBreak is only supported by json and cbor.
// - Read(Map|Array)End is only supported by json.
// - Read(Map|Array)Elem(Kay|Value) is only supported by json.
// Honor these in the code, to reduce the number of interface calls (even if empty).
func (d *Decoder) checkBreak() (v bool) {
// MARKER: jsonDecDriver.CheckBreak() cannot be inlined (over budget inlining cost).
// Consequently, there's no benefit in incurring the cost of this wrapping function.
// It is faster to just call the interface method directly.
// if d.js {
// return d.jsondriver().CheckBreak()
// }
// if d.cbor {
// return d.cbordriver().CheckBreak()
// }
if d.cbreak {
v = d.d.CheckBreak()
}
return
}
func (d *Decoder) containerNext(j, containerLen int, hasLen bool) bool {
// MARKER: keep in sync with gen-helper.go.tmpl
// return (hasLen && j < containerLen) || !(hasLen || slh.d.checkBreak())
if hasLen {
return j < containerLen
@ -1990,7 +1990,10 @@ func (d *Decoder) mapElemValue() {
}
func (d *Decoder) mapEnd() {
d.d.ReadMapEnd()
if d.js {
d.jsondriver().ReadMapEnd()
}
// d.d.ReadMapEnd()
d.depthDecr()
d.c = 0
}
@ -2011,7 +2014,10 @@ func (d *Decoder) arrayElem() {
}
func (d *Decoder) arrayEnd() {
d.d.ReadArrayEnd()
if d.js {
d.jsondriver().ReadArrayEnd()
}
// d.d.ReadArrayEnd()
d.depthDecr()
d.c = 0
}
@ -2046,7 +2052,7 @@ func (d *Decoder) interfaceExtConvertAndDecode(v interface{}, ext InterfaceExt)
if !rv.CanAddr() {
rvk = rv.Kind()
rv2 = d.oneShotAddrRV(rvType(rv), rvk)
rv2 = d.oneShotAddrRV(rv.Type(), rvk)
if rvk == reflect.Interface {
rvSetIntf(rv2, rv)
} else {
@ -2196,6 +2202,12 @@ func (x decNextValueBytesHelper) appendN(v *[]byte, b ...byte) {
}
}
func (x decNextValueBytesHelper) appendS(v *[]byte, b string) {
if *v != nil && !x.d.bytes {
*v = append(*v, b...)
}
}
func (x decNextValueBytesHelper) bytesRdV(v *[]byte, startpos uint) {
if x.d.bytes {
*v = x.d.rb.b[startpos:x.d.rb.c]
@ -2299,12 +2311,8 @@ func isDecodeable(rv reflect.Value) (canDecode bool, reason decNotDecodeableReas
}
func decByteSlice(r *decRd, clen, maxInitLen int, bs []byte) (bsOut []byte) {
if clen == 0 {
return zeroByteSlice
}
if len(bs) == clen {
bsOut = bs
r.readb(bsOut)
if clen <= 0 {
bsOut = zeroByteSlice
} else if cap(bs) >= clen {
bsOut = bs[:clen]
r.readb(bsOut)

@ -1325,7 +1325,7 @@ TOP:
}
if fn == nil {
fn = e.h.fn(rvType(rv))
fn = e.h.fn(rv.Type())
}
if !fn.i.addrE { // typically, addrE = false, so check it first
@ -1346,7 +1346,7 @@ TOP:
// OR non-nil values of kind map, slice and chan.
func (e *Encoder) encodeValueNonNil(rv reflect.Value, fn *codecFn) {
if fn == nil {
fn = e.h.fn(rvType(rv))
fn = e.h.fn(rv.Type())
}
if fn.i.addrE { // typically, addrE = false, so check it first

@ -3019,7 +3019,7 @@ func (fastpathT) DecSliceIntfY(v []interface{}, d *Decoder) (v2 []interface{}, c
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
v = make([]interface{}, uint(xlen))
@ -3052,7 +3052,7 @@ func (fastpathT) DecSliceIntfN(v []interface{}, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3118,7 +3118,7 @@ func (fastpathT) DecSliceStringY(v []string, d *Decoder) (v2 []string, changed b
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
v = make([]string, uint(xlen))
@ -3151,7 +3151,7 @@ func (fastpathT) DecSliceStringN(v []string, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3217,7 +3217,7 @@ func (fastpathT) DecSliceBytesY(v [][]byte, d *Decoder) (v2 [][]byte, changed bo
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 24)
v = make([][]byte, uint(xlen))
@ -3250,7 +3250,7 @@ func (fastpathT) DecSliceBytesN(v [][]byte, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3316,7 +3316,7 @@ func (fastpathT) DecSliceFloat32Y(v []float32, d *Decoder) (v2 []float32, change
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
v = make([]float32, uint(xlen))
@ -3349,7 +3349,7 @@ func (fastpathT) DecSliceFloat32N(v []float32, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3415,7 +3415,7 @@ func (fastpathT) DecSliceFloat64Y(v []float64, d *Decoder) (v2 []float64, change
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
v = make([]float64, uint(xlen))
@ -3448,7 +3448,7 @@ func (fastpathT) DecSliceFloat64N(v []float64, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3522,7 +3522,7 @@ func (fastpathT) DecSliceUint8Y(v []uint8, d *Decoder) (v2 []uint8, changed bool
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
v = make([]uint8, uint(xlen))
@ -3565,7 +3565,7 @@ func (fastpathT) DecSliceUint8N(v []uint8, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3631,7 +3631,7 @@ func (fastpathT) DecSliceUint64Y(v []uint64, d *Decoder) (v2 []uint64, changed b
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
v = make([]uint64, uint(xlen))
@ -3664,7 +3664,7 @@ func (fastpathT) DecSliceUint64N(v []uint64, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3730,7 +3730,7 @@ func (fastpathT) DecSliceIntY(v []int, d *Decoder) (v2 []int, changed bool) {
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
v = make([]int, uint(xlen))
@ -3763,7 +3763,7 @@ func (fastpathT) DecSliceIntN(v []int, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3829,7 +3829,7 @@ func (fastpathT) DecSliceInt32Y(v []int32, d *Decoder) (v2 []int32, changed bool
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
v = make([]int32, uint(xlen))
@ -3862,7 +3862,7 @@ func (fastpathT) DecSliceInt32N(v []int32, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -3928,7 +3928,7 @@ func (fastpathT) DecSliceInt64Y(v []int64, d *Decoder) (v2 []int64, changed bool
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
v = make([]int64, uint(xlen))
@ -3961,7 +3961,7 @@ func (fastpathT) DecSliceInt64N(v []int64, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -4027,7 +4027,7 @@ func (fastpathT) DecSliceBoolY(v []bool, d *Decoder) (v2 []bool, changed bool) {
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
v = make([]bool, uint(xlen))
@ -4060,7 +4060,7 @@ func (fastpathT) DecSliceBoolN(v []bool, d *Decoder) {
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
return
@ -4108,7 +4108,7 @@ func (fastpathT) DecMapStringIntfL(v map[string]interface{}, containerLen int, d
var mk string
var mv interface{}
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4158,7 +4158,7 @@ func (fastpathT) DecMapStringStringL(v map[string]string, containerLen int, d *D
var mk string
var mv string
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4204,7 +4204,7 @@ func (fastpathT) DecMapStringBytesL(v map[string][]byte, containerLen int, d *De
var mk string
var mv []byte
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4254,7 +4254,7 @@ func (fastpathT) DecMapStringUint8L(v map[string]uint8, containerLen int, d *Dec
var mk string
var mv uint8
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4299,7 +4299,7 @@ func (fastpathT) DecMapStringUint64L(v map[string]uint64, containerLen int, d *D
var mk string
var mv uint64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4344,7 +4344,7 @@ func (fastpathT) DecMapStringIntL(v map[string]int, containerLen int, d *Decoder
var mk string
var mv int
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4389,7 +4389,7 @@ func (fastpathT) DecMapStringInt32L(v map[string]int32, containerLen int, d *Dec
var mk string
var mv int32
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4434,7 +4434,7 @@ func (fastpathT) DecMapStringFloat64L(v map[string]float64, containerLen int, d
var mk string
var mv float64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4479,7 +4479,7 @@ func (fastpathT) DecMapStringBoolL(v map[string]bool, containerLen int, d *Decod
var mk string
var mv bool
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.stringZC(d.d.DecodeStringAsBytes())
d.mapElemValue()
@ -4525,7 +4525,7 @@ func (fastpathT) DecMapUint8IntfL(v map[uint8]interface{}, containerLen int, d *
var mk uint8
var mv interface{}
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4575,7 +4575,7 @@ func (fastpathT) DecMapUint8StringL(v map[uint8]string, containerLen int, d *Dec
var mk uint8
var mv string
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4621,7 +4621,7 @@ func (fastpathT) DecMapUint8BytesL(v map[uint8][]byte, containerLen int, d *Deco
var mk uint8
var mv []byte
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4671,7 +4671,7 @@ func (fastpathT) DecMapUint8Uint8L(v map[uint8]uint8, containerLen int, d *Decod
var mk uint8
var mv uint8
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4716,7 +4716,7 @@ func (fastpathT) DecMapUint8Uint64L(v map[uint8]uint64, containerLen int, d *Dec
var mk uint8
var mv uint64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4761,7 +4761,7 @@ func (fastpathT) DecMapUint8IntL(v map[uint8]int, containerLen int, d *Decoder)
var mk uint8
var mv int
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4806,7 +4806,7 @@ func (fastpathT) DecMapUint8Int32L(v map[uint8]int32, containerLen int, d *Decod
var mk uint8
var mv int32
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4851,7 +4851,7 @@ func (fastpathT) DecMapUint8Float64L(v map[uint8]float64, containerLen int, d *D
var mk uint8
var mv float64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4896,7 +4896,7 @@ func (fastpathT) DecMapUint8BoolL(v map[uint8]bool, containerLen int, d *Decoder
var mk uint8
var mv bool
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
d.mapElemValue()
@ -4942,7 +4942,7 @@ func (fastpathT) DecMapUint64IntfL(v map[uint64]interface{}, containerLen int, d
var mk uint64
var mv interface{}
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -4992,7 +4992,7 @@ func (fastpathT) DecMapUint64StringL(v map[uint64]string, containerLen int, d *D
var mk uint64
var mv string
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -5038,7 +5038,7 @@ func (fastpathT) DecMapUint64BytesL(v map[uint64][]byte, containerLen int, d *De
var mk uint64
var mv []byte
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -5088,7 +5088,7 @@ func (fastpathT) DecMapUint64Uint8L(v map[uint64]uint8, containerLen int, d *Dec
var mk uint64
var mv uint8
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -5133,7 +5133,7 @@ func (fastpathT) DecMapUint64Uint64L(v map[uint64]uint64, containerLen int, d *D
var mk uint64
var mv uint64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -5178,7 +5178,7 @@ func (fastpathT) DecMapUint64IntL(v map[uint64]int, containerLen int, d *Decoder
var mk uint64
var mv int
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -5223,7 +5223,7 @@ func (fastpathT) DecMapUint64Int32L(v map[uint64]int32, containerLen int, d *Dec
var mk uint64
var mv int32
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -5268,7 +5268,7 @@ func (fastpathT) DecMapUint64Float64L(v map[uint64]float64, containerLen int, d
var mk uint64
var mv float64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -5313,7 +5313,7 @@ func (fastpathT) DecMapUint64BoolL(v map[uint64]bool, containerLen int, d *Decod
var mk uint64
var mv bool
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = d.d.DecodeUint64()
d.mapElemValue()
@ -5359,7 +5359,7 @@ func (fastpathT) DecMapIntIntfL(v map[int]interface{}, containerLen int, d *Deco
var mk int
var mv interface{}
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5409,7 +5409,7 @@ func (fastpathT) DecMapIntStringL(v map[int]string, containerLen int, d *Decoder
var mk int
var mv string
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5455,7 +5455,7 @@ func (fastpathT) DecMapIntBytesL(v map[int][]byte, containerLen int, d *Decoder)
var mk int
var mv []byte
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5505,7 +5505,7 @@ func (fastpathT) DecMapIntUint8L(v map[int]uint8, containerLen int, d *Decoder)
var mk int
var mv uint8
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5550,7 +5550,7 @@ func (fastpathT) DecMapIntUint64L(v map[int]uint64, containerLen int, d *Decoder
var mk int
var mv uint64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5595,7 +5595,7 @@ func (fastpathT) DecMapIntIntL(v map[int]int, containerLen int, d *Decoder) {
var mk int
var mv int
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5640,7 +5640,7 @@ func (fastpathT) DecMapIntInt32L(v map[int]int32, containerLen int, d *Decoder)
var mk int
var mv int32
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5685,7 +5685,7 @@ func (fastpathT) DecMapIntFloat64L(v map[int]float64, containerLen int, d *Decod
var mk int
var mv float64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5730,7 +5730,7 @@ func (fastpathT) DecMapIntBoolL(v map[int]bool, containerLen int, d *Decoder) {
var mk int
var mv bool
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
d.mapElemValue()
@ -5776,7 +5776,7 @@ func (fastpathT) DecMapInt32IntfL(v map[int32]interface{}, containerLen int, d *
var mk int32
var mv interface{}
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()
@ -5826,7 +5826,7 @@ func (fastpathT) DecMapInt32StringL(v map[int32]string, containerLen int, d *Dec
var mk int32
var mv string
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()
@ -5872,7 +5872,7 @@ func (fastpathT) DecMapInt32BytesL(v map[int32][]byte, containerLen int, d *Deco
var mk int32
var mv []byte
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()
@ -5922,7 +5922,7 @@ func (fastpathT) DecMapInt32Uint8L(v map[int32]uint8, containerLen int, d *Decod
var mk int32
var mv uint8
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()
@ -5967,7 +5967,7 @@ func (fastpathT) DecMapInt32Uint64L(v map[int32]uint64, containerLen int, d *Dec
var mk int32
var mv uint64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()
@ -6012,7 +6012,7 @@ func (fastpathT) DecMapInt32IntL(v map[int32]int, containerLen int, d *Decoder)
var mk int32
var mv int
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()
@ -6057,7 +6057,7 @@ func (fastpathT) DecMapInt32Int32L(v map[int32]int32, containerLen int, d *Decod
var mk int32
var mv int32
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()
@ -6102,7 +6102,7 @@ func (fastpathT) DecMapInt32Float64L(v map[int32]float64, containerLen int, d *D
var mk int32
var mv float64
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()
@ -6147,7 +6147,7 @@ func (fastpathT) DecMapInt32BoolL(v map[int32]bool, containerLen int, d *Decoder
var mk int32
var mv bool
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
mk = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
d.mapElemValue()

@ -409,7 +409,7 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}Y(v []{{ .Elem }}, d *Decoder)
}
}
var j int
for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j = 0; d.containerNext(j, containerLenS, hasLen); j++ {
if j == 0 && len(v) == 0 { // means hasLen == false
xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) {{/* xlen = decDefSliceCap */}}
v = make([]{{ .Elem }}, uint(xlen))
@ -455,7 +455,7 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}N(v []{{ .Elem }}, d *Decoder)
return
}
hasLen := containerLenS > 0
for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLenS, hasLen); j++ {
{{/* // if indefinite, etc, then expand the slice if necessary */ -}}
if j >= len(v) {
slh.arrayCannotExpand(hasLen, len(v), j, containerLenS)
@ -531,7 +531,7 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}L(v map[{{ .MapKey }}]{{ .Elem
var mk {{ .MapKey }}
var mv {{ .Elem }}
hasLen := containerLen > 0
for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
for j := 0; d.containerNext(j, containerLen, hasLen); j++ {
d.mapElemKey()
{{ if eq .MapKey "interface{}" }}mk = nil
d.decode(&mk)

@ -42,8 +42,8 @@ if {{var "l"}} == 0 {
}
{{end -}}
var {{var "j"}} int
{{/* // var {{var "dn"}} bool */ -}}
for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { // bounds-check-elimination
{{/* // var {{var "dn"}} bool */ -}}
for {{var "j"}} = 0; z.DecContainerNext({{var "j"}}, {{var "l"}}, {{var "hl"}}); {{var "j"}}++ {
{{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil {
if {{var "hl"}} {
{{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})

@ -19,7 +19,7 @@ if z.DecBasicHandle().MapValueReset {
{{end}} }
if {{var "l"}} != 0 {
{{var "hl"}} := {{var "l"}} > 0
for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ {
for {{var "j"}} := 0; z.DecContainerNext({{var "j"}}, {{var "l"}}, {{var "hl"}}); {{var "j"}}++ {
z.DecReadMapElemKey()
{{ if eq .KTyp "string" -}}
{{ decLineVarK $mk -}}{{- /* decLineVarKStrZC $mk */ -}}

@ -13,7 +13,7 @@ import (
)
// GenVersion is the current version of codecgen.
const GenVersion = 25
const GenVersion = 26
// This file is used to generate helper code for codecgen.
// The values here i.e. genHelper(En|De)coder are not to be used directly by
@ -65,6 +65,11 @@ func (f genHelperEncoder) EncBasicHandle() *BasicHandle {
return f.e.h
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncWr() *encWr {
return f.e.w()
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncBinary() bool {
return f.e.be // f.e.hh.isBinaryEncoding()
@ -112,11 +117,6 @@ func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) {
f.e.e.EncodeExt(v, xfFn.rt, xfFn.tag, xfFn.ext)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) WriteStr(s string) {
f.e.w().writestr(s)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
@ -277,11 +277,18 @@ func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecStringZC(v []byte) string { return f.d.stringZC(v) }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecodeBytesInto(v []byte) []byte { return f.d.decodeBytesInto(v) }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecContainerNext(j, containerLen int, hasLen bool) bool {
// return f.d.containerNext(j, containerLen, hasLen)
// rewriting so it can be inlined
if hasLen {
return j < containerLen
}
return !f.d.checkBreak()
}

@ -73,6 +73,10 @@ func (f genHelperEncoder) EncBasicHandle() *BasicHandle {
return f.e.h
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncWr() *encWr {
return f.e.w()
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncBinary() bool {
return f.e.be // f.e.hh.isBinaryEncoding()
}
@ -111,10 +115,7 @@ func (f genHelperEncoder) Extension(v interface{}) (xfn *extTypeTagFn) {
func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) {
f.e.e.EncodeExt(v, xfFn.rt, xfFn.tag, xfFn.ext)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) WriteStr(s string) {
f.e.w().writestr(s)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
@ -211,12 +212,6 @@ func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() }
func (f genHelperDecoder) IsJSONHandle() bool {
return f.d.js
}
{{/*
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) I2Rtid(v interface{}) uintptr {
return i2rtid(v)
}
*/ -}}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) Extension(v interface{}) (xfn *extTypeTagFn) {
return f.d.h.getExtForI(v)
@ -248,8 +243,31 @@ func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecStringZC(v []byte) string { return f.d.stringZC(v) }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecodeBytesInto(v []byte) []byte { return f.d.decodeBytesInto(v) }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecContainerNext(j, containerLen int, hasLen bool) bool {
// return f.d.containerNext(j, containerLen, hasLen)
// rewriting so it can be inlined
if hasLen {
return j < containerLen
}
return !f.d.checkBreak()
}
{{/*
// MARKER: remove WriteStr, as it cannot be inlined as of 20230201.
// Instead, generated code calls (*encWr).WriteStr directly.
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
// func (f genHelperEncoder) WriteStr(s string) {
// f.e.encWr.writestr(s)
// }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) I2Rtid(v interface{}) uintptr {
return i2rtid(v)
}
*/ -}}

@ -29,7 +29,7 @@ if z.DecBasicHandle().MapValueReset {
{{end}} }
if {{var "l"}} != 0 {
{{var "hl"}} := {{var "l"}} > 0
for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ {
for {{var "j"}} := 0; z.DecContainerNext({{var "j"}}, {{var "l"}}, {{var "hl"}}); {{var "j"}}++ {
z.DecReadMapElemKey()
{{ if eq .KTyp "string" -}}
{{ decLineVarK $mk -}}{{- /* decLineVarKStrZC $mk */ -}}
@ -113,8 +113,8 @@ if {{var "l"}} == 0 {
}
{{end -}}
var {{var "j"}} int
{{/* // var {{var "dn"}} bool */ -}}
for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { // bounds-check-elimination
{{/* // var {{var "dn"}} bool */ -}}
for {{var "j"}} = 0; z.DecContainerNext({{var "j"}}, {{var "l"}}, {{var "hl"}}); {{var "j"}}++ {
{{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil {
if {{var "hl"}} {
{{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})

@ -127,16 +127,13 @@ import (
//
// v1: Initial Version
// v2: -
// v3: Changes for Kubernetes:
//
// changes in signature of some unpublished helper methods and codecgen cmdline arguments.
//
// v3: For Kubernetes: changes in signature of some unpublished helper methods and codecgen cmdline arguments.
// v4: Removed separator support from (en|de)cDriver, and refactored codec(gen)
// v5: changes to support faster json decoding. Let encoder/decoder maintain state of collections.
// v6: removed unsafe from gen, and now uses codecgen.exec tag
// v7: -
// v8: current - we now maintain compatibility with old generated code.
// v9: skipped
// v9: - skipped
// v10: modified encDriver and decDriver interfaces.
// v11: remove deprecated methods of encDriver and decDriver.
// v12: removed deprecated methods from genHelper and changed container tracking logic
@ -153,7 +150,8 @@ import (
// v23: 20210203 changed slice/map types for which we generate fast-path functions
// v24: 20210226 robust handling for Canonical|CheckCircularRef flags and MissingFielder implementations
// v25: 20210406 pass base reflect.Type to side(En|De)code and (En|De)codeExt calls
const genVersion = 25
// v26: 20230201 genHelper changes for more inlining and consequent performance
const genVersion = 26
const (
genCodecPkg = "codec1978" // MARKER: keep in sync with codecgen/gen.go
@ -164,13 +162,6 @@ const (
// This is because nil can appear anywhere, so we should always check.
genAnythingCanBeNil = true
// if genUseOneFunctionForDecStructMap, make a single codecDecodeSelferFromMap function;
// else make codecDecodeSelferFromMap{LenPrefix,CheckBreak} so that conditionals
// are not executed a lot.
//
// From testing, it didn't make much difference in runtime, so keep as true (one function only)
genUseOneFunctionForDecStructMap = true
// genStructCanonical configures whether we generate 2 paths based on Canonical flag
// when encoding struct fields.
genStructCanonical = true
@ -183,15 +174,8 @@ const (
// genFastpathTrimTypes configures whether we trim uncommon fastpath types.
genFastpathTrimTypes = true
// genDecStructArrayInlineLoopCheck configures whether we create a next function
// for each iteration in the loop and call it, or just inline it.
//
// with inlining, we get better performance but about 10% larger files.
genDecStructArrayInlineLoopCheck = true
)
type genStructMapStyle uint8
type genStringDecAsBytes string
type genStringDecZC string
@ -199,12 +183,6 @@ var genStringDecAsBytesTyp = reflect.TypeOf(genStringDecAsBytes(""))
var genStringDecZCTyp = reflect.TypeOf(genStringDecZC(""))
var genFormats = []string{"Json", "Cbor", "Msgpack", "Binc", "Simple"}
const (
genStructMapStyleConsolidated genStructMapStyle = iota
genStructMapStyleLenPrefix
genStructMapStyleCheckBreak
)
var (
errGenAllTypesSamePkg = errors.New("All types must be in the same package")
errGenExpectArrayOrMap = errors.New("unexpected type - expecting array/map/slice")
@ -774,28 +752,12 @@ func (x *genRunner) selfer(encode bool) {
}
// write is containerMap
if genUseOneFunctionForDecStructMap {
x.out(fnSigPfx)
x.line(") codecDecodeSelfFromMap(l int, d *" + x.cpfx + "Decoder) {")
x.genRequiredMethodVars(false)
x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleConsolidated)
x.line("}")
x.line("")
} else {
x.out(fnSigPfx)
x.line(") codecDecodeSelfFromMapLenPrefix(l int, d *" + x.cpfx + "Decoder) {")
x.genRequiredMethodVars(false)
x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleLenPrefix)
x.line("}")
x.line("")
x.out(fnSigPfx)
x.line(") codecDecodeSelfFromMapCheckBreak(l int, d *" + x.cpfx + "Decoder) {")
x.genRequiredMethodVars(false)
x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleCheckBreak)
x.line("}")
x.line("")
}
x.out(fnSigPfx)
x.line(") codecDecodeSelfFromMap(l int, d *" + x.cpfx + "Decoder) {")
x.genRequiredMethodVars(false)
x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0)
x.line("}")
x.line("")
// write containerArray
x.out(fnSigPfx)
@ -1388,7 +1350,7 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
default: // string
if x.jsonOnlyWhen == nil {
if si.path.encNameAsciiAlphaNum {
x.linef(`if z.IsJSONHandle() { z.WriteStr("\"%s\"") } else { `, si.encName)
x.linef(`if z.IsJSONHandle() { z.EncWr().WriteStr("\"%s\"") } else { `, si.encName)
}
x.linef("r.EncodeString(`%s`)", si.encName)
if si.path.encNameAsciiAlphaNum {
@ -1396,7 +1358,7 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
}
} else if *(x.jsonOnlyWhen) {
if si.path.encNameAsciiAlphaNum {
x.linef(`z.WriteStr("\"%s\"")`, si.encName)
x.linef(`z.EncWr().WriteStr("\"%s\"")`, si.encName)
} else {
x.linef("r.EncodeString(`%s`)", si.encName)
}
@ -2088,23 +2050,16 @@ func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintpt
x.linef("} // end switch %s", kName)
}
func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t reflect.Type, style genStructMapStyle) {
func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t reflect.Type) {
tpfx := genTempVarPfx
ti := x.ti.get(rtid, t)
i := x.varsfx()
kName := tpfx + "s" + i
switch style {
case genStructMapStyleLenPrefix:
x.linef("for %sj%s := 0; %sj%s < %s; %sj%s++ {", tpfx, i, tpfx, i, lenvarname, tpfx, i)
case genStructMapStyleCheckBreak:
x.linef("for %sj%s := 0; !z.DecCheckBreak(); %sj%s++ {", tpfx, i, tpfx, i)
default: // 0, otherwise.
x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length
x.linef("for %sj%s := 0; ; %sj%s++ {", tpfx, i, tpfx, i)
x.linef("if %shl%s { if %sj%s >= %s { break }", tpfx, i, tpfx, i, lenvarname)
x.line("} else { if z.DecCheckBreak() { break }; }")
}
x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length
x.linef("for %sj%s := 0; z.DecContainerNext(%sj%s, %s, %shl%s); %sj%s++ {",
tpfx, i, tpfx, i, lenvarname, tpfx, i, tpfx, i)
x.line("z.DecReadMapElemKey()")
// emulate decstructfieldkey
@ -2133,24 +2088,11 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid
x.linef("var %sj%s int", tpfx, i)
x.linef("var %sb%s bool", tpfx, i) // break
x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length
if !genDecStructArrayInlineLoopCheck {
x.linef("var %sfn%s = func() bool { ", tpfx, i)
x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() };",
tpfx, i, tpfx, i, tpfx, i,
tpfx, i, lenvarname, tpfx, i)
x.linef("if %sb%s { z.DecReadArrayEnd(); return true }; return false", tpfx, i)
x.linef("} // end func %sfn%s", tpfx, i)
}
var newbuf, nilbuf genBuf
for _, si := range tisfi {
if genDecStructArrayInlineLoopCheck {
x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() }",
tpfx, i, tpfx, i, tpfx, i,
tpfx, i, lenvarname, tpfx, i)
x.linef("if %sb%s { z.DecReadArrayEnd(); %s }", tpfx, i, breakString)
} else {
x.linef("if %sfn%s() { %s }", tpfx, i, breakString)
}
x.linef("%sj%s++", tpfx, i)
x.linef("%sb%s = !z.DecContainerNext(%sj%s, %s, %shl%s)", tpfx, i, tpfx, i, lenvarname, tpfx, i)
x.linef("if %sb%s { z.DecReadArrayEnd(); %s }", tpfx, i, breakString)
x.line("z.DecReadArrayElem()")
newbuf.reset()
nilbuf.reset()
@ -2164,11 +2106,8 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid
}
}
// read remaining values and throw away.
x.line("for {")
x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() }",
tpfx, i, tpfx, i, tpfx, i,
tpfx, i, lenvarname, tpfx, i)
x.linef("if %sb%s { break }", tpfx, i)
x.linef("for %sj%s++; z.DecContainerNext(%sj%s, %s, %shl%s); %sj%s++ {",
tpfx, i, tpfx, i, lenvarname, tpfx, i, tpfx, i)
x.line("z.DecReadArrayElem()")
x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i)
x.line("}")
@ -2183,15 +2122,10 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
x.linef("} else if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs)
x.line(genTempVarPfx + "l" + i + " := z.DecReadMapStart()")
x.linef("if %sl%s == 0 {", genTempVarPfx, i)
if genUseOneFunctionForDecStructMap {
x.line("} else { ")
x.linef("%s.codecDecodeSelfFromMap(%sl%s, d)", varname, genTempVarPfx, i)
} else {
x.line("} else if " + genTempVarPfx + "l" + i + " > 0 { ")
x.line(varname + ".codecDecodeSelfFromMapLenPrefix(" + genTempVarPfx + "l" + i + ", d)")
x.line("} else {")
x.line(varname + ".codecDecodeSelfFromMapCheckBreak(" + genTempVarPfx + "l" + i + ", d)")
}
x.line("} else { ")
x.linef("%s.codecDecodeSelfFromMap(%sl%s, d)", varname, genTempVarPfx, i)
x.line("}")
x.line("z.DecReadMapEnd()")

@ -11,6 +11,18 @@ import (
"unsafe"
)
//go:linkname growslice reflect.growslice
func growslice(typ unsafe.Pointer, old unsafeSlice, num int) (s unsafeSlice) {
// culled from GOROOT/runtime/slice.go
num -= old.Cap - old.Len
s = rtgrowslice(old.Data, old.Cap+num, old.Cap, num, typ)
s.Len = old.Len
return
}
//go:linkname rtgrowslice runtime.growslice
//go:noescape
func growslice(typ unsafe.Pointer, old unsafeSlice, cap int) unsafeSlice
func rtgrowslice(oldPtr unsafe.Pointer, newLen, oldCap, num int, typ unsafe.Pointer) unsafeSlice
// //go:linkname growslice reflect.growslice
// //go:noescape
// func growslice(typ unsafe.Pointer, old unsafeSlice, cap int) unsafeSlice

@ -13,4 +13,4 @@ import (
//go:linkname growslice runtime.growslice
//go:noescape
func growslice(typ unsafe.Pointer, old unsafeSlice, cap int) unsafeSlice
func growslice(typ unsafe.Pointer, old unsafeSlice, num int) unsafeSlice

@ -1562,6 +1562,10 @@ func (z bigenHelper) writeUint16(w *encWr, v uint16) {
}
func (z bigenHelper) writeUint32(w *encWr, v uint32) {
// w.writeb((z.PutUint32(v))[:])
// x := z.PutUint32(v)
// w.writeb(x[:])
// w.writen4(x[0], x[1], x[2], x[3])
w.writen4(z.PutUint32(v))
}
@ -1739,7 +1743,7 @@ func (path *structFieldInfoPathNode) fieldAlloc(v reflect.Value) (rv2 reflect.Va
v = parent.fieldAlloc(v)
for j, k := uint8(0), parent.numderef; j < k; j++ {
if rvIsNil(v) {
rvSetDirect(v, reflect.New(rvType(v).Elem()))
rvSetDirect(v, reflect.New(v.Type().Elem()))
}
v = v.Elem()
}
@ -2459,6 +2463,14 @@ func implIntf(rt, iTyp reflect.Type) (base bool, indir bool) {
return
}
func bool2int(b bool) (v uint8) {
// MARKER: optimized to be a single instruction
if b {
v = 1
}
return
}
func isSliceBoundsError(s string) bool {
return strings.Contains(s, "index out of range") ||
strings.Contains(s, "slice bounds out of range")

@ -22,6 +22,22 @@ const safeMode = true
const transientSizeMax = 0
const transientValueHasStringSlice = true
func byteAt(b []byte, index uint) byte {
return b[index]
}
func setByteAt(b []byte, index uint, val byte) {
b[index] = val
}
func byteSliceOf(b []byte, start, end uint) []byte {
return b[start:end]
}
// func byteSliceWithLen(b []byte, length uint) []byte {
// return b[:length]
// }
func stringView(v []byte) string {
return string(v)
}
@ -34,8 +50,13 @@ func byteSliceSameData(v1 []byte, v2 []byte) bool {
return cap(v1) != 0 && cap(v2) != 0 && &(v1[:1][0]) == &(v2[:1][0])
}
func okBytes3(b []byte) (v [4]byte) {
copy(v[1:], b)
func okBytes2(b []byte) (v [2]byte) {
copy(v[:], b)
return
}
func okBytes3(b []byte) (v [3]byte) {
copy(v[:], b)
return
}
@ -164,7 +185,7 @@ func isEmptyStruct(v reflect.Value, tinfos *TypeInfos, recursive bool) bool {
// We only check isZero on a struct kind, to reduce the amount of times
// that we lookup the rtid and typeInfo for each type as we walk the tree.
vt := rvType(v)
vt := v.Type()
rtid := rt2id(vt)
if tinfos == nil {
tinfos = defTypeInfos
@ -516,7 +537,7 @@ func rvGetArrayBytes(rv reflect.Value, scratch []byte) (bs []byte) {
}
func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) {
v = rvZeroAddrK(reflectArrayOf(rvLenSlice(rv), rvType(rv).Elem()), reflect.Array)
v = rvZeroAddrK(reflectArrayOf(rvLenSlice(rv), rv.Type().Elem()), reflect.Array)
reflect.Copy(v, rv)
return
}
@ -626,6 +647,14 @@ func rvLenMap(rv reflect.Value) int {
return rv.Len()
}
// func copybytes(to, from []byte) int {
// return copy(to, from)
// }
// func copybytestr(to []byte, from string) int {
// return copy(to, from)
// }
// func rvLenArray(rv reflect.Value) int { return rv.Len() }
// ------------ map range and map indexing ----------
@ -656,10 +685,6 @@ func (e *Encoder) jsondriver() *jsonEncDriver {
// ---------- DECODER optimized ---------------
func (d *Decoder) checkBreak() bool {
return d.d.CheckBreak()
}
func (d *Decoder) jsondriver() *jsonDecDriver {
return d.d.(*jsonDecDriver)
}

@ -6,7 +6,7 @@
package codec
import "reflect"
// import "reflect"
// This files contains safe versions of the code where the unsafe versions are not supported
// in either gccgo or gollvm.
@ -14,6 +14,8 @@ import "reflect"
// - rvType:
// reflect.toType is not supported in gccgo, gollvm.
func rvType(rv reflect.Value) reflect.Type {
return rv.Type()
}
// func rvType(rv reflect.Value) reflect.Type {
// return rv.Type()
// }
var _ = 0

@ -51,11 +51,9 @@ import (
// - IsNil
// MARKER: Some functions here will not be hit during code coverage runs due to optimizations, e.g.
// - rvCopySlice: decode calls it if rvGrowSlice didn't set the new slice into the pointer to the orig slice.
// however, helper_unsafe sets it, so there's no need to call rvCopySlice later
// - rvCopySlice: called by decode if rvGrowSlice did not set new slice into pointer to orig slice.
// however, helper_unsafe sets it, so no need to call rvCopySlice later
// - rvSlice: same as above
// - rvGetArray4Bytes: only called within kArray for []byte, but that is now handled
// within the fast-path directly
const safeMode = false
@ -177,6 +175,32 @@ func (encPerType) AddressableRO(v reflect.Value) reflect.Value {
return rvAddressableReadonly(v)
}
// byteAt returns the byte given an index which is guaranteed
// to be within the bounds of the slice i.e. we defensively
// already verified that the index is less than the length of the slice.
func byteAt(b []byte, index uint) byte {
// return b[index]
return *(*byte)(unsafe.Pointer(uintptr((*unsafeSlice)(unsafe.Pointer(&b)).Data) + uintptr(index)))
}
func byteSliceOf(b []byte, start, end uint) []byte {
s := (*unsafeSlice)(unsafe.Pointer(&b))
s.Data = unsafe.Pointer(uintptr(s.Data) + uintptr(start))
s.Len = int(end - start)
s.Cap -= int(start)
return b
}
// func byteSliceWithLen(b []byte, length uint) []byte {
// (*unsafeSlice)(unsafe.Pointer(&b)).Len = int(length)
// return b
// }
func setByteAt(b []byte, index uint, val byte) {
// b[index] = val
*(*byte)(unsafe.Pointer(uintptr((*unsafeSlice)(unsafe.Pointer(&b)).Data) + uintptr(index))) = val
}
// stringView returns a view of the []byte as a string.
// In unsafe mode, it doesn't incur allocation and copying caused by conversion.
// In regular safe mode, it is an allocation and copy.
@ -199,12 +223,15 @@ func byteSliceSameData(v1 []byte, v2 []byte) bool {
}
// MARKER: okBytesN functions will copy N bytes into the top slots of the return array.
// These functions expect that the bounds are valid, and have been checked before this is called.
// These functions expect that the bound check already occured and are are valid.
// copy(...) does a number of checks which are unnecessary in this situation when in bounds.
func okBytes3(b []byte) (v [4]byte) {
*(*[3]byte)(unsafe.Pointer(&v[1])) = *((*[3]byte)(((*unsafeSlice)(unsafe.Pointer(&b))).Data))
return
func okBytes2(b []byte) [2]byte {
return *((*[2]byte)(((*unsafeSlice)(unsafe.Pointer(&b))).Data))
}
func okBytes3(b []byte) [3]byte {
return *((*[3]byte)(((*unsafeSlice)(unsafe.Pointer(&b))).Data))
}
func okBytes4(b []byte) [4]byte {
@ -446,7 +473,7 @@ func isEmptyValueFallbackRecur(urv *unsafeReflectValue, v reflect.Value, tinfos
}
ti := tinfos.find(uintptr(urv.typ))
if ti == nil {
ti = tinfos.load(rvType(v))
ti = tinfos.load(v.Type())
}
return unsafeCmpZero(urv.ptr, int(ti.size))
case reflect.Interface, reflect.Ptr:
@ -862,7 +889,7 @@ func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) {
//
// Consequently, we use rvLenSlice, not rvCapSlice.
t := reflectArrayOf(rvLenSlice(rv), rvType(rv).Elem())
t := reflectArrayOf(rvLenSlice(rv), rv.Type().Elem())
// v = rvZeroAddrK(t, reflect.Array)
uv := (*unsafeReflectValue)(unsafe.Pointer(&v))
@ -1000,6 +1027,32 @@ func rvLenMap(rv reflect.Value) int {
return len_map(rvRefPtr((*unsafeReflectValue)(unsafe.Pointer(&rv))))
}
// copy is an intrinsic, which may use asm if length is small,
// or make a runtime call to runtime.memmove if length is large.
// Performance suffers when you always call runtime.memmove function.
//
// Consequently, there's no value in a copybytes call - just call copy() directly
// func copybytes(to, from []byte) (n int) {
// n = (*unsafeSlice)(unsafe.Pointer(&from)).Len
// memmove(
// (*unsafeSlice)(unsafe.Pointer(&to)).Data,
// (*unsafeSlice)(unsafe.Pointer(&from)).Data,
// uintptr(n),
// )
// return
// }
// func copybytestr(to []byte, from string) (n int) {
// n = (*unsafeSlice)(unsafe.Pointer(&from)).Len
// memmove(
// (*unsafeSlice)(unsafe.Pointer(&to)).Data,
// (*unsafeSlice)(unsafe.Pointer(&from)).Data,
// uintptr(n),
// )
// return
// }
// Note: it is hard to find len(...) of an array type,
// as that is a field in the arrayType representing the array, and hard to introspect.
//
@ -1163,7 +1216,10 @@ func (d *Decoder) zerocopystate() bool {
}
func (d *Decoder) stringZC(v []byte) (s string) {
if d.zerocopystate() {
// MARKER: inline zerocopystate directly so genHelper forwarding function fits within inlining cost
// if d.zerocopystate() {
if d.decByteState == decByteStateZerocopy && d.h.ZeroCopy {
return stringView(v)
}
return d.string(v)
@ -1182,22 +1238,6 @@ func (d *Decoder) mapKeyString(callFnRvk *bool, kstrbs, kstr2bs *[]byte) string
// ---------- DECODER optimized ---------------
func (d *Decoder) checkBreak() bool {
// MARKER: jsonDecDriver.CheckBreak() costs over 80, and this isn't inlined.
// Consequently, there's no benefit in incurring the cost of this
// wrapping function checkBreak.
//
// It is faster to just call the interface method directly.
// if d.js {
// return d.jsondriver().CheckBreak()
// }
// if d.cbor {
// return d.cbordriver().CheckBreak()
// }
return d.d.CheckBreak()
}
func (d *Decoder) jsondriver() *jsonDecDriver {
return (*jsonDecDriver)((*unsafeIntf)(unsafe.Pointer(&d.d)).ptr)
}
@ -1259,6 +1299,10 @@ func unsafeNew(typ unsafe.Pointer) unsafe.Pointer {
// failing with "error: undefined reference" error.
// however, runtime.{mallocgc, newarray} are supported, so use that instead.
//go:linkname memmove runtime.memmove
//go:noescape
func memmove(to, from unsafe.Pointer, n uintptr)
//go:linkname mallocgc runtime.mallocgc
//go:noescape
func mallocgc(size uintptr, typ unsafe.Pointer, needzero bool) unsafe.Pointer

@ -28,9 +28,10 @@ func unsafeGrowslice(typ unsafe.Pointer, old unsafeSlice, cap, incr int) (v unsa
return growslice(typ, old, cap+incr)
}
func rvType(rv reflect.Value) reflect.Type {
return rvPtrToType(((*unsafeReflectValue)(unsafe.Pointer(&rv))).typ) // rv.Type()
}
// func rvType(rv reflect.Value) reflect.Type {
// return rvPtrToType(((*unsafeReflectValue)(unsafe.Pointer(&rv))).typ)
// // return rv.Type()
// }
// mapStoresElemIndirect tells if the element type is stored indirectly in the map.
//
@ -131,9 +132,9 @@ func mapGet(m, k, v reflect.Value, keyFastKind mapKeyFastKind, valIsIndirect, va
//go:linkname unsafeZeroArr runtime.zeroVal
var unsafeZeroArr [1024]byte
//go:linkname rvPtrToType reflect.toType
//go:noescape
func rvPtrToType(typ unsafe.Pointer) reflect.Type
// //go:linkname rvPtrToType reflect.toType
// //go:noescape
// func rvPtrToType(typ unsafe.Pointer) reflect.Type
//go:linkname mapassign_fast32 runtime.mapassign_fast32
//go:noescape

@ -17,7 +17,6 @@ package codec
// We cannot use strconv.(Q|Unq)uote because json quotes/unquotes differently.
import (
"bytes"
"encoding/base64"
"math"
"reflect"
@ -30,35 +29,34 @@ import (
//--------------------------------
var jsonLiterals = [...]byte{
'"', 't', 'r', 'u', 'e', '"',
'"', 'f', 'a', 'l', 's', 'e', '"',
'"', 'n', 'u', 'l', 'l', '"',
}
// jsonLits and jsonLitb are defined at the package level,
// so they are guaranteed to be stored efficiently, making
// for better append/string comparison/etc.
//
// (anecdotal evidence from some benchmarking on go 1.20 devel in 20220104)
const jsonLits = `"true"false"null"`
var jsonLitb = []byte(jsonLits)
const (
jsonLitTrueQ = 0
jsonLitTrue = 1
jsonLitFalseQ = 6
jsonLitFalse = 7
jsonLitNullQ = 13
jsonLitNull = 14
jsonLitT = 1
jsonLitF = 6
jsonLitN = 12
)
var (
// jsonLiteralTrueQ = jsonLiterals[jsonLitTrueQ : jsonLitTrueQ+6]
// jsonLiteralFalseQ = jsonLiterals[jsonLitFalseQ : jsonLitFalseQ+7]
// jsonLiteralNullQ = jsonLiterals[jsonLitNullQ : jsonLitNullQ+6]
jsonLiteralTrue = jsonLiterals[jsonLitTrue : jsonLitTrue+4]
jsonLiteralFalse = jsonLiterals[jsonLitFalse : jsonLitFalse+5]
jsonLiteralNull = jsonLiterals[jsonLitNull : jsonLitNull+4]
// these are used, after consuming the first char
jsonLiteral4True = jsonLiterals[jsonLitTrue+1 : jsonLitTrue+4]
jsonLiteral4False = jsonLiterals[jsonLitFalse+1 : jsonLitFalse+5]
jsonLiteral4Null = jsonLiterals[jsonLitNull+1 : jsonLitNull+4]
)
const jsonEncodeUintSmallsString = "" +
"00010203040506070809" +
"10111213141516171819" +
"20212223242526272829" +
"30313233343536373839" +
"40414243444546474849" +
"50515253545556575859" +
"60616263646566676869" +
"70717273747576777879" +
"80818283848586878889" +
"90919293949596979899"
var jsonEncodeUintSmallsStringBytes = []byte(jsonEncodeUintSmallsString)
const (
jsonU4Chk2 = '0'
@ -82,6 +80,11 @@ const (
// Both technically valid JSON, but bomb on JSONP, so fix here unconditionally.
jsonEscapeMultiByteUnicodeSep = true
// jsonRecognizeBoolNullInQuotedStr is used during decoding into a blank interface{}
// to control whether we detect quoted values of bools and null where a map key is expected,
// and treat as nil, true or false.
jsonNakedBoolNullInQuotedStr = true
// jsonManualInlineDecRdInHotZones controls whether we manually inline some decReader calls.
//
// encode performance is at par with libraries that just iterate over bytes directly,
@ -186,7 +189,7 @@ type jsonEncDriver struct {
// -xxx.yyyyyyyyyyyye-zzz
// Consequently, 35 characters should be sufficient for encoding time, integers or floats.
// We use up all the remaining bytes to make this use full cache lines.
b [56]byte
b [48]byte
e Encoder
}
@ -240,11 +243,9 @@ func (e *jsonEncDriver) WriteMapElemValue() {
func (e *jsonEncDriver) EncodeNil() {
// We always encode nil as just null (never in quotes)
// This allows us to easily decode if a nil in the json stream
// ie if initial token is n.
// so we can easily decode if a nil in the json stream ie if initial token is n.
// e.e.encWr.writeb(jsonLiteralNull)
e.e.encWr.writen4([4]byte{'n', 'u', 'l', 'l'})
e.e.encWr.writestr(jsonLits[jsonLitN : jsonLitN+4])
}
func (e *jsonEncDriver) EncodeTime(t time.Time) {
@ -280,30 +281,32 @@ func (e *jsonEncDriver) EncodeRawExt(re *RawExt) {
}
}
func (e *jsonEncDriver) EncodeBool(b bool) {
// Use writen with an array instead of writeb with a slice
// i.e. in place of e.e.encWr.writeb(jsonLiteralTrueQ)
// OR jsonLiteralTrue, jsonLiteralFalse, jsonLiteralFalseQ, etc
if e.ks && e.e.c == containerMapKey {
if b {
e.e.encWr.writen4([4]byte{'"', 't', 'r', 'u'})
e.e.encWr.writen2('e', '"')
} else {
e.e.encWr.writen4([4]byte{'"', 'f', 'a', 'l'})
e.e.encWr.writen2('s', 'e')
e.e.encWr.writen1('"')
}
} else {
if b {
e.e.encWr.writen4([4]byte{'t', 'r', 'u', 'e'})
} else {
e.e.encWr.writen4([4]byte{'f', 'a', 'l', 's'})
e.e.encWr.writen1('e')
}
}
var jsonEncBoolStrs = [2][2]string{
{jsonLits[jsonLitF : jsonLitF+5], jsonLits[jsonLitT : jsonLitT+4]},
{jsonLits[jsonLitF-1 : jsonLitF+6], jsonLits[jsonLitT-1 : jsonLitT+5]},
}
func (e *jsonEncDriver) EncodeBool(b bool) {
e.e.encWr.writestr(
jsonEncBoolStrs[bool2int(e.ks && e.e.c == containerMapKey)%2][bool2int(b)%2])
}
// func (e *jsonEncDriver) EncodeBool(b bool) {
// if e.ks && e.e.c == containerMapKey {
// if b {
// e.e.encWr.writestr(jsonLits[jsonLitT-1 : jsonLitT+5])
// } else {
// e.e.encWr.writestr(jsonLits[jsonLitF-1 : jsonLitF+6])
// }
// } else {
// if b {
// e.e.encWr.writestr(jsonLits[jsonLitT : jsonLitT+4])
// } else {
// e.e.encWr.writestr(jsonLits[jsonLitF : jsonLitF+5])
// }
// }
// }
func (e *jsonEncDriver) encodeFloat(f float64, bitsize, fmt byte, prec int8) {
var blen uint
if e.ks && e.e.c == containerMapKey {
@ -339,25 +342,18 @@ func (e *jsonEncDriver) encodeUint(neg bool, quotes bool, u uint64) {
// copied mostly from std library: strconv
// this should only be called on 64bit OS.
const smallsString = "00010203040506070809" +
"10111213141516171819" +
"20212223242526272829" +
"30313233343536373839" +
"40414243444546474849" +
"50515253545556575859" +
"60616263646566676869" +
"70717273747576777879" +
"80818283848586878889" +
"90919293949596979899"
// const smallsString = jsonEncodeUintSmallsString
var ss = jsonEncodeUintSmallsStringBytes
// typically, 19 or 20 bytes sufficient for decimal encoding a uint64
// var a [24]byte
var a = e.b[0:24]
var i = uint8(len(a))
var i = uint(len(a))
if quotes {
i--
a[i] = '"'
setByteAt(a, i, '"')
// a[i] = '"'
}
// u guaranteed to fit into a uint (as we are not 32bit OS)
var is uint
@ -366,25 +362,31 @@ func (e *jsonEncDriver) encodeUint(neg bool, quotes bool, u uint64) {
is = us % 100 * 2
us /= 100
i -= 2
a[i+1] = smallsString[is+1]
a[i+0] = smallsString[is+0]
setByteAt(a, i+1, byteAt(ss, is+1))
setByteAt(a, i, byteAt(ss, is))
// a[i+1] = smallsString[is+1]
// a[i+0] = smallsString[is+0]
}
// us < 100
is = us * 2
i--
a[i] = smallsString[is+1]
setByteAt(a, i, byteAt(ss, is+1))
// a[i] = smallsString[is+1]
if us >= 10 {
i--
a[i] = smallsString[is]
setByteAt(a, i, byteAt(ss, is))
// a[i] = smallsString[is]
}
if neg {
i--
a[i] = '-'
setByteAt(a, i, '-')
// a[i] = '-'
}
if quotes {
i--
a[i] = '"'
setByteAt(a, i, '"')
// a[i] = '"'
}
e.e.encWr.writeb(a[i:])
}
@ -413,7 +415,8 @@ func (e *jsonEncDriver) EncodeInt(v int64) {
}
func (e *jsonEncDriver) EncodeUint(v uint64) {
quotes := e.is == 'A' || e.is == 'L' && v > 1<<53 || (e.ks && e.e.c == containerMapKey)
quotes := e.is == 'A' || e.is == 'L' && v > 1<<53 ||
(e.ks && e.e.c == containerMapKey)
if cpu32Bit {
// use strconv directly, as optimized encodeUint only works on 64-bit alone
@ -461,11 +464,12 @@ func (e *jsonEncDriver) EncodeStringBytesRaw(v []byte) {
// bs := e.e.blist.check(*e.buf, n)[:slen]
// *e.buf = bs
bs := e.e.blist.peek(slen, false)[:slen]
bs := e.e.blist.peek(slen, false)
bs = bs[:slen]
bs[0] = '"'
base64.StdEncoding.Encode(bs[1:], v)
bs[len(bs)-1] = '"'
bs[0] = '"'
e.e.encWr.writeb(bs)
}
@ -632,7 +636,7 @@ func (d *jsonDecDriver) decoder() *Decoder {
func (d *jsonDecDriver) ReadMapStart() int {
d.advance()
if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
return containerLenNil
}
if d.tok != '{' {
@ -645,7 +649,7 @@ func (d *jsonDecDriver) ReadMapStart() int {
func (d *jsonDecDriver) ReadArrayStart() int {
d.advance()
if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
return containerLenNil
}
if d.tok != '[' {
@ -655,6 +659,12 @@ func (d *jsonDecDriver) ReadArrayStart() int {
return containerLenUnknown
}
// MARKER:
// We attempted making sure CheckBreak can be inlined, by moving the skipWhitespace
// call to an explicit (noinline) function call.
// However, this forces CheckBreak to always incur a function call if there was whitespace,
// with no clear benefit.
func (d *jsonDecDriver) CheckBreak() bool {
d.advance()
return d.tok == '}' || d.tok == ']'
@ -713,40 +723,31 @@ func (d *jsonDecDriver) readDelimError(xc uint8) {
d.d.errorf("read json delimiter - expect char '%c' but got char '%c'", xc, d.tok)
}
// MARKER: readLit4XXX takes the readn(3|4) as a parameter so they can be inlined.
// MARKER: checkLit takes the readn(3|4) result as a parameter so they can be inlined.
// We pass the array directly to errorf, as passing slice pushes past inlining threshold,
// and passing slice also might cause allocation of the bs array on the heap.
func (d *jsonDecDriver) readLit4True(bs [4]byte) {
// bs := d.d.decRd.readn3()
func (d *jsonDecDriver) checkLit3(got, expect [3]byte) {
d.tok = 0
if jsonValidateSymbols && bs != [...]byte{0, 'r', 'u', 'e'} { // !Equal jsonLiteral4True
// d.d.errorf("expecting %s: got %s", jsonLiteral4True, bs[:])
d.d.errorf("expecting true: got t%s", bs)
if jsonValidateSymbols && got != expect {
d.d.errorf("expecting %s: got %s", expect, got)
}
}
func (d *jsonDecDriver) readLit4False(bs [4]byte) {
// bs := d.d.decRd.readn4()
func (d *jsonDecDriver) checkLit4(got, expect [4]byte) {
d.tok = 0
if jsonValidateSymbols && bs != [4]byte{'a', 'l', 's', 'e'} { // !Equal jsonLiteral4False
// d.d.errorf("expecting %s: got %s", jsonLiteral4False, bs)
d.d.errorf("expecting false: got f%s", bs)
if jsonValidateSymbols && got != expect {
d.d.errorf("expecting %s: got %s", expect, got)
}
}
func (d *jsonDecDriver) readLit4Null(bs [4]byte) {
// bs := d.d.decRd.readn3() // readx(3)
d.tok = 0
if jsonValidateSymbols && bs != [...]byte{0, 'u', 'l', 'l'} { // !Equal jsonLiteral4Null
// d.d.errorf("expecting %s: got %s", jsonLiteral4Null, bs[:])
d.d.errorf("expecting null: got n%s", bs)
}
func (d *jsonDecDriver) skipWhitespace() {
d.tok = d.d.decRd.skipWhitespace()
}
func (d *jsonDecDriver) advance() {
if d.tok == 0 {
d.tok = d.d.decRd.skipWhitespace() // skip(&whitespaceCharBitset)
d.skipWhitespace()
}
}
@ -779,14 +780,14 @@ func (d *jsonDecDriver) nextValueBytesR(v0 []byte) (v []byte, cursor uint) {
default:
h.appendN(&v, dr.jsonReadNum()...)
case 'n':
d.readLit4Null(d.d.decRd.readn3())
h.appendN(&v, jsonLiteralNull...)
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
h.appendS(&v, jsonLits[jsonLitN:jsonLitN+4])
case 'f':
d.readLit4False(d.d.decRd.readn4())
h.appendN(&v, jsonLiteralFalse...)
d.checkLit4([4]byte{'a', 'l', 's', 'e'}, d.d.decRd.readn4())
h.appendS(&v, jsonLits[jsonLitF:jsonLitF+5])
case 't':
d.readLit4True(d.d.decRd.readn3())
h.appendN(&v, jsonLiteralTrue...)
d.checkLit3([3]byte{'r', 'u', 'e'}, d.d.decRd.readn3())
h.appendS(&v, jsonLits[jsonLitT:jsonLitT+4])
case '"':
h.append1(&v, '"')
consumeString()
@ -820,7 +821,7 @@ func (d *jsonDecDriver) TryNil() bool {
// we shouldn't try to see if quoted "null" was here, right?
// only the plain string: `null` denotes a nil (ie not quotes)
if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
return true
}
return false
@ -828,21 +829,21 @@ func (d *jsonDecDriver) TryNil() bool {
func (d *jsonDecDriver) DecodeBool() (v bool) {
d.advance()
if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
return
}
// bool can be in quotes if and only if it's a map key
fquot := d.d.c == containerMapKey && d.tok == '"'
if fquot {
d.tok = d.d.decRd.readn1()
}
switch d.tok {
case 'f':
d.readLit4False(d.d.decRd.readn4())
d.checkLit4([4]byte{'a', 'l', 's', 'e'}, d.d.decRd.readn4())
// v = false
case 't':
d.readLit4True(d.d.decRd.readn3())
d.checkLit3([3]byte{'r', 'u', 'e'}, d.d.decRd.readn3())
v = true
case 'n':
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
// v = false
default:
d.d.errorf("decode bool: got first char %c", d.tok)
// v = false // "unreachable"
@ -857,7 +858,7 @@ func (d *jsonDecDriver) DecodeTime() (t time.Time) {
// read string, and pass the string into json.unmarshal
d.advance()
if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
return
}
d.ensureReadingString()
@ -881,7 +882,7 @@ func (d *jsonDecDriver) ContainerType() (vt valueType) {
} else if d.tok == '[' {
return valueTypeArray
} else if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
return valueTypeNil
} else if d.tok == '"' {
return valueTypeString
@ -895,13 +896,11 @@ func (d *jsonDecDriver) decNumBytes() (bs []byte) {
if d.tok == '"' {
bs = dr.readUntil('"')
} else if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, dr.readn3())
} else {
if jsonManualInlineDecRdInHotZones {
if dr.bytes {
bs = dr.rb.jsonReadNum()
} else if dr.bufio {
bs = dr.bi.jsonReadNum()
} else {
bs = dr.ri.jsonReadNum()
}
@ -967,7 +966,7 @@ func (d *jsonDecDriver) DecodeFloat32() (f float32) {
func (d *jsonDecDriver) DecodeExt(rv interface{}, basetype reflect.Type, xtag uint64, ext Ext) {
d.advance()
if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
return
}
if ext == nil {
@ -982,9 +981,7 @@ func (d *jsonDecDriver) DecodeExt(rv interface{}, basetype reflect.Type, xtag ui
}
func (d *jsonDecDriver) decBytesFromArray(bs []byte) []byte {
if bs == nil {
bs = []byte{}
} else {
if bs != nil {
bs = bs[:0]
}
d.tok = 0
@ -1006,7 +1003,7 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte) (bsOut []byte) {
d.d.decByteState = decByteStateNone
d.advance()
if d.tok == 'n' {
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
return nil
}
// if decoding into raw bytes, and the RawBytesExt is configured, use it to decode.
@ -1037,7 +1034,8 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte) (bsOut []byte) {
bsOut = bs[:slen]
} else if bs == nil {
d.d.decByteState = decByteStateReuseBuf
bsOut = d.d.blist.check(*d.buf, slen)[:slen]
bsOut = d.d.blist.check(*d.buf, slen)
bsOut = bsOut[:slen]
*d.buf = bsOut
} else {
bsOut = make([]byte, slen)
@ -1056,7 +1054,7 @@ func (d *jsonDecDriver) DecodeStringAsBytes() (s []byte) {
d.d.decByteState = decByteStateNone
d.advance()
// common case
// common case - hoist outside the switch statement
if d.tok == '"' {
return d.dblQuoteStringAsBytes()
}
@ -1064,19 +1062,19 @@ func (d *jsonDecDriver) DecodeStringAsBytes() (s []byte) {
// handle non-string scalar: null, true, false or a number
switch d.tok {
case 'n':
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
return nil // []byte{}
case 'f':
d.readLit4False(d.d.decRd.readn4())
return jsonLiteralFalse
d.checkLit4([4]byte{'a', 'l', 's', 'e'}, d.d.decRd.readn4())
return jsonLitb[jsonLitF : jsonLitF+5]
case 't':
d.readLit4True(d.d.decRd.readn3())
return jsonLiteralTrue
d.checkLit3([3]byte{'r', 'u', 'e'}, d.d.decRd.readn3())
return jsonLitb[jsonLitT : jsonLitT+4]
default:
// try to parse a valid number
d.tok = 0
return d.d.decRd.jsonReadNum()
}
// try to parse a valid number
d.tok = 0
return d.d.decRd.jsonReadNum()
}
func (d *jsonDecDriver) ensureReadingString() {
@ -1120,8 +1118,6 @@ func (d *jsonDecDriver) dblQuoteStringAsBytes() (buf []byte) {
if jsonManualInlineDecRdInHotZones {
if dr.bytes {
bs = dr.rb.jsonReadAsisChars()
} else if dr.bufio {
bs = dr.bi.jsonReadAsisChars()
} else {
bs = dr.ri.jsonReadAsisChars()
}
@ -1130,6 +1126,7 @@ func (d *jsonDecDriver) dblQuoteStringAsBytes() (buf []byte) {
}
APPEND:
_ = bs[0] // bounds check hint - slice must be > 0 elements
buf = append(buf, bs[:len(bs)-1]...)
c = bs[len(bs)-1]
@ -1226,14 +1223,14 @@ func (d *jsonDecDriver) DecodeNaked() {
var bs []byte
switch d.tok {
case 'n':
d.readLit4Null(d.d.decRd.readn3())
d.checkLit3([3]byte{'u', 'l', 'l'}, d.d.decRd.readn3())
z.v = valueTypeNil
case 'f':
d.readLit4False(d.d.decRd.readn4())
d.checkLit4([4]byte{'a', 'l', 's', 'e'}, d.d.decRd.readn4())
z.v = valueTypeBool
z.b = false
case 't':
d.readLit4True(d.d.decRd.readn3())
d.checkLit3([3]byte{'r', 'u', 'e'}, d.d.decRd.readn3())
z.v = valueTypeBool
z.b = true
case '{':
@ -1241,18 +1238,20 @@ func (d *jsonDecDriver) DecodeNaked() {
case '[':
z.v = valueTypeArray // don't consume. kInterfaceNaked will call ReadArrayStart
case '"':
// if a string, and MapKeyAsString, then try to decode it as a nil, bool or number first
// if a string, and MapKeyAsString, then try to decode it as a bool or number first
bs = d.dblQuoteStringAsBytes()
if len(bs) > 0 && d.d.c == containerMapKey && d.h.MapKeyAsString {
if bytes.Equal(bs, jsonLiteralNull) {
z.v = valueTypeNil
} else if bytes.Equal(bs, jsonLiteralTrue) {
if jsonNakedBoolNullInQuotedStr &&
d.h.MapKeyAsString && len(bs) > 0 && d.d.c == containerMapKey {
switch string(bs) {
// case "null": // nil is never quoted
// z.v = valueTypeNil
case "true":
z.v = valueTypeBool
z.b = true
} else if bytes.Equal(bs, jsonLiteralFalse) {
case "false":
z.v = valueTypeBool
z.b = false
} else {
default:
// check if a number: float, int or uint
if err := d.nakedNum(z, bs); err != nil {
z.v = valueTypeString
@ -1458,5 +1457,4 @@ func jsonFloatStrconvFmtPrec32(f float32) (fmt byte, prec int8) {
var _ decDriverContainerTracker = (*jsonDecDriver)(nil)
var _ encDriverContainerTracker = (*jsonEncDriver)(nil)
var _ decDriver = (*jsonDecDriver)(nil)
var _ encDriver = (*jsonEncDriver)(nil)

@ -3,7 +3,12 @@
package codec
import "io"
import (
"bufio"
"bytes"
"io"
"strings"
)
// decReader abstracts the reading source, allowing implementations that can
// read from an io.Reader or directly off a byte slice with zero-copying.
@ -17,8 +22,7 @@ type decReader interface {
readn1() byte
readn2() [2]byte
// readn3 will read 3 bytes into the top-most elements of a 4-byte array
readn3() [4]byte
readn3() [3]byte
readn4() [4]byte
readn8() [8]byte
// readn1eof() (v uint8, eof bool)
@ -62,55 +66,57 @@ const (
unreadByteCanUnread
)
// const defBufReaderSize = 4096
// --------------------
type ioDecReaderCommon struct {
r io.Reader // the reader passed in
// ioReaderByteScanner contains the io.Reader and io.ByteScanner interfaces
type ioReaderByteScanner interface {
io.Reader
io.ByteScanner
// ReadByte() (byte, error)
// UnreadByte() error
// Read(p []byte) (n int, err error)
}
n uint // num read
// ioReaderByteScannerT does a simple wrapper of a io.ByteScanner
// over a io.Reader
type ioReaderByteScannerT struct {
r io.Reader
l byte // last byte
ls unreadByteStatus // last byte status
b [6]byte // tiny buffer for reading single bytes
blist *bytesFreelist
bufr []byte // buffer for readTo/readUntil
_ [2]byte // padding
b [4]byte // tiny buffer for reading single bytes
}
func (z *ioDecReaderCommon) reset(r io.Reader, blist *bytesFreelist) {
z.blist = blist
z.r = r
z.ls = unreadByteUndefined
z.l, z.n = 0, 0
z.bufr = z.blist.check(z.bufr, 256)
}
func (z *ioDecReaderCommon) numread() uint {
return z.n
}
// ------------------------------------------
// ioDecReader is a decReader that reads off an io.Reader.
//
// It also has a fallback implementation of ByteScanner if needed.
type ioDecReader struct {
ioDecReaderCommon
br io.ByteScanner
x [64 + 48]byte // for: get struct field name, swallow valueTypeBytes, etc
func (z *ioReaderByteScannerT) ReadByte() (c byte, err error) {
if z.ls == unreadByteCanRead {
z.ls = unreadByteCanUnread
c = z.l
} else {
_, err = z.Read(z.b[:1])
c = z.b[0]
}
return
}
func (z *ioDecReader) reset(r io.Reader, blist *bytesFreelist) {
z.ioDecReaderCommon.reset(r, blist)
z.br, _ = r.(io.ByteScanner)
func (z *ioReaderByteScannerT) UnreadByte() (err error) {
switch z.ls {
case unreadByteCanUnread:
z.ls = unreadByteCanRead
case unreadByteCanRead:
err = errDecUnreadByteLastByteNotRead
case unreadByteUndefined:
err = errDecUnreadByteNothingToRead
default:
err = errDecUnreadByteUnknown
}
return
}
func (z *ioDecReader) Read(p []byte) (n int, err error) {
func (z *ioReaderByteScannerT) Read(p []byte) (n int, err error) {
if len(p) == 0 {
return
}
@ -139,45 +145,79 @@ func (z *ioDecReader) Read(p []byte) (n int, err error) {
return
}
func (z *ioDecReader) ReadByte() (c byte, err error) {
if z.br != nil {
c, err = z.br.ReadByte()
if err == nil {
z.l = c
z.ls = unreadByteCanUnread
func (z *ioReaderByteScannerT) reset(r io.Reader) {
z.r = r
z.ls = unreadByteUndefined
z.l = 0
}
// ioDecReader is a decReader that reads off an io.Reader.
type ioDecReader struct {
rr ioReaderByteScannerT // the reader passed in, wrapped into a reader+bytescanner
n uint // num read
blist *bytesFreelist
bufr []byte // buffer for readTo/readUntil
br ioReaderByteScanner // main reader used for Read|ReadByte|UnreadByte
bb *bufio.Reader // created internally, and reused on reset if needed
x [64 + 40]byte // for: get struct field name, swallow valueTypeBytes, etc
}
func (z *ioDecReader) reset(r io.Reader, bufsize int, blist *bytesFreelist) {
z.blist = blist
z.n = 0
z.bufr = z.blist.check(z.bufr, 256)
z.br = nil
var ok bool
if bufsize <= 0 {
z.br, ok = r.(ioReaderByteScanner)
if !ok {
z.rr.reset(r)
z.br = &z.rr
}
return
}
n, err := z.Read(z.b[:1])
if n == 1 {
c = z.b[0]
if err == io.EOF {
err = nil // read was successful, so postpone EOF (till next time)
// bufsize > 0 ...
// if bytes.[Buffer|Reader], no value in adding extra buffer
// if bufio.Reader, no value in extra buffer unless size changes
switch bb := r.(type) {
case *strings.Reader:
z.br = bb
case *bytes.Buffer:
z.br = bb
case *bytes.Reader:
z.br = bb
case *bufio.Reader:
if bb.Size() == bufsize {
z.br = bb
}
}
return
}
func (z *ioDecReader) UnreadByte() (err error) {
if z.br != nil {
err = z.br.UnreadByte()
if err == nil {
z.ls = unreadByteCanRead
if z.br == nil {
if z.bb != nil && z.bb.Size() == bufsize {
z.bb.Reset(r)
} else {
z.bb = bufio.NewReaderSize(r, bufsize)
}
return
z.br = z.bb
}
}
switch z.ls {
case unreadByteCanUnread:
z.ls = unreadByteCanRead
case unreadByteCanRead:
err = errDecUnreadByteLastByteNotRead
case unreadByteUndefined:
err = errDecUnreadByteNothingToRead
default:
err = errDecUnreadByteUnknown
}
func (z *ioDecReader) numread() uint {
return z.n
}
func (z *ioDecReader) readn1() (b uint8) {
b, err := z.br.ReadByte()
halt.onerror(err)
z.n++
return
}
@ -186,8 +226,8 @@ func (z *ioDecReader) readn2() (bs [2]byte) {
return
}
func (z *ioDecReader) readn3() (bs [4]byte) {
z.readb(bs[1:])
func (z *ioDecReader) readn3() (bs [3]byte) {
z.readb(bs[:])
return
}
@ -203,16 +243,16 @@ func (z *ioDecReader) readn8() (bs [8]byte) {
func (z *ioDecReader) readx(n uint) (bs []byte) {
if n == 0 {
return
return zeroByteSlice
}
if n < uint(len(z.x)) {
bs = z.x[:n]
} else {
bs = make([]byte, n)
}
_, err := readFull(z.r, bs)
nn, err := readFull(z.br, bs)
z.n += nn
halt.onerror(err)
z.n += uint(len(bs))
return
}
@ -220,38 +260,36 @@ func (z *ioDecReader) readb(bs []byte) {
if len(bs) == 0 {
return
}
_, err := readFull(z.r, bs)
nn, err := readFull(z.br, bs)
z.n += nn
halt.onerror(err)
z.n += uint(len(bs))
}
func (z *ioDecReader) readn1() (b uint8) {
b, err := z.ReadByte()
halt.onerror(err)
z.n++
return
}
func (z *ioDecReader) readn1eof() (b uint8, eof bool) {
b, err := z.ReadByte()
if err == nil {
z.n++
} else if err == io.EOF {
eof = true
} else {
halt.onerror(err)
}
return
}
// func (z *ioDecReader) readn1eof() (b uint8, eof bool) {
// b, err := z.br.ReadByte()
// if err == nil {
// z.n++
// } else if err == io.EOF {
// eof = true
// } else {
// halt.onerror(err)
// }
// return
// }
func (z *ioDecReader) jsonReadNum() (bs []byte) {
z.unreadn1()
z.bufr = z.bufr[:0]
LOOP:
i, eof := z.readn1eof()
if eof {
// i, eof := z.readn1eof()
i, err := z.br.ReadByte()
if err == io.EOF {
return z.bufr
}
if err != nil {
halt.onerror(err)
}
z.n++
if isNumberChar(i) {
z.bufr = append(z.bufr, i)
goto LOOP
@ -280,307 +318,45 @@ LOOP:
return
}
// func (z *ioDecReader) readUntil(stop byte) []byte {
// z.bufr = z.bufr[:0]
// LOOP:
// token := z.readn1()
// z.bufr = append(z.bufr, token)
// if token == stop {
// return z.bufr[:len(z.bufr)-1]
// }
// goto LOOP
// }
func (z *ioDecReader) readUntil(stop byte) []byte {
z.bufr = z.bufr[:0]
LOOP:
token := z.readn1()
z.bufr = append(z.bufr, token)
if token == stop {
return z.bufr[:len(z.bufr)-1]
return z.bufr
}
z.bufr = append(z.bufr, token)
goto LOOP
}
func (z *ioDecReader) unreadn1() {
err := z.UnreadByte()
err := z.br.UnreadByte()
halt.onerror(err)
z.n--
}
// ------------------------------------
type bufioDecReader struct {
ioDecReaderCommon
c uint // cursor
buf []byte
}
func (z *bufioDecReader) reset(r io.Reader, bufsize int, blist *bytesFreelist) {
z.ioDecReaderCommon.reset(r, blist)
z.c = 0
if cap(z.buf) < bufsize {
z.buf = blist.get(bufsize)
} else {
z.buf = z.buf[:0]
}
}
func (z *bufioDecReader) readb(p []byte) {
var n = uint(copy(p, z.buf[z.c:]))
z.n += n
z.c += n
if len(p) != int(n) {
z.readbFill(p, n, true, false)
}
}
func readbFillHandleErr(err error, must, eof bool) (isEOF bool) {
if err == io.EOF {
isEOF = true
}
if must && !(eof && isEOF) {
halt.onerror(err)
}
return
}
func (z *bufioDecReader) readbFill(p0 []byte, n uint, must, eof bool) (isEOF bool, err error) {
// at this point, there's nothing in z.buf to read (z.buf is fully consumed)
var p []byte
if p0 != nil {
p = p0[n:]
}
var n2 uint
if len(p) > cap(z.buf) {
n2, err = readFull(z.r, p)
if err != nil {
isEOF = readbFillHandleErr(err, must, eof)
return
}
n += n2
z.n += n2
// always keep last byte in z.buf
z.buf = z.buf[:1]
z.buf[0] = p[len(p)-1]
z.c = 1
return
}
// z.c is now 0, and len(p) <= cap(z.buf)
var n1 int
LOOP:
// for len(p) > 0 && z.err == nil {
z.buf = z.buf[0:cap(z.buf)]
n1, err = z.r.Read(z.buf)
n2 = uint(n1)
if n2 == 0 && err != nil {
isEOF = readbFillHandleErr(err, must, eof)
return
}
err = nil
z.buf = z.buf[:n2]
z.c = 0
if len(p) > 0 {
n2 = uint(copy(p, z.buf))
z.c = n2
n += n2
z.n += n2
p = p[n2:]
if len(p) > 0 {
goto LOOP
}
if z.c == 0 {
z.buf = z.buf[:1]
z.buf[0] = p[len(p)-1]
z.c = 1
}
}
return
}
func (z *bufioDecReader) readn1() (b byte) {
if z.c >= uint(len(z.buf)) {
z.readbFill(nil, 0, true, false)
}
b = z.buf[z.c]
z.c++
z.n++
return
}
func (z *bufioDecReader) readn1eof() (b byte, eof bool) {
if z.c >= uint(len(z.buf)) {
eof, _ = z.readbFill(nil, 0, true, true)
if eof {
return
}
}
b = z.buf[z.c]
z.c++
z.n++
return
}
func (z *bufioDecReader) unreadn1() {
if z.c == 0 {
halt.onerror(errDecUnreadByteNothingToRead)
}
z.c--
z.n--
}
func (z *bufioDecReader) readn2() (bs [2]byte) {
z.readb(bs[:])
return
}
func (z *bufioDecReader) readn3() (bs [4]byte) {
z.readb(bs[1:])
return
}
func (z *bufioDecReader) readn4() (bs [4]byte) {
z.readb(bs[:])
return
}
func (z *bufioDecReader) readn8() (bs [8]byte) {
z.readb(bs[:])
return
}
func (z *bufioDecReader) readx(n uint) (bs []byte) {
if n == 0 {
// return
} else if z.c+n <= uint(len(z.buf)) {
bs = z.buf[z.c : z.c+n]
z.n += n
z.c += n
} else {
bs = make([]byte, n)
// n no longer used - can reuse
n = uint(copy(bs, z.buf[z.c:]))
z.n += n
z.c += n
z.readbFill(bs, n, true, false)
}
return
}
func (z *bufioDecReader) jsonReadNum() (bs []byte) {
z.unreadn1()
z.bufr = z.bufr[:0]
LOOP:
i, eof := z.readn1eof()
if eof {
return z.bufr
}
if isNumberChar(i) {
z.bufr = append(z.bufr, i)
goto LOOP
}
z.unreadn1()
return z.bufr
}
func (z *bufioDecReader) jsonReadAsisChars() (bs []byte) {
z.bufr = z.bufr[:0]
LOOP:
i := z.readn1()
z.bufr = append(z.bufr, i)
if i == '"' || i == '\\' {
return z.bufr
}
goto LOOP
}
func (z *bufioDecReader) skipWhitespace() (token byte) {
i := z.c
LOOP:
if i < uint(len(z.buf)) {
// inline z.skipLoopFn(i) and refactor, so cost is within inline budget
token = z.buf[i]
i++
if isWhitespaceChar(token) {
goto LOOP
}
z.n += i - 2 - z.c
z.c = i
return
}
return z.skipFillWhitespace()
}
func (z *bufioDecReader) skipFillWhitespace() (token byte) {
z.n += uint(len(z.buf)) - z.c
var i, n2 int
var err error
for {
z.c = 0
z.buf = z.buf[0:cap(z.buf)]
n2, err = z.r.Read(z.buf)
if n2 == 0 {
halt.onerror(err)
}
z.buf = z.buf[:n2]
for i, token = range z.buf {
if !isWhitespaceChar(token) {
z.n += (uint(i) - z.c) - 1
z.loopFn(uint(i + 1))
return
}
}
z.n += uint(n2)
}
}
func (z *bufioDecReader) loopFn(i uint) {
z.c = i
}
func (z *bufioDecReader) readUntil(stop byte) (out []byte) {
i := z.c
LOOP:
if i < uint(len(z.buf)) {
if z.buf[i] == stop {
z.n += (i - z.c) - 1
i++
out = z.buf[z.c:i]
z.c = i
goto FINISH
}
i++
goto LOOP
}
out = z.readUntilFill(stop)
FINISH:
return out[:len(out)-1]
}
func (z *bufioDecReader) readUntilFill(stop byte) []byte {
z.bufr = z.bufr[:0]
z.n += uint(len(z.buf)) - z.c
z.bufr = append(z.bufr, z.buf[z.c:]...)
for {
z.c = 0
z.buf = z.buf[0:cap(z.buf)]
n1, err := z.r.Read(z.buf)
if n1 == 0 {
halt.onerror(err)
}
n2 := uint(n1)
z.buf = z.buf[:n2]
for i, token := range z.buf {
if token == stop {
z.n += (uint(i) - z.c) - 1
z.bufr = append(z.bufr, z.buf[z.c:i+1]...)
z.loopFn(uint(i + 1))
return z.bufr
}
}
z.bufr = append(z.bufr, z.buf...)
z.n += n2
}
}
// ------------------------------------
// bytesDecReader is a decReader that reads off a byte slice with zero copying
//
// Note: we do not try to convert index'ing out of bounds to an io.EOF.
// instead, we let it bubble up to the exported Encode/Decode method
// and recover it as an io.EOF.
//
// Every function here MUST defensively check bounds either explicitly
// or via a bounds check.
//
// see panicValToErr(...) function in helper.go.
type bytesDecReader struct {
b []byte // data
@ -601,9 +377,11 @@ func (z *bytesDecReader) numread() uint {
// However, we do it only once, and it's better than reslicing both z.b and return value.
func (z *bytesDecReader) readx(n uint) (bs []byte) {
x := z.c + n
bs = z.b[z.c:x]
z.c = x
// x := z.c + n
// bs = z.b[z.c:x]
// z.c = x
bs = z.b[z.c : z.c+n]
z.c += n
return
}
@ -630,23 +408,26 @@ func (z *bytesDecReader) readb(bs []byte) {
// return z.b[z.c-1]
// }
// MARKER: readn{1,2,3,4,8} should throw an out of bounds error if past length.
// MARKER: readn1: explicitly ensure bounds check is done
// MARKER: readn{2,3,4,8}: ensure you slice z.b completely so we get bounds error if past end.
func (z *bytesDecReader) readn1() (v uint8) {
v = z.b[z.c]
z.c++
return
}
// MARKER: for readn{2,3,4,8}, ensure you slice z.b completely so we get bounds error if past end.
func (z *bytesDecReader) readn2() (bs [2]byte) {
// copy(bs[:], z.b[z.c:z.c+2])
bs[1] = z.b[z.c+1]
bs[0] = z.b[z.c]
// bs[1] = z.b[z.c+1]
// bs[0] = z.b[z.c]
bs = okBytes2(z.b[z.c : z.c+2])
z.c += 2
return
}
func (z *bytesDecReader) readn3() (bs [4]byte) {
func (z *bytesDecReader) readn3() (bs [3]byte) {
// copy(bs[1:], z.b[z.c:z.c+3])
bs = okBytes3(z.b[z.c : z.c+3])
z.c += 3
@ -668,14 +449,17 @@ func (z *bytesDecReader) readn8() (bs [8]byte) {
}
func (z *bytesDecReader) jsonReadNum() []byte {
z.c--
z.c-- // unread
i := z.c
LOOP:
// gracefully handle end of slice, as end of stream is meaningful here
if i < uint(len(z.b)) && isNumberChar(z.b[i]) {
i++
goto LOOP
}
z.c, i = i, z.c
// MARKER: 20230103: byteSliceOf here prevents inlining of jsonReadNum
// return byteSliceOf(z.b, i, z.c)
return z.b[i:z.c]
}
@ -686,7 +470,8 @@ LOOP:
i++
if token == '"' || token == '\\' {
z.c, i = i, z.c
return z.b[i:z.c]
return byteSliceOf(z.b, i, z.c)
// return z.b[i:z.c]
}
goto LOOP
}
@ -707,7 +492,8 @@ func (z *bytesDecReader) readUntil(stop byte) (out []byte) {
i := z.c
LOOP:
if z.b[i] == stop {
out = z.b[z.c:i]
out = byteSliceOf(z.b, z.c, i)
// out = z.b[z.c:i]
z.c = i + 1
return
}
@ -718,6 +504,16 @@ LOOP:
// --------------
type decRd struct {
rb bytesDecReader
ri *ioDecReader
decReader
bytes bool // is bytes reader
// MARKER: these fields below should belong directly in Encoder.
// we pack them here for space efficiency and cache-line optimization.
mtr bool // is maptype a known type?
str bool // is slicetype a known type?
@ -726,73 +522,66 @@ type decRd struct {
jsms bool // is json handle, and MapKeyAsString
cbor bool // is cbor handle
bytes bool // is bytes reader
bufio bool // is this a bufioDecReader?
rb bytesDecReader
ri *ioDecReader
bi *bufioDecReader
cbreak bool // is a check breaker
decReader
}
// From out benchmarking, we see the following in terms of performance:
//
// - interface calls
// - branch that can inline what it calls
// From out benchmarking, we see the following impact performance:
//
// the if/else-if/else block is expensive to inline.
// Each node of this construct costs a lot and dominates the budget.
// Best to only do an if fast-path else block (so fast-path is inlined).
// This is irrespective of inlineExtraCallCost set in $GOROOT/src/cmd/compile/internal/gc/inl.go
// - functions that are too big to inline
// - interface calls (as no inlining can occur)
//
// In decRd methods below, we delegate all IO functions into their own methods.
// This allows for the inlining of the common path when z.bytes=true.
// Go 1.12+ supports inlining methods with up to 1 inlined function (or 2 if no other constructs).
// decRd is designed to embed a decReader, and then re-implement some of the decReader
// methods using a conditional branch.
//
// However, up through Go 1.13, decRd's readXXX, skip and unreadXXX methods are not inlined.
// Consequently, there is no benefit to do the xxxIO methods for decRd at this time.
// Instead, we have a if/else-if/else block so that IO calls do not have to jump through
// a second unnecessary function call.
// We only override the ones where the bytes version is inlined AND the wrapper method
// (containing the bytes version alongside a conditional branch) is also inlined.
//
// If golang inlining gets better and bytesDecReader methods can be inlined,
// then we can revert to using these 2 functions so the bytesDecReader
// methods are inlined and the IO paths call out to a function.
// We use ./run.sh -z to check.
//
// decRd is designed to embed a decReader, and then re-implement some of the decReader
// methods using a conditional branch. We only override the ones that have a bytes version
// that is small enough to be inlined. We use ./run.sh -z to check.
// Right now, only numread and readn1 can be inlined.
// Right now, only numread and "carefully crafted" readn1 can be inlined.
func (z *decRd) numread() uint {
if z.bytes {
return z.rb.numread()
} else if z.bufio {
return z.bi.numread()
} else {
return z.ri.numread()
}
return z.ri.numread()
}
func (z *decRd) readn1() (v uint8) {
if z.bytes {
// MARKER: manually inline, else this function is not inlined.
// Keep in sync with bytesDecReader.readn1
// return z.rb.readn1()
// MARKER: calling z.rb.readn1() prevents decRd.readn1 from being inlined.
// copy code, to manually inline and explicitly return here.
// Keep in sync with bytesDecReader.readn1
v = z.rb.b[z.rb.c]
z.rb.c++
} else {
v = z.readn1IO()
}
return
}
func (z *decRd) readn1IO() uint8 {
if z.bufio {
return z.bi.readn1()
return
}
return z.ri.readn1()
}
// func (z *decRd) readn4() [4]byte {
// if z.bytes {
// return z.rb.readn4()
// }
// return z.ri.readn4()
// }
// func (z *decRd) readn3() [3]byte {
// if z.bytes {
// return z.rb.readn3()
// }
// return z.ri.readn3()
// }
// func (z *decRd) skipWhitespace() byte {
// if z.bytes {
// return z.rb.skipWhitespace()
// }
// return z.ri.skipWhitespace()
// }
type devNullReader struct{}
func (devNullReader) Read(p []byte) (int, error) { return 0, io.EOF }

@ -106,7 +106,8 @@ func (z *bufioEncWriter) writeqstr(s string) {
if z.n+len(s)+2 > len(z.buf) {
z.flush()
}
z.buf[z.n] = '"'
setByteAt(z.buf, uint(z.n), '"')
// z.buf[z.n] = '"'
z.n++
LOOP:
a := len(z.buf) - z.n
@ -117,7 +118,8 @@ LOOP:
goto LOOP
}
z.n += copy(z.buf[z.n:], s)
z.buf[z.n] = '"'
setByteAt(z.buf, uint(z.n), '"')
// z.buf[z.n] = '"'
z.n++
}
@ -125,21 +127,29 @@ func (z *bufioEncWriter) writen1(b1 byte) {
if 1 > len(z.buf)-z.n {
z.flush()
}
z.buf[z.n] = b1
setByteAt(z.buf, uint(z.n), b1)
// z.buf[z.n] = b1
z.n++
}
func (z *bufioEncWriter) writen2(b1, b2 byte) {
if 2 > len(z.buf)-z.n {
z.flush()
}
z.buf[z.n+1] = b2
z.buf[z.n] = b1
setByteAt(z.buf, uint(z.n+1), b2)
setByteAt(z.buf, uint(z.n), b1)
// z.buf[z.n+1] = b2
// z.buf[z.n] = b1
z.n += 2
}
func (z *bufioEncWriter) writen4(b [4]byte) {
if 4 > len(z.buf)-z.n {
z.flush()
}
// setByteAt(z.buf, uint(z.n+3), b4)
// setByteAt(z.buf, uint(z.n+2), b3)
// setByteAt(z.buf, uint(z.n+1), b2)
// setByteAt(z.buf, uint(z.n), b1)
copy(z.buf[z.n:], b[:])
z.n += 4
}
@ -185,14 +195,17 @@ func (z *bytesEncAppender) writen1(b1 byte) {
func (z *bytesEncAppender) writen2(b1, b2 byte) {
z.b = append(z.b, b1, b2)
}
func (z *bytesEncAppender) writen4(b [4]byte) {
z.b = append(z.b, b[:]...)
// z.b = append(z.b, b[0], b[1], b[2], b[3]) // prevents inlining encWr.writen4
// z.b = append(z.b, b1, b2, b3, b4) // prevents inlining encWr.writen4
}
func (z *bytesEncAppender) writen8(b [8]byte) {
z.b = append(z.b, b[:]...)
// z.b = append(z.b, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]) // prevents inlining encWr.writen4
}
func (z *bytesEncAppender) endErr() error {
*(z.out) = z.b
return nil
@ -205,16 +218,21 @@ func (z *bytesEncAppender) reset(in []byte, out *[]byte) {
// --------------------------------------------------
type encWr struct {
wb bytesEncAppender
wf *bufioEncWriter
bytes bool // encoding to []byte
js bool // is json encoder?
be bool // is binary encoder?
// MARKER: these fields below should belong directly in Encoder.
// we pack them here for space efficiency and cache-line optimization.
js bool // is json encoder?
be bool // is binary encoder?
c containerState
calls uint16
seq uint16 // sequencer (e.g. used by binc for symbols, etc)
wb bytesEncAppender
wf *bufioEncWriter
}
// MARKER: manually inline bytesEncAppender.writenx/writeqstr methods,
@ -229,21 +247,25 @@ func (z *encWr) writeb(s []byte) {
z.wf.writeb(s)
}
}
func (z *encWr) writeqstr(s string) {
func (z *encWr) writestr(s string) {
if z.bytes {
// MARKER: z.wb.writeqstr(s)
z.wb.b = append(append(append(z.wb.b, '"'), s...), '"')
z.wb.writestr(s)
} else {
z.wf.writeqstr(s)
z.wf.writestr(s)
}
}
func (z *encWr) writestr(s string) {
// MARKER: Add WriteStr to be called directly by generated code without a genHelper forwarding function.
// Go's inlining model adds cost for forwarding functions, preventing inlining (cost goes above 80 budget).
func (z *encWr) WriteStr(s string) {
if z.bytes {
z.wb.writestr(s)
} else {
z.wf.writestr(s)
}
}
func (z *encWr) writen1(b1 byte) {
if z.bytes {
z.wb.writen1(b1)
@ -260,21 +282,34 @@ func (z *encWr) writen2(b1, b2 byte) {
z.wf.writen2(b1, b2)
}
}
func (z *encWr) writen4(b [4]byte) {
if z.bytes {
z.wb.writen4(b)
// MARKER: z.wb.writen4(b1, b2, b3, b4)
z.wb.b = append(z.wb.b, b[:]...)
// z.wb.writen4(b)
} else {
z.wf.writen4(b)
}
}
func (z *encWr) writen8(b [8]byte) {
if z.bytes {
// z.wb.b = append(z.wb.b, b[:]...)
z.wb.writen8(b)
} else {
z.wf.writen8(b)
}
}
func (z *encWr) writeqstr(s string) {
if z.bytes {
// MARKER: z.wb.writeqstr(s)
z.wb.b = append(append(append(z.wb.b, '"'), s...), '"')
} else {
z.wf.writeqstr(s)
}
}
func (z *encWr) endErr() error {
if z.bytes {
return z.wb.endErr()

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build (386 || amd64 || amd64p32) && gccgo
// +build 386 amd64 amd64p32
// +build gccgo

@ -0,0 +1,11 @@
// Copyright 2023 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.
//go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64
// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64
package cpu
// IsBigEndian records whether the GOARCH's byte order is big endian.
const IsBigEndian = true

@ -0,0 +1,11 @@
// Copyright 2023 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.
//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh
// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh
package cpu
// IsBigEndian records whether the GOARCH's byte order is big endian.
const IsBigEndian = false

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build gccgo,!hurd
// +build !aix,!hurd
//go:build gccgo && !aix && !hurd
// +build gccgo,!aix,!hurd
#include <errno.h>
#include <stdint.h>

@ -230,6 +230,7 @@ func direntNamlen(buf []byte) (uint64, bool) {
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
func PtraceDenyAttach() (err error) { return ptrace(PT_DENY_ATTACH, 0, 0, 0) }
//sysnb pipe(p *[2]int32) (err error)

@ -60,8 +60,13 @@ func PtraceGetFsBase(pid int, fsbase *int64) (err error) {
return ptrace(PT_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0)
}
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint32(countin)}
func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{
Op: int32(req),
Offs: offs,
Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe.
Len: uint32(countin),
}
err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
return int(ioDesc.Len), err
}

@ -60,8 +60,13 @@ func PtraceGetFsBase(pid int, fsbase *int64) (err error) {
return ptrace(PT_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0)
}
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)}
func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{
Op: int32(req),
Offs: offs,
Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe.
Len: uint64(countin),
}
err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
return int(ioDesc.Len), err
}

@ -56,8 +56,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint32(countin)}
func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{
Op: int32(req),
Offs: offs,
Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe.
Len: uint32(countin),
}
err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
return int(ioDesc.Len), err
}

@ -56,8 +56,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)}
func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{
Op: int32(req),
Offs: offs,
Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe.
Len: uint64(countin),
}
err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
return int(ioDesc.Len), err
}

@ -56,8 +56,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)}
func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) {
ioDesc := PtraceIoDesc{
Op: int32(req),
Offs: offs,
Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe.
Len: uint64(countin),
}
err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)
return int(ioDesc.Len), err
}

@ -1800,6 +1800,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
//sysnb Capset(hdr *CapUserHeader, data *CapUserData) (err error)
//sys Chdir(path string) (err error)
//sys Chroot(path string) (err error)
//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
//sys ClockGetres(clockid int32, res *Timespec) (err error)
//sys ClockGettime(clockid int32, time *Timespec) (err error)
//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
@ -1999,7 +2000,7 @@ func appendBytes(vecs []Iovec, bs [][]byte) []Iovec {
// offs2lohi splits offs into its low and high order bits.
func offs2lohi(offs int64) (lo, hi uintptr) {
const longBits = SizeofLong * 8
return uintptr(offs), uintptr(uint64(offs) >> longBits)
return uintptr(offs), uintptr(uint64(offs) >> (longBits - 1) >> 1) // two shifts to avoid false positive in vet
}
func Readv(fd int, iovs [][]byte) (n int, err error) {

@ -578,7 +578,7 @@ func Lutimes(path string, tv []Timeval) error {
return UtimesNanoAt(AT_FDCWD, path, ts, AT_SYMLINK_NOFOLLOW)
}
// emptyIovec reports whether there are no bytes in the slice of Iovec.
// emptyIovecs reports whether there are no bytes in the slice of Iovec.
func emptyIovecs(iov []Iovec) bool {
for i := range iov {
if iov[i].Len > 0 {

@ -9,7 +9,7 @@ package unix
import "time"
// TimespecToNSec returns the time stored in ts as nanoseconds.
// TimespecToNsec returns the time stored in ts as nanoseconds.
func TimespecToNsec(ts Timespec) int64 { return ts.Nano() }
// NsecToTimespec converts a number of nanoseconds into a Timespec.

@ -36,9 +36,14 @@ func xattrnamespace(fullattr string) (ns int, attr string, err error) {
func initxattrdest(dest []byte, idx int) (d unsafe.Pointer) {
if len(dest) > idx {
return unsafe.Pointer(&dest[idx])
} else {
return unsafe.Pointer(_zero)
}
if dest != nil {
// extattr_get_file and extattr_list_file treat NULL differently from
// a non-NULL pointer of length zero. Preserve the property of nilness,
// even if we can't use dest directly.
return unsafe.Pointer(&_zero)
}
return nil
}
// FreeBSD and NetBSD implement their own syscalls to handle extended attributes

@ -457,7 +457,6 @@ const (
B600 = 0x8
B75 = 0x2
B9600 = 0xd
BALLOON_KVM_MAGIC = 0x13661366
BDEVFS_MAGIC = 0x62646576
BINDERFS_SUPER_MAGIC = 0x6c6f6f70
BINFMTFS_MAGIC = 0x42494e4d
@ -563,6 +562,7 @@ const (
BUS_USB = 0x3
BUS_VIRTUAL = 0x6
CAN_BCM = 0x2
CAN_BUS_OFF_THRESHOLD = 0x100
CAN_CTRLMODE_3_SAMPLES = 0x4
CAN_CTRLMODE_BERR_REPORTING = 0x10
CAN_CTRLMODE_CC_LEN8_DLC = 0x100
@ -577,9 +577,12 @@ const (
CAN_EFF_FLAG = 0x80000000
CAN_EFF_ID_BITS = 0x1d
CAN_EFF_MASK = 0x1fffffff
CAN_ERROR_PASSIVE_THRESHOLD = 0x80
CAN_ERROR_WARNING_THRESHOLD = 0x60
CAN_ERR_ACK = 0x20
CAN_ERR_BUSERROR = 0x80
CAN_ERR_BUSOFF = 0x40
CAN_ERR_CNT = 0x200
CAN_ERR_CRTL = 0x4
CAN_ERR_CRTL_ACTIVE = 0x40
CAN_ERR_CRTL_RX_OVERFLOW = 0x1
@ -820,9 +823,9 @@ const (
DM_UUID_FLAG = 0x4000
DM_UUID_LEN = 0x81
DM_VERSION = 0xc138fd00
DM_VERSION_EXTRA = "-ioctl (2022-02-22)"
DM_VERSION_EXTRA = "-ioctl (2022-07-28)"
DM_VERSION_MAJOR = 0x4
DM_VERSION_MINOR = 0x2e
DM_VERSION_MINOR = 0x2f
DM_VERSION_PATCHLEVEL = 0x0
DT_BLK = 0x6
DT_CHR = 0x2
@ -1049,6 +1052,7 @@ const (
ETH_P_CAIF = 0xf7
ETH_P_CAN = 0xc
ETH_P_CANFD = 0xd
ETH_P_CANXL = 0xe
ETH_P_CFM = 0x8902
ETH_P_CONTROL = 0x16
ETH_P_CUST = 0x6006
@ -1060,6 +1064,7 @@ const (
ETH_P_DNA_RT = 0x6003
ETH_P_DSA = 0x1b
ETH_P_DSA_8021Q = 0xdadb
ETH_P_DSA_A5PSW = 0xe001
ETH_P_ECONET = 0x18
ETH_P_EDSA = 0xdada
ETH_P_ERSPAN = 0x88be
@ -1194,8 +1199,10 @@ const (
FAN_MARK_EVICTABLE = 0x200
FAN_MARK_FILESYSTEM = 0x100
FAN_MARK_FLUSH = 0x80
FAN_MARK_IGNORE = 0x400
FAN_MARK_IGNORED_MASK = 0x20
FAN_MARK_IGNORED_SURV_MODIFY = 0x40
FAN_MARK_IGNORE_SURV = 0x440
FAN_MARK_INODE = 0x0
FAN_MARK_MOUNT = 0x10
FAN_MARK_ONLYDIR = 0x8
@ -1253,6 +1260,7 @@ const (
FSCRYPT_MODE_AES_128_CBC = 0x5
FSCRYPT_MODE_AES_128_CTS = 0x6
FSCRYPT_MODE_AES_256_CTS = 0x4
FSCRYPT_MODE_AES_256_HCTR2 = 0xa
FSCRYPT_MODE_AES_256_XTS = 0x1
FSCRYPT_POLICY_FLAGS_PAD_16 = 0x2
FSCRYPT_POLICY_FLAGS_PAD_32 = 0x3
@ -1430,6 +1438,7 @@ const (
IFF_NOARP = 0x80
IFF_NOFILTER = 0x1000
IFF_NOTRAILERS = 0x20
IFF_NO_CARRIER = 0x40
IFF_NO_PI = 0x1000
IFF_ONE_QUEUE = 0x2000
IFF_PERSIST = 0x800
@ -1805,6 +1814,7 @@ const (
MADV_DONTDUMP = 0x10
MADV_DONTFORK = 0xa
MADV_DONTNEED = 0x4
MADV_DONTNEED_LOCKED = 0x18
MADV_FREE = 0x8
MADV_HUGEPAGE = 0xe
MADV_HWPOISON = 0x64
@ -1846,7 +1856,7 @@ const (
MFD_ALLOW_SEALING = 0x2
MFD_CLOEXEC = 0x1
MFD_HUGETLB = 0x4
MFD_HUGE_16GB = -0x78000000
MFD_HUGE_16GB = 0x88000000
MFD_HUGE_16MB = 0x60000000
MFD_HUGE_1GB = 0x78000000
MFD_HUGE_1MB = 0x50000000
@ -2212,6 +2222,11 @@ const (
PERF_AUX_FLAG_PARTIAL = 0x4
PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK = 0xff00
PERF_AUX_FLAG_TRUNCATED = 0x1
PERF_BR_ARM64_DEBUG_DATA = 0x7
PERF_BR_ARM64_DEBUG_EXIT = 0x5
PERF_BR_ARM64_DEBUG_HALT = 0x4
PERF_BR_ARM64_DEBUG_INST = 0x6
PERF_BR_ARM64_FIQ = 0x3
PERF_FLAG_FD_CLOEXEC = 0x8
PERF_FLAG_FD_NO_GROUP = 0x1
PERF_FLAG_FD_OUTPUT = 0x2
@ -2232,6 +2247,8 @@ const (
PERF_MEM_LOCK_NA = 0x1
PERF_MEM_LOCK_SHIFT = 0x18
PERF_MEM_LVLNUM_ANY_CACHE = 0xb
PERF_MEM_LVLNUM_CXL = 0x9
PERF_MEM_LVLNUM_IO = 0xa
PERF_MEM_LVLNUM_L1 = 0x1
PERF_MEM_LVLNUM_L2 = 0x2
PERF_MEM_LVLNUM_L3 = 0x3
@ -2265,6 +2282,7 @@ const (
PERF_MEM_REMOTE_REMOTE = 0x1
PERF_MEM_REMOTE_SHIFT = 0x25
PERF_MEM_SNOOPX_FWD = 0x1
PERF_MEM_SNOOPX_PEER = 0x2
PERF_MEM_SNOOPX_SHIFT = 0x26
PERF_MEM_SNOOP_HIT = 0x4
PERF_MEM_SNOOP_HITM = 0x10
@ -2301,7 +2319,6 @@ const (
PERF_SAMPLE_BRANCH_PLM_ALL = 0x7
PERF_SAMPLE_WEIGHT_TYPE = 0x1004000
PIPEFS_MAGIC = 0x50495045
PPC_CMM_MAGIC = 0xc7571590
PPPIOCGNPMODE = 0xc008744c
PPPIOCNEWUNIT = 0xc004743e
PRIO_PGRP = 0x1
@ -2999,6 +3016,7 @@ const (
STATX_BLOCKS = 0x400
STATX_BTIME = 0x800
STATX_CTIME = 0x80
STATX_DIOALIGN = 0x2000
STATX_GID = 0x10
STATX_INO = 0x100
STATX_MNT_ID = 0x1000
@ -3392,9 +3410,7 @@ const (
XDP_ZEROCOPY = 0x4
XENFS_SUPER_MAGIC = 0xabba1974
XFS_SUPER_MAGIC = 0x58465342
Z3FOLD_MAGIC = 0x33
ZONEFS_MAGIC = 0x5a4f4653
ZSMALLOC_MAGIC = 0x58295829
_HIDIOCGRAWNAME_LEN = 0x80
_HIDIOCGRAWPHYS_LEN = 0x40
_HIDIOCGRAWUNIQ_LEN = 0x40

@ -133,6 +133,7 @@ const (
MEMGETREGIONCOUNT = 0x80044d07
MEMISLOCKED = 0x80084d17
MEMLOCK = 0x40084d05
MEMREAD = 0xc03c4d1a
MEMREADOOB = 0xc00c4d04
MEMSETBADBLOCK = 0x40084d0c
MEMUNLOCK = 0x40084d06

@ -133,6 +133,7 @@ const (
MEMGETREGIONCOUNT = 0x80044d07
MEMISLOCKED = 0x80084d17
MEMLOCK = 0x40084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x40084d0c
MEMUNLOCK = 0x40084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x80044d07
MEMISLOCKED = 0x80084d17
MEMLOCK = 0x40084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc00c4d04
MEMSETBADBLOCK = 0x40084d0c
MEMUNLOCK = 0x40084d06

@ -134,6 +134,7 @@ const (
MEMGETREGIONCOUNT = 0x80044d07
MEMISLOCKED = 0x80084d17
MEMLOCK = 0x40084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x40084d0c
MEMUNLOCK = 0x40084d06

@ -132,6 +132,7 @@ const (
MEMGETREGIONCOUNT = 0x80044d07
MEMISLOCKED = 0x80084d17
MEMLOCK = 0x40084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x40084d0c
MEMUNLOCK = 0x40084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x40044d07
MEMISLOCKED = 0x40084d17
MEMLOCK = 0x80084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc00c4d04
MEMSETBADBLOCK = 0x80084d0c
MEMUNLOCK = 0x80084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x40044d07
MEMISLOCKED = 0x40084d17
MEMLOCK = 0x80084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x80084d0c
MEMUNLOCK = 0x80084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x40044d07
MEMISLOCKED = 0x40084d17
MEMLOCK = 0x80084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x80084d0c
MEMUNLOCK = 0x80084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x40044d07
MEMISLOCKED = 0x40084d17
MEMLOCK = 0x80084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc00c4d04
MEMSETBADBLOCK = 0x80084d0c
MEMUNLOCK = 0x80084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x40044d07
MEMISLOCKED = 0x40084d17
MEMLOCK = 0x80084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc00c4d04
MEMSETBADBLOCK = 0x80084d0c
MEMUNLOCK = 0x80084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x40044d07
MEMISLOCKED = 0x40084d17
MEMLOCK = 0x80084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x80084d0c
MEMUNLOCK = 0x80084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x40044d07
MEMISLOCKED = 0x40084d17
MEMLOCK = 0x80084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x80084d0c
MEMUNLOCK = 0x80084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x80044d07
MEMISLOCKED = 0x80084d17
MEMLOCK = 0x40084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x40084d0c
MEMUNLOCK = 0x40084d06

@ -131,6 +131,7 @@ const (
MEMGETREGIONCOUNT = 0x80044d07
MEMISLOCKED = 0x80084d17
MEMLOCK = 0x40084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x40084d0c
MEMUNLOCK = 0x40084d06

@ -136,6 +136,7 @@ const (
MEMGETREGIONCOUNT = 0x40044d07
MEMISLOCKED = 0x40084d17
MEMLOCK = 0x80084d05
MEMREAD = 0xc0404d1a
MEMREADOOB = 0xc0104d04
MEMSETBADBLOCK = 0x80084d0c
MEMUNLOCK = 0x80084d06

@ -537,6 +537,17 @@ func Chroot(path string) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockAdjtime(clockid int32, buf *Timex) (state int, err error) {
r0, _, e1 := Syscall(SYS_CLOCK_ADJTIME, uintptr(clockid), uintptr(unsafe.Pointer(buf)), 0)
state = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockGetres(clockid int32, res *Timespec) (err error) {
_, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0)
if e1 != 0 {

@ -29,6 +29,41 @@ type Itimerval struct {
Value Timeval
}
const (
ADJ_OFFSET = 0x1
ADJ_FREQUENCY = 0x2
ADJ_MAXERROR = 0x4
ADJ_ESTERROR = 0x8
ADJ_STATUS = 0x10
ADJ_TIMECONST = 0x20
ADJ_TAI = 0x80
ADJ_SETOFFSET = 0x100
ADJ_MICRO = 0x1000
ADJ_NANO = 0x2000
ADJ_TICK = 0x4000
ADJ_OFFSET_SINGLESHOT = 0x8001
ADJ_OFFSET_SS_READ = 0xa001
)
const (
STA_PLL = 0x1
STA_PPSFREQ = 0x2
STA_PPSTIME = 0x4
STA_FLL = 0x8
STA_INS = 0x10
STA_DEL = 0x20
STA_UNSYNC = 0x40
STA_FREQHOLD = 0x80
STA_PPSSIGNAL = 0x100
STA_PPSJITTER = 0x200
STA_PPSWANDER = 0x400
STA_PPSERROR = 0x800
STA_CLOCKERR = 0x1000
STA_NANO = 0x2000
STA_MODE = 0x4000
STA_CLK = 0x8000
)
const (
TIME_OK = 0x0
TIME_INS = 0x1
@ -53,29 +88,30 @@ type StatxTimestamp struct {
}
type Statx_t struct {
Mask uint32
Blksize uint32
Attributes uint64
Nlink uint32
Uid uint32
Gid uint32
Mode uint16
_ [1]uint16
Ino uint64
Size uint64
Blocks uint64
Attributes_mask uint64
Atime StatxTimestamp
Btime StatxTimestamp
Ctime StatxTimestamp
Mtime StatxTimestamp
Rdev_major uint32
Rdev_minor uint32
Dev_major uint32
Dev_minor uint32
Mnt_id uint64
_ uint64
_ [12]uint64
Mask uint32
Blksize uint32
Attributes uint64
Nlink uint32
Uid uint32
Gid uint32
Mode uint16
_ [1]uint16
Ino uint64
Size uint64
Blocks uint64
Attributes_mask uint64
Atime StatxTimestamp
Btime StatxTimestamp
Ctime StatxTimestamp
Mtime StatxTimestamp
Rdev_major uint32
Rdev_minor uint32
Dev_major uint32
Dev_minor uint32
Mnt_id uint64
Dio_mem_align uint32
Dio_offset_align uint32
_ [12]uint64
}
type Fsid struct {
@ -1099,7 +1135,8 @@ const (
PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 0xf
PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 0x10
PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 0x11
PERF_SAMPLE_BRANCH_MAX_SHIFT = 0x12
PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT = 0x12
PERF_SAMPLE_BRANCH_MAX_SHIFT = 0x13
PERF_SAMPLE_BRANCH_USER = 0x1
PERF_SAMPLE_BRANCH_KERNEL = 0x2
PERF_SAMPLE_BRANCH_HV = 0x4
@ -1118,7 +1155,8 @@ const (
PERF_SAMPLE_BRANCH_NO_CYCLES = 0x8000
PERF_SAMPLE_BRANCH_TYPE_SAVE = 0x10000
PERF_SAMPLE_BRANCH_HW_INDEX = 0x20000
PERF_SAMPLE_BRANCH_MAX = 0x40000
PERF_SAMPLE_BRANCH_PRIV_SAVE = 0x40000
PERF_SAMPLE_BRANCH_MAX = 0x80000
PERF_BR_UNKNOWN = 0x0
PERF_BR_COND = 0x1
PERF_BR_UNCOND = 0x2
@ -1132,7 +1170,10 @@ const (
PERF_BR_COND_RET = 0xa
PERF_BR_ERET = 0xb
PERF_BR_IRQ = 0xc
PERF_BR_MAX = 0xd
PERF_BR_SERROR = 0xd
PERF_BR_NO_TX = 0xe
PERF_BR_EXTEND_ABI = 0xf
PERF_BR_MAX = 0x10
PERF_SAMPLE_REGS_ABI_NONE = 0x0
PERF_SAMPLE_REGS_ABI_32 = 0x1
PERF_SAMPLE_REGS_ABI_64 = 0x2
@ -1151,7 +1192,8 @@ const (
PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
PERF_FORMAT_ID = 0x4
PERF_FORMAT_GROUP = 0x8
PERF_FORMAT_MAX = 0x10
PERF_FORMAT_LOST = 0x10
PERF_FORMAT_MAX = 0x20
PERF_IOC_FLAG_GROUP = 0x1
PERF_RECORD_MMAP = 0x1
PERF_RECORD_LOST = 0x2
@ -2979,7 +3021,16 @@ const (
DEVLINK_CMD_TRAP_POLICER_NEW = 0x47
DEVLINK_CMD_TRAP_POLICER_DEL = 0x48
DEVLINK_CMD_HEALTH_REPORTER_TEST = 0x49
DEVLINK_CMD_MAX = 0x51
DEVLINK_CMD_RATE_GET = 0x4a
DEVLINK_CMD_RATE_SET = 0x4b
DEVLINK_CMD_RATE_NEW = 0x4c
DEVLINK_CMD_RATE_DEL = 0x4d
DEVLINK_CMD_LINECARD_GET = 0x4e
DEVLINK_CMD_LINECARD_SET = 0x4f
DEVLINK_CMD_LINECARD_NEW = 0x50
DEVLINK_CMD_LINECARD_DEL = 0x51
DEVLINK_CMD_SELFTESTS_GET = 0x52
DEVLINK_CMD_MAX = 0x53
DEVLINK_PORT_TYPE_NOTSET = 0x0
DEVLINK_PORT_TYPE_AUTO = 0x1
DEVLINK_PORT_TYPE_ETH = 0x2
@ -3208,7 +3259,13 @@ const (
DEVLINK_ATTR_RATE_NODE_NAME = 0xa8
DEVLINK_ATTR_RATE_PARENT_NODE_NAME = 0xa9
DEVLINK_ATTR_REGION_MAX_SNAPSHOTS = 0xaa
DEVLINK_ATTR_MAX = 0xae
DEVLINK_ATTR_LINECARD_INDEX = 0xab
DEVLINK_ATTR_LINECARD_STATE = 0xac
DEVLINK_ATTR_LINECARD_TYPE = 0xad
DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES = 0xae
DEVLINK_ATTR_NESTED_DEVLINK = 0xaf
DEVLINK_ATTR_SELFTESTS = 0xb0
DEVLINK_ATTR_MAX = 0xb0
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1
DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0
@ -3317,7 +3374,8 @@ const (
LWTUNNEL_ENCAP_SEG6_LOCAL = 0x7
LWTUNNEL_ENCAP_RPL = 0x8
LWTUNNEL_ENCAP_IOAM6 = 0x9
LWTUNNEL_ENCAP_MAX = 0x9
LWTUNNEL_ENCAP_XFRM = 0xa
LWTUNNEL_ENCAP_MAX = 0xa
MPLS_IPTUNNEL_UNSPEC = 0x0
MPLS_IPTUNNEL_DST = 0x1
@ -3512,7 +3570,9 @@ const (
ETHTOOL_MSG_PHC_VCLOCKS_GET = 0x21
ETHTOOL_MSG_MODULE_GET = 0x22
ETHTOOL_MSG_MODULE_SET = 0x23
ETHTOOL_MSG_USER_MAX = 0x23
ETHTOOL_MSG_PSE_GET = 0x24
ETHTOOL_MSG_PSE_SET = 0x25
ETHTOOL_MSG_USER_MAX = 0x25
ETHTOOL_MSG_KERNEL_NONE = 0x0
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@ -3550,7 +3610,8 @@ const (
ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY = 0x22
ETHTOOL_MSG_MODULE_GET_REPLY = 0x23
ETHTOOL_MSG_MODULE_NTF = 0x24
ETHTOOL_MSG_KERNEL_MAX = 0x24
ETHTOOL_MSG_PSE_GET_REPLY = 0x25
ETHTOOL_MSG_KERNEL_MAX = 0x25
ETHTOOL_A_HEADER_UNSPEC = 0x0
ETHTOOL_A_HEADER_DEV_INDEX = 0x1
ETHTOOL_A_HEADER_DEV_NAME = 0x2
@ -3609,7 +3670,8 @@ const (
ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG = 0x7
ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE = 0x8
ETHTOOL_A_LINKMODES_LANES = 0x9
ETHTOOL_A_LINKMODES_MAX = 0x9
ETHTOOL_A_LINKMODES_RATE_MATCHING = 0xa
ETHTOOL_A_LINKMODES_MAX = 0xa
ETHTOOL_A_LINKSTATE_UNSPEC = 0x0
ETHTOOL_A_LINKSTATE_HEADER = 0x1
ETHTOOL_A_LINKSTATE_LINK = 0x2
@ -4201,6 +4263,9 @@ const (
NL80211_ACL_POLICY_DENY_UNLESS_LISTED = 0x1
NL80211_AC_VI = 0x1
NL80211_AC_VO = 0x0
NL80211_AP_SETTINGS_EXTERNAL_AUTH_SUPPORT = 0x1
NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT = 0x2
NL80211_AP_SME_SA_QUERY_OFFLOAD = 0x1
NL80211_ATTR_4ADDR = 0x53
NL80211_ATTR_ACK = 0x5c
NL80211_ATTR_ACK_SIGNAL = 0x107
@ -4209,6 +4274,7 @@ const (
NL80211_ATTR_AIRTIME_WEIGHT = 0x112
NL80211_ATTR_AKM_SUITES = 0x4c
NL80211_ATTR_AP_ISOLATE = 0x60
NL80211_ATTR_AP_SETTINGS_FLAGS = 0x135
NL80211_ATTR_AUTH_DATA = 0x9c
NL80211_ATTR_AUTH_TYPE = 0x35
NL80211_ATTR_BANDS = 0xef
@ -4240,6 +4306,9 @@ const (
NL80211_ATTR_COALESCE_RULE_DELAY = 0x1
NL80211_ATTR_COALESCE_RULE_MAX = 0x3
NL80211_ATTR_COALESCE_RULE_PKT_PATTERN = 0x3
NL80211_ATTR_COLOR_CHANGE_COLOR = 0x130
NL80211_ATTR_COLOR_CHANGE_COUNT = 0x12f
NL80211_ATTR_COLOR_CHANGE_ELEMS = 0x131
NL80211_ATTR_CONN_FAILED_REASON = 0x9b
NL80211_ATTR_CONTROL_PORT = 0x44
NL80211_ATTR_CONTROL_PORT_ETHERTYPE = 0x66
@ -4266,6 +4335,7 @@ const (
NL80211_ATTR_DEVICE_AP_SME = 0x8d
NL80211_ATTR_DFS_CAC_TIME = 0x7
NL80211_ATTR_DFS_REGION = 0x92
NL80211_ATTR_DISABLE_EHT = 0x137
NL80211_ATTR_DISABLE_HE = 0x12d
NL80211_ATTR_DISABLE_HT = 0x93
NL80211_ATTR_DISABLE_VHT = 0xaf
@ -4273,6 +4343,8 @@ const (
NL80211_ATTR_DONT_WAIT_FOR_ACK = 0x8e
NL80211_ATTR_DTIM_PERIOD = 0xd
NL80211_ATTR_DURATION = 0x57
NL80211_ATTR_EHT_CAPABILITY = 0x136
NL80211_ATTR_EML_CAPABILITY = 0x13d
NL80211_ATTR_EXT_CAPA = 0xa9
NL80211_ATTR_EXT_CAPA_MASK = 0xaa
NL80211_ATTR_EXTERNAL_AUTH_ACTION = 0x104
@ -4337,10 +4409,11 @@ const (
NL80211_ATTR_MAC_HINT = 0xc8
NL80211_ATTR_MAC_MASK = 0xd7
NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca
NL80211_ATTR_MAX = 0x137
NL80211_ATTR_MAX = 0x140
NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4
NL80211_ATTR_MAX_CSA_COUNTERS = 0xce
NL80211_ATTR_MAX_MATCH_SETS = 0x85
NL80211_ATTR_MAX_NUM_AKM_SUITES = 0x13c
NL80211_ATTR_MAX_NUM_PMKIDS = 0x56
NL80211_ATTR_MAX_NUM_SCAN_SSIDS = 0x2b
NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS = 0xde
@ -4350,6 +4423,8 @@ const (
NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL = 0xdf
NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS = 0xe0
NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN = 0x7c
NL80211_ATTR_MBSSID_CONFIG = 0x132
NL80211_ATTR_MBSSID_ELEMS = 0x133
NL80211_ATTR_MCAST_RATE = 0x6b
NL80211_ATTR_MDID = 0xb1
NL80211_ATTR_MEASUREMENT_DURATION = 0xeb
@ -4359,6 +4434,11 @@ const (
NL80211_ATTR_MESH_PEER_AID = 0xed
NL80211_ATTR_MESH_SETUP = 0x70
NL80211_ATTR_MGMT_SUBTYPE = 0x29
NL80211_ATTR_MLD_ADDR = 0x13a
NL80211_ATTR_MLD_CAPA_AND_OPS = 0x13e
NL80211_ATTR_MLO_LINK_ID = 0x139
NL80211_ATTR_MLO_LINKS = 0x138
NL80211_ATTR_MLO_SUPPORT = 0x13b
NL80211_ATTR_MNTR_FLAGS = 0x17
NL80211_ATTR_MPATH_INFO = 0x1b
NL80211_ATTR_MPATH_NEXT_HOP = 0x1a
@ -4371,6 +4451,7 @@ const (
NL80211_ATTR_NETNS_FD = 0xdb
NL80211_ATTR_NOACK_MAP = 0x95
NL80211_ATTR_NSS = 0x106
NL80211_ATTR_OBSS_COLOR_BITMAP = 0x12e
NL80211_ATTR_OFFCHANNEL_TX_OK = 0x6c
NL80211_ATTR_OPER_CLASS = 0xd6
NL80211_ATTR_OPMODE_NOTIF = 0xc2
@ -4397,6 +4478,7 @@ const (
NL80211_ATTR_PROTOCOL_FEATURES = 0xad
NL80211_ATTR_PS_STATE = 0x5d
NL80211_ATTR_QOS_MAP = 0xc7
NL80211_ATTR_RADAR_BACKGROUND = 0x134
NL80211_ATTR_RADAR_EVENT = 0xa8
NL80211_ATTR_REASON_CODE = 0x36
NL80211_ATTR_RECEIVE_MULTICAST = 0x121
@ -4412,6 +4494,7 @@ const (
NL80211_ATTR_RESP_IE = 0x4e
NL80211_ATTR_ROAM_SUPPORT = 0x83
NL80211_ATTR_RX_FRAME_TYPES = 0x64
NL80211_ATTR_RX_HW_TIMESTAMP = 0x140
NL80211_ATTR_RXMGMT_FLAGS = 0xbc
NL80211_ATTR_RX_SIGNAL_DBM = 0x97
NL80211_ATTR_S1G_CAPABILITY = 0x128
@ -4484,6 +4567,7 @@ const (
NL80211_ATTR_TSID = 0xd2
NL80211_ATTR_TWT_RESPONDER = 0x116
NL80211_ATTR_TX_FRAME_TYPES = 0x63
NL80211_ATTR_TX_HW_TIMESTAMP = 0x13f
NL80211_ATTR_TX_NO_CCK_RATE = 0x87
NL80211_ATTR_TXQ_LIMIT = 0x10a
NL80211_ATTR_TXQ_MEMORY_LIMIT = 0x10b
@ -4557,6 +4641,10 @@ const (
NL80211_BAND_ATTR_RATES = 0x2
NL80211_BAND_ATTR_VHT_CAPA = 0x8
NL80211_BAND_ATTR_VHT_MCS_SET = 0x7
NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MAC = 0x8
NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MCS_SET = 0xa
NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PHY = 0x9
NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PPE = 0xb
NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA = 0x6
NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC = 0x2
NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET = 0x4
@ -4564,6 +4652,8 @@ const (
NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE = 0x5
NL80211_BAND_IFTYPE_ATTR_IFTYPES = 0x1
NL80211_BAND_IFTYPE_ATTR_MAX = 0xb
NL80211_BAND_IFTYPE_ATTR_VENDOR_ELEMS = 0x7
NL80211_BAND_LC = 0x5
NL80211_BAND_S1GHZ = 0x4
NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE = 0x2
NL80211_BITRATE_ATTR_MAX = 0x2
@ -4584,7 +4674,9 @@ const (
NL80211_BSS_FREQUENCY_OFFSET = 0x14
NL80211_BSS_INFORMATION_ELEMENTS = 0x6
NL80211_BSS_LAST_SEEN_BOOTTIME = 0xf
NL80211_BSS_MAX = 0x14
NL80211_BSS_MAX = 0x16
NL80211_BSS_MLD_ADDR = 0x16
NL80211_BSS_MLO_LINK_ID = 0x15
NL80211_BSS_PAD = 0x10
NL80211_BSS_PARENT_BSSID = 0x12
NL80211_BSS_PARENT_TSF = 0x11
@ -4612,6 +4704,7 @@ const (
NL80211_CHAN_WIDTH_20 = 0x1
NL80211_CHAN_WIDTH_20_NOHT = 0x0
NL80211_CHAN_WIDTH_2 = 0x9
NL80211_CHAN_WIDTH_320 = 0xd
NL80211_CHAN_WIDTH_40 = 0x2
NL80211_CHAN_WIDTH_4 = 0xa
NL80211_CHAN_WIDTH_5 = 0x6
@ -4621,8 +4714,11 @@ const (
NL80211_CMD_ABORT_SCAN = 0x72
NL80211_CMD_ACTION = 0x3b
NL80211_CMD_ACTION_TX_STATUS = 0x3c
NL80211_CMD_ADD_LINK = 0x94
NL80211_CMD_ADD_LINK_STA = 0x96
NL80211_CMD_ADD_NAN_FUNCTION = 0x75
NL80211_CMD_ADD_TX_TS = 0x69
NL80211_CMD_ASSOC_COMEBACK = 0x93
NL80211_CMD_ASSOCIATE = 0x26
NL80211_CMD_AUTHENTICATE = 0x25
NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL = 0x38
@ -4630,6 +4726,10 @@ const (
NL80211_CMD_CHANNEL_SWITCH = 0x66
NL80211_CMD_CH_SWITCH_NOTIFY = 0x58
NL80211_CMD_CH_SWITCH_STARTED_NOTIFY = 0x6e
NL80211_CMD_COLOR_CHANGE_ABORTED = 0x90
NL80211_CMD_COLOR_CHANGE_COMPLETED = 0x91
NL80211_CMD_COLOR_CHANGE_REQUEST = 0x8e
NL80211_CMD_COLOR_CHANGE_STARTED = 0x8f
NL80211_CMD_CONNECT = 0x2e
NL80211_CMD_CONN_FAILED = 0x5b
NL80211_CMD_CONTROL_PORT_FRAME = 0x81
@ -4678,8 +4778,9 @@ const (
NL80211_CMD_LEAVE_IBSS = 0x2c
NL80211_CMD_LEAVE_MESH = 0x45
NL80211_CMD_LEAVE_OCB = 0x6d
NL80211_CMD_MAX = 0x93
NL80211_CMD_MAX = 0x98
NL80211_CMD_MICHAEL_MIC_FAILURE = 0x29
NL80211_CMD_MODIFY_LINK_STA = 0x97
NL80211_CMD_NAN_MATCH = 0x78
NL80211_CMD_NEW_BEACON = 0xf
NL80211_CMD_NEW_INTERFACE = 0x7
@ -4692,6 +4793,7 @@ const (
NL80211_CMD_NEW_WIPHY = 0x3
NL80211_CMD_NOTIFY_CQM = 0x40
NL80211_CMD_NOTIFY_RADAR = 0x86
NL80211_CMD_OBSS_COLOR_COLLISION = 0x8d
NL80211_CMD_PEER_MEASUREMENT_COMPLETE = 0x85
NL80211_CMD_PEER_MEASUREMENT_RESULT = 0x84
NL80211_CMD_PEER_MEASUREMENT_START = 0x83
@ -4707,6 +4809,8 @@ const (
NL80211_CMD_REGISTER_FRAME = 0x3a
NL80211_CMD_RELOAD_REGDB = 0x7e
NL80211_CMD_REMAIN_ON_CHANNEL = 0x37
NL80211_CMD_REMOVE_LINK = 0x95
NL80211_CMD_REMOVE_LINK_STA = 0x98
NL80211_CMD_REQ_SET_REG = 0x1b
NL80211_CMD_ROAM = 0x2f
NL80211_CMD_SCAN_ABORTED = 0x23
@ -4717,6 +4821,7 @@ const (
NL80211_CMD_SET_CHANNEL = 0x41
NL80211_CMD_SET_COALESCE = 0x65
NL80211_CMD_SET_CQM = 0x3f
NL80211_CMD_SET_FILS_AAD = 0x92
NL80211_CMD_SET_INTERFACE = 0x6
NL80211_CMD_SET_KEY = 0xa
NL80211_CMD_SET_MAC_ACL = 0x5d
@ -4791,6 +4896,8 @@ const (
NL80211_EDMG_BW_CONFIG_MIN = 0x4
NL80211_EDMG_CHANNELS_MAX = 0x3c
NL80211_EDMG_CHANNELS_MIN = 0x1
NL80211_EHT_MAX_CAPABILITY_LEN = 0x33
NL80211_EHT_MIN_CAPABILITY_LEN = 0xd
NL80211_EXTERNAL_AUTH_ABORT = 0x1
NL80211_EXTERNAL_AUTH_START = 0x0
NL80211_EXT_FEATURE_4WAY_HANDSHAKE_AP_PSK = 0x32
@ -4807,6 +4914,7 @@ const (
NL80211_EXT_FEATURE_BEACON_RATE_HT = 0x7
NL80211_EXT_FEATURE_BEACON_RATE_LEGACY = 0x6
NL80211_EXT_FEATURE_BEACON_RATE_VHT = 0x8
NL80211_EXT_FEATURE_BSS_COLOR = 0x3a
NL80211_EXT_FEATURE_BSS_PARENT_TSF = 0x4
NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 = 0x1f
NL80211_EXT_FEATURE_CONTROL_PORT_NO_PREAUTH = 0x2a
@ -4818,6 +4926,7 @@ const (
NL80211_EXT_FEATURE_DFS_OFFLOAD = 0x19
NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER = 0x20
NL80211_EXT_FEATURE_EXT_KEY_ID = 0x24
NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD = 0x3b
NL80211_EXT_FEATURE_FILS_DISCOVERY = 0x34
NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME = 0x11
NL80211_EXT_FEATURE_FILS_SK_OFFLOAD = 0xe
@ -4833,8 +4942,10 @@ const (
NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION = 0x14
NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE = 0x13
NL80211_EXT_FEATURE_OPERATING_CHANNEL_VALIDATION = 0x31
NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE = 0x3d
NL80211_EXT_FEATURE_PROTECTED_TWT = 0x2b
NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE = 0x39
NL80211_EXT_FEATURE_RADAR_BACKGROUND = 0x3c
NL80211_EXT_FEATURE_RRM = 0x1
NL80211_EXT_FEATURE_SAE_OFFLOAD_AP = 0x33
NL80211_EXT_FEATURE_SAE_OFFLOAD = 0x26
@ -4906,7 +5017,9 @@ const (
NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11
NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc
NL80211_FREQUENCY_ATTR_NO_20MHZ = 0x10
NL80211_FREQUENCY_ATTR_NO_320MHZ = 0x1a
NL80211_FREQUENCY_ATTR_NO_80MHZ = 0xb
NL80211_FREQUENCY_ATTR_NO_EHT = 0x1b
NL80211_FREQUENCY_ATTR_NO_HE = 0x13
NL80211_FREQUENCY_ATTR_NO_HT40_MINUS = 0x9
NL80211_FREQUENCY_ATTR_NO_HT40_PLUS = 0xa
@ -5006,6 +5119,12 @@ const (
NL80211_MAX_SUPP_HT_RATES = 0x4d
NL80211_MAX_SUPP_RATES = 0x20
NL80211_MAX_SUPP_REG_RULES = 0x80
NL80211_MBSSID_CONFIG_ATTR_EMA = 0x5
NL80211_MBSSID_CONFIG_ATTR_INDEX = 0x3
NL80211_MBSSID_CONFIG_ATTR_MAX = 0x5
NL80211_MBSSID_CONFIG_ATTR_MAX_EMA_PROFILE_PERIODICITY = 0x2
NL80211_MBSSID_CONFIG_ATTR_MAX_INTERFACES = 0x1
NL80211_MBSSID_CONFIG_ATTR_TX_IFINDEX = 0x4
NL80211_MESHCONF_ATTR_MAX = 0x1f
NL80211_MESHCONF_AUTO_OPEN_PLINKS = 0x7
NL80211_MESHCONF_AWAKE_WINDOW = 0x1b
@ -5168,6 +5287,7 @@ const (
NL80211_PMSR_FTM_FAILURE_UNSPECIFIED = 0x0
NL80211_PMSR_FTM_FAILURE_WRONG_CHANNEL = 0x3
NL80211_PMSR_FTM_REQ_ATTR_ASAP = 0x1
NL80211_PMSR_FTM_REQ_ATTR_BSS_COLOR = 0xd
NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION = 0x5
NL80211_PMSR_FTM_REQ_ATTR_BURST_PERIOD = 0x4
NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST = 0x6
@ -5244,12 +5364,36 @@ const (
NL80211_RADAR_PRE_CAC_EXPIRED = 0x4
NL80211_RATE_INFO_10_MHZ_WIDTH = 0xb
NL80211_RATE_INFO_160_MHZ_WIDTH = 0xa
NL80211_RATE_INFO_320_MHZ_WIDTH = 0x12
NL80211_RATE_INFO_40_MHZ_WIDTH = 0x3
NL80211_RATE_INFO_5_MHZ_WIDTH = 0xc
NL80211_RATE_INFO_80_MHZ_WIDTH = 0x8
NL80211_RATE_INFO_80P80_MHZ_WIDTH = 0x9
NL80211_RATE_INFO_BITRATE32 = 0x5
NL80211_RATE_INFO_BITRATE = 0x1
NL80211_RATE_INFO_EHT_GI_0_8 = 0x0
NL80211_RATE_INFO_EHT_GI_1_6 = 0x1
NL80211_RATE_INFO_EHT_GI_3_2 = 0x2
NL80211_RATE_INFO_EHT_GI = 0x15
NL80211_RATE_INFO_EHT_MCS = 0x13
NL80211_RATE_INFO_EHT_NSS = 0x14
NL80211_RATE_INFO_EHT_RU_ALLOC_106 = 0x3
NL80211_RATE_INFO_EHT_RU_ALLOC_106P26 = 0x4
NL80211_RATE_INFO_EHT_RU_ALLOC_242 = 0x5
NL80211_RATE_INFO_EHT_RU_ALLOC_26 = 0x0
NL80211_RATE_INFO_EHT_RU_ALLOC_2x996 = 0xb
NL80211_RATE_INFO_EHT_RU_ALLOC_2x996P484 = 0xc
NL80211_RATE_INFO_EHT_RU_ALLOC_3x996 = 0xd
NL80211_RATE_INFO_EHT_RU_ALLOC_3x996P484 = 0xe
NL80211_RATE_INFO_EHT_RU_ALLOC_484 = 0x6
NL80211_RATE_INFO_EHT_RU_ALLOC_484P242 = 0x7
NL80211_RATE_INFO_EHT_RU_ALLOC_4x996 = 0xf
NL80211_RATE_INFO_EHT_RU_ALLOC_52 = 0x1
NL80211_RATE_INFO_EHT_RU_ALLOC_52P26 = 0x2
NL80211_RATE_INFO_EHT_RU_ALLOC_996 = 0x8
NL80211_RATE_INFO_EHT_RU_ALLOC_996P484 = 0x9
NL80211_RATE_INFO_EHT_RU_ALLOC_996P484P242 = 0xa
NL80211_RATE_INFO_EHT_RU_ALLOC = 0x16
NL80211_RATE_INFO_HE_1XLTF = 0x0
NL80211_RATE_INFO_HE_2XLTF = 0x1
NL80211_RATE_INFO_HE_4XLTF = 0x2
@ -5292,6 +5436,7 @@ const (
NL80211_RRF_GO_CONCURRENT = 0x1000
NL80211_RRF_IR_CONCURRENT = 0x1000
NL80211_RRF_NO_160MHZ = 0x10000
NL80211_RRF_NO_320MHZ = 0x40000
NL80211_RRF_NO_80MHZ = 0x8000
NL80211_RRF_NO_CCK = 0x2
NL80211_RRF_NO_HE = 0x20000

@ -10,7 +10,6 @@ import (
errorspkg "errors"
"fmt"
"runtime"
"strings"
"sync"
"syscall"
"time"
@ -87,22 +86,13 @@ func StringToUTF16(s string) []uint16 {
// s, with a terminating NUL added. If s contains a NUL byte at any
// location, it returns (nil, syscall.EINVAL).
func UTF16FromString(s string) ([]uint16, error) {
if strings.IndexByte(s, 0) != -1 {
return nil, syscall.EINVAL
}
return utf16.Encode([]rune(s + "\x00")), nil
return syscall.UTF16FromString(s)
}
// UTF16ToString returns the UTF-8 encoding of the UTF-16 sequence s,
// with a terminating NUL and any bytes after the NUL removed.
func UTF16ToString(s []uint16) string {
for i, v := range s {
if v == 0 {
s = s[:i]
break
}
}
return string(utf16.Decode(s))
return syscall.UTF16ToString(s)
}
// StringToUTF16Ptr is deprecated. Use UTF16PtrFromString instead.

27
vendor/gorm.io/gen/do.go generated vendored

@ -70,7 +70,7 @@ func (d *DO) ReplaceDB(db *gorm.DB) {
// ReplaceConnPool replace db connection pool
func (d *DO) ReplaceConnPool(pool gorm.ConnPool) {
d.db = d.db.Session(&gorm.Session{})
d.db = d.db.Session(&gorm.Session{Initialized: true}).Session(&gorm.Session{})
d.db.Statement.ConnPool = pool
}
@ -256,11 +256,16 @@ func (d *DO) Order(columns ...field.Expr) Dao {
func (d *DO) toOrderValue(columns ...field.Expr) string {
// eager build Columns
orderArray := make([]string, len(columns))
stmt := &gorm.Statement{DB: d.db.Statement.DB, Table: d.db.Statement.Table, Schema: d.db.Statement.Schema}
for i, c := range columns {
orderArray[i] = c.Build(d.db.Statement).String()
if i != 0 {
stmt.WriteByte(',')
}
c.Build(stmt)
}
return strings.Join(orderArray, ",")
return stmt.SQL.String()
}
// Distinct ...
@ -281,11 +286,17 @@ func (d *DO) Group(columns ...field.Expr) Dao {
if len(columns) == 0 {
return d
}
name := string(columns[0].Build(d.db.Statement))
for _, col := range columns[1:] {
name += "," + string(col.Build(d.db.Statement))
stmt := &gorm.Statement{DB: d.db.Statement.DB, Table: d.db.Statement.Table, Schema: d.db.Statement.Schema}
for i, c := range columns {
if i != 0 {
stmt.WriteByte(',')
}
c.Build(stmt)
}
return d.getInstance(d.db.Group(name))
return d.getInstance(d.db.Group(stmt.SQL.String()))
}
// Having ...

16
vendor/gorm.io/gen/field/expr.go generated vendored

@ -18,10 +18,12 @@ type AssignExpr interface {
// Expr a query expression about field
type Expr interface {
// Clause Expression interface
Build(clause.Builder)
As(alias string) Expr
ColumnName() sql
BuildColumn(*gorm.Statement, ...BuildOpt) sql
Build(*gorm.Statement) sql
BuildWithArgs(*gorm.Statement) (query sql, args []interface{})
RawExpr() expression
@ -110,13 +112,15 @@ func (e expr) BuildColumn(stmt *gorm.Statement, opts ...BuildOpt) sql {
return sql(stmt.Quote(col))
}
func (e expr) Build(stmt *gorm.Statement) sql {
func (e expr) Build(builder clause.Builder) {
if e.e == nil {
return sql(e.BuildColumn(stmt, WithAll))
if stmt, ok := builder.(*gorm.Statement); ok {
builder.WriteString(string(e.BuildColumn(stmt, WithAll)))
return
}
}
newStmt := &gorm.Statement{DB: stmt.DB, Table: stmt.Table, Schema: stmt.Schema}
e.e.Build(newStmt)
return sql(newStmt.SQL.String())
e.e.Build(builder)
}
func (e expr) BuildWithArgs(stmt *gorm.Statement) (sql, []interface{}) {

14
vendor/gorm.io/gen/generator.go generated vendored

@ -3,6 +3,7 @@ package gen
import (
"bytes"
"context"
"database/sql"
"fmt"
"io"
"io/ioutil"
@ -33,6 +34,15 @@ type T interface{}
// M map[string]interface{}
type M map[string]interface{}
// SQLResult sql.result
type SQLResult sql.Result
// SQLRow sql.Row
type SQLRow sql.Row
// SQLRows sql.Rows
type SQLRows sql.Rows
// RowsAffected execute affected raws
type RowsAffected int64
@ -200,12 +210,12 @@ func (g *Generator) genModelObjConfig() *model.Config {
}
}
// ApplyBasic specify models which will implement basic method
// ApplyBasic specify models which will implement basic .diy_method
func (g *Generator) ApplyBasic(models ...interface{}) {
g.ApplyInterface(func() {}, models...)
}
// ApplyInterface specifies method interfaces on structures, implment codes will be generated after calling g.Execute()
// ApplyInterface specifies .diy_method interfaces on structures, implment codes will be generated after calling g.Execute()
// eg: g.ApplyInterface(func(model.Method){}, model.User{}, model.Company{})
func (g *Generator) ApplyInterface(fc interface{}, models ...interface{}) {
structs, err := generate.ConvertStructs(g.db, models...)

@ -57,6 +57,46 @@ func (m *InterfaceMethod) GormRunMethodName() string {
return "Take"
}
// ReturnSQLResult return sql result
func (m *InterfaceMethod) ReturnSQLResult() bool {
for _, res := range m.Result {
if res.IsSQLResult() {
return true
}
}
return false
}
// ReturnSQLRow return sql result
func (m *InterfaceMethod) ReturnSQLRow() bool {
for _, res := range m.Result {
if res.IsSQLRow() {
return true
}
}
return false
}
// ReturnSQLRows return sql result
func (m *InterfaceMethod) ReturnSQLRows() bool {
for _, res := range m.Result {
if res.IsSQLRows() {
return true
}
}
return false
}
// ReturnNothing not return error and rowAffected
func (m *InterfaceMethod) ReturnNothing() bool {
for _, res := range m.Result {
if res.IsError() || res.Name == "rowsAffected" {
return false
}
}
return true
}
// ReturnRowsAffected return rows affected
func (m *InterfaceMethod) ReturnRowsAffected() bool {
for _, res := range m.Result {
@ -113,7 +153,7 @@ func paramToString(params []parser.Param) string {
// DocComment return comment sql add "//" every line
func (m *InterfaceMethod) DocComment() string {
return strings.Replace(strings.TrimSpace(m.Doc), "\n", "\n//", -1)
return strings.Replace(strings.Replace(strings.TrimSpace(m.Doc), "\n", "\n// ", -1), "// ", "// ", -1)
}
// checkParams check all parameters
@ -196,6 +236,23 @@ func (m *InterfaceMethod) checkResult(result []parser.Param) (err error) {
param.Package = ""
param.SetName("rowsAffected")
m.GormOption = "Exec"
case param.IsSQLResult():
param.Type = "Result"
param.Package = "sql"
param.SetName("result")
m.GormOption = "Statement.ConnPool.ExecContext"
case param.IsSQLRow():
param.Type = "Row"
param.Package = "sql"
param.SetName("row")
m.GormOption = "Raw"
param.IsPointer = true
case param.IsSQLRows():
param.Type = "Rows"
param.Package = "sql"
param.SetName("rows")
m.GormOption = "Raw"
param.IsPointer = true
default:
if !m.ResultData.IsNull() {
return fmt.Errorf("query method cannot return more than 1 data value in [%s.%s]", m.InterfaceName, m.MethodName)

@ -181,6 +181,21 @@ func (p *Param) IsTime() bool {
return p.Package == "time" && p.Type == "Time"
}
// IsSQLResult ...
func (p *Param) IsSQLResult() bool {
return (p.Package == "sql" && p.Type == "Result") || (p.Package == "gen" && p.Type == "SQLResult")
}
// IsSQLRow ...
func (p *Param) IsSQLRow() bool {
return (p.Package == "sql" && p.Type == "Row") || (p.Package == "gen" && p.Type == "SQLRow")
}
// IsSQLRows ...
func (p *Param) IsSQLRows() bool {
return (p.Package == "sql" && p.Type == "Rows") || (p.Package == "gen" && p.Type == "SQLRows")
}
// SetName ...
func (p *Param) SetName(name string) {
p.Name = name

@ -3,7 +3,7 @@ package template
// DIYMethod DIY method
const DIYMethod = `
//{{.DocComment }}
// {{.DocComment }}
func ({{.S}} {{.TargetStruct}}Do){{.FuncSign}}{
{{if .HasSQLData}}var params []interface{}
@ -12,12 +12,17 @@ func ({{.S}} {{.TargetStruct}}Do){{.FuncSign}}{
{{end}}
{{if .HasNeedNewResult}}result ={{if .ResultData.IsMap}}make{{else}}new{{end}}({{if ne .ResultData.Package ""}}{{.ResultData.Package}}.{{end}}{{.ResultData.Type}}){{end}}
{{if or .ReturnRowsAffected .ReturnError}}var executeSQL *gorm.DB
{{end}}
{{if or .ReturnRowsAffected .ReturnError}}executeSQL{{else}}_{{end}} = {{.S}}.UnderlyingDB().{{.GormOption}}(generateSQL.String(){{if .HasSQLData}},params...{{end}}){{if not .ResultData.IsNull}}.{{.GormRunMethodName}}({{if .HasGotPoint}}&{{end}}{{.ResultData.Name}}){{end}}
{{if .ReturnSQLResult}}stmt := {{.S}}.UnderlyingDB().Statement
result,{{if .ReturnError}}err{{else}}_{{end}} = stmt.ConnPool.ExecContext(stmt.Context,generateSQL.String(){{if .HasSQLData}},params...{{end}}) // ignore_security_alert
{{else if .ReturnSQLRow}}row = {{.S}}.UnderlyingDB().Raw(generateSQL.String(){{if .HasSQLData}},params...{{end}}).Row() // ignore_security_alert
{{else if .ReturnSQLRows}}rows,{{if .ReturnError}}err{{else}}_{{end}} = {{.S}}.UnderlyingDB().Raw(generateSQL.String(){{if .HasSQLData}},params...{{end}}).Rows() // ignore_security_alert
{{else}}var executeSQL *gorm.DB
executeSQL = {{.S}}.UnderlyingDB().{{.GormOption}}(generateSQL.String(){{if .HasSQLData}},params...{{end}}){{if not .ResultData.IsNull}}.{{.GormRunMethodName}}({{if .HasGotPoint}}&{{end}}{{.ResultData.Name}}){{end}} // ignore_security_alert
{{if .ReturnRowsAffected}}rowsAffected = executeSQL.RowsAffected
{{end}}{{if .ReturnError}}err = executeSQL.Error
{{end}}return
{{end}}{{if .ReturnNothing}}_ = executeSQL
{{end}}{{end}}
return
}
`

@ -49,11 +49,11 @@ func (q *Query) clone(db *gorm.DB) *Query {
}
func (q *Query) ReadDB() *Query {
return q.clone(q.db.Clauses(dbresolver.Read))
return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
}
func (q *Query) WriteDB() *Query {
return q.clone(q.db.Clauses(dbresolver.Write))
return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
}
func (q *Query) ReplaceDB(db *gorm.DB) *Query {

3
vendor/gorm.io/gorm/README.md generated vendored

@ -4,9 +4,6 @@ The fantastic ORM library for Golang, aims to be developer friendly.
[![go report card](https://goreportcard.com/badge/github.com/go-gorm/gorm "go report card")](https://goreportcard.com/report/github.com/go-gorm/gorm)
[![test status](https://github.com/go-gorm/gorm/workflows/tests/badge.svg?branch=master "test status")](https://github.com/go-gorm/gorm/actions)
[![Join the chat at https://gitter.im/jinzhu/gorm](https://img.shields.io/gitter/room/jinzhu/gorm.svg)](https://gitter.im/jinzhu/gorm?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Open Collective Backer](https://opencollective.com/gorm/tiers/backer/badge.svg?label=backer&color=brightgreen "Open Collective Backer")](https://opencollective.com/gorm)
[![Open Collective Sponsor](https://opencollective.com/gorm/tiers/sponsor/badge.svg?label=sponsor&color=brightgreen "Open Collective Sponsor")](https://opencollective.com/gorm)
[![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
[![Go.Dev reference](https://img.shields.io/badge/go.dev-reference-blue?logo=go&logoColor=white)](https://pkg.go.dev/gorm.io/gorm?tab=doc)

4
vendor/gorm.io/gorm/callbacks.go generated vendored

@ -93,6 +93,10 @@ func (p *processor) Execute(db *DB) *DB {
resetBuildClauses = true
}
if optimizer, ok := db.Statement.Dest.(StatementModifier); ok {
optimizer.ModifyStatement(stmt)
}
// assign model values
if stmt.Model == nil {
stmt.Model = stmt.Dest

@ -55,7 +55,7 @@ func (db *DB) Clauses(conds ...clause.Expression) (tx *DB) {
return
}
var tableRegexp = regexp.MustCompile(`(?i).+? AS (\w+)\s*(?:$|,)`)
var tableRegexp = regexp.MustCompile(`(?i)(?:.+? AS (\w+)\s*(?:$|,)|^\w+\s+(\w+)$)`)
// Table specify the table you would like to run db operations
//
@ -65,8 +65,12 @@ func (db *DB) Table(name string, args ...interface{}) (tx *DB) {
tx = db.getInstance()
if strings.Contains(name, " ") || strings.Contains(name, "`") || len(args) > 0 {
tx.Statement.TableExpr = &clause.Expr{SQL: name, Vars: args}
if results := tableRegexp.FindStringSubmatch(name); len(results) == 2 {
tx.Statement.Table = results[1]
if results := tableRegexp.FindStringSubmatch(name); len(results) == 3 {
if results[1] != "" {
tx.Statement.Table = results[1]
} else {
tx.Statement.Table = results[2]
}
}
} else if tables := strings.Split(name, "."); len(tables) == 2 {
tx.Statement.TableExpr = &clause.Expr{SQL: tx.Statement.Quote(name)}

@ -20,6 +20,7 @@ type Builder interface {
Writer
WriteQuoted(field interface{})
AddVar(Writer, ...interface{})
AddError(error) error
}
// Clause

@ -120,7 +120,10 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
if err != nil {
return err
}
var (
parseIndexes = stmt.Schema.ParseIndexes()
parseCheckConstraints = stmt.Schema.ParseCheckConstraints()
)
for _, dbName := range stmt.Schema.DBNames {
field := stmt.Schema.FieldsByDBName[dbName]
var foundColumn gorm.ColumnType
@ -157,7 +160,7 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
}
}
for _, chk := range stmt.Schema.ParseCheckConstraints() {
for _, chk := range parseCheckConstraints {
if !queryTx.Migrator().HasConstraint(value, chk.Name) {
if err := execTx.Migrator().CreateConstraint(value, chk.Name); err != nil {
return err
@ -165,7 +168,7 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
}
}
for _, idx := range stmt.Schema.ParseIndexes() {
for _, idx := range parseIndexes {
if !queryTx.Migrator().HasIndex(value, idx.Name) {
if err := execTx.Migrator().CreateIndex(value, idx.Name); err != nil {
return err
@ -430,7 +433,8 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
realDataType := strings.ToLower(columnType.DatabaseTypeName())
var (
alterColumn, isSameType bool
alterColumn bool
isSameType = fullDataType == realDataType
)
if !field.PrimaryKey {

@ -65,7 +65,11 @@ func (schema *Schema) ParseIndexes() map[string]Index {
}
}
}
for _, index := range indexes {
if index.Class == "UNIQUE" && len(index.Fields) == 1 {
index.Fields[0].Field.Unique = true
}
}
return indexes
}

@ -246,14 +246,6 @@ func ParseWithSpecialTableName(dest interface{}, cacheStore *sync.Map, namer Nam
field.HasDefaultValue = true
field.AutoIncrement = true
}
case String:
if _, ok := field.TagSettings["PRIMARYKEY"]; !ok {
if !field.HasDefaultValue || field.DefaultValueInterface != nil {
schema.FieldsWithDefaultDBValue = append(schema.FieldsWithDefaultDBValue, field)
}
field.HasDefaultValue = true
}
}
}

@ -6,6 +6,7 @@ import (
"encoding/json"
"reflect"
"github.com/jinzhu/now"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
)
@ -45,11 +46,21 @@ func (n *DeletedAt) UnmarshalJSON(b []byte) error {
}
func (DeletedAt) QueryClauses(f *schema.Field) []clause.Interface {
return []clause.Interface{SoftDeleteQueryClause{Field: f}}
return []clause.Interface{SoftDeleteQueryClause{Field: f, ZeroValue: parseZeroValueTag(f)}}
}
func parseZeroValueTag(f *schema.Field) sql.NullString {
if v, ok := f.TagSettings["ZEROVALUE"]; ok {
if _, err := now.Parse(v); err == nil {
return sql.NullString{String: v, Valid: true}
}
}
return sql.NullString{Valid: false}
}
type SoftDeleteQueryClause struct {
Field *schema.Field
ZeroValue sql.NullString
Field *schema.Field
}
func (sd SoftDeleteQueryClause) Name() string {
@ -78,18 +89,19 @@ func (sd SoftDeleteQueryClause) ModifyStatement(stmt *Statement) {
}
stmt.AddClause(clause.Where{Exprs: []clause.Expression{
clause.Eq{Column: clause.Column{Table: clause.CurrentTable, Name: sd.Field.DBName}, Value: nil},
clause.Eq{Column: clause.Column{Table: clause.CurrentTable, Name: sd.Field.DBName}, Value: sd.ZeroValue},
}})
stmt.Clauses["soft_delete_enabled"] = clause.Clause{}
}
}
func (DeletedAt) UpdateClauses(f *schema.Field) []clause.Interface {
return []clause.Interface{SoftDeleteUpdateClause{Field: f}}
return []clause.Interface{SoftDeleteUpdateClause{Field: f, ZeroValue: parseZeroValueTag(f)}}
}
type SoftDeleteUpdateClause struct {
Field *schema.Field
ZeroValue sql.NullString
Field *schema.Field
}
func (sd SoftDeleteUpdateClause) Name() string {
@ -109,11 +121,12 @@ func (sd SoftDeleteUpdateClause) ModifyStatement(stmt *Statement) {
}
func (DeletedAt) DeleteClauses(f *schema.Field) []clause.Interface {
return []clause.Interface{SoftDeleteDeleteClause{Field: f}}
return []clause.Interface{SoftDeleteDeleteClause{Field: f, ZeroValue: parseZeroValueTag(f)}}
}
type SoftDeleteDeleteClause struct {
Field *schema.Field
ZeroValue sql.NullString
Field *schema.Field
}
func (sd SoftDeleteDeleteClause) Name() string {

51
vendor/gorm.io/gorm/statement.go generated vendored

@ -311,6 +311,9 @@ func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) []
conds := make([]clause.Expression, 0, 4)
args = append([]interface{}{query}, args...)
for idx, arg := range args {
if arg == nil {
continue
}
if valuer, ok := arg.(driver.Valuer); ok {
arg, _ = valuer.Value()
}
@ -665,47 +668,41 @@ func (stmt *Statement) SelectAndOmitColumns(requireCreate, requireUpdate bool) (
results := map[string]bool{}
notRestricted := false
// select columns
for _, column := range stmt.Selects {
processColumn := func(column string, result bool) {
if stmt.Schema == nil {
results[column] = true
results[column] = result
} else if column == "*" {
notRestricted = true
notRestricted = result
for _, dbName := range stmt.Schema.DBNames {
results[dbName] = true
results[dbName] = result
}
} else if column == clause.Associations {
for _, rel := range stmt.Schema.Relationships.Relations {
results[rel.Name] = true
results[rel.Name] = result
}
} else if field := stmt.Schema.LookUpField(column); field != nil && field.DBName != "" {
results[field.DBName] = true
results[field.DBName] = result
} else if matches := nameMatcher.FindStringSubmatch(column); len(matches) == 3 && (matches[1] == stmt.Table || matches[1] == "") {
results[matches[2]] = true
if matches[2] == "*" {
for _, dbName := range stmt.Schema.DBNames {
results[dbName] = result
}
} else {
results[matches[2]] = result
}
} else {
results[column] = true
results[column] = result
}
}
// select columns
for _, column := range stmt.Selects {
processColumn(column, true)
}
// omit columns
for _, omit := range stmt.Omits {
if stmt.Schema == nil {
results[omit] = false
} else if omit == "*" {
for _, dbName := range stmt.Schema.DBNames {
results[dbName] = false
}
} else if omit == clause.Associations {
for _, rel := range stmt.Schema.Relationships.Relations {
results[rel.Name] = false
}
} else if field := stmt.Schema.LookUpField(omit); field != nil && field.DBName != "" {
results[field.DBName] = false
} else if matches := nameMatcher.FindStringSubmatch(omit); len(matches) == 2 {
results[matches[1]] = false
} else {
results[omit] = false
}
for _, column := range stmt.Omits {
processColumn(column, false)
}
if stmt.Schema != nil {

@ -27,6 +27,8 @@ DB.Use(dbresolver.Register(dbresolver.Config{
Replicas: []gorm.Dialector{mysql.Open("db3_dsn"), mysql.Open("db4_dsn")},
// sources/replicas load balancing policy
Policy: dbresolver.RandomPolicy{},
// print sources/replicas mode in logger
ResolverModeReplica: true,
}).Register(dbresolver.Config{
// use `db1` as sources (DB's default connection), `db5` as replicas for `User`, `Address`
Replicas: []gorm.Dialector{mysql.Open("db5_dsn")},

@ -27,7 +27,7 @@ func (dr *DBResolver) switchReplica(db *gorm.DB) {
dr.switchGuess(db)
} else {
_, locking := db.Statement.Clauses["FOR"]
if _, ok := db.Statement.Clauses[writeName]; ok || locking {
if _, ok := db.Statement.Settings.Load(writeName); ok || locking {
db.Statement.ConnPool = dr.resolve(db.Statement, Write)
} else {
db.Statement.ConnPool = dr.resolve(db.Statement, Read)
@ -38,7 +38,7 @@ func (dr *DBResolver) switchReplica(db *gorm.DB) {
func (dr *DBResolver) switchGuess(db *gorm.DB) {
if !isTransaction(db.Statement.ConnPool) {
if _, ok := db.Statement.Clauses[writeName]; ok {
if _, ok := db.Statement.Settings.Load(writeName); ok {
db.Statement.ConnPool = dr.resolve(db.Statement, Write)
} else if rawSQL := strings.TrimSpace(db.Statement.SQL.String()); len(rawSQL) > 10 && strings.EqualFold(rawSQL[:6], "select") && !strings.EqualFold(rawSQL[len(rawSQL)-10:], "for update") {
db.Statement.ConnPool = dr.resolve(db.Statement, Read)

@ -18,14 +18,14 @@ func (op Operation) ModifyStatement(stmt *gorm.Statement) {
var optName string
if op == Write {
optName = writeName
delete(stmt.Clauses, readName)
stmt.Settings.Delete(readName)
} else if op == Read {
optName = readName
delete(stmt.Clauses, writeName)
stmt.Settings.Delete(writeName)
}
if optName != "" {
stmt.Clauses[optName] = clause.Clause{}
stmt.Settings.Store(optName, struct{}{})
if fc := stmt.DB.Callback().Query().Get("gorm:db_resolver"); fc != nil {
fc(stmt.DB)
}

22
vendor/modules.txt vendored

@ -5,7 +5,7 @@ github.com/aliyun/aliyun-oss-go-sdk/oss
## explicit; go 1.16
github.com/allegro/bigcache/v3
github.com/allegro/bigcache/v3/queue
# github.com/baidubce/bce-sdk-go v0.9.141
# github.com/baidubce/bce-sdk-go v0.9.142
## explicit; go 1.11
github.com/baidubce/bce-sdk-go/auth
github.com/baidubce/bce-sdk-go/bce
@ -52,11 +52,11 @@ github.com/go-playground/locales
github.com/go-playground/locales/currency
github.com/go-playground/locales/en
github.com/go-playground/locales/zh
# github.com/go-playground/universal-translator v0.18.0
## explicit; go 1.13
# github.com/go-playground/universal-translator v0.18.1
## explicit; go 1.18
github.com/go-playground/universal-translator
# github.com/go-playground/validator/v10 v10.11.1
## explicit; go 1.13
# github.com/go-playground/validator/v10 v10.11.2
## explicit; go 1.18
github.com/go-playground/validator/v10
github.com/go-playground/validator/v10/translations/en
github.com/go-playground/validator/v10/translations/zh
@ -180,7 +180,7 @@ github.com/qiniu/go-sdk/v7/internal/hostprovider
github.com/qiniu/go-sdk/v7/internal/log
github.com/qiniu/go-sdk/v7/reqid
github.com/qiniu/go-sdk/v7/storage
# github.com/redis/go-redis/v9 v9.0.0-rc.4
# github.com/redis/go-redis/v9 v9.0.2
## explicit; go 1.17
github.com/redis/go-redis/v9
github.com/redis/go-redis/v9/internal
@ -239,7 +239,7 @@ github.com/tklauser/go-sysconf
# github.com/tklauser/numcpus v0.6.0
## explicit; go 1.13
github.com/tklauser/numcpus
# github.com/ugorji/go/codec v1.2.8
# github.com/ugorji/go/codec v1.2.9
## explicit; go 1.11
github.com/ugorji/go/codec
# github.com/ulikunitz/xz v0.5.11
@ -348,7 +348,7 @@ golang.org/x/net/idna
## explicit
golang.org/x/sync/errgroup
golang.org/x/sync/singleflight
# golang.org/x/sys v0.4.0
# golang.org/x/sys v0.5.0
## explicit; go 1.17
golang.org/x/sys/cpu
golang.org/x/sys/execabs
@ -439,7 +439,7 @@ gorm.io/driver/mysql
# gorm.io/driver/postgres v1.4.6
## explicit; go 1.14
gorm.io/driver/postgres
# gorm.io/gen v0.3.19
# gorm.io/gen v0.3.21
## explicit; go 1.18
gorm.io/gen
gorm.io/gen/field
@ -449,7 +449,7 @@ gorm.io/gen/internal/model
gorm.io/gen/internal/parser
gorm.io/gen/internal/template
gorm.io/gen/internal/utils/pools
# gorm.io/gorm v1.24.3
# gorm.io/gorm v1.24.5
## explicit; go 1.16
gorm.io/gorm
gorm.io/gorm/callbacks
@ -462,7 +462,7 @@ gorm.io/gorm/utils/tests
# gorm.io/hints v1.1.1
## explicit; go 1.14
gorm.io/hints
# gorm.io/plugin/dbresolver v1.4.0
# gorm.io/plugin/dbresolver v1.4.1
## explicit; go 1.14
gorm.io/plugin/dbresolver
# xorm.io/builder v0.3.12

Loading…
Cancel
Save