mirror of
				https://github.com/kardolus/chatgpt-cli.git
				synced 2024-09-08 23:15:00 +03:00 
			
		
		
		
	Bump dependencies
This commit is contained in:
		
							
								
								
									
										14
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								go.mod
									
									
									
									
									
								
							| @@ -7,25 +7,29 @@ require ( | ||||
| 	github.com/onsi/gomega v1.28.0 | ||||
| 	github.com/sclevine/spec v1.4.0 | ||||
| 	github.com/spf13/cobra v1.7.0 | ||||
| 	github.com/spf13/viper v1.16.0 | ||||
| 	github.com/spf13/viper v1.17.0 | ||||
| 	gopkg.in/yaml.v3 v3.0.1 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/fsnotify/fsnotify v1.6.0 // indirect | ||||
| 	github.com/google/go-cmp v0.5.9 // indirect | ||||
| 	github.com/google/go-cmp v0.6.0 // indirect | ||||
| 	github.com/hashicorp/hcl v1.0.0 // indirect | ||||
| 	github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||||
| 	github.com/magiconair/properties v1.8.7 // indirect | ||||
| 	github.com/mitchellh/mapstructure v1.5.0 // indirect | ||||
| 	github.com/pelletier/go-toml/v2 v2.1.0 // indirect | ||||
| 	github.com/sagikazarmark/locafero v0.3.0 // indirect | ||||
| 	github.com/sagikazarmark/slog-shim v0.1.0 // indirect | ||||
| 	github.com/sourcegraph/conc v0.3.0 // indirect | ||||
| 	github.com/spf13/afero v1.10.0 // indirect | ||||
| 	github.com/spf13/cast v1.5.1 // indirect | ||||
| 	github.com/spf13/jwalterweatherman v1.1.0 // indirect | ||||
| 	github.com/spf13/pflag v1.0.5 // indirect | ||||
| 	github.com/subosito/gotenv v1.6.0 // indirect | ||||
| 	golang.org/x/net v0.15.0 // indirect | ||||
| 	golang.org/x/sys v0.12.0 // indirect | ||||
| 	go.uber.org/multierr v1.11.0 // indirect | ||||
| 	golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect | ||||
| 	golang.org/x/net v0.17.0 // indirect | ||||
| 	golang.org/x/sys v0.13.0 // indirect | ||||
| 	golang.org/x/text v0.13.0 // indirect | ||||
| 	gopkg.in/ini.v1 v1.67.0 // indirect | ||||
| ) | ||||
|   | ||||
							
								
								
									
										37
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								go.sum
									
									
									
									
									
								
							| @@ -48,8 +48,8 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht | ||||
| github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= | ||||
| github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= | ||||
| github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | ||||
| github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | ||||
| github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= | ||||
| @@ -102,8 +102,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ | ||||
| github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= | ||||
| github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||||
| github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||||
| github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||||
| github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= | ||||
| github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= | ||||
| github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= | ||||
| @@ -151,30 +151,33 @@ github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6 | ||||
| github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= | ||||
| github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||
| github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= | ||||
| github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= | ||||
| github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= | ||||
| github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= | ||||
| github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||||
| github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= | ||||
| github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= | ||||
| github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= | ||||
| github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= | ||||
| github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= | ||||
| github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= | ||||
| github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= | ||||
| github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= | ||||
| github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= | ||||
| github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= | ||||
| github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= | ||||
| github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= | ||||
| github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= | ||||
| github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= | ||||
| github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= | ||||
| github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= | ||||
| github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= | ||||
| github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= | ||||
| github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= | ||||
| github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= | ||||
| github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= | ||||
| github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||||
| github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= | ||||
| github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||||
| github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| @@ -195,6 +198,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= | ||||
| go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= | ||||
| go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= | ||||
| go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= | ||||
| go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= | ||||
| go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
| golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
| @@ -212,6 +217,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 | ||||
| golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= | ||||
| golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= | ||||
| golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= | ||||
| golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= | ||||
| golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= | ||||
| golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= | ||||
| golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | ||||
| golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | ||||
| @@ -269,8 +276,8 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v | ||||
| golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | ||||
| golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= | ||||
| golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||||
| golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= | ||||
| golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= | ||||
| golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= | ||||
| golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= | ||||
| golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | ||||
| golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | ||||
| golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | ||||
| @@ -329,8 +336,8 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w | ||||
| golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= | ||||
| golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= | ||||
| golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||||
| golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| @@ -393,7 +400,7 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f | ||||
| golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | ||||
| golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= | ||||
| golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= | ||||
| golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= | ||||
| golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= | ||||
| 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= | ||||
| @@ -487,8 +494,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD | ||||
| google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= | ||||
| google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= | ||||
| gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= | ||||
| gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= | ||||
| gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= | ||||
| gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= | ||||
|   | ||||
							
								
								
									
										38
									
								
								vendor/github.com/google/go-cmp/cmp/compare.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										38
									
								
								vendor/github.com/google/go-cmp/cmp/compare.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -5,7 +5,7 @@ | ||||
| // Package cmp determines equality of values. | ||||
| // | ||||
| // This package is intended to be a more powerful and safer alternative to | ||||
| // reflect.DeepEqual for comparing whether two values are semantically equal. | ||||
| // [reflect.DeepEqual] for comparing whether two values are semantically equal. | ||||
| // It is intended to only be used in tests, as performance is not a goal and | ||||
| // it may panic if it cannot compare the values. Its propensity towards | ||||
| // panicking means that its unsuitable for production environments where a | ||||
| @@ -18,16 +18,17 @@ | ||||
| //     For example, an equality function may report floats as equal so long as | ||||
| //     they are within some tolerance of each other. | ||||
| // | ||||
| //   - Types with an Equal method may use that method to determine equality. | ||||
| //     This allows package authors to determine the equality operation | ||||
| //     for the types that they define. | ||||
| //   - Types with an Equal method (e.g., [time.Time.Equal]) may use that method | ||||
| //     to determine equality. This allows package authors to determine | ||||
| //     the equality operation for the types that they define. | ||||
| // | ||||
| //   - If no custom equality functions are used and no Equal method is defined, | ||||
| //     equality is determined by recursively comparing the primitive kinds on | ||||
| //     both values, much like reflect.DeepEqual. Unlike reflect.DeepEqual, | ||||
| //     both values, much like [reflect.DeepEqual]. Unlike [reflect.DeepEqual], | ||||
| //     unexported fields are not compared by default; they result in panics | ||||
| //     unless suppressed by using an Ignore option (see cmpopts.IgnoreUnexported) | ||||
| //     or explicitly compared using the Exporter option. | ||||
| //     unless suppressed by using an [Ignore] option | ||||
| //     (see [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported]) | ||||
| //     or explicitly compared using the [Exporter] option. | ||||
| package cmp | ||||
|  | ||||
| import ( | ||||
| @@ -45,14 +46,14 @@ import ( | ||||
| // Equal reports whether x and y are equal by recursively applying the | ||||
| // following rules in the given order to x and y and all of their sub-values: | ||||
| // | ||||
| //   - Let S be the set of all Ignore, Transformer, and Comparer options that | ||||
| //   - Let S be the set of all [Ignore], [Transformer], and [Comparer] options that | ||||
| //     remain after applying all path filters, value filters, and type filters. | ||||
| //     If at least one Ignore exists in S, then the comparison is ignored. | ||||
| //     If the number of Transformer and Comparer options in S is non-zero, | ||||
| //     If at least one [Ignore] exists in S, then the comparison is ignored. | ||||
| //     If the number of [Transformer] and [Comparer] options in S is non-zero, | ||||
| //     then Equal panics because it is ambiguous which option to use. | ||||
| //     If S contains a single Transformer, then use that to transform | ||||
| //     If S contains a single [Transformer], then use that to transform | ||||
| //     the current values and recursively call Equal on the output values. | ||||
| //     If S contains a single Comparer, then use that to compare the current values. | ||||
| //     If S contains a single [Comparer], then use that to compare the current values. | ||||
| //     Otherwise, evaluation proceeds to the next rule. | ||||
| // | ||||
| //   - If the values have an Equal method of the form "(T) Equal(T) bool" or | ||||
| @@ -66,21 +67,22 @@ import ( | ||||
| //     Functions are only equal if they are both nil, otherwise they are unequal. | ||||
| // | ||||
| // Structs are equal if recursively calling Equal on all fields report equal. | ||||
| // If a struct contains unexported fields, Equal panics unless an Ignore option | ||||
| // (e.g., cmpopts.IgnoreUnexported) ignores that field or the Exporter option | ||||
| // explicitly permits comparing the unexported field. | ||||
| // If a struct contains unexported fields, Equal panics unless an [Ignore] option | ||||
| // (e.g., [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported]) ignores that field | ||||
| // or the [Exporter] option explicitly permits comparing the unexported field. | ||||
| // | ||||
| // Slices are equal if they are both nil or both non-nil, where recursively | ||||
| // calling Equal on all non-ignored slice or array elements report equal. | ||||
| // Empty non-nil slices and nil slices are not equal; to equate empty slices, | ||||
| // consider using cmpopts.EquateEmpty. | ||||
| // consider using [github.com/google/go-cmp/cmp/cmpopts.EquateEmpty]. | ||||
| // | ||||
| // Maps are equal if they are both nil or both non-nil, where recursively | ||||
| // calling Equal on all non-ignored map entries report equal. | ||||
| // Map keys are equal according to the == operator. | ||||
| // To use custom comparisons for map keys, consider using cmpopts.SortMaps. | ||||
| // To use custom comparisons for map keys, consider using | ||||
| // [github.com/google/go-cmp/cmp/cmpopts.SortMaps]. | ||||
| // Empty non-nil maps and nil maps are not equal; to equate empty maps, | ||||
| // consider using cmpopts.EquateEmpty. | ||||
| // consider using [github.com/google/go-cmp/cmp/cmpopts.EquateEmpty]. | ||||
| // | ||||
| // Pointers and interfaces are equal if they are both nil or both non-nil, | ||||
| // where they have the same underlying concrete type and recursively | ||||
|   | ||||
| @@ -2,9 +2,6 @@ | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build !purego | ||||
| // +build !purego | ||||
| 
 | ||||
| package cmp | ||||
| 
 | ||||
| import ( | ||||
| @@ -12,8 +9,6 @@ import ( | ||||
| 	"unsafe" | ||||
| ) | ||||
| 
 | ||||
| const supportExporters = true | ||||
| 
 | ||||
| // retrieveUnexportedField uses unsafe to forcibly retrieve any field from | ||||
| // a struct such that the value has read-write permissions. | ||||
| // | ||||
							
								
								
									
										16
									
								
								vendor/github.com/google/go-cmp/cmp/export_panic.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								vendor/github.com/google/go-cmp/cmp/export_panic.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,16 +0,0 @@ | ||||
| // Copyright 2017, 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 purego | ||||
| // +build purego | ||||
|  | ||||
| package cmp | ||||
|  | ||||
| import "reflect" | ||||
|  | ||||
| const supportExporters = false | ||||
|  | ||||
| func retrieveUnexportedField(reflect.Value, reflect.StructField, bool) reflect.Value { | ||||
| 	panic("no support for forcibly accessing unexported fields") | ||||
| } | ||||
| @@ -2,9 +2,6 @@ | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build !purego | ||||
| // +build !purego | ||||
| 
 | ||||
| package value | ||||
| 
 | ||||
| import ( | ||||
							
								
								
									
										34
									
								
								vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,34 +0,0 @@ | ||||
| // Copyright 2018, The Go Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| //go:build purego | ||||
| // +build purego | ||||
|  | ||||
| package value | ||||
|  | ||||
| import "reflect" | ||||
|  | ||||
| // Pointer is an opaque typed pointer and is guaranteed to be comparable. | ||||
| type Pointer struct { | ||||
| 	p uintptr | ||||
| 	t reflect.Type | ||||
| } | ||||
|  | ||||
| // PointerOf returns a Pointer from v, which must be a | ||||
| // reflect.Ptr, reflect.Slice, or reflect.Map. | ||||
| func PointerOf(v reflect.Value) Pointer { | ||||
| 	// NOTE: Storing a pointer as an uintptr is technically incorrect as it | ||||
| 	// assumes that the GC implementation does not use a moving collector. | ||||
| 	return Pointer{v.Pointer(), v.Type()} | ||||
| } | ||||
|  | ||||
| // IsNil reports whether the pointer is nil. | ||||
| func (p Pointer) IsNil() bool { | ||||
| 	return p.p == 0 | ||||
| } | ||||
|  | ||||
| // Uintptr returns the pointer as a uintptr. | ||||
| func (p Pointer) Uintptr() uintptr { | ||||
| 	return p.p | ||||
| } | ||||
							
								
								
									
										84
									
								
								vendor/github.com/google/go-cmp/cmp/options.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										84
									
								
								vendor/github.com/google/go-cmp/cmp/options.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -13,15 +13,15 @@ import ( | ||||
| 	"github.com/google/go-cmp/cmp/internal/function" | ||||
| ) | ||||
|  | ||||
| // Option configures for specific behavior of Equal and Diff. In particular, | ||||
| // the fundamental Option functions (Ignore, Transformer, and Comparer), | ||||
| // Option configures for specific behavior of [Equal] and [Diff]. In particular, | ||||
| // the fundamental Option functions ([Ignore], [Transformer], and [Comparer]), | ||||
| // configure how equality is determined. | ||||
| // | ||||
| // The fundamental options may be composed with filters (FilterPath and | ||||
| // FilterValues) to control the scope over which they are applied. | ||||
| // The fundamental options may be composed with filters ([FilterPath] and | ||||
| // [FilterValues]) to control the scope over which they are applied. | ||||
| // | ||||
| // The cmp/cmpopts package provides helper functions for creating options that | ||||
| // may be used with Equal and Diff. | ||||
| // The [github.com/google/go-cmp/cmp/cmpopts] package provides helper functions | ||||
| // for creating options that may be used with [Equal] and [Diff]. | ||||
| type Option interface { | ||||
| 	// filter applies all filters and returns the option that remains. | ||||
| 	// Each option may only read s.curPath and call s.callTTBFunc. | ||||
| @@ -56,9 +56,9 @@ type core struct{} | ||||
|  | ||||
| func (core) isCore() {} | ||||
|  | ||||
| // Options is a list of Option values that also satisfies the Option interface. | ||||
| // Options is a list of [Option] values that also satisfies the [Option] interface. | ||||
| // Helper comparison packages may return an Options value when packing multiple | ||||
| // Option values into a single Option. When this package processes an Options, | ||||
| // [Option] values into a single [Option]. When this package processes an Options, | ||||
| // it will be implicitly expanded into a flat list. | ||||
| // | ||||
| // Applying a filter on an Options is equivalent to applying that same filter | ||||
| @@ -105,16 +105,16 @@ func (opts Options) String() string { | ||||
| 	return fmt.Sprintf("Options{%s}", strings.Join(ss, ", ")) | ||||
| } | ||||
|  | ||||
| // FilterPath returns a new Option where opt is only evaluated if filter f | ||||
| // returns true for the current Path in the value tree. | ||||
| // FilterPath returns a new [Option] where opt is only evaluated if filter f | ||||
| // returns true for the current [Path] in the value tree. | ||||
| // | ||||
| // This filter is called even if a slice element or map entry is missing and | ||||
| // provides an opportunity to ignore such cases. The filter function must be | ||||
| // symmetric such that the filter result is identical regardless of whether the | ||||
| // missing value is from x or y. | ||||
| // | ||||
| // The option passed in may be an Ignore, Transformer, Comparer, Options, or | ||||
| // a previously filtered Option. | ||||
| // The option passed in may be an [Ignore], [Transformer], [Comparer], [Options], or | ||||
| // a previously filtered [Option]. | ||||
| func FilterPath(f func(Path) bool, opt Option) Option { | ||||
| 	if f == nil { | ||||
| 		panic("invalid path filter function") | ||||
| @@ -142,7 +142,7 @@ func (f pathFilter) String() string { | ||||
| 	return fmt.Sprintf("FilterPath(%s, %v)", function.NameOf(reflect.ValueOf(f.fnc)), f.opt) | ||||
| } | ||||
|  | ||||
| // FilterValues returns a new Option where opt is only evaluated if filter f, | ||||
| // FilterValues returns a new [Option] where opt is only evaluated if filter f, | ||||
| // which is a function of the form "func(T, T) bool", returns true for the | ||||
| // current pair of values being compared. If either value is invalid or | ||||
| // the type of the values is not assignable to T, then this filter implicitly | ||||
| @@ -154,8 +154,8 @@ func (f pathFilter) String() string { | ||||
| // If T is an interface, it is possible that f is called with two values with | ||||
| // different concrete types that both implement T. | ||||
| // | ||||
| // The option passed in may be an Ignore, Transformer, Comparer, Options, or | ||||
| // a previously filtered Option. | ||||
| // The option passed in may be an [Ignore], [Transformer], [Comparer], [Options], or | ||||
| // a previously filtered [Option]. | ||||
| func FilterValues(f interface{}, opt Option) Option { | ||||
| 	v := reflect.ValueOf(f) | ||||
| 	if !function.IsType(v.Type(), function.ValueFilter) || v.IsNil() { | ||||
| @@ -192,9 +192,9 @@ func (f valuesFilter) String() string { | ||||
| 	return fmt.Sprintf("FilterValues(%s, %v)", function.NameOf(f.fnc), f.opt) | ||||
| } | ||||
|  | ||||
| // Ignore is an Option that causes all comparisons to be ignored. | ||||
| // This value is intended to be combined with FilterPath or FilterValues. | ||||
| // It is an error to pass an unfiltered Ignore option to Equal. | ||||
| // Ignore is an [Option] that causes all comparisons to be ignored. | ||||
| // This value is intended to be combined with [FilterPath] or [FilterValues]. | ||||
| // It is an error to pass an unfiltered Ignore option to [Equal]. | ||||
| func Ignore() Option { return ignore{} } | ||||
|  | ||||
| type ignore struct{ core } | ||||
| @@ -234,6 +234,8 @@ func (validator) apply(s *state, vx, vy reflect.Value) { | ||||
| 			name = fmt.Sprintf("%q.%v", t.PkgPath(), t.Name()) // e.g., "path/to/package".MyType | ||||
| 			if _, ok := reflect.New(t).Interface().(error); ok { | ||||
| 				help = "consider using cmpopts.EquateErrors to compare error values" | ||||
| 			} else if t.Comparable() { | ||||
| 				help = "consider using cmpopts.EquateComparable to compare comparable Go types" | ||||
| 			} | ||||
| 		} else { | ||||
| 			// Unnamed type with unexported fields. Derive PkgPath from field. | ||||
| @@ -254,7 +256,7 @@ const identRx = `[_\p{L}][_\p{L}\p{N}]*` | ||||
|  | ||||
| var identsRx = regexp.MustCompile(`^` + identRx + `(\.` + identRx + `)*$`) | ||||
|  | ||||
| // Transformer returns an Option that applies a transformation function that | ||||
| // Transformer returns an [Option] that applies a transformation function that | ||||
| // converts values of a certain type into that of another. | ||||
| // | ||||
| // The transformer f must be a function "func(T) R" that converts values of | ||||
| @@ -265,13 +267,14 @@ var identsRx = regexp.MustCompile(`^` + identRx + `(\.` + identRx + `)*$`) | ||||
| // same transform to the output of itself (e.g., in the case where the | ||||
| // input and output types are the same), an implicit filter is added such that | ||||
| // a transformer is applicable only if that exact transformer is not already | ||||
| // in the tail of the Path since the last non-Transform step. | ||||
| // in the tail of the [Path] since the last non-[Transform] step. | ||||
| // For situations where the implicit filter is still insufficient, | ||||
| // consider using cmpopts.AcyclicTransformer, which adds a filter | ||||
| // to prevent the transformer from being recursively applied upon itself. | ||||
| // consider using [github.com/google/go-cmp/cmp/cmpopts.AcyclicTransformer], | ||||
| // which adds a filter to prevent the transformer from | ||||
| // being recursively applied upon itself. | ||||
| // | ||||
| // The name is a user provided label that is used as the Transform.Name in the | ||||
| // transformation PathStep (and eventually shown in the Diff output). | ||||
| // The name is a user provided label that is used as the [Transform.Name] in the | ||||
| // transformation [PathStep] (and eventually shown in the [Diff] output). | ||||
| // The name must be a valid identifier or qualified identifier in Go syntax. | ||||
| // If empty, an arbitrary name is used. | ||||
| func Transformer(name string, f interface{}) Option { | ||||
| @@ -329,7 +332,7 @@ func (tr transformer) String() string { | ||||
| 	return fmt.Sprintf("Transformer(%s, %s)", tr.name, function.NameOf(tr.fnc)) | ||||
| } | ||||
|  | ||||
| // Comparer returns an Option that determines whether two values are equal | ||||
| // Comparer returns an [Option] that determines whether two values are equal | ||||
| // to each other. | ||||
| // | ||||
| // The comparer f must be a function "func(T, T) bool" and is implicitly | ||||
| @@ -377,35 +380,32 @@ func (cm comparer) String() string { | ||||
| 	return fmt.Sprintf("Comparer(%s)", function.NameOf(cm.fnc)) | ||||
| } | ||||
|  | ||||
| // Exporter returns an Option that specifies whether Equal is allowed to | ||||
| // Exporter returns an [Option] that specifies whether [Equal] is allowed to | ||||
| // introspect into the unexported fields of certain struct types. | ||||
| // | ||||
| // Users of this option must understand that comparing on unexported fields | ||||
| // from external packages is not safe since changes in the internal | ||||
| // implementation of some external package may cause the result of Equal | ||||
| // implementation of some external package may cause the result of [Equal] | ||||
| // to unexpectedly change. However, it may be valid to use this option on types | ||||
| // defined in an internal package where the semantic meaning of an unexported | ||||
| // field is in the control of the user. | ||||
| // | ||||
| // In many cases, a custom Comparer should be used instead that defines | ||||
| // In many cases, a custom [Comparer] should be used instead that defines | ||||
| // equality as a function of the public API of a type rather than the underlying | ||||
| // unexported implementation. | ||||
| // | ||||
| // For example, the reflect.Type documentation defines equality to be determined | ||||
| // For example, the [reflect.Type] documentation defines equality to be determined | ||||
| // by the == operator on the interface (essentially performing a shallow pointer | ||||
| // comparison) and most attempts to compare *regexp.Regexp types are interested | ||||
| // comparison) and most attempts to compare *[regexp.Regexp] types are interested | ||||
| // in only checking that the regular expression strings are equal. | ||||
| // Both of these are accomplished using Comparers: | ||||
| // Both of these are accomplished using [Comparer] options: | ||||
| // | ||||
| //	Comparer(func(x, y reflect.Type) bool { return x == y }) | ||||
| //	Comparer(func(x, y *regexp.Regexp) bool { return x.String() == y.String() }) | ||||
| // | ||||
| // In other cases, the cmpopts.IgnoreUnexported option can be used to ignore | ||||
| // all unexported fields on specified struct types. | ||||
| // In other cases, the [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported] | ||||
| // option can be used to ignore all unexported fields on specified struct types. | ||||
| func Exporter(f func(reflect.Type) bool) Option { | ||||
| 	if !supportExporters { | ||||
| 		panic("Exporter is not supported on purego builds") | ||||
| 	} | ||||
| 	return exporter(f) | ||||
| } | ||||
|  | ||||
| @@ -415,10 +415,10 @@ func (exporter) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableO | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| // AllowUnexported returns an Options that allows Equal to forcibly introspect | ||||
| // AllowUnexported returns an [Option] that allows [Equal] to forcibly introspect | ||||
| // unexported fields of the specified struct types. | ||||
| // | ||||
| // See Exporter for the proper use of this option. | ||||
| // See [Exporter] for the proper use of this option. | ||||
| func AllowUnexported(types ...interface{}) Option { | ||||
| 	m := make(map[reflect.Type]bool) | ||||
| 	for _, typ := range types { | ||||
| @@ -432,7 +432,7 @@ func AllowUnexported(types ...interface{}) Option { | ||||
| } | ||||
|  | ||||
| // Result represents the comparison result for a single node and | ||||
| // is provided by cmp when calling Report (see Reporter). | ||||
| // is provided by cmp when calling Report (see [Reporter]). | ||||
| type Result struct { | ||||
| 	_     [0]func() // Make Result incomparable | ||||
| 	flags resultFlags | ||||
| @@ -445,7 +445,7 @@ func (r Result) Equal() bool { | ||||
| } | ||||
|  | ||||
| // ByIgnore reports whether the node is equal because it was ignored. | ||||
| // This never reports true if Equal reports false. | ||||
| // This never reports true if [Result.Equal] reports false. | ||||
| func (r Result) ByIgnore() bool { | ||||
| 	return r.flags&reportByIgnore != 0 | ||||
| } | ||||
| @@ -455,7 +455,7 @@ func (r Result) ByMethod() bool { | ||||
| 	return r.flags&reportByMethod != 0 | ||||
| } | ||||
|  | ||||
| // ByFunc reports whether a Comparer function determined equality. | ||||
| // ByFunc reports whether a [Comparer] function determined equality. | ||||
| func (r Result) ByFunc() bool { | ||||
| 	return r.flags&reportByFunc != 0 | ||||
| } | ||||
| @@ -478,7 +478,7 @@ const ( | ||||
| 	reportByCycle | ||||
| ) | ||||
|  | ||||
| // Reporter is an Option that can be passed to Equal. When Equal traverses | ||||
| // Reporter is an [Option] that can be passed to [Equal]. When [Equal] traverses | ||||
| // the value trees, it calls PushStep as it descends into each node in the | ||||
| // tree and PopStep as it ascend out of the node. The leaves of the tree are | ||||
| // either compared (determined to be equal or not equal) or ignored and reported | ||||
|   | ||||
							
								
								
									
										46
									
								
								vendor/github.com/google/go-cmp/cmp/path.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								vendor/github.com/google/go-cmp/cmp/path.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -14,9 +14,9 @@ import ( | ||||
| 	"github.com/google/go-cmp/cmp/internal/value" | ||||
| ) | ||||
|  | ||||
| // Path is a list of PathSteps describing the sequence of operations to get | ||||
| // Path is a list of [PathStep] describing the sequence of operations to get | ||||
| // from some root type to the current position in the value tree. | ||||
| // The first Path element is always an operation-less PathStep that exists | ||||
| // The first Path element is always an operation-less [PathStep] that exists | ||||
| // simply to identify the initial type. | ||||
| // | ||||
| // When traversing structs with embedded structs, the embedded struct will | ||||
| @@ -29,8 +29,13 @@ type Path []PathStep | ||||
| // a value's tree structure. Users of this package never need to implement | ||||
| // these types as values of this type will be returned by this package. | ||||
| // | ||||
| // Implementations of this interface are | ||||
| // StructField, SliceIndex, MapIndex, Indirect, TypeAssertion, and Transform. | ||||
| // Implementations of this interface: | ||||
| //   - [StructField] | ||||
| //   - [SliceIndex] | ||||
| //   - [MapIndex] | ||||
| //   - [Indirect] | ||||
| //   - [TypeAssertion] | ||||
| //   - [Transform] | ||||
| type PathStep interface { | ||||
| 	String() string | ||||
|  | ||||
| @@ -70,8 +75,9 @@ func (pa *Path) pop() { | ||||
| 	*pa = (*pa)[:len(*pa)-1] | ||||
| } | ||||
|  | ||||
| // Last returns the last PathStep in the Path. | ||||
| // If the path is empty, this returns a non-nil PathStep that reports a nil Type. | ||||
| // Last returns the last [PathStep] in the Path. | ||||
| // If the path is empty, this returns a non-nil [PathStep] | ||||
| // that reports a nil [PathStep.Type]. | ||||
| func (pa Path) Last() PathStep { | ||||
| 	return pa.Index(-1) | ||||
| } | ||||
| @@ -79,7 +85,8 @@ func (pa Path) Last() PathStep { | ||||
| // Index returns the ith step in the Path and supports negative indexing. | ||||
| // A negative index starts counting from the tail of the Path such that -1 | ||||
| // refers to the last step, -2 refers to the second-to-last step, and so on. | ||||
| // If index is invalid, this returns a non-nil PathStep that reports a nil Type. | ||||
| // If index is invalid, this returns a non-nil [PathStep] | ||||
| // that reports a nil [PathStep.Type]. | ||||
| func (pa Path) Index(i int) PathStep { | ||||
| 	if i < 0 { | ||||
| 		i = len(pa) + i | ||||
| @@ -168,7 +175,8 @@ func (ps pathStep) String() string { | ||||
| 	return fmt.Sprintf("{%s}", s) | ||||
| } | ||||
|  | ||||
| // StructField represents a struct field access on a field called Name. | ||||
| // StructField is a [PathStep] that represents a struct field access | ||||
| // on a field called [StructField.Name]. | ||||
| type StructField struct{ *structField } | ||||
| type structField struct { | ||||
| 	pathStep | ||||
| @@ -204,10 +212,11 @@ func (sf StructField) String() string { return fmt.Sprintf(".%s", sf.name) } | ||||
| func (sf StructField) Name() string { return sf.name } | ||||
|  | ||||
| // Index is the index of the field in the parent struct type. | ||||
| // See reflect.Type.Field. | ||||
| // See [reflect.Type.Field]. | ||||
| func (sf StructField) Index() int { return sf.idx } | ||||
|  | ||||
| // SliceIndex is an index operation on a slice or array at some index Key. | ||||
| // SliceIndex is a [PathStep] that represents an index operation on | ||||
| // a slice or array at some index [SliceIndex.Key]. | ||||
| type SliceIndex struct{ *sliceIndex } | ||||
| type sliceIndex struct { | ||||
| 	pathStep | ||||
| @@ -247,12 +256,12 @@ func (si SliceIndex) Key() int { | ||||
| // all of the indexes to be shifted. If an index is -1, then that | ||||
| // indicates that the element does not exist in the associated slice. | ||||
| // | ||||
| // Key is guaranteed to return -1 if and only if the indexes returned | ||||
| // by SplitKeys are not the same. SplitKeys will never return -1 for | ||||
| // [SliceIndex.Key] is guaranteed to return -1 if and only if the indexes | ||||
| // returned by SplitKeys are not the same. SplitKeys will never return -1 for | ||||
| // both indexes. | ||||
| func (si SliceIndex) SplitKeys() (ix, iy int) { return si.xkey, si.ykey } | ||||
|  | ||||
| // MapIndex is an index operation on a map at some index Key. | ||||
| // MapIndex is a [PathStep] that represents an index operation on a map at some index Key. | ||||
| type MapIndex struct{ *mapIndex } | ||||
| type mapIndex struct { | ||||
| 	pathStep | ||||
| @@ -266,7 +275,7 @@ func (mi MapIndex) String() string                 { return fmt.Sprintf("[%#v]", | ||||
| // Key is the value of the map key. | ||||
| func (mi MapIndex) Key() reflect.Value { return mi.key } | ||||
|  | ||||
| // Indirect represents pointer indirection on the parent type. | ||||
| // Indirect is a [PathStep] that represents pointer indirection on the parent type. | ||||
| type Indirect struct{ *indirect } | ||||
| type indirect struct { | ||||
| 	pathStep | ||||
| @@ -276,7 +285,7 @@ func (in Indirect) Type() reflect.Type             { return in.typ } | ||||
| func (in Indirect) Values() (vx, vy reflect.Value) { return in.vx, in.vy } | ||||
| func (in Indirect) String() string                 { return "*" } | ||||
|  | ||||
| // TypeAssertion represents a type assertion on an interface. | ||||
| // TypeAssertion is a [PathStep] that represents a type assertion on an interface. | ||||
| type TypeAssertion struct{ *typeAssertion } | ||||
| type typeAssertion struct { | ||||
| 	pathStep | ||||
| @@ -286,7 +295,8 @@ func (ta TypeAssertion) Type() reflect.Type             { return ta.typ } | ||||
| func (ta TypeAssertion) Values() (vx, vy reflect.Value) { return ta.vx, ta.vy } | ||||
| func (ta TypeAssertion) String() string                 { return fmt.Sprintf(".(%v)", value.TypeString(ta.typ, false)) } | ||||
|  | ||||
| // Transform is a transformation from the parent type to the current type. | ||||
| // Transform is a [PathStep] that represents a transformation | ||||
| // from the parent type to the current type. | ||||
| type Transform struct{ *transform } | ||||
| type transform struct { | ||||
| 	pathStep | ||||
| @@ -297,13 +307,13 @@ func (tf Transform) Type() reflect.Type             { return tf.typ } | ||||
| func (tf Transform) Values() (vx, vy reflect.Value) { return tf.vx, tf.vy } | ||||
| func (tf Transform) String() string                 { return fmt.Sprintf("%s()", tf.trans.name) } | ||||
|  | ||||
| // Name is the name of the Transformer. | ||||
| // Name is the name of the [Transformer]. | ||||
| func (tf Transform) Name() string { return tf.trans.name } | ||||
|  | ||||
| // Func is the function pointer to the transformer function. | ||||
| func (tf Transform) Func() reflect.Value { return tf.trans.fnc } | ||||
|  | ||||
| // Option returns the originally constructed Transformer option. | ||||
| // Option returns the originally constructed [Transformer] option. | ||||
| // The == operator can be used to detect the exact option used. | ||||
| func (tf Transform) Option() Option { return tf.trans } | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/google/go-cmp/cmp/report_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/google/go-cmp/cmp/report_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -199,7 +199,7 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind, | ||||
| 				break | ||||
| 			} | ||||
| 			sf := t.Field(i) | ||||
| 			if supportExporters && !isExported(sf.Name) { | ||||
| 			if !isExported(sf.Name) { | ||||
| 				vv = retrieveUnexportedField(v, sf, true) | ||||
| 			} | ||||
| 			s := opts.WithTypeMode(autoType).FormatValue(vv, t.Kind(), ptrs) | ||||
|   | ||||
							
								
								
									
										21
									
								
								vendor/github.com/sagikazarmark/locafero/.editorconfig
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/sagikazarmark/locafero/.editorconfig
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| root = true | ||||
|  | ||||
| [*] | ||||
| charset = utf-8 | ||||
| end_of_line = lf | ||||
| indent_size = 4 | ||||
| indent_style = space | ||||
| insert_final_newline = true | ||||
| trim_trailing_whitespace = true | ||||
|  | ||||
| [{Makefile,*.mk}] | ||||
| indent_style = tab | ||||
|  | ||||
| [*.nix] | ||||
| indent_size = 2 | ||||
|  | ||||
| [*.go] | ||||
| indent_style = tab | ||||
|  | ||||
| [{*.yml,*.yaml}] | ||||
| indent_size = 2 | ||||
							
								
								
									
										4
									
								
								vendor/github.com/sagikazarmark/locafero/.envrc
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/sagikazarmark/locafero/.envrc
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then | ||||
|   source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" | ||||
| fi | ||||
| use flake . --impure | ||||
							
								
								
									
										8
									
								
								vendor/github.com/sagikazarmark/locafero/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/sagikazarmark/locafero/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| /.devenv/ | ||||
| /.direnv/ | ||||
| /.task/ | ||||
| /bin/ | ||||
| /build/ | ||||
| /tmp/ | ||||
| /var/ | ||||
| /vendor/ | ||||
							
								
								
									
										27
									
								
								vendor/github.com/sagikazarmark/locafero/.golangci.yaml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								vendor/github.com/sagikazarmark/locafero/.golangci.yaml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| run: | ||||
|   timeout: 10m | ||||
|  | ||||
| linters-settings: | ||||
|   gci: | ||||
|     sections: | ||||
|       - standard | ||||
|       - default | ||||
|       - prefix(github.com/sagikazarmark/locafero) | ||||
|   goimports: | ||||
|     local-prefixes: github.com/sagikazarmark/locafero | ||||
|   misspell: | ||||
|     locale: US | ||||
|   nolintlint: | ||||
|     allow-leading-space: false # require machine-readable nolint directives (with no leading space) | ||||
|     allow-unused: false # report any unused nolint directives | ||||
|     require-specific: false # don't require nolint directives to be specific about which linter is being skipped | ||||
|   revive: | ||||
|     confidence: 0 | ||||
|  | ||||
| linters: | ||||
|   enable: | ||||
|     - gci | ||||
|     - goimports | ||||
|     - misspell | ||||
|     - nolintlint | ||||
|     - revive | ||||
							
								
								
									
										19
									
								
								vendor/github.com/sagikazarmark/locafero/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/sagikazarmark/locafero/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| Copyright (c) 2023 Márk Sági-Kazár <mark.sagikazar@gmail.com> | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is furnished | ||||
| to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
| THE SOFTWARE. | ||||
							
								
								
									
										37
									
								
								vendor/github.com/sagikazarmark/locafero/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								vendor/github.com/sagikazarmark/locafero/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| # Finder library for [Afero](https://github.com/spf13/afero) | ||||
|  | ||||
| [](https://github.com/sagikazarmark/locafero/actions/workflows/ci.yaml) | ||||
| [](https://pkg.go.dev/mod/github.com/sagikazarmark/locafero) | ||||
|  | ||||
| [](https://builtwithnix.org) | ||||
|  | ||||
| **Finder library for [Afero](https://github.com/spf13/afero) ported from [go-finder](https://github.com/sagikazarmark/go-finder).** | ||||
|  | ||||
| > [!WARNING] | ||||
| > This is an experimental library under development. | ||||
| > | ||||
| > **Backwards compatibility is not guaranteed, expect breaking changes.** | ||||
|  | ||||
| ## Installation | ||||
|  | ||||
| ```shell | ||||
| go get github.com/sagikazarmark/locafero | ||||
| ``` | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
| Check out the [package example](https://pkg.go.dev/github.com/sagikazarmark/locafero#example-package) on go.dev. | ||||
|  | ||||
| ## Development | ||||
|  | ||||
| **For an optimal developer experience, it is recommended to install [Nix](https://nixos.org/download.html) and [direnv](https://direnv.net/docs/installation.html).** | ||||
|  | ||||
| Run the test suite: | ||||
|  | ||||
| ```shell | ||||
| just test | ||||
| ``` | ||||
|  | ||||
| ## License | ||||
|  | ||||
| The project is licensed under the [MIT License](LICENSE). | ||||
							
								
								
									
										28
									
								
								vendor/github.com/sagikazarmark/locafero/file_type.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/sagikazarmark/locafero/file_type.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| package locafero | ||||
|  | ||||
| import "io/fs" | ||||
|  | ||||
| // FileType represents the kind of entries [Finder] can return. | ||||
| type FileType int | ||||
|  | ||||
| const ( | ||||
| 	FileTypeAll FileType = iota | ||||
| 	FileTypeFile | ||||
| 	FileTypeDir | ||||
| ) | ||||
|  | ||||
| func (ft FileType) matchFileInfo(info fs.FileInfo) bool { | ||||
| 	switch ft { | ||||
| 	case FileTypeAll: | ||||
| 		return true | ||||
|  | ||||
| 	case FileTypeFile: | ||||
| 		return !info.IsDir() | ||||
|  | ||||
| 	case FileTypeDir: | ||||
| 		return info.IsDir() | ||||
|  | ||||
| 	default: | ||||
| 		return false | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										165
									
								
								vendor/github.com/sagikazarmark/locafero/finder.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								vendor/github.com/sagikazarmark/locafero/finder.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,165 @@ | ||||
| // Package finder looks for files and directories in an {fs.Fs} filesystem. | ||||
| package locafero | ||||
|  | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"io/fs" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/sourcegraph/conc/iter" | ||||
| 	"github.com/spf13/afero" | ||||
| ) | ||||
|  | ||||
| // Finder looks for files and directories in an [afero.Fs] filesystem. | ||||
| type Finder struct { | ||||
| 	// Paths represents a list of locations that the [Finder] will search in. | ||||
| 	// | ||||
| 	// They are essentially the root directories or starting points for the search. | ||||
| 	// | ||||
| 	// Examples: | ||||
| 	//   - home/user | ||||
| 	//   - etc | ||||
| 	Paths []string | ||||
|  | ||||
| 	// Names are specific entries that the [Finder] will look for within the given Paths. | ||||
| 	// | ||||
| 	// It provides the capability to search for entries with depth, | ||||
| 	// meaning it can target deeper locations within the directory structure. | ||||
| 	// | ||||
| 	// It also supports glob syntax (as defined by [filepat.Match]), offering greater flexibility in search patterns. | ||||
| 	// | ||||
| 	// Examples: | ||||
| 	//   - config.yaml | ||||
| 	//   - home/*/config.yaml | ||||
| 	//   - home/*/config.* | ||||
| 	Names []string | ||||
|  | ||||
| 	// Type restricts the kind of entries returned by the [Finder]. | ||||
| 	// | ||||
| 	// This parameter helps in differentiating and filtering out files from directories or vice versa. | ||||
| 	Type FileType | ||||
| } | ||||
|  | ||||
| // Find looks for files and directories in an [afero.Fs] filesystem. | ||||
| func (f Finder) Find(fsys afero.Fs) ([]string, error) { | ||||
| 	// Arbitrary go routine limit (TODO: make this a parameter) | ||||
| 	// pool := pool.NewWithResults[[]string]().WithMaxGoroutines(5).WithErrors().WithFirstError() | ||||
|  | ||||
| 	type searchItem struct { | ||||
| 		path string | ||||
| 		name string | ||||
| 	} | ||||
|  | ||||
| 	var searchItems []searchItem | ||||
|  | ||||
| 	for _, searchPath := range f.Paths { | ||||
| 		searchPath := searchPath | ||||
|  | ||||
| 		for _, searchName := range f.Names { | ||||
| 			searchName := searchName | ||||
|  | ||||
| 			searchItems = append(searchItems, searchItem{searchPath, searchName}) | ||||
|  | ||||
| 			// pool.Go(func() ([]string, error) { | ||||
| 			// 	// If the name contains any glob character, perform a glob match | ||||
| 			// 	if strings.ContainsAny(searchName, "*?[]\\^") { | ||||
| 			// 		return globWalkSearch(fsys, searchPath, searchName, f.Type) | ||||
| 			// 	} | ||||
| 			// | ||||
| 			// 	return statSearch(fsys, searchPath, searchName, f.Type) | ||||
| 			// }) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// allResults, err := pool.Wait() | ||||
| 	// if err != nil { | ||||
| 	// 	return nil, err | ||||
| 	// } | ||||
|  | ||||
| 	allResults, err := iter.MapErr(searchItems, func(item *searchItem) ([]string, error) { | ||||
| 		// If the name contains any glob character, perform a glob match | ||||
| 		if strings.ContainsAny(item.name, "*?[]\\^") { | ||||
| 			return globWalkSearch(fsys, item.path, item.name, f.Type) | ||||
| 		} | ||||
|  | ||||
| 		return statSearch(fsys, item.path, item.name, f.Type) | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	var results []string | ||||
|  | ||||
| 	for _, r := range allResults { | ||||
| 		results = append(results, r...) | ||||
| 	} | ||||
|  | ||||
| 	// Sort results in alphabetical order for now | ||||
| 	// sort.Strings(results) | ||||
|  | ||||
| 	return results, nil | ||||
| } | ||||
|  | ||||
| func globWalkSearch(fsys afero.Fs, searchPath string, searchName string, searchType FileType) ([]string, error) { | ||||
| 	var results []string | ||||
|  | ||||
| 	err := afero.Walk(fsys, searchPath, func(p string, fileInfo fs.FileInfo, err error) error { | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
|  | ||||
| 		// Skip the root path | ||||
| 		if p == searchPath { | ||||
| 			return nil | ||||
| 		} | ||||
|  | ||||
| 		var result error | ||||
|  | ||||
| 		// Stop reading subdirectories | ||||
| 		// TODO: add depth detection here | ||||
| 		if fileInfo.IsDir() && filepath.Dir(p) == searchPath { | ||||
| 			result = fs.SkipDir | ||||
| 		} | ||||
|  | ||||
| 		// Skip unmatching type | ||||
| 		if !searchType.matchFileInfo(fileInfo) { | ||||
| 			return result | ||||
| 		} | ||||
|  | ||||
| 		match, err := filepath.Match(searchName, fileInfo.Name()) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
|  | ||||
| 		if match { | ||||
| 			results = append(results, p) | ||||
| 		} | ||||
|  | ||||
| 		return result | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		return results, err | ||||
| 	} | ||||
|  | ||||
| 	return results, nil | ||||
| } | ||||
|  | ||||
| func statSearch(fsys afero.Fs, searchPath string, searchName string, searchType FileType) ([]string, error) { | ||||
| 	filePath := filepath.Join(searchPath, searchName) | ||||
|  | ||||
| 	fileInfo, err := fsys.Stat(filePath) | ||||
| 	if errors.Is(err, fs.ErrNotExist) { | ||||
| 		return nil, nil | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	// Skip unmatching type | ||||
| 	if !searchType.matchFileInfo(fileInfo) { | ||||
| 		return nil, nil | ||||
| 	} | ||||
|  | ||||
| 	return []string{filePath}, nil | ||||
| } | ||||
							
								
								
									
										273
									
								
								vendor/github.com/sagikazarmark/locafero/flake.lock
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										273
									
								
								vendor/github.com/sagikazarmark/locafero/flake.lock
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,273 @@ | ||||
| { | ||||
|   "nodes": { | ||||
|     "devenv": { | ||||
|       "inputs": { | ||||
|         "flake-compat": "flake-compat", | ||||
|         "nix": "nix", | ||||
|         "nixpkgs": "nixpkgs", | ||||
|         "pre-commit-hooks": "pre-commit-hooks" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1694097209, | ||||
|         "narHash": "sha256-gQmBjjxeSyySjbh0yQVBKApo2KWIFqqbRUvG+Fa+QpM=", | ||||
|         "owner": "cachix", | ||||
|         "repo": "devenv", | ||||
|         "rev": "7a8e6a91510efe89d8dcb8e43233f93e86f6b189", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "cachix", | ||||
|         "repo": "devenv", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-compat": { | ||||
|       "flake": false, | ||||
|       "locked": { | ||||
|         "lastModified": 1673956053, | ||||
|         "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", | ||||
|         "owner": "edolstra", | ||||
|         "repo": "flake-compat", | ||||
|         "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "edolstra", | ||||
|         "repo": "flake-compat", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-parts": { | ||||
|       "inputs": { | ||||
|         "nixpkgs-lib": "nixpkgs-lib" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1693611461, | ||||
|         "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "flake-parts", | ||||
|         "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "flake-parts", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-utils": { | ||||
|       "inputs": { | ||||
|         "systems": "systems" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1685518550, | ||||
|         "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", | ||||
|         "owner": "numtide", | ||||
|         "repo": "flake-utils", | ||||
|         "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "numtide", | ||||
|         "repo": "flake-utils", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "gitignore": { | ||||
|       "inputs": { | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "pre-commit-hooks", | ||||
|           "nixpkgs" | ||||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1660459072, | ||||
|         "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "gitignore.nix", | ||||
|         "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "gitignore.nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "lowdown-src": { | ||||
|       "flake": false, | ||||
|       "locked": { | ||||
|         "lastModified": 1633514407, | ||||
|         "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", | ||||
|         "owner": "kristapsdz", | ||||
|         "repo": "lowdown", | ||||
|         "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "kristapsdz", | ||||
|         "repo": "lowdown", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nix": { | ||||
|       "inputs": { | ||||
|         "lowdown-src": "lowdown-src", | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "nixpkgs" | ||||
|         ], | ||||
|         "nixpkgs-regression": "nixpkgs-regression" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1676545802, | ||||
|         "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=", | ||||
|         "owner": "domenkozar", | ||||
|         "repo": "nix", | ||||
|         "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "domenkozar", | ||||
|         "ref": "relaxed-flakes", | ||||
|         "repo": "nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs": { | ||||
|       "locked": { | ||||
|         "lastModified": 1678875422, | ||||
|         "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixpkgs-unstable", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-lib": { | ||||
|       "locked": { | ||||
|         "dir": "lib", | ||||
|         "lastModified": 1693471703, | ||||
|         "narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "dir": "lib", | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixos-unstable", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-regression": { | ||||
|       "locked": { | ||||
|         "lastModified": 1643052045, | ||||
|         "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-stable": { | ||||
|       "locked": { | ||||
|         "lastModified": 1685801374, | ||||
|         "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixos-23.05", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs_2": { | ||||
|       "locked": { | ||||
|         "lastModified": 1694343207, | ||||
|         "narHash": "sha256-jWi7OwFxU5Owi4k2JmiL1sa/OuBCQtpaAesuj5LXC8w=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "78058d810644f5ed276804ce7ea9e82d92bee293", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixpkgs-unstable", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "pre-commit-hooks": { | ||||
|       "inputs": { | ||||
|         "flake-compat": [ | ||||
|           "devenv", | ||||
|           "flake-compat" | ||||
|         ], | ||||
|         "flake-utils": "flake-utils", | ||||
|         "gitignore": "gitignore", | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "nixpkgs" | ||||
|         ], | ||||
|         "nixpkgs-stable": "nixpkgs-stable" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1688056373, | ||||
|         "narHash": "sha256-2+SDlNRTKsgo3LBRiMUcoEUb6sDViRNQhzJquZ4koOI=", | ||||
|         "owner": "cachix", | ||||
|         "repo": "pre-commit-hooks.nix", | ||||
|         "rev": "5843cf069272d92b60c3ed9e55b7a8989c01d4c7", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "cachix", | ||||
|         "repo": "pre-commit-hooks.nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "root": { | ||||
|       "inputs": { | ||||
|         "devenv": "devenv", | ||||
|         "flake-parts": "flake-parts", | ||||
|         "nixpkgs": "nixpkgs_2" | ||||
|       } | ||||
|     }, | ||||
|     "systems": { | ||||
|       "locked": { | ||||
|         "lastModified": 1681028828, | ||||
|         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | ||||
|         "owner": "nix-systems", | ||||
|         "repo": "default", | ||||
|         "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "nix-systems", | ||||
|         "repo": "default", | ||||
|         "type": "github" | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   "root": "root", | ||||
|   "version": 7 | ||||
| } | ||||
							
								
								
									
										47
									
								
								vendor/github.com/sagikazarmark/locafero/flake.nix
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								vendor/github.com/sagikazarmark/locafero/flake.nix
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| { | ||||
|   description = "Finder library for Afero"; | ||||
|  | ||||
|   inputs = { | ||||
|     nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||||
|     flake-parts.url = "github:hercules-ci/flake-parts"; | ||||
|     devenv.url = "github:cachix/devenv"; | ||||
|   }; | ||||
|  | ||||
|   outputs = inputs@{ flake-parts, ... }: | ||||
|     flake-parts.lib.mkFlake { inherit inputs; } { | ||||
|       imports = [ | ||||
|         inputs.devenv.flakeModule | ||||
|       ]; | ||||
|  | ||||
|       systems = [ "x86_64-linux" "aarch64-darwin" ]; | ||||
|  | ||||
|       perSystem = { config, self', inputs', pkgs, system, ... }: rec { | ||||
|         devenv.shells = { | ||||
|           default = { | ||||
|             languages = { | ||||
|               go.enable = true; | ||||
|             }; | ||||
|  | ||||
|             packages = with pkgs; [ | ||||
|               just | ||||
|  | ||||
|               golangci-lint | ||||
|             ]; | ||||
|  | ||||
|             # https://github.com/cachix/devenv/issues/528#issuecomment-1556108767 | ||||
|             containers = pkgs.lib.mkForce { }; | ||||
|           }; | ||||
|  | ||||
|           ci = devenv.shells.default; | ||||
|  | ||||
|           ci_1_20 = { | ||||
|             imports = [ devenv.shells.ci ]; | ||||
|  | ||||
|             languages = { | ||||
|               go.package = pkgs.go_1_20; | ||||
|             }; | ||||
|           }; | ||||
|         }; | ||||
|       }; | ||||
|     }; | ||||
| } | ||||
							
								
								
									
										41
									
								
								vendor/github.com/sagikazarmark/locafero/helpers.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								vendor/github.com/sagikazarmark/locafero/helpers.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| package locafero | ||||
|  | ||||
| import "fmt" | ||||
|  | ||||
| // NameWithExtensions creates a list of names from a base name and a list of extensions. | ||||
| // | ||||
| // TODO: find a better name for this function. | ||||
| func NameWithExtensions(baseName string, extensions ...string) []string { | ||||
| 	var names []string | ||||
|  | ||||
| 	if baseName == "" { | ||||
| 		return names | ||||
| 	} | ||||
|  | ||||
| 	for _, ext := range extensions { | ||||
| 		if ext == "" { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		names = append(names, fmt.Sprintf("%s.%s", baseName, ext)) | ||||
| 	} | ||||
|  | ||||
| 	return names | ||||
| } | ||||
|  | ||||
| // NameWithOptionalExtensions creates a list of names from a base name and a list of extensions, | ||||
| // plus it adds the base name (without any extensions) to the end of the list. | ||||
| // | ||||
| // TODO: find a better name for this function. | ||||
| func NameWithOptionalExtensions(baseName string, extensions ...string) []string { | ||||
| 	var names []string | ||||
|  | ||||
| 	if baseName == "" { | ||||
| 		return names | ||||
| 	} | ||||
|  | ||||
| 	names = NameWithExtensions(baseName, extensions...) | ||||
| 	names = append(names, baseName) | ||||
|  | ||||
| 	return names | ||||
| } | ||||
							
								
								
									
										11
									
								
								vendor/github.com/sagikazarmark/locafero/justfile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								vendor/github.com/sagikazarmark/locafero/justfile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| default: | ||||
|     just --list | ||||
|  | ||||
| test: | ||||
|     go test -race -v ./... | ||||
|  | ||||
| lint: | ||||
|     golangci-lint run | ||||
|  | ||||
| fmt: | ||||
|     golangci-lint run --fix | ||||
							
								
								
									
										18
									
								
								vendor/github.com/sagikazarmark/slog-shim/.editorconfig
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								vendor/github.com/sagikazarmark/slog-shim/.editorconfig
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| root = true | ||||
|  | ||||
| [*] | ||||
| charset = utf-8 | ||||
| end_of_line = lf | ||||
| indent_size = 4 | ||||
| indent_style = space | ||||
| insert_final_newline = true | ||||
| trim_trailing_whitespace = true | ||||
|  | ||||
| [*.nix] | ||||
| indent_size = 2 | ||||
|  | ||||
| [{Makefile,*.mk}] | ||||
| indent_style = tab | ||||
|  | ||||
| [Taskfile.yaml] | ||||
| indent_size = 2 | ||||
							
								
								
									
										4
									
								
								vendor/github.com/sagikazarmark/slog-shim/.envrc
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/sagikazarmark/slog-shim/.envrc
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then | ||||
|   source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" | ||||
| fi | ||||
| use flake . --impure | ||||
							
								
								
									
										4
									
								
								vendor/github.com/sagikazarmark/slog-shim/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/sagikazarmark/slog-shim/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| /.devenv/ | ||||
| /.direnv/ | ||||
| /.task/ | ||||
| /build/ | ||||
							
								
								
									
										27
									
								
								vendor/github.com/sagikazarmark/slog-shim/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								vendor/github.com/sagikazarmark/slog-shim/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| Copyright (c) 2009 The Go Authors. All rights reserved. | ||||
|  | ||||
| Redistribution and use in source and binary forms, with or without | ||||
| modification, are permitted provided that the following conditions are | ||||
| met: | ||||
|  | ||||
|    * Redistributions of source code must retain the above copyright | ||||
| notice, this list of conditions and the following disclaimer. | ||||
|    * Redistributions in binary form must reproduce the above | ||||
| copyright notice, this list of conditions and the following disclaimer | ||||
| in the documentation and/or other materials provided with the | ||||
| distribution. | ||||
|    * Neither the name of Google Inc. nor the names of its | ||||
| contributors may be used to endorse or promote products derived from | ||||
| this software without specific prior written permission. | ||||
|  | ||||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
							
								
								
									
										81
									
								
								vendor/github.com/sagikazarmark/slog-shim/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								vendor/github.com/sagikazarmark/slog-shim/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,81 @@ | ||||
| # [slog](https://pkg.go.dev/log/slog) shim | ||||
|  | ||||
| [](https://github.com/sagikazarmark/slog-shim/actions/workflows/ci.yaml) | ||||
| [](https://pkg.go.dev/mod/github.com/sagikazarmark/slog-shim) | ||||
|  | ||||
| [](https://builtwithnix.org) | ||||
|  | ||||
| Go 1.21 introduced a [new structured logging package](https://golang.org/doc/go1.21#slog), `log/slog`, to the standard library. | ||||
| Although it's been eagerly anticipated by many, widespread adoption isn't expected to occur immediately, | ||||
| especially since updating to Go 1.21 is a decision that most libraries won't make overnight. | ||||
|  | ||||
| Before this package was added to the standard library, there was an _experimental_ version available at [golang.org/x/exp/slog](https://pkg.go.dev/golang.org/x/exp/slog). | ||||
| While it's generally advised against using experimental packages in production, | ||||
| this one served as a sort of backport package for the last few years, | ||||
| incorporating new features before they were added to the standard library (like `slices`, `maps` or `errors`). | ||||
|  | ||||
| This package serves as a bridge, helping libraries integrate slog in a backward-compatible way without having to immediately update their Go version requirement to 1.21. On Go 1.21 (and above), it acts as a drop-in replacement for `log/slog`, while below 1.21 it falls back to `golang.org/x/exp/slog`. | ||||
|  | ||||
| **How does it achieve backwards compatibility?** | ||||
|  | ||||
| Although there's no consensus on whether dropping support for older Go versions is considered backward compatible, a majority seems to believe it is. | ||||
| (I don't have scientific proof for this, but it's based on conversations with various individuals across different channels.) | ||||
|  | ||||
| This package adheres to that interpretation of backward compatibility. On Go 1.21, the shim uses type aliases to offer the same API as `slog/log`. | ||||
| Once a library upgrades its version requirement to Go 1.21, it should be able to discard this shim and use `log/slog` directly. | ||||
|  | ||||
| For older Go versions, the library might become unstable after removing the shim. | ||||
| However, since those older versions are no longer supported, the promise of backward compatibility remains intact. | ||||
|  | ||||
| ## Installation | ||||
|  | ||||
| ```shell | ||||
| go get github.com/sagikazarmark/slog-shim | ||||
| ``` | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
| Import this package into your library and use it in your public API: | ||||
|  | ||||
| ```go | ||||
| package mylib | ||||
|  | ||||
| import slog "github.com/sagikazarmark/slog-shim" | ||||
|  | ||||
| func New(logger *slog.Logger) MyLib { | ||||
|     // ... | ||||
| } | ||||
| ``` | ||||
|  | ||||
| When using the library, clients can either use `log/slog` (when on Go 1.21) or `golang.org/x/exp/slog` (below Go 1.21): | ||||
|  | ||||
| ```go | ||||
| package main | ||||
|  | ||||
| import "log/slog" | ||||
|  | ||||
| // OR | ||||
|  | ||||
| import "golang.org/x/exp/slog" | ||||
|  | ||||
| mylib.New(slog.Default()) | ||||
| ``` | ||||
|  | ||||
| **Make sure consumers are aware that your API behaves differently on different Go versions.** | ||||
|  | ||||
| Once you bump your Go version requirement to Go 1.21, you can drop the shim entirely from your code: | ||||
|  | ||||
| ```diff | ||||
| package mylib | ||||
|  | ||||
| - import slog "github.com/sagikazarmark/slog-shim" | ||||
| + import "log/slog" | ||||
|  | ||||
| func New(logger *slog.Logger) MyLib { | ||||
|     // ... | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ## License | ||||
|  | ||||
| The project is licensed under a [BSD-style license](LICENSE). | ||||
							
								
								
									
										74
									
								
								vendor/github.com/sagikazarmark/slog-shim/attr.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								vendor/github.com/sagikazarmark/slog-shim/attr.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,74 @@ | ||||
| // Copyright 2022 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 go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"log/slog" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| // An Attr is a key-value pair. | ||||
| type Attr = slog.Attr | ||||
|  | ||||
| // String returns an Attr for a string value. | ||||
| func String(key, value string) Attr { | ||||
| 	return slog.String(key, value) | ||||
| } | ||||
|  | ||||
| // Int64 returns an Attr for an int64. | ||||
| func Int64(key string, value int64) Attr { | ||||
| 	return slog.Int64(key, value) | ||||
| } | ||||
|  | ||||
| // Int converts an int to an int64 and returns | ||||
| // an Attr with that value. | ||||
| func Int(key string, value int) Attr { | ||||
| 	return slog.Int(key, value) | ||||
| } | ||||
|  | ||||
| // Uint64 returns an Attr for a uint64. | ||||
| func Uint64(key string, v uint64) Attr { | ||||
| 	return slog.Uint64(key, v) | ||||
| } | ||||
|  | ||||
| // Float64 returns an Attr for a floating-point number. | ||||
| func Float64(key string, v float64) Attr { | ||||
| 	return slog.Float64(key, v) | ||||
| } | ||||
|  | ||||
| // Bool returns an Attr for a bool. | ||||
| func Bool(key string, v bool) Attr { | ||||
| 	return slog.Bool(key, v) | ||||
| } | ||||
|  | ||||
| // Time returns an Attr for a time.Time. | ||||
| // It discards the monotonic portion. | ||||
| func Time(key string, v time.Time) Attr { | ||||
| 	return slog.Time(key, v) | ||||
| } | ||||
|  | ||||
| // Duration returns an Attr for a time.Duration. | ||||
| func Duration(key string, v time.Duration) Attr { | ||||
| 	return slog.Duration(key, v) | ||||
| } | ||||
|  | ||||
| // Group returns an Attr for a Group Value. | ||||
| // The first argument is the key; the remaining arguments | ||||
| // are converted to Attrs as in [Logger.Log]. | ||||
| // | ||||
| // Use Group to collect several key-value pairs under a single | ||||
| // key on a log line, or as the result of LogValue | ||||
| // in order to log a single value as multiple Attrs. | ||||
| func Group(key string, args ...any) Attr { | ||||
| 	return slog.Group(key, args...) | ||||
| } | ||||
|  | ||||
| // Any returns an Attr for the supplied value. | ||||
| // See [Value.AnyValue] for how values are treated. | ||||
| func Any(key string, value any) Attr { | ||||
| 	return slog.Any(key, value) | ||||
| } | ||||
							
								
								
									
										75
									
								
								vendor/github.com/sagikazarmark/slog-shim/attr_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								vendor/github.com/sagikazarmark/slog-shim/attr_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| // Copyright 2022 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 !go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/exp/slog" | ||||
| ) | ||||
|  | ||||
| // An Attr is a key-value pair. | ||||
| type Attr = slog.Attr | ||||
|  | ||||
| // String returns an Attr for a string value. | ||||
| func String(key, value string) Attr { | ||||
| 	return slog.String(key, value) | ||||
| } | ||||
|  | ||||
| // Int64 returns an Attr for an int64. | ||||
| func Int64(key string, value int64) Attr { | ||||
| 	return slog.Int64(key, value) | ||||
| } | ||||
|  | ||||
| // Int converts an int to an int64 and returns | ||||
| // an Attr with that value. | ||||
| func Int(key string, value int) Attr { | ||||
| 	return slog.Int(key, value) | ||||
| } | ||||
|  | ||||
| // Uint64 returns an Attr for a uint64. | ||||
| func Uint64(key string, v uint64) Attr { | ||||
| 	return slog.Uint64(key, v) | ||||
| } | ||||
|  | ||||
| // Float64 returns an Attr for a floating-point number. | ||||
| func Float64(key string, v float64) Attr { | ||||
| 	return slog.Float64(key, v) | ||||
| } | ||||
|  | ||||
| // Bool returns an Attr for a bool. | ||||
| func Bool(key string, v bool) Attr { | ||||
| 	return slog.Bool(key, v) | ||||
| } | ||||
|  | ||||
| // Time returns an Attr for a time.Time. | ||||
| // It discards the monotonic portion. | ||||
| func Time(key string, v time.Time) Attr { | ||||
| 	return slog.Time(key, v) | ||||
| } | ||||
|  | ||||
| // Duration returns an Attr for a time.Duration. | ||||
| func Duration(key string, v time.Duration) Attr { | ||||
| 	return slog.Duration(key, v) | ||||
| } | ||||
|  | ||||
| // Group returns an Attr for a Group Value. | ||||
| // The first argument is the key; the remaining arguments | ||||
| // are converted to Attrs as in [Logger.Log]. | ||||
| // | ||||
| // Use Group to collect several key-value pairs under a single | ||||
| // key on a log line, or as the result of LogValue | ||||
| // in order to log a single value as multiple Attrs. | ||||
| func Group(key string, args ...any) Attr { | ||||
| 	return slog.Group(key, args...) | ||||
| } | ||||
|  | ||||
| // Any returns an Attr for the supplied value. | ||||
| // See [Value.AnyValue] for how values are treated. | ||||
| func Any(key string, value any) Attr { | ||||
| 	return slog.Any(key, value) | ||||
| } | ||||
							
								
								
									
										273
									
								
								vendor/github.com/sagikazarmark/slog-shim/flake.lock
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										273
									
								
								vendor/github.com/sagikazarmark/slog-shim/flake.lock
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,273 @@ | ||||
| { | ||||
|   "nodes": { | ||||
|     "devenv": { | ||||
|       "inputs": { | ||||
|         "flake-compat": "flake-compat", | ||||
|         "nix": "nix", | ||||
|         "nixpkgs": "nixpkgs", | ||||
|         "pre-commit-hooks": "pre-commit-hooks" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1694097209, | ||||
|         "narHash": "sha256-gQmBjjxeSyySjbh0yQVBKApo2KWIFqqbRUvG+Fa+QpM=", | ||||
|         "owner": "cachix", | ||||
|         "repo": "devenv", | ||||
|         "rev": "7a8e6a91510efe89d8dcb8e43233f93e86f6b189", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "cachix", | ||||
|         "repo": "devenv", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-compat": { | ||||
|       "flake": false, | ||||
|       "locked": { | ||||
|         "lastModified": 1673956053, | ||||
|         "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", | ||||
|         "owner": "edolstra", | ||||
|         "repo": "flake-compat", | ||||
|         "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "edolstra", | ||||
|         "repo": "flake-compat", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-parts": { | ||||
|       "inputs": { | ||||
|         "nixpkgs-lib": "nixpkgs-lib" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1693611461, | ||||
|         "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "flake-parts", | ||||
|         "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "flake-parts", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-utils": { | ||||
|       "inputs": { | ||||
|         "systems": "systems" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1685518550, | ||||
|         "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", | ||||
|         "owner": "numtide", | ||||
|         "repo": "flake-utils", | ||||
|         "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "numtide", | ||||
|         "repo": "flake-utils", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "gitignore": { | ||||
|       "inputs": { | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "pre-commit-hooks", | ||||
|           "nixpkgs" | ||||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1660459072, | ||||
|         "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "gitignore.nix", | ||||
|         "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "gitignore.nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "lowdown-src": { | ||||
|       "flake": false, | ||||
|       "locked": { | ||||
|         "lastModified": 1633514407, | ||||
|         "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", | ||||
|         "owner": "kristapsdz", | ||||
|         "repo": "lowdown", | ||||
|         "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "kristapsdz", | ||||
|         "repo": "lowdown", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nix": { | ||||
|       "inputs": { | ||||
|         "lowdown-src": "lowdown-src", | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "nixpkgs" | ||||
|         ], | ||||
|         "nixpkgs-regression": "nixpkgs-regression" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1676545802, | ||||
|         "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=", | ||||
|         "owner": "domenkozar", | ||||
|         "repo": "nix", | ||||
|         "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "domenkozar", | ||||
|         "ref": "relaxed-flakes", | ||||
|         "repo": "nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs": { | ||||
|       "locked": { | ||||
|         "lastModified": 1678875422, | ||||
|         "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixpkgs-unstable", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-lib": { | ||||
|       "locked": { | ||||
|         "dir": "lib", | ||||
|         "lastModified": 1693471703, | ||||
|         "narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "dir": "lib", | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixos-unstable", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-regression": { | ||||
|       "locked": { | ||||
|         "lastModified": 1643052045, | ||||
|         "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-stable": { | ||||
|       "locked": { | ||||
|         "lastModified": 1685801374, | ||||
|         "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixos-23.05", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs_2": { | ||||
|       "locked": { | ||||
|         "lastModified": 1694345580, | ||||
|         "narHash": "sha256-BbG0NUxQTz1dN/Y87yPWZc/0Kp/coJ0vM3+7sNa5kUM=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "f002de6834fdde9c864f33c1ec51da7df19cd832", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "master", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "pre-commit-hooks": { | ||||
|       "inputs": { | ||||
|         "flake-compat": [ | ||||
|           "devenv", | ||||
|           "flake-compat" | ||||
|         ], | ||||
|         "flake-utils": "flake-utils", | ||||
|         "gitignore": "gitignore", | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "nixpkgs" | ||||
|         ], | ||||
|         "nixpkgs-stable": "nixpkgs-stable" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1688056373, | ||||
|         "narHash": "sha256-2+SDlNRTKsgo3LBRiMUcoEUb6sDViRNQhzJquZ4koOI=", | ||||
|         "owner": "cachix", | ||||
|         "repo": "pre-commit-hooks.nix", | ||||
|         "rev": "5843cf069272d92b60c3ed9e55b7a8989c01d4c7", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "cachix", | ||||
|         "repo": "pre-commit-hooks.nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "root": { | ||||
|       "inputs": { | ||||
|         "devenv": "devenv", | ||||
|         "flake-parts": "flake-parts", | ||||
|         "nixpkgs": "nixpkgs_2" | ||||
|       } | ||||
|     }, | ||||
|     "systems": { | ||||
|       "locked": { | ||||
|         "lastModified": 1681028828, | ||||
|         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | ||||
|         "owner": "nix-systems", | ||||
|         "repo": "default", | ||||
|         "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "nix-systems", | ||||
|         "repo": "default", | ||||
|         "type": "github" | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   "root": "root", | ||||
|   "version": 7 | ||||
| } | ||||
							
								
								
									
										57
									
								
								vendor/github.com/sagikazarmark/slog-shim/flake.nix
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								vendor/github.com/sagikazarmark/slog-shim/flake.nix
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| { | ||||
|   inputs = { | ||||
|     # nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||||
|     nixpkgs.url = "github:NixOS/nixpkgs/master"; | ||||
|     flake-parts.url = "github:hercules-ci/flake-parts"; | ||||
|     devenv.url = "github:cachix/devenv"; | ||||
|   }; | ||||
|  | ||||
|   outputs = inputs@{ flake-parts, ... }: | ||||
|     flake-parts.lib.mkFlake { inherit inputs; } { | ||||
|       imports = [ | ||||
|         inputs.devenv.flakeModule | ||||
|       ]; | ||||
|  | ||||
|       systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; | ||||
|  | ||||
|       perSystem = { config, self', inputs', pkgs, system, ... }: rec { | ||||
|         devenv.shells = { | ||||
|           default = { | ||||
|             languages = { | ||||
|               go.enable = true; | ||||
|               go.package = pkgs.lib.mkDefault pkgs.go_1_21; | ||||
|             }; | ||||
|  | ||||
|             # https://github.com/cachix/devenv/issues/528#issuecomment-1556108767 | ||||
|             containers = pkgs.lib.mkForce { }; | ||||
|           }; | ||||
|  | ||||
|           ci = devenv.shells.default; | ||||
|  | ||||
|           ci_1_19 = { | ||||
|             imports = [ devenv.shells.ci ]; | ||||
|  | ||||
|             languages = { | ||||
|               go.package = pkgs.go_1_19; | ||||
|             }; | ||||
|           }; | ||||
|  | ||||
|           ci_1_20 = { | ||||
|             imports = [ devenv.shells.ci ]; | ||||
|  | ||||
|             languages = { | ||||
|               go.package = pkgs.go_1_20; | ||||
|             }; | ||||
|           }; | ||||
|  | ||||
|           ci_1_21 = { | ||||
|             imports = [ devenv.shells.ci ]; | ||||
|  | ||||
|             languages = { | ||||
|               go.package = pkgs.go_1_21; | ||||
|             }; | ||||
|           }; | ||||
|         }; | ||||
|       }; | ||||
|     }; | ||||
| } | ||||
							
								
								
									
										45
									
								
								vendor/github.com/sagikazarmark/slog-shim/handler.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								vendor/github.com/sagikazarmark/slog-shim/handler.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| // Copyright 2022 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 go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"log/slog" | ||||
| ) | ||||
|  | ||||
| // A Handler handles log records produced by a Logger.. | ||||
| // | ||||
| // A typical handler may print log records to standard error, | ||||
| // or write them to a file or database, or perhaps augment them | ||||
| // with additional attributes and pass them on to another handler. | ||||
| // | ||||
| // Any of the Handler's methods may be called concurrently with itself | ||||
| // or with other methods. It is the responsibility of the Handler to | ||||
| // manage this concurrency. | ||||
| // | ||||
| // Users of the slog package should not invoke Handler methods directly. | ||||
| // They should use the methods of [Logger] instead. | ||||
| type Handler = slog.Handler | ||||
|  | ||||
| // HandlerOptions are options for a TextHandler or JSONHandler. | ||||
| // A zero HandlerOptions consists entirely of default values. | ||||
| type HandlerOptions = slog.HandlerOptions | ||||
|  | ||||
| // Keys for "built-in" attributes. | ||||
| const ( | ||||
| 	// TimeKey is the key used by the built-in handlers for the time | ||||
| 	// when the log method is called. The associated Value is a [time.Time]. | ||||
| 	TimeKey = slog.TimeKey | ||||
| 	// LevelKey is the key used by the built-in handlers for the level | ||||
| 	// of the log call. The associated value is a [Level]. | ||||
| 	LevelKey = slog.LevelKey | ||||
| 	// MessageKey is the key used by the built-in handlers for the | ||||
| 	// message of the log call. The associated value is a string. | ||||
| 	MessageKey = slog.MessageKey | ||||
| 	// SourceKey is the key used by the built-in handlers for the source file | ||||
| 	// and line of the log call. The associated value is a string. | ||||
| 	SourceKey = slog.SourceKey | ||||
| ) | ||||
							
								
								
									
										45
									
								
								vendor/github.com/sagikazarmark/slog-shim/handler_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								vendor/github.com/sagikazarmark/slog-shim/handler_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| // Copyright 2022 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 !go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/exp/slog" | ||||
| ) | ||||
|  | ||||
| // A Handler handles log records produced by a Logger.. | ||||
| // | ||||
| // A typical handler may print log records to standard error, | ||||
| // or write them to a file or database, or perhaps augment them | ||||
| // with additional attributes and pass them on to another handler. | ||||
| // | ||||
| // Any of the Handler's methods may be called concurrently with itself | ||||
| // or with other methods. It is the responsibility of the Handler to | ||||
| // manage this concurrency. | ||||
| // | ||||
| // Users of the slog package should not invoke Handler methods directly. | ||||
| // They should use the methods of [Logger] instead. | ||||
| type Handler = slog.Handler | ||||
|  | ||||
| // HandlerOptions are options for a TextHandler or JSONHandler. | ||||
| // A zero HandlerOptions consists entirely of default values. | ||||
| type HandlerOptions = slog.HandlerOptions | ||||
|  | ||||
| // Keys for "built-in" attributes. | ||||
| const ( | ||||
| 	// TimeKey is the key used by the built-in handlers for the time | ||||
| 	// when the log method is called. The associated Value is a [time.Time]. | ||||
| 	TimeKey = slog.TimeKey | ||||
| 	// LevelKey is the key used by the built-in handlers for the level | ||||
| 	// of the log call. The associated value is a [Level]. | ||||
| 	LevelKey = slog.LevelKey | ||||
| 	// MessageKey is the key used by the built-in handlers for the | ||||
| 	// message of the log call. The associated value is a string. | ||||
| 	MessageKey = slog.MessageKey | ||||
| 	// SourceKey is the key used by the built-in handlers for the source file | ||||
| 	// and line of the log call. The associated value is a string. | ||||
| 	SourceKey = slog.SourceKey | ||||
| ) | ||||
							
								
								
									
										23
									
								
								vendor/github.com/sagikazarmark/slog-shim/json_handler.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/sagikazarmark/slog-shim/json_handler.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| // Copyright 2022 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 go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
| 	"log/slog" | ||||
| ) | ||||
|  | ||||
| // JSONHandler is a Handler that writes Records to an io.Writer as | ||||
| // line-delimited JSON objects. | ||||
| type JSONHandler = slog.JSONHandler | ||||
|  | ||||
| // NewJSONHandler creates a JSONHandler that writes to w, | ||||
| // using the given options. | ||||
| // If opts is nil, the default options are used. | ||||
| func NewJSONHandler(w io.Writer, opts *HandlerOptions) *JSONHandler { | ||||
| 	return slog.NewJSONHandler(w, opts) | ||||
| } | ||||
							
								
								
									
										24
									
								
								vendor/github.com/sagikazarmark/slog-shim/json_handler_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								vendor/github.com/sagikazarmark/slog-shim/json_handler_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| // Copyright 2022 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 !go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
|  | ||||
| 	"golang.org/x/exp/slog" | ||||
| ) | ||||
|  | ||||
| // JSONHandler is a Handler that writes Records to an io.Writer as | ||||
| // line-delimited JSON objects. | ||||
| type JSONHandler = slog.JSONHandler | ||||
|  | ||||
| // NewJSONHandler creates a JSONHandler that writes to w, | ||||
| // using the given options. | ||||
| // If opts is nil, the default options are used. | ||||
| func NewJSONHandler(w io.Writer, opts *HandlerOptions) *JSONHandler { | ||||
| 	return slog.NewJSONHandler(w, opts) | ||||
| } | ||||
							
								
								
									
										61
									
								
								vendor/github.com/sagikazarmark/slog-shim/level.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								vendor/github.com/sagikazarmark/slog-shim/level.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| // Copyright 2022 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 go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"log/slog" | ||||
| ) | ||||
|  | ||||
| // A Level is the importance or severity of a log event. | ||||
| // The higher the level, the more important or severe the event. | ||||
| type Level = slog.Level | ||||
|  | ||||
| // Level numbers are inherently arbitrary, | ||||
| // but we picked them to satisfy three constraints. | ||||
| // Any system can map them to another numbering scheme if it wishes. | ||||
| // | ||||
| // First, we wanted the default level to be Info, Since Levels are ints, Info is | ||||
| // the default value for int, zero. | ||||
| // | ||||
| // Second, we wanted to make it easy to use levels to specify logger verbosity. | ||||
| // Since a larger level means a more severe event, a logger that accepts events | ||||
| // with smaller (or more negative) level means a more verbose logger. Logger | ||||
| // verbosity is thus the negation of event severity, and the default verbosity | ||||
| // of 0 accepts all events at least as severe as INFO. | ||||
| // | ||||
| // Third, we wanted some room between levels to accommodate schemes with named | ||||
| // levels between ours. For example, Google Cloud Logging defines a Notice level | ||||
| // between Info and Warn. Since there are only a few of these intermediate | ||||
| // levels, the gap between the numbers need not be large. Our gap of 4 matches | ||||
| // OpenTelemetry's mapping. Subtracting 9 from an OpenTelemetry level in the | ||||
| // DEBUG, INFO, WARN and ERROR ranges converts it to the corresponding slog | ||||
| // Level range. OpenTelemetry also has the names TRACE and FATAL, which slog | ||||
| // does not. But those OpenTelemetry levels can still be represented as slog | ||||
| // Levels by using the appropriate integers. | ||||
| // | ||||
| // Names for common levels. | ||||
| const ( | ||||
| 	LevelDebug Level = slog.LevelDebug | ||||
| 	LevelInfo  Level = slog.LevelInfo | ||||
| 	LevelWarn  Level = slog.LevelWarn | ||||
| 	LevelError Level = slog.LevelError | ||||
| ) | ||||
|  | ||||
| // A LevelVar is a Level variable, to allow a Handler level to change | ||||
| // dynamically. | ||||
| // It implements Leveler as well as a Set method, | ||||
| // and it is safe for use by multiple goroutines. | ||||
| // The zero LevelVar corresponds to LevelInfo. | ||||
| type LevelVar = slog.LevelVar | ||||
|  | ||||
| // A Leveler provides a Level value. | ||||
| // | ||||
| // As Level itself implements Leveler, clients typically supply | ||||
| // a Level value wherever a Leveler is needed, such as in HandlerOptions. | ||||
| // Clients who need to vary the level dynamically can provide a more complex | ||||
| // Leveler implementation such as *LevelVar. | ||||
| type Leveler = slog.Leveler | ||||
							
								
								
									
										61
									
								
								vendor/github.com/sagikazarmark/slog-shim/level_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								vendor/github.com/sagikazarmark/slog-shim/level_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| // Copyright 2022 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 !go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/exp/slog" | ||||
| ) | ||||
|  | ||||
| // A Level is the importance or severity of a log event. | ||||
| // The higher the level, the more important or severe the event. | ||||
| type Level = slog.Level | ||||
|  | ||||
| // Level numbers are inherently arbitrary, | ||||
| // but we picked them to satisfy three constraints. | ||||
| // Any system can map them to another numbering scheme if it wishes. | ||||
| // | ||||
| // First, we wanted the default level to be Info, Since Levels are ints, Info is | ||||
| // the default value for int, zero. | ||||
| // | ||||
| // Second, we wanted to make it easy to use levels to specify logger verbosity. | ||||
| // Since a larger level means a more severe event, a logger that accepts events | ||||
| // with smaller (or more negative) level means a more verbose logger. Logger | ||||
| // verbosity is thus the negation of event severity, and the default verbosity | ||||
| // of 0 accepts all events at least as severe as INFO. | ||||
| // | ||||
| // Third, we wanted some room between levels to accommodate schemes with named | ||||
| // levels between ours. For example, Google Cloud Logging defines a Notice level | ||||
| // between Info and Warn. Since there are only a few of these intermediate | ||||
| // levels, the gap between the numbers need not be large. Our gap of 4 matches | ||||
| // OpenTelemetry's mapping. Subtracting 9 from an OpenTelemetry level in the | ||||
| // DEBUG, INFO, WARN and ERROR ranges converts it to the corresponding slog | ||||
| // Level range. OpenTelemetry also has the names TRACE and FATAL, which slog | ||||
| // does not. But those OpenTelemetry levels can still be represented as slog | ||||
| // Levels by using the appropriate integers. | ||||
| // | ||||
| // Names for common levels. | ||||
| const ( | ||||
| 	LevelDebug Level = slog.LevelDebug | ||||
| 	LevelInfo  Level = slog.LevelInfo | ||||
| 	LevelWarn  Level = slog.LevelWarn | ||||
| 	LevelError Level = slog.LevelError | ||||
| ) | ||||
|  | ||||
| // A LevelVar is a Level variable, to allow a Handler level to change | ||||
| // dynamically. | ||||
| // It implements Leveler as well as a Set method, | ||||
| // and it is safe for use by multiple goroutines. | ||||
| // The zero LevelVar corresponds to LevelInfo. | ||||
| type LevelVar = slog.LevelVar | ||||
|  | ||||
| // A Leveler provides a Level value. | ||||
| // | ||||
| // As Level itself implements Leveler, clients typically supply | ||||
| // a Level value wherever a Leveler is needed, such as in HandlerOptions. | ||||
| // Clients who need to vary the level dynamically can provide a more complex | ||||
| // Leveler implementation such as *LevelVar. | ||||
| type Leveler = slog.Leveler | ||||
							
								
								
									
										98
									
								
								vendor/github.com/sagikazarmark/slog-shim/logger.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								vendor/github.com/sagikazarmark/slog-shim/logger.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,98 @@ | ||||
| // Copyright 2022 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 go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"log" | ||||
| 	"log/slog" | ||||
| ) | ||||
|  | ||||
| // Default returns the default Logger. | ||||
| func Default() *Logger { return slog.Default() } | ||||
|  | ||||
| // SetDefault makes l the default Logger. | ||||
| // After this call, output from the log package's default Logger | ||||
| // (as with [log.Print], etc.) will be logged at LevelInfo using l's Handler. | ||||
| func SetDefault(l *Logger) { | ||||
| 	slog.SetDefault(l) | ||||
| } | ||||
|  | ||||
| // A Logger records structured information about each call to its | ||||
| // Log, Debug, Info, Warn, and Error methods. | ||||
| // For each call, it creates a Record and passes it to a Handler. | ||||
| // | ||||
| // To create a new Logger, call [New] or a Logger method | ||||
| // that begins "With". | ||||
| type Logger = slog.Logger | ||||
|  | ||||
| // New creates a new Logger with the given non-nil Handler. | ||||
| func New(h Handler) *Logger { | ||||
| 	return slog.New(h) | ||||
| } | ||||
|  | ||||
| // With calls Logger.With on the default logger. | ||||
| func With(args ...any) *Logger { | ||||
| 	return slog.With(args...) | ||||
| } | ||||
|  | ||||
| // NewLogLogger returns a new log.Logger such that each call to its Output method | ||||
| // dispatches a Record to the specified handler. The logger acts as a bridge from | ||||
| // the older log API to newer structured logging handlers. | ||||
| func NewLogLogger(h Handler, level Level) *log.Logger { | ||||
| 	return slog.NewLogLogger(h, level) | ||||
| } | ||||
|  | ||||
| // Debug calls Logger.Debug on the default logger. | ||||
| func Debug(msg string, args ...any) { | ||||
| 	slog.Debug(msg, args...) | ||||
| } | ||||
|  | ||||
| // DebugContext calls Logger.DebugContext on the default logger. | ||||
| func DebugContext(ctx context.Context, msg string, args ...any) { | ||||
| 	slog.DebugContext(ctx, msg, args...) | ||||
| } | ||||
|  | ||||
| // Info calls Logger.Info on the default logger. | ||||
| func Info(msg string, args ...any) { | ||||
| 	slog.Info(msg, args...) | ||||
| } | ||||
|  | ||||
| // InfoContext calls Logger.InfoContext on the default logger. | ||||
| func InfoContext(ctx context.Context, msg string, args ...any) { | ||||
| 	slog.InfoContext(ctx, msg, args...) | ||||
| } | ||||
|  | ||||
| // Warn calls Logger.Warn on the default logger. | ||||
| func Warn(msg string, args ...any) { | ||||
| 	slog.Warn(msg, args...) | ||||
| } | ||||
|  | ||||
| // WarnContext calls Logger.WarnContext on the default logger. | ||||
| func WarnContext(ctx context.Context, msg string, args ...any) { | ||||
| 	slog.WarnContext(ctx, msg, args...) | ||||
| } | ||||
|  | ||||
| // Error calls Logger.Error on the default logger. | ||||
| func Error(msg string, args ...any) { | ||||
| 	slog.Error(msg, args...) | ||||
| } | ||||
|  | ||||
| // ErrorContext calls Logger.ErrorContext on the default logger. | ||||
| func ErrorContext(ctx context.Context, msg string, args ...any) { | ||||
| 	slog.ErrorContext(ctx, msg, args...) | ||||
| } | ||||
|  | ||||
| // Log calls Logger.Log on the default logger. | ||||
| func Log(ctx context.Context, level Level, msg string, args ...any) { | ||||
| 	slog.Log(ctx, level, msg, args...) | ||||
| } | ||||
|  | ||||
| // LogAttrs calls Logger.LogAttrs on the default logger. | ||||
| func LogAttrs(ctx context.Context, level Level, msg string, attrs ...Attr) { | ||||
| 	slog.LogAttrs(ctx, level, msg, attrs...) | ||||
| } | ||||
							
								
								
									
										99
									
								
								vendor/github.com/sagikazarmark/slog-shim/logger_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								vendor/github.com/sagikazarmark/slog-shim/logger_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,99 @@ | ||||
| // Copyright 2022 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 !go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"log" | ||||
|  | ||||
| 	"golang.org/x/exp/slog" | ||||
| ) | ||||
|  | ||||
| // Default returns the default Logger. | ||||
| func Default() *Logger { return slog.Default() } | ||||
|  | ||||
| // SetDefault makes l the default Logger. | ||||
| // After this call, output from the log package's default Logger | ||||
| // (as with [log.Print], etc.) will be logged at LevelInfo using l's Handler. | ||||
| func SetDefault(l *Logger) { | ||||
| 	slog.SetDefault(l) | ||||
| } | ||||
|  | ||||
| // A Logger records structured information about each call to its | ||||
| // Log, Debug, Info, Warn, and Error methods. | ||||
| // For each call, it creates a Record and passes it to a Handler. | ||||
| // | ||||
| // To create a new Logger, call [New] or a Logger method | ||||
| // that begins "With". | ||||
| type Logger = slog.Logger | ||||
|  | ||||
| // New creates a new Logger with the given non-nil Handler. | ||||
| func New(h Handler) *Logger { | ||||
| 	return slog.New(h) | ||||
| } | ||||
|  | ||||
| // With calls Logger.With on the default logger. | ||||
| func With(args ...any) *Logger { | ||||
| 	return slog.With(args...) | ||||
| } | ||||
|  | ||||
| // NewLogLogger returns a new log.Logger such that each call to its Output method | ||||
| // dispatches a Record to the specified handler. The logger acts as a bridge from | ||||
| // the older log API to newer structured logging handlers. | ||||
| func NewLogLogger(h Handler, level Level) *log.Logger { | ||||
| 	return slog.NewLogLogger(h, level) | ||||
| } | ||||
|  | ||||
| // Debug calls Logger.Debug on the default logger. | ||||
| func Debug(msg string, args ...any) { | ||||
| 	slog.Debug(msg, args...) | ||||
| } | ||||
|  | ||||
| // DebugContext calls Logger.DebugContext on the default logger. | ||||
| func DebugContext(ctx context.Context, msg string, args ...any) { | ||||
| 	slog.DebugContext(ctx, msg, args...) | ||||
| } | ||||
|  | ||||
| // Info calls Logger.Info on the default logger. | ||||
| func Info(msg string, args ...any) { | ||||
| 	slog.Info(msg, args...) | ||||
| } | ||||
|  | ||||
| // InfoContext calls Logger.InfoContext on the default logger. | ||||
| func InfoContext(ctx context.Context, msg string, args ...any) { | ||||
| 	slog.InfoContext(ctx, msg, args...) | ||||
| } | ||||
|  | ||||
| // Warn calls Logger.Warn on the default logger. | ||||
| func Warn(msg string, args ...any) { | ||||
| 	slog.Warn(msg, args...) | ||||
| } | ||||
|  | ||||
| // WarnContext calls Logger.WarnContext on the default logger. | ||||
| func WarnContext(ctx context.Context, msg string, args ...any) { | ||||
| 	slog.WarnContext(ctx, msg, args...) | ||||
| } | ||||
|  | ||||
| // Error calls Logger.Error on the default logger. | ||||
| func Error(msg string, args ...any) { | ||||
| 	slog.Error(msg, args...) | ||||
| } | ||||
|  | ||||
| // ErrorContext calls Logger.ErrorContext on the default logger. | ||||
| func ErrorContext(ctx context.Context, msg string, args ...any) { | ||||
| 	slog.ErrorContext(ctx, msg, args...) | ||||
| } | ||||
|  | ||||
| // Log calls Logger.Log on the default logger. | ||||
| func Log(ctx context.Context, level Level, msg string, args ...any) { | ||||
| 	slog.Log(ctx, level, msg, args...) | ||||
| } | ||||
|  | ||||
| // LogAttrs calls Logger.LogAttrs on the default logger. | ||||
| func LogAttrs(ctx context.Context, level Level, msg string, attrs ...Attr) { | ||||
| 	slog.LogAttrs(ctx, level, msg, attrs...) | ||||
| } | ||||
							
								
								
									
										31
									
								
								vendor/github.com/sagikazarmark/slog-shim/record.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								vendor/github.com/sagikazarmark/slog-shim/record.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| // Copyright 2022 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 go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"log/slog" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| // A Record holds information about a log event. | ||||
| // Copies of a Record share state. | ||||
| // Do not modify a Record after handing out a copy to it. | ||||
| // Call [NewRecord] to create a new Record. | ||||
| // Use [Record.Clone] to create a copy with no shared state. | ||||
| type Record = slog.Record | ||||
|  | ||||
| // NewRecord creates a Record from the given arguments. | ||||
| // Use [Record.AddAttrs] to add attributes to the Record. | ||||
| // | ||||
| // NewRecord is intended for logging APIs that want to support a [Handler] as | ||||
| // a backend. | ||||
| func NewRecord(t time.Time, level Level, msg string, pc uintptr) Record { | ||||
| 	return slog.NewRecord(t, level, msg, pc) | ||||
| } | ||||
|  | ||||
| // Source describes the location of a line of source code. | ||||
| type Source = slog.Source | ||||
							
								
								
									
										32
									
								
								vendor/github.com/sagikazarmark/slog-shim/record_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								vendor/github.com/sagikazarmark/slog-shim/record_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| // Copyright 2022 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 !go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/exp/slog" | ||||
| ) | ||||
|  | ||||
| // A Record holds information about a log event. | ||||
| // Copies of a Record share state. | ||||
| // Do not modify a Record after handing out a copy to it. | ||||
| // Call [NewRecord] to create a new Record. | ||||
| // Use [Record.Clone] to create a copy with no shared state. | ||||
| type Record = slog.Record | ||||
|  | ||||
| // NewRecord creates a Record from the given arguments. | ||||
| // Use [Record.AddAttrs] to add attributes to the Record. | ||||
| // | ||||
| // NewRecord is intended for logging APIs that want to support a [Handler] as | ||||
| // a backend. | ||||
| func NewRecord(t time.Time, level Level, msg string, pc uintptr) Record { | ||||
| 	return slog.NewRecord(t, level, msg, pc) | ||||
| } | ||||
|  | ||||
| // Source describes the location of a line of source code. | ||||
| type Source = slog.Source | ||||
							
								
								
									
										23
									
								
								vendor/github.com/sagikazarmark/slog-shim/text_handler.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/sagikazarmark/slog-shim/text_handler.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| // Copyright 2022 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 go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
| 	"log/slog" | ||||
| ) | ||||
|  | ||||
| // TextHandler is a Handler that writes Records to an io.Writer as a | ||||
| // sequence of key=value pairs separated by spaces and followed by a newline. | ||||
| type TextHandler = slog.TextHandler | ||||
|  | ||||
| // NewTextHandler creates a TextHandler that writes to w, | ||||
| // using the given options. | ||||
| // If opts is nil, the default options are used. | ||||
| func NewTextHandler(w io.Writer, opts *HandlerOptions) *TextHandler { | ||||
| 	return slog.NewTextHandler(w, opts) | ||||
| } | ||||
							
								
								
									
										24
									
								
								vendor/github.com/sagikazarmark/slog-shim/text_handler_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								vendor/github.com/sagikazarmark/slog-shim/text_handler_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| // Copyright 2022 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 !go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
|  | ||||
| 	"golang.org/x/exp/slog" | ||||
| ) | ||||
|  | ||||
| // TextHandler is a Handler that writes Records to an io.Writer as a | ||||
| // sequence of key=value pairs separated by spaces and followed by a newline. | ||||
| type TextHandler = slog.TextHandler | ||||
|  | ||||
| // NewTextHandler creates a TextHandler that writes to w, | ||||
| // using the given options. | ||||
| // If opts is nil, the default options are used. | ||||
| func NewTextHandler(w io.Writer, opts *HandlerOptions) *TextHandler { | ||||
| 	return slog.NewTextHandler(w, opts) | ||||
| } | ||||
							
								
								
									
										109
									
								
								vendor/github.com/sagikazarmark/slog-shim/value.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								vendor/github.com/sagikazarmark/slog-shim/value.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,109 @@ | ||||
| // Copyright 2022 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 go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"log/slog" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| // A Value can represent any Go value, but unlike type any, | ||||
| // it can represent most small values without an allocation. | ||||
| // The zero Value corresponds to nil. | ||||
| type Value = slog.Value | ||||
|  | ||||
| // Kind is the kind of a Value. | ||||
| type Kind = slog.Kind | ||||
|  | ||||
| // The following list is sorted alphabetically, but it's also important that | ||||
| // KindAny is 0 so that a zero Value represents nil. | ||||
| const ( | ||||
| 	KindAny       = slog.KindAny | ||||
| 	KindBool      = slog.KindBool | ||||
| 	KindDuration  = slog.KindDuration | ||||
| 	KindFloat64   = slog.KindFloat64 | ||||
| 	KindInt64     = slog.KindInt64 | ||||
| 	KindString    = slog.KindString | ||||
| 	KindTime      = slog.KindTime | ||||
| 	KindUint64    = slog.KindUint64 | ||||
| 	KindGroup     = slog.KindGroup | ||||
| 	KindLogValuer = slog.KindLogValuer | ||||
| ) | ||||
|  | ||||
| //////////////// Constructors | ||||
|  | ||||
| // StringValue returns a new Value for a string. | ||||
| func StringValue(value string) Value { | ||||
| 	return slog.StringValue(value) | ||||
| } | ||||
|  | ||||
| // IntValue returns a Value for an int. | ||||
| func IntValue(v int) Value { | ||||
| 	return slog.IntValue(v) | ||||
| } | ||||
|  | ||||
| // Int64Value returns a Value for an int64. | ||||
| func Int64Value(v int64) Value { | ||||
| 	return slog.Int64Value(v) | ||||
| } | ||||
|  | ||||
| // Uint64Value returns a Value for a uint64. | ||||
| func Uint64Value(v uint64) Value { | ||||
| 	return slog.Uint64Value(v) | ||||
| } | ||||
|  | ||||
| // Float64Value returns a Value for a floating-point number. | ||||
| func Float64Value(v float64) Value { | ||||
| 	return slog.Float64Value(v) | ||||
| } | ||||
|  | ||||
| // BoolValue returns a Value for a bool. | ||||
| func BoolValue(v bool) Value { | ||||
| 	return slog.BoolValue(v) | ||||
| } | ||||
|  | ||||
| // TimeValue returns a Value for a time.Time. | ||||
| // It discards the monotonic portion. | ||||
| func TimeValue(v time.Time) Value { | ||||
| 	return slog.TimeValue(v) | ||||
| } | ||||
|  | ||||
| // DurationValue returns a Value for a time.Duration. | ||||
| func DurationValue(v time.Duration) Value { | ||||
| 	return slog.DurationValue(v) | ||||
| } | ||||
|  | ||||
| // GroupValue returns a new Value for a list of Attrs. | ||||
| // The caller must not subsequently mutate the argument slice. | ||||
| func GroupValue(as ...Attr) Value { | ||||
| 	return slog.GroupValue(as...) | ||||
| } | ||||
|  | ||||
| // AnyValue returns a Value for the supplied value. | ||||
| // | ||||
| // If the supplied value is of type Value, it is returned | ||||
| // unmodified. | ||||
| // | ||||
| // Given a value of one of Go's predeclared string, bool, or | ||||
| // (non-complex) numeric types, AnyValue returns a Value of kind | ||||
| // String, Bool, Uint64, Int64, or Float64. The width of the | ||||
| // original numeric type is not preserved. | ||||
| // | ||||
| // Given a time.Time or time.Duration value, AnyValue returns a Value of kind | ||||
| // KindTime or KindDuration. The monotonic time is not preserved. | ||||
| // | ||||
| // For nil, or values of all other types, including named types whose | ||||
| // underlying type is numeric, AnyValue returns a value of kind KindAny. | ||||
| func AnyValue(v any) Value { | ||||
| 	return slog.AnyValue(v) | ||||
| } | ||||
|  | ||||
| // A LogValuer is any Go value that can convert itself into a Value for logging. | ||||
| // | ||||
| // This mechanism may be used to defer expensive operations until they are | ||||
| // needed, or to expand a single value into a sequence of components. | ||||
| type LogValuer = slog.LogValuer | ||||
							
								
								
									
										110
									
								
								vendor/github.com/sagikazarmark/slog-shim/value_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								vendor/github.com/sagikazarmark/slog-shim/value_120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | ||||
| // Copyright 2022 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 !go1.21 | ||||
|  | ||||
| package slog | ||||
|  | ||||
| import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/exp/slog" | ||||
| ) | ||||
|  | ||||
| // A Value can represent any Go value, but unlike type any, | ||||
| // it can represent most small values without an allocation. | ||||
| // The zero Value corresponds to nil. | ||||
| type Value = slog.Value | ||||
|  | ||||
| // Kind is the kind of a Value. | ||||
| type Kind = slog.Kind | ||||
|  | ||||
| // The following list is sorted alphabetically, but it's also important that | ||||
| // KindAny is 0 so that a zero Value represents nil. | ||||
| const ( | ||||
| 	KindAny       = slog.KindAny | ||||
| 	KindBool      = slog.KindBool | ||||
| 	KindDuration  = slog.KindDuration | ||||
| 	KindFloat64   = slog.KindFloat64 | ||||
| 	KindInt64     = slog.KindInt64 | ||||
| 	KindString    = slog.KindString | ||||
| 	KindTime      = slog.KindTime | ||||
| 	KindUint64    = slog.KindUint64 | ||||
| 	KindGroup     = slog.KindGroup | ||||
| 	KindLogValuer = slog.KindLogValuer | ||||
| ) | ||||
|  | ||||
| //////////////// Constructors | ||||
|  | ||||
| // StringValue returns a new Value for a string. | ||||
| func StringValue(value string) Value { | ||||
| 	return slog.StringValue(value) | ||||
| } | ||||
|  | ||||
| // IntValue returns a Value for an int. | ||||
| func IntValue(v int) Value { | ||||
| 	return slog.IntValue(v) | ||||
| } | ||||
|  | ||||
| // Int64Value returns a Value for an int64. | ||||
| func Int64Value(v int64) Value { | ||||
| 	return slog.Int64Value(v) | ||||
| } | ||||
|  | ||||
| // Uint64Value returns a Value for a uint64. | ||||
| func Uint64Value(v uint64) Value { | ||||
| 	return slog.Uint64Value(v) | ||||
| } | ||||
|  | ||||
| // Float64Value returns a Value for a floating-point number. | ||||
| func Float64Value(v float64) Value { | ||||
| 	return slog.Float64Value(v) | ||||
| } | ||||
|  | ||||
| // BoolValue returns a Value for a bool. | ||||
| func BoolValue(v bool) Value { | ||||
| 	return slog.BoolValue(v) | ||||
| } | ||||
|  | ||||
| // TimeValue returns a Value for a time.Time. | ||||
| // It discards the monotonic portion. | ||||
| func TimeValue(v time.Time) Value { | ||||
| 	return slog.TimeValue(v) | ||||
| } | ||||
|  | ||||
| // DurationValue returns a Value for a time.Duration. | ||||
| func DurationValue(v time.Duration) Value { | ||||
| 	return slog.DurationValue(v) | ||||
| } | ||||
|  | ||||
| // GroupValue returns a new Value for a list of Attrs. | ||||
| // The caller must not subsequently mutate the argument slice. | ||||
| func GroupValue(as ...Attr) Value { | ||||
| 	return slog.GroupValue(as...) | ||||
| } | ||||
|  | ||||
| // AnyValue returns a Value for the supplied value. | ||||
| // | ||||
| // If the supplied value is of type Value, it is returned | ||||
| // unmodified. | ||||
| // | ||||
| // Given a value of one of Go's predeclared string, bool, or | ||||
| // (non-complex) numeric types, AnyValue returns a Value of kind | ||||
| // String, Bool, Uint64, Int64, or Float64. The width of the | ||||
| // original numeric type is not preserved. | ||||
| // | ||||
| // Given a time.Time or time.Duration value, AnyValue returns a Value of kind | ||||
| // KindTime or KindDuration. The monotonic time is not preserved. | ||||
| // | ||||
| // For nil, or values of all other types, including named types whose | ||||
| // underlying type is numeric, AnyValue returns a value of kind KindAny. | ||||
| func AnyValue(v any) Value { | ||||
| 	return slog.AnyValue(v) | ||||
| } | ||||
|  | ||||
| // A LogValuer is any Go value that can convert itself into a Value for logging. | ||||
| // | ||||
| // This mechanism may be used to defer expensive operations until they are | ||||
| // needed, or to expand a single value into a sequence of components. | ||||
| type LogValuer = slog.LogValuer | ||||
							
								
								
									
										11
									
								
								vendor/github.com/sourcegraph/conc/.golangci.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								vendor/github.com/sourcegraph/conc/.golangci.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| linters: | ||||
|   disable-all: true | ||||
|   enable: | ||||
|     - errcheck | ||||
|     - godot | ||||
|     - gosimple | ||||
|     - govet | ||||
|     - ineffassign | ||||
|     - staticcheck | ||||
|     - typecheck | ||||
|     - unused | ||||
| @@ -1,6 +1,6 @@ | ||||
| The MIT License (MIT) | ||||
| MIT License | ||||
| 
 | ||||
| Copyright (c) 2014 Steve Francia | ||||
| Copyright (c) 2023 Sourcegraph | ||||
| 
 | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
| SOFTWARE. | ||||
							
								
								
									
										464
									
								
								vendor/github.com/sourcegraph/conc/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										464
									
								
								vendor/github.com/sourcegraph/conc/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,464 @@ | ||||
|  | ||||
|  | ||||
| # `conc`: better structured concurrency for go | ||||
|  | ||||
| [](https://pkg.go.dev/github.com/sourcegraph/conc) | ||||
| [](https://sourcegraph.com/github.com/sourcegraph/conc) | ||||
| [](https://goreportcard.com/report/github.com/sourcegraph/conc) | ||||
| [](https://codecov.io/gh/sourcegraph/conc) | ||||
| [](https://discord.gg/bvXQXmtRjN) | ||||
|  | ||||
| `conc` is your toolbelt for structured concurrency in go, making common tasks | ||||
| easier and safer. | ||||
|  | ||||
| ```sh | ||||
| go get github.com/sourcegraph/conc | ||||
| ``` | ||||
|  | ||||
| # At a glance | ||||
|  | ||||
| - Use [`conc.WaitGroup`](https://pkg.go.dev/github.com/sourcegraph/conc#WaitGroup) if you just want a safer version of `sync.WaitGroup` | ||||
| - Use [`pool.Pool`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#Pool) if you want a concurrency-limited task runner | ||||
| - Use [`pool.ResultPool`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#ResultPool) if you want a concurrent task runner that collects task results | ||||
| - Use [`pool.(Result)?ErrorPool`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#ErrorPool) if your tasks are fallible | ||||
| - Use [`pool.(Result)?ContextPool`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#ContextPool) if your tasks should be canceled on failure | ||||
| - Use [`stream.Stream`](https://pkg.go.dev/github.com/sourcegraph/conc/stream#Stream) if you want to process an ordered stream of tasks in parallel with serial callbacks | ||||
| - Use [`iter.Map`](https://pkg.go.dev/github.com/sourcegraph/conc/iter#Map) if you want to concurrently map a slice | ||||
| - Use [`iter.ForEach`](https://pkg.go.dev/github.com/sourcegraph/conc/iter#ForEach) if you want to concurrently iterate over a slice | ||||
| - Use [`panics.Catcher`](https://pkg.go.dev/github.com/sourcegraph/conc/panics#Catcher) if you want to catch panics in your own goroutines | ||||
|  | ||||
| All pools are created with | ||||
| [`pool.New()`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#New) | ||||
| or | ||||
| [`pool.NewWithResults[T]()`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#NewWithResults), | ||||
| then configured with methods: | ||||
|  | ||||
| - [`p.WithMaxGoroutines()`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#Pool.MaxGoroutines) configures the maximum number of goroutines in the pool | ||||
| - [`p.WithErrors()`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#Pool.WithErrors) configures the pool to run tasks that return errors | ||||
| - [`p.WithContext(ctx)`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#Pool.WithContext) configures the pool to run tasks that should be canceled on first error | ||||
| - [`p.WithFirstError()`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#ErrorPool.WithFirstError) configures error pools to only keep the first returned error rather than an aggregated error | ||||
| - [`p.WithCollectErrored()`](https://pkg.go.dev/github.com/sourcegraph/conc/pool#ResultContextPool.WithCollectErrored) configures result pools to collect results even when the task errored | ||||
|  | ||||
| # Goals | ||||
|  | ||||
| The main goals of the package are: | ||||
| 1) Make it harder to leak goroutines | ||||
| 2) Handle panics gracefully | ||||
| 3) Make concurrent code easier to read | ||||
|  | ||||
| ## Goal #1: Make it harder to leak goroutines | ||||
|  | ||||
| A common pain point when working with goroutines is cleaning them up. It's | ||||
| really easy to fire off a `go` statement and fail to properly wait for it to | ||||
| complete. | ||||
|  | ||||
| `conc` takes the opinionated stance that all concurrency should be scoped. | ||||
| That is, goroutines should have an owner and that owner should always | ||||
| ensure that its owned goroutines exit properly. | ||||
|  | ||||
| In `conc`, the owner of a goroutine is always a `conc.WaitGroup`. Goroutines | ||||
| are spawned in a `WaitGroup` with `(*WaitGroup).Go()`, and | ||||
| `(*WaitGroup).Wait()` should always be called before the `WaitGroup` goes out | ||||
| of scope. | ||||
|  | ||||
| In some cases, you might want a spawned goroutine to outlast the scope of the | ||||
| caller. In that case, you could pass a `WaitGroup` into the spawning function. | ||||
|  | ||||
| ```go | ||||
| func main() { | ||||
|     var wg conc.WaitGroup | ||||
|     defer wg.Wait() | ||||
|  | ||||
|     startTheThing(&wg) | ||||
| } | ||||
|  | ||||
| func startTheThing(wg *conc.WaitGroup) { | ||||
|     wg.Go(func() { ... }) | ||||
| } | ||||
| ``` | ||||
|  | ||||
| For some more discussion on why scoped concurrency is nice, check out [this | ||||
| blog | ||||
| post](https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/). | ||||
|  | ||||
| ## Goal #2: Handle panics gracefully | ||||
|  | ||||
| A frequent problem with goroutines in long-running applications is handling | ||||
| panics. A goroutine spawned without a panic handler will crash the whole process | ||||
| on panic. This is usually undesirable. | ||||
|  | ||||
| However, if you do add a panic handler to a goroutine, what do you do with the | ||||
| panic once you catch it? Some options: | ||||
| 1) Ignore it | ||||
| 2) Log it | ||||
| 3) Turn it into an error and return that to the goroutine spawner | ||||
| 4) Propagate the panic to the goroutine spawner | ||||
|  | ||||
| Ignoring panics is a bad idea since panics usually mean there is actually | ||||
| something wrong and someone should fix it. | ||||
|  | ||||
| Just logging panics isn't great either because then there is no indication to the spawner | ||||
| that something bad happened, and it might just continue on as normal even though your | ||||
| program is in a really bad state. | ||||
|  | ||||
| Both (3) and (4) are reasonable options, but both require the goroutine to have | ||||
| an owner that can actually receive the message that something went wrong. This | ||||
| is generally not true with a goroutine spawned with `go`, but in the `conc` | ||||
| package, all goroutines have an owner that must collect the spawned goroutine. | ||||
| In the conc package, any call to `Wait()` will panic if any of the spawned goroutines | ||||
| panicked. Additionally, it decorates the panic value with a stacktrace from the child | ||||
| goroutine so that you don't lose information about what caused the panic. | ||||
|  | ||||
| Doing this all correctly every time you spawn something with `go` is not | ||||
| trivial and it requires a lot of boilerplate that makes the important parts of | ||||
| the code more difficult to read, so `conc` does this for you. | ||||
|  | ||||
| <table> | ||||
| <tr> | ||||
| <th><code>stdlib</code></th> | ||||
| <th><code>conc</code></th> | ||||
| </tr> | ||||
| <tr> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| type caughtPanicError struct { | ||||
|     val   any | ||||
|     stack []byte | ||||
| } | ||||
|  | ||||
| func (e *caughtPanicError) Error() string { | ||||
|     return fmt.Sprintf( | ||||
|         "panic: %q\n%s", | ||||
|         e.val, | ||||
|         string(e.stack) | ||||
|     ) | ||||
| } | ||||
|  | ||||
| func main() { | ||||
|     done := make(chan error) | ||||
|     go func() { | ||||
|         defer func() { | ||||
|             if v := recover(); v != nil { | ||||
|                 done <- &caughtPanicError{ | ||||
|                     val: v, | ||||
|                     stack: debug.Stack() | ||||
|                 } | ||||
|             } else { | ||||
|                 done <- nil | ||||
|             } | ||||
|         }() | ||||
|         doSomethingThatMightPanic() | ||||
|     }() | ||||
|     err := <-done | ||||
|     if err != nil { | ||||
|         panic(err) | ||||
|     } | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func main() { | ||||
|     var wg conc.WaitGroup | ||||
|     wg.Go(doSomethingThatMightPanic) | ||||
|     // panics with a nice stacktrace | ||||
|     wg.Wait() | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| </tr> | ||||
| </table> | ||||
|  | ||||
| ## Goal #3: Make concurrent code easier to read | ||||
|  | ||||
| Doing concurrency correctly is difficult. Doing it in a way that doesn't | ||||
| obfuscate what the code is actually doing is more difficult. The `conc` package | ||||
| attempts to make common operations easier by abstracting as much boilerplate | ||||
| complexity as possible. | ||||
|  | ||||
| Want to run a set of concurrent tasks with a bounded set of goroutines? Use | ||||
| `pool.New()`. Want to process an ordered stream of results concurrently, but | ||||
| still maintain order? Try `stream.New()`. What about a concurrent map over | ||||
| a slice? Take a peek at `iter.Map()`. | ||||
|  | ||||
| Browse some examples below for some comparisons with doing these by hand. | ||||
|  | ||||
| # Examples | ||||
|  | ||||
| Each of these examples forgoes propagating panics for simplicity. To see | ||||
| what kind of complexity that would add, check out the "Goal #2" header above. | ||||
|  | ||||
| Spawn a set of goroutines and waiting for them to finish: | ||||
|  | ||||
| <table> | ||||
| <tr> | ||||
| <th><code>stdlib</code></th> | ||||
| <th><code>conc</code></th> | ||||
| </tr> | ||||
| <tr> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func main() { | ||||
|     var wg sync.WaitGroup | ||||
|     for i := 0; i < 10; i++ { | ||||
|         wg.Add(1) | ||||
|         go func() { | ||||
|             defer wg.Done() | ||||
|             // crashes on panic! | ||||
|             doSomething() | ||||
|         }() | ||||
|     } | ||||
|     wg.Wait() | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func main() { | ||||
|     var wg conc.WaitGroup | ||||
|     for i := 0; i < 10; i++ { | ||||
|         wg.Go(doSomething) | ||||
|     } | ||||
|     wg.Wait() | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| </tr> | ||||
| </table> | ||||
|  | ||||
| Process each element of a stream in a static pool of goroutines: | ||||
|  | ||||
| <table> | ||||
| <tr> | ||||
| <th><code>stdlib</code></th> | ||||
| <th><code>conc</code></th> | ||||
| </tr> | ||||
| <tr> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func process(stream chan int) { | ||||
|     var wg sync.WaitGroup | ||||
|     for i := 0; i < 10; i++ { | ||||
|         wg.Add(1) | ||||
|         go func() { | ||||
|             defer wg.Done() | ||||
|             for elem := range stream { | ||||
|                 handle(elem) | ||||
|             } | ||||
|         }() | ||||
|     } | ||||
|     wg.Wait() | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func process(stream chan int) { | ||||
|     p := pool.New().WithMaxGoroutines(10) | ||||
|     for elem := range stream { | ||||
|         elem := elem | ||||
|         p.Go(func() { | ||||
|             handle(elem) | ||||
|         }) | ||||
|     } | ||||
|     p.Wait() | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| </tr> | ||||
| </table> | ||||
|  | ||||
| Process each element of a slice in a static pool of goroutines: | ||||
|  | ||||
| <table> | ||||
| <tr> | ||||
| <th><code>stdlib</code></th> | ||||
| <th><code>conc</code></th> | ||||
| </tr> | ||||
| <tr> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func process(values []int) { | ||||
|     feeder := make(chan int, 8) | ||||
|  | ||||
|     var wg sync.WaitGroup | ||||
|     for i := 0; i < 10; i++ { | ||||
|         wg.Add(1) | ||||
|         go func() { | ||||
|             defer wg.Done() | ||||
|             for elem := range feeder { | ||||
|                 handle(elem) | ||||
|             } | ||||
|         }() | ||||
|     } | ||||
|  | ||||
|     for _, value := range values { | ||||
|         feeder <- value | ||||
|     } | ||||
|     close(feeder) | ||||
|     wg.Wait() | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func process(values []int) { | ||||
|     iter.ForEach(values, handle) | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| </tr> | ||||
| </table> | ||||
|  | ||||
| Concurrently map a slice: | ||||
|  | ||||
| <table> | ||||
| <tr> | ||||
| <th><code>stdlib</code></th> | ||||
| <th><code>conc</code></th> | ||||
| </tr> | ||||
| <tr> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func concMap( | ||||
|     input []int, | ||||
|     f func(int) int, | ||||
| ) []int { | ||||
|     res := make([]int, len(input)) | ||||
|     var idx atomic.Int64 | ||||
|  | ||||
|     var wg sync.WaitGroup | ||||
|     for i := 0; i < 10; i++ { | ||||
|         wg.Add(1) | ||||
|         go func() { | ||||
|             defer wg.Done() | ||||
|  | ||||
|             for { | ||||
|                 i := int(idx.Add(1) - 1) | ||||
|                 if i >= len(input) { | ||||
|                     return | ||||
|                 } | ||||
|  | ||||
|                 res[i] = f(input[i]) | ||||
|             } | ||||
|         }() | ||||
|     } | ||||
|     wg.Wait() | ||||
|     return res | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func concMap( | ||||
|     input []int, | ||||
|     f func(*int) int, | ||||
| ) []int { | ||||
|     return iter.Map(input, f) | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| </tr> | ||||
| </table> | ||||
|  | ||||
| Process an ordered stream concurrently: | ||||
|  | ||||
|  | ||||
| <table> | ||||
| <tr> | ||||
| <th><code>stdlib</code></th> | ||||
| <th><code>conc</code></th> | ||||
| </tr> | ||||
| <tr> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func mapStream( | ||||
|     in chan int, | ||||
|     out chan int, | ||||
|     f func(int) int, | ||||
| ) { | ||||
|     tasks := make(chan func()) | ||||
|     taskResults := make(chan chan int) | ||||
|  | ||||
|     // Worker goroutines | ||||
|     var workerWg sync.WaitGroup | ||||
|     for i := 0; i < 10; i++ { | ||||
|         workerWg.Add(1) | ||||
|         go func() { | ||||
|             defer workerWg.Done() | ||||
|             for task := range tasks { | ||||
|                 task() | ||||
|             } | ||||
|         }() | ||||
|     } | ||||
|  | ||||
|     // Ordered reader goroutines | ||||
|     var readerWg sync.WaitGroup | ||||
|     readerWg.Add(1) | ||||
|     go func() { | ||||
|         defer readerWg.Done() | ||||
|         for result := range taskResults { | ||||
|             item := <-result | ||||
|             out <- item | ||||
|         } | ||||
|     }() | ||||
|  | ||||
|     // Feed the workers with tasks | ||||
|     for elem := range in { | ||||
|         resultCh := make(chan int, 1) | ||||
|         taskResults <- resultCh | ||||
|         tasks <- func() { | ||||
|             resultCh <- f(elem) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // We've exhausted input. | ||||
|     // Wait for everything to finish | ||||
|     close(tasks) | ||||
|     workerWg.Wait() | ||||
|     close(taskResults) | ||||
|     readerWg.Wait() | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| <td> | ||||
|  | ||||
| ```go | ||||
| func mapStream( | ||||
|     in chan int, | ||||
|     out chan int, | ||||
|     f func(int) int, | ||||
| ) { | ||||
|     s := stream.New().WithMaxGoroutines(10) | ||||
|     for elem := range in { | ||||
|         elem := elem | ||||
|         s.Go(func() stream.Callback { | ||||
|             res := f(elem) | ||||
|             return func() { out <- res } | ||||
|         }) | ||||
|     } | ||||
|     s.Wait() | ||||
| } | ||||
| ``` | ||||
| </td> | ||||
| </tr> | ||||
| </table> | ||||
|  | ||||
| # Status | ||||
|  | ||||
| This package is currently pre-1.0. There are likely to be minor breaking | ||||
| changes before a 1.0 release as we stabilize the APIs and tweak defaults. | ||||
| Please open an issue if you have questions, concerns, or requests that you'd | ||||
| like addressed before the 1.0 release. Currently, a 1.0 is targeted for  | ||||
| March 2023. | ||||
							
								
								
									
										10
									
								
								vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go119.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go119.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| //go:build !go1.20 | ||||
| // +build !go1.20 | ||||
|  | ||||
| package multierror | ||||
|  | ||||
| import "go.uber.org/multierr" | ||||
|  | ||||
| var ( | ||||
| 	Join = multierr.Combine | ||||
| ) | ||||
							
								
								
									
										10
									
								
								vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| //go:build go1.20 | ||||
| // +build go1.20 | ||||
|  | ||||
| package multierror | ||||
|  | ||||
| import "errors" | ||||
|  | ||||
| var ( | ||||
| 	Join = errors.Join | ||||
| ) | ||||
							
								
								
									
										85
									
								
								vendor/github.com/sourcegraph/conc/iter/iter.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								vendor/github.com/sourcegraph/conc/iter/iter.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,85 @@ | ||||
| package iter | ||||
|  | ||||
| import ( | ||||
| 	"runtime" | ||||
| 	"sync/atomic" | ||||
|  | ||||
| 	"github.com/sourcegraph/conc" | ||||
| ) | ||||
|  | ||||
| // defaultMaxGoroutines returns the default maximum number of | ||||
| // goroutines to use within this package. | ||||
| func defaultMaxGoroutines() int { return runtime.GOMAXPROCS(0) } | ||||
|  | ||||
| // Iterator can be used to configure the behaviour of ForEach | ||||
| // and ForEachIdx. The zero value is safe to use with reasonable | ||||
| // defaults. | ||||
| // | ||||
| // Iterator is also safe for reuse and concurrent use. | ||||
| type Iterator[T any] struct { | ||||
| 	// MaxGoroutines controls the maximum number of goroutines | ||||
| 	// to use on this Iterator's methods. | ||||
| 	// | ||||
| 	// If unset, MaxGoroutines defaults to runtime.GOMAXPROCS(0). | ||||
| 	MaxGoroutines int | ||||
| } | ||||
|  | ||||
| // ForEach executes f in parallel over each element in input. | ||||
| // | ||||
| // It is safe to mutate the input parameter, which makes it | ||||
| // possible to map in place. | ||||
| // | ||||
| // ForEach always uses at most runtime.GOMAXPROCS goroutines. | ||||
| // It takes roughly 2µs to start up the goroutines and adds | ||||
| // an overhead of roughly 50ns per element of input. For | ||||
| // a configurable goroutine limit, use a custom Iterator. | ||||
| func ForEach[T any](input []T, f func(*T)) { Iterator[T]{}.ForEach(input, f) } | ||||
|  | ||||
| // ForEach executes f in parallel over each element in input, | ||||
| // using up to the Iterator's configured maximum number of | ||||
| // goroutines. | ||||
| // | ||||
| // It is safe to mutate the input parameter, which makes it | ||||
| // possible to map in place. | ||||
| // | ||||
| // It takes roughly 2µs to start up the goroutines and adds | ||||
| // an overhead of roughly 50ns per element of input. | ||||
| func (iter Iterator[T]) ForEach(input []T, f func(*T)) { | ||||
| 	iter.ForEachIdx(input, func(_ int, t *T) { | ||||
| 		f(t) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ForEachIdx is the same as ForEach except it also provides the | ||||
| // index of the element to the callback. | ||||
| func ForEachIdx[T any](input []T, f func(int, *T)) { Iterator[T]{}.ForEachIdx(input, f) } | ||||
|  | ||||
| // ForEachIdx is the same as ForEach except it also provides the | ||||
| // index of the element to the callback. | ||||
| func (iter Iterator[T]) ForEachIdx(input []T, f func(int, *T)) { | ||||
| 	if iter.MaxGoroutines == 0 { | ||||
| 		// iter is a value receiver and is hence safe to mutate | ||||
| 		iter.MaxGoroutines = defaultMaxGoroutines() | ||||
| 	} | ||||
|  | ||||
| 	numInput := len(input) | ||||
| 	if iter.MaxGoroutines > numInput { | ||||
| 		// No more concurrent tasks than the number of input items. | ||||
| 		iter.MaxGoroutines = numInput | ||||
| 	} | ||||
|  | ||||
| 	var idx atomic.Int64 | ||||
| 	// Create the task outside the loop to avoid extra closure allocations. | ||||
| 	task := func() { | ||||
| 		i := int(idx.Add(1) - 1) | ||||
| 		for ; i < numInput; i = int(idx.Add(1) - 1) { | ||||
| 			f(i, &input[i]) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	var wg conc.WaitGroup | ||||
| 	for i := 0; i < iter.MaxGoroutines; i++ { | ||||
| 		wg.Go(task) | ||||
| 	} | ||||
| 	wg.Wait() | ||||
| } | ||||
							
								
								
									
										65
									
								
								vendor/github.com/sourcegraph/conc/iter/map.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								vendor/github.com/sourcegraph/conc/iter/map.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| package iter | ||||
|  | ||||
| import ( | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/sourcegraph/conc/internal/multierror" | ||||
| ) | ||||
|  | ||||
| // Mapper is an Iterator with a result type R. It can be used to configure | ||||
| // the behaviour of Map and MapErr. The zero value is safe to use with | ||||
| // reasonable defaults. | ||||
| // | ||||
| // Mapper is also safe for reuse and concurrent use. | ||||
| type Mapper[T, R any] Iterator[T] | ||||
|  | ||||
| // Map applies f to each element of input, returning the mapped result. | ||||
| // | ||||
| // Map always uses at most runtime.GOMAXPROCS goroutines. For a configurable | ||||
| // goroutine limit, use a custom Mapper. | ||||
| func Map[T, R any](input []T, f func(*T) R) []R { | ||||
| 	return Mapper[T, R]{}.Map(input, f) | ||||
| } | ||||
|  | ||||
| // Map applies f to each element of input, returning the mapped result. | ||||
| // | ||||
| // Map uses up to the configured Mapper's maximum number of goroutines. | ||||
| func (m Mapper[T, R]) Map(input []T, f func(*T) R) []R { | ||||
| 	res := make([]R, len(input)) | ||||
| 	Iterator[T](m).ForEachIdx(input, func(i int, t *T) { | ||||
| 		res[i] = f(t) | ||||
| 	}) | ||||
| 	return res | ||||
| } | ||||
|  | ||||
| // MapErr applies f to each element of the input, returning the mapped result | ||||
| // and a combined error of all returned errors. | ||||
| // | ||||
| // Map always uses at most runtime.GOMAXPROCS goroutines. For a configurable | ||||
| // goroutine limit, use a custom Mapper. | ||||
| func MapErr[T, R any](input []T, f func(*T) (R, error)) ([]R, error) { | ||||
| 	return Mapper[T, R]{}.MapErr(input, f) | ||||
| } | ||||
|  | ||||
| // MapErr applies f to each element of the input, returning the mapped result | ||||
| // and a combined error of all returned errors. | ||||
| // | ||||
| // Map uses up to the configured Mapper's maximum number of goroutines. | ||||
| func (m Mapper[T, R]) MapErr(input []T, f func(*T) (R, error)) ([]R, error) { | ||||
| 	var ( | ||||
| 		res    = make([]R, len(input)) | ||||
| 		errMux sync.Mutex | ||||
| 		errs   error | ||||
| 	) | ||||
| 	Iterator[T](m).ForEachIdx(input, func(i int, t *T) { | ||||
| 		var err error | ||||
| 		res[i], err = f(t) | ||||
| 		if err != nil { | ||||
| 			errMux.Lock() | ||||
| 			// TODO: use stdlib errors once multierrors land in go 1.20 | ||||
| 			errs = multierror.Join(errs, err) | ||||
| 			errMux.Unlock() | ||||
| 		} | ||||
| 	}) | ||||
| 	return res, errs | ||||
| } | ||||
							
								
								
									
										102
									
								
								vendor/github.com/sourcegraph/conc/panics/panics.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								vendor/github.com/sourcegraph/conc/panics/panics.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,102 @@ | ||||
| package panics | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"runtime" | ||||
| 	"runtime/debug" | ||||
| 	"sync/atomic" | ||||
| ) | ||||
|  | ||||
| // Catcher is used to catch panics. You can execute a function with Try, | ||||
| // which will catch any spawned panic. Try can be called any number of times, | ||||
| // from any number of goroutines. Once all calls to Try have completed, you can | ||||
| // get the value of the first panic (if any) with Recovered(), or you can just | ||||
| // propagate the panic (re-panic) with Repanic(). | ||||
| type Catcher struct { | ||||
| 	recovered atomic.Pointer[Recovered] | ||||
| } | ||||
|  | ||||
| // Try executes f, catching any panic it might spawn. It is safe | ||||
| // to call from multiple goroutines simultaneously. | ||||
| func (p *Catcher) Try(f func()) { | ||||
| 	defer p.tryRecover() | ||||
| 	f() | ||||
| } | ||||
|  | ||||
| func (p *Catcher) tryRecover() { | ||||
| 	if val := recover(); val != nil { | ||||
| 		rp := NewRecovered(1, val) | ||||
| 		p.recovered.CompareAndSwap(nil, &rp) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Repanic panics if any calls to Try caught a panic. It will panic with the | ||||
| // value of the first panic caught, wrapped in a panics.Recovered with caller | ||||
| // information. | ||||
| func (p *Catcher) Repanic() { | ||||
| 	if val := p.Recovered(); val != nil { | ||||
| 		panic(val) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Recovered returns the value of the first panic caught by Try, or nil if | ||||
| // no calls to Try panicked. | ||||
| func (p *Catcher) Recovered() *Recovered { | ||||
| 	return p.recovered.Load() | ||||
| } | ||||
|  | ||||
| // NewRecovered creates a panics.Recovered from a panic value and a collected | ||||
| // stacktrace. The skip parameter allows the caller to skip stack frames when | ||||
| // collecting the stacktrace. Calling with a skip of 0 means include the call to | ||||
| // NewRecovered in the stacktrace. | ||||
| func NewRecovered(skip int, value any) Recovered { | ||||
| 	// 64 frames should be plenty | ||||
| 	var callers [64]uintptr | ||||
| 	n := runtime.Callers(skip+1, callers[:]) | ||||
| 	return Recovered{ | ||||
| 		Value:   value, | ||||
| 		Callers: callers[:n], | ||||
| 		Stack:   debug.Stack(), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Recovered is a panic that was caught with recover(). | ||||
| type Recovered struct { | ||||
| 	// The original value of the panic. | ||||
| 	Value any | ||||
| 	// The caller list as returned by runtime.Callers when the panic was | ||||
| 	// recovered. Can be used to produce a more detailed stack information with | ||||
| 	// runtime.CallersFrames. | ||||
| 	Callers []uintptr | ||||
| 	// The formatted stacktrace from the goroutine where the panic was recovered. | ||||
| 	// Easier to use than Callers. | ||||
| 	Stack []byte | ||||
| } | ||||
|  | ||||
| // String renders a human-readable formatting of the panic. | ||||
| func (p *Recovered) String() string { | ||||
| 	return fmt.Sprintf("panic: %v\nstacktrace:\n%s\n", p.Value, p.Stack) | ||||
| } | ||||
|  | ||||
| // AsError casts the panic into an error implementation. The implementation | ||||
| // is unwrappable with the cause of the panic, if the panic was provided one. | ||||
| func (p *Recovered) AsError() error { | ||||
| 	if p == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &ErrRecovered{*p} | ||||
| } | ||||
|  | ||||
| // ErrRecovered wraps a panics.Recovered in an error implementation. | ||||
| type ErrRecovered struct{ Recovered } | ||||
|  | ||||
| var _ error = (*ErrRecovered)(nil) | ||||
|  | ||||
| func (p *ErrRecovered) Error() string { return p.String() } | ||||
|  | ||||
| func (p *ErrRecovered) Unwrap() error { | ||||
| 	if err, ok := p.Value.(error); ok { | ||||
| 		return err | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										11
									
								
								vendor/github.com/sourcegraph/conc/panics/try.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								vendor/github.com/sourcegraph/conc/panics/try.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| package panics | ||||
|  | ||||
| // Try executes f, catching and returning any panic it might spawn. | ||||
| // | ||||
| // The recovered panic can be propagated with panic(), or handled as a normal error with | ||||
| // (*panics.Recovered).AsError(). | ||||
| func Try(f func()) *Recovered { | ||||
| 	var c Catcher | ||||
| 	c.Try(f) | ||||
| 	return c.Recovered() | ||||
| } | ||||
							
								
								
									
										52
									
								
								vendor/github.com/sourcegraph/conc/waitgroup.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								vendor/github.com/sourcegraph/conc/waitgroup.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| package conc | ||||
|  | ||||
| import ( | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/sourcegraph/conc/panics" | ||||
| ) | ||||
|  | ||||
| // NewWaitGroup creates a new WaitGroup. | ||||
| func NewWaitGroup() *WaitGroup { | ||||
| 	return &WaitGroup{} | ||||
| } | ||||
|  | ||||
| // WaitGroup is the primary building block for scoped concurrency. | ||||
| // Goroutines can be spawned in the WaitGroup with the Go method, | ||||
| // and calling Wait() will ensure that each of those goroutines exits | ||||
| // before continuing. Any panics in a child goroutine will be caught | ||||
| // and propagated to the caller of Wait(). | ||||
| // | ||||
| // The zero value of WaitGroup is usable, just like sync.WaitGroup. | ||||
| // Also like sync.WaitGroup, it must not be copied after first use. | ||||
| type WaitGroup struct { | ||||
| 	wg sync.WaitGroup | ||||
| 	pc panics.Catcher | ||||
| } | ||||
|  | ||||
| // Go spawns a new goroutine in the WaitGroup. | ||||
| func (h *WaitGroup) Go(f func()) { | ||||
| 	h.wg.Add(1) | ||||
| 	go func() { | ||||
| 		defer h.wg.Done() | ||||
| 		h.pc.Try(f) | ||||
| 	}() | ||||
| } | ||||
|  | ||||
| // Wait will block until all goroutines spawned with Go exit and will | ||||
| // propagate any panics spawned in a child goroutine. | ||||
| func (h *WaitGroup) Wait() { | ||||
| 	h.wg.Wait() | ||||
|  | ||||
| 	// Propagate a panic if we caught one from a child goroutine. | ||||
| 	h.pc.Repanic() | ||||
| } | ||||
|  | ||||
| // WaitAndRecover will block until all goroutines spawned with Go exit and | ||||
| // will return a *panics.Recovered if one of the child goroutines panics. | ||||
| func (h *WaitGroup) WaitAndRecover() *panics.Recovered { | ||||
| 	h.wg.Wait() | ||||
|  | ||||
| 	// Return a recovered panic if we caught one from a child goroutine. | ||||
| 	return h.pc.Recovered() | ||||
| } | ||||
							
								
								
									
										24
									
								
								vendor/github.com/spf13/jwalterweatherman/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								vendor/github.com/spf13/jwalterweatherman/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,24 +0,0 @@ | ||||
| # Compiled Object files, Static and Dynamic libs (Shared Objects) | ||||
| *.o | ||||
| *.a | ||||
| *.so | ||||
|  | ||||
| # Folders | ||||
| _obj | ||||
| _test | ||||
|  | ||||
| # Architecture specific extensions/prefixes | ||||
| *.[568vq] | ||||
| [568vq].out | ||||
|  | ||||
| *.cgo1.go | ||||
| *.cgo2.c | ||||
| _cgo_defun.c | ||||
| _cgo_gotypes.go | ||||
| _cgo_export.* | ||||
|  | ||||
| _testmain.go | ||||
|  | ||||
| *.exe | ||||
| *.bench | ||||
| go.sum | ||||
							
								
								
									
										148
									
								
								vendor/github.com/spf13/jwalterweatherman/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										148
									
								
								vendor/github.com/spf13/jwalterweatherman/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,148 +0,0 @@ | ||||
| jWalterWeatherman | ||||
| ================= | ||||
|  | ||||
| Seamless printing to the terminal (stdout) and logging to a io.Writer | ||||
| (file) that’s as easy to use as fmt.Println. | ||||
|  | ||||
|  | ||||
| Graphic by [JonnyEtc](http://jonnyetc.deviantart.com/art/And-That-s-Why-You-Always-Leave-a-Note-315311422) | ||||
|  | ||||
| JWW is primarily a wrapper around the excellent standard log library. It | ||||
| provides a few advantages over using the standard log library alone. | ||||
|  | ||||
| 1. Ready to go out of the box.  | ||||
| 2. One library for both printing to the terminal and logging (to files). | ||||
| 3. Really easy to log to either a temp file or a file you specify. | ||||
|  | ||||
|  | ||||
| I really wanted a very straightforward library that could seamlessly do | ||||
| the following things. | ||||
|  | ||||
| 1. Replace all the println, printf, etc statements thoughout my code with | ||||
|    something more useful | ||||
| 2. Allow the user to easily control what levels are printed to stdout | ||||
| 3. Allow the user to easily control what levels are logged | ||||
| 4. Provide an easy mechanism (like fmt.Println) to print info to the user | ||||
|    which can be easily logged as well  | ||||
| 5. Due to 2 & 3 provide easy verbose mode for output and logs | ||||
| 6. Not have any unnecessary initialization cruft. Just use it. | ||||
|  | ||||
| # Usage | ||||
|  | ||||
| ## Step 1. Use it | ||||
| Put calls throughout your source based on type of feedback. | ||||
| No initialization or setup needs to happen. Just start calling things. | ||||
|  | ||||
| Available Loggers are: | ||||
|  | ||||
|  * TRACE | ||||
|  * DEBUG | ||||
|  * INFO | ||||
|  * WARN | ||||
|  * ERROR | ||||
|  * CRITICAL | ||||
|  * FATAL | ||||
|  | ||||
| These each are loggers based on the log standard library and follow the | ||||
| standard usage. Eg. | ||||
|  | ||||
| ```go | ||||
|     import ( | ||||
|         jww "github.com/spf13/jwalterweatherman" | ||||
|     ) | ||||
|  | ||||
|     ... | ||||
|  | ||||
|     if err != nil { | ||||
|  | ||||
|         // This is a pretty serious error and the user should know about | ||||
|         // it. It will be printed to the terminal as well as logged under the | ||||
|         // default thresholds. | ||||
|  | ||||
|         jww.ERROR.Println(err) | ||||
|     } | ||||
|  | ||||
|     if err2 != nil { | ||||
|         // This error isn’t going to materially change the behavior of the | ||||
|         // application, but it’s something that may not be what the user | ||||
|         // expects. Under the default thresholds, Warn will be logged, but | ||||
|         // not printed to the terminal.  | ||||
|  | ||||
|         jww.WARN.Println(err2) | ||||
|     } | ||||
|  | ||||
|     // Information that’s relevant to what’s happening, but not very | ||||
|     // important for the user. Under the default thresholds this will be | ||||
|     // discarded. | ||||
|  | ||||
|     jww.INFO.Printf("information %q", response) | ||||
|  | ||||
| ``` | ||||
|  | ||||
| NOTE: You can also use the library in a non-global setting by creating an instance of a Notebook: | ||||
|  | ||||
| ```go | ||||
| notepad = jww.NewNotepad(jww.LevelInfo, jww.LevelTrace, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime) | ||||
| notepad.WARN.Println("Some warning"") | ||||
| ``` | ||||
|  | ||||
| _Why 7 levels?_ | ||||
|  | ||||
| Maybe you think that 7 levels are too much for any application... and you | ||||
| are probably correct. Just because there are seven levels doesn’t mean | ||||
| that you should be using all 7 levels. Pick the right set for your needs. | ||||
| Remember they only have to mean something to your project. | ||||
|  | ||||
| ## Step 2. Optionally configure JWW | ||||
|  | ||||
| Under the default thresholds : | ||||
|  | ||||
|  * Debug, Trace & Info goto /dev/null | ||||
|  * Warn and above is logged (when a log file/io.Writer is provided) | ||||
|  * Error and above is printed to the terminal (stdout) | ||||
|  | ||||
| ### Changing the thresholds | ||||
|  | ||||
| The threshold can be changed at any time, but will only affect calls that | ||||
| execute after the change was made. | ||||
|  | ||||
| This is very useful if your application has a verbose mode. Of course you | ||||
| can decide what verbose means to you or even have multiple levels of | ||||
| verbosity. | ||||
|  | ||||
|  | ||||
| ```go | ||||
|     import ( | ||||
|         jww "github.com/spf13/jwalterweatherman" | ||||
|     ) | ||||
|  | ||||
|     if Verbose { | ||||
|         jww.SetLogThreshold(jww.LevelTrace) | ||||
|         jww.SetStdoutThreshold(jww.LevelInfo) | ||||
|     } | ||||
| ``` | ||||
|  | ||||
| Note that JWW's own internal output uses log levels as well, so set the log | ||||
| level before making any other calls if you want to see what it's up to. | ||||
|  | ||||
|  | ||||
| ### Setting a log file | ||||
|  | ||||
| JWW can log to any `io.Writer`: | ||||
|  | ||||
|  | ||||
| ```go | ||||
|  | ||||
|     jww.SetLogOutput(customWriter)  | ||||
|  | ||||
| ``` | ||||
|  | ||||
|  | ||||
| # More information | ||||
|  | ||||
| This is an early release. I’ve been using it for a while and this is the | ||||
| third interface I’ve tried. I like this one pretty well, but no guarantees | ||||
| that it won’t change a bit. | ||||
|  | ||||
| I wrote this for use in [hugo](https://gohugo.io). If you are looking | ||||
| for a static website engine that’s super fast please checkout Hugo. | ||||
							
								
								
									
										111
									
								
								vendor/github.com/spf13/jwalterweatherman/default_notepad.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										111
									
								
								vendor/github.com/spf13/jwalterweatherman/default_notepad.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,111 +0,0 @@ | ||||
| // Copyright © 2016 Steve Francia <spf@spf13.com>. | ||||
| // | ||||
| // Use of this source code is governed by an MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package jwalterweatherman | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"log" | ||||
| 	"os" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	TRACE    *log.Logger | ||||
| 	DEBUG    *log.Logger | ||||
| 	INFO     *log.Logger | ||||
| 	WARN     *log.Logger | ||||
| 	ERROR    *log.Logger | ||||
| 	CRITICAL *log.Logger | ||||
| 	FATAL    *log.Logger | ||||
|  | ||||
| 	LOG      *log.Logger | ||||
| 	FEEDBACK *Feedback | ||||
|  | ||||
| 	defaultNotepad *Notepad | ||||
| ) | ||||
|  | ||||
| func reloadDefaultNotepad() { | ||||
| 	TRACE = defaultNotepad.TRACE | ||||
| 	DEBUG = defaultNotepad.DEBUG | ||||
| 	INFO = defaultNotepad.INFO | ||||
| 	WARN = defaultNotepad.WARN | ||||
| 	ERROR = defaultNotepad.ERROR | ||||
| 	CRITICAL = defaultNotepad.CRITICAL | ||||
| 	FATAL = defaultNotepad.FATAL | ||||
|  | ||||
| 	LOG = defaultNotepad.LOG | ||||
| 	FEEDBACK = defaultNotepad.FEEDBACK | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	defaultNotepad = NewNotepad(LevelError, LevelWarn, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime) | ||||
| 	reloadDefaultNotepad() | ||||
| } | ||||
|  | ||||
| // SetLogThreshold set the log threshold for the default notepad. Trace by default. | ||||
| func SetLogThreshold(threshold Threshold) { | ||||
| 	defaultNotepad.SetLogThreshold(threshold) | ||||
| 	reloadDefaultNotepad() | ||||
| } | ||||
|  | ||||
| // SetLogOutput set the log output for the default notepad. Discarded by default. | ||||
| func SetLogOutput(handle io.Writer) { | ||||
| 	defaultNotepad.SetLogOutput(handle) | ||||
| 	reloadDefaultNotepad() | ||||
| } | ||||
|  | ||||
| // SetStdoutThreshold set the standard output threshold for the default notepad. | ||||
| // Info by default. | ||||
| func SetStdoutThreshold(threshold Threshold) { | ||||
| 	defaultNotepad.SetStdoutThreshold(threshold) | ||||
| 	reloadDefaultNotepad() | ||||
| } | ||||
|  | ||||
| // SetStdoutOutput set the stdout output for the default notepad. Default is stdout. | ||||
| func SetStdoutOutput(handle io.Writer) { | ||||
| 	defaultNotepad.outHandle = handle | ||||
| 	defaultNotepad.init() | ||||
| 	reloadDefaultNotepad() | ||||
| } | ||||
|  | ||||
| // SetPrefix set the prefix for the default logger. Empty by default. | ||||
| func SetPrefix(prefix string) { | ||||
| 	defaultNotepad.SetPrefix(prefix) | ||||
| 	reloadDefaultNotepad() | ||||
| } | ||||
|  | ||||
| // SetFlags set the flags for the default logger. "log.Ldate | log.Ltime" by default. | ||||
| func SetFlags(flags int) { | ||||
| 	defaultNotepad.SetFlags(flags) | ||||
| 	reloadDefaultNotepad() | ||||
| } | ||||
|  | ||||
| // SetLogListeners configures the default logger with one or more log listeners. | ||||
| func SetLogListeners(l ...LogListener) { | ||||
| 	defaultNotepad.logListeners = l | ||||
| 	defaultNotepad.init() | ||||
| 	reloadDefaultNotepad() | ||||
| } | ||||
|  | ||||
| // Level returns the current global log threshold. | ||||
| func LogThreshold() Threshold { | ||||
| 	return defaultNotepad.logThreshold | ||||
| } | ||||
|  | ||||
| // Level returns the current global output threshold. | ||||
| func StdoutThreshold() Threshold { | ||||
| 	return defaultNotepad.stdoutThreshold | ||||
| } | ||||
|  | ||||
| // GetStdoutThreshold returns the defined Treshold for the log logger. | ||||
| func GetLogThreshold() Threshold { | ||||
| 	return defaultNotepad.GetLogThreshold() | ||||
| } | ||||
|  | ||||
| // GetStdoutThreshold returns the Treshold for the stdout logger. | ||||
| func GetStdoutThreshold() Threshold { | ||||
| 	return defaultNotepad.GetStdoutThreshold() | ||||
| } | ||||
							
								
								
									
										46
									
								
								vendor/github.com/spf13/jwalterweatherman/log_counter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								vendor/github.com/spf13/jwalterweatherman/log_counter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,46 +0,0 @@ | ||||
| // Copyright © 2016 Steve Francia <spf@spf13.com>. | ||||
| // | ||||
| // Use of this source code is governed by an MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package jwalterweatherman | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
| 	"sync/atomic" | ||||
| ) | ||||
|  | ||||
| // Counter is an io.Writer that increments a counter on Write. | ||||
| type Counter struct { | ||||
| 	count uint64 | ||||
| } | ||||
|  | ||||
| func (c *Counter) incr() { | ||||
| 	atomic.AddUint64(&c.count, 1) | ||||
| } | ||||
|  | ||||
| // Reset resets the counter. | ||||
| func (c *Counter) Reset() { | ||||
| 	atomic.StoreUint64(&c.count, 0) | ||||
| } | ||||
|  | ||||
| // Count returns the current count. | ||||
| func (c *Counter) Count() uint64 { | ||||
| 	return atomic.LoadUint64(&c.count) | ||||
| } | ||||
|  | ||||
| func (c *Counter) Write(p []byte) (n int, err error) { | ||||
| 	c.incr() | ||||
| 	return len(p), nil | ||||
| } | ||||
|  | ||||
| // LogCounter creates a LogListener that counts log statements >= the given threshold. | ||||
| func LogCounter(counter *Counter, t1 Threshold) LogListener { | ||||
| 	return func(t2 Threshold) io.Writer { | ||||
| 		if t2 < t1 { | ||||
| 			// Not interested in this threshold. | ||||
| 			return nil | ||||
| 		} | ||||
| 		return counter | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										225
									
								
								vendor/github.com/spf13/jwalterweatherman/notepad.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										225
									
								
								vendor/github.com/spf13/jwalterweatherman/notepad.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,225 +0,0 @@ | ||||
| // Copyright © 2016 Steve Francia <spf@spf13.com>. | ||||
| // | ||||
| // Use of this source code is governed by an MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package jwalterweatherman | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"log" | ||||
| ) | ||||
|  | ||||
| type Threshold int | ||||
|  | ||||
| func (t Threshold) String() string { | ||||
| 	return prefixes[t] | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	LevelTrace Threshold = iota | ||||
| 	LevelDebug | ||||
| 	LevelInfo | ||||
| 	LevelWarn | ||||
| 	LevelError | ||||
| 	LevelCritical | ||||
| 	LevelFatal | ||||
| ) | ||||
|  | ||||
| var prefixes map[Threshold]string = map[Threshold]string{ | ||||
| 	LevelTrace:    "TRACE", | ||||
| 	LevelDebug:    "DEBUG", | ||||
| 	LevelInfo:     "INFO", | ||||
| 	LevelWarn:     "WARN", | ||||
| 	LevelError:    "ERROR", | ||||
| 	LevelCritical: "CRITICAL", | ||||
| 	LevelFatal:    "FATAL", | ||||
| } | ||||
|  | ||||
| // Notepad is where you leave a note! | ||||
| type Notepad struct { | ||||
| 	TRACE    *log.Logger | ||||
| 	DEBUG    *log.Logger | ||||
| 	INFO     *log.Logger | ||||
| 	WARN     *log.Logger | ||||
| 	ERROR    *log.Logger | ||||
| 	CRITICAL *log.Logger | ||||
| 	FATAL    *log.Logger | ||||
|  | ||||
| 	LOG      *log.Logger | ||||
| 	FEEDBACK *Feedback | ||||
|  | ||||
| 	loggers         [7]**log.Logger | ||||
| 	logHandle       io.Writer | ||||
| 	outHandle       io.Writer | ||||
| 	logThreshold    Threshold | ||||
| 	stdoutThreshold Threshold | ||||
| 	prefix          string | ||||
| 	flags           int | ||||
|  | ||||
| 	logListeners []LogListener | ||||
| } | ||||
|  | ||||
| // A LogListener can ble supplied to a Notepad to listen on log writes for a given | ||||
| // threshold. This can be used to capture log events in unit tests and similar. | ||||
| // Note that this function will be invoked once for each log threshold. If | ||||
| // the given threshold is not of interest to you, return nil. | ||||
| // Note that these listeners will receive log events for a given threshold, even | ||||
| // if the current configuration says not to log it. That way you can count ERRORs even | ||||
| // if you don't print them to the console. | ||||
| type LogListener func(t Threshold) io.Writer | ||||
|  | ||||
| // NewNotepad creates a new Notepad. | ||||
| func NewNotepad( | ||||
| 	outThreshold Threshold, | ||||
| 	logThreshold Threshold, | ||||
| 	outHandle, logHandle io.Writer, | ||||
| 	prefix string, flags int, | ||||
| 	logListeners ...LogListener, | ||||
| ) *Notepad { | ||||
|  | ||||
| 	n := &Notepad{logListeners: logListeners} | ||||
|  | ||||
| 	n.loggers = [7]**log.Logger{&n.TRACE, &n.DEBUG, &n.INFO, &n.WARN, &n.ERROR, &n.CRITICAL, &n.FATAL} | ||||
| 	n.outHandle = outHandle | ||||
| 	n.logHandle = logHandle | ||||
| 	n.stdoutThreshold = outThreshold | ||||
| 	n.logThreshold = logThreshold | ||||
|  | ||||
| 	if len(prefix) != 0 { | ||||
| 		n.prefix = "[" + prefix + "] " | ||||
| 	} else { | ||||
| 		n.prefix = "" | ||||
| 	} | ||||
|  | ||||
| 	n.flags = flags | ||||
|  | ||||
| 	n.LOG = log.New(n.logHandle, | ||||
| 		"LOG:   ", | ||||
| 		n.flags) | ||||
| 	n.FEEDBACK = &Feedback{out: log.New(outHandle, "", 0), log: n.LOG} | ||||
|  | ||||
| 	n.init() | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| // init creates the loggers for each level depending on the notepad thresholds. | ||||
| func (n *Notepad) init() { | ||||
| 	logAndOut := io.MultiWriter(n.outHandle, n.logHandle) | ||||
|  | ||||
| 	for t, logger := range n.loggers { | ||||
| 		threshold := Threshold(t) | ||||
| 		prefix := n.prefix + threshold.String() + " " | ||||
|  | ||||
| 		switch { | ||||
| 		case threshold >= n.logThreshold && threshold >= n.stdoutThreshold: | ||||
| 			*logger = log.New(n.createLogWriters(threshold, logAndOut), prefix, n.flags) | ||||
|  | ||||
| 		case threshold >= n.logThreshold: | ||||
| 			*logger = log.New(n.createLogWriters(threshold, n.logHandle), prefix, n.flags) | ||||
|  | ||||
| 		case threshold >= n.stdoutThreshold: | ||||
| 			*logger = log.New(n.createLogWriters(threshold, n.outHandle), prefix, n.flags) | ||||
|  | ||||
| 		default: | ||||
| 			*logger = log.New(n.createLogWriters(threshold, ioutil.Discard), prefix, n.flags) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (n *Notepad) createLogWriters(t Threshold, handle io.Writer) io.Writer { | ||||
| 	if len(n.logListeners) == 0 { | ||||
| 		return handle | ||||
| 	} | ||||
| 	writers := []io.Writer{handle} | ||||
| 	for _, l := range n.logListeners { | ||||
| 		w := l(t) | ||||
| 		if w != nil { | ||||
| 			writers = append(writers, w) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if len(writers) == 1 { | ||||
| 		return handle | ||||
| 	} | ||||
|  | ||||
| 	return io.MultiWriter(writers...) | ||||
| } | ||||
|  | ||||
| // SetLogThreshold changes the threshold above which messages are written to the | ||||
| // log file. | ||||
| func (n *Notepad) SetLogThreshold(threshold Threshold) { | ||||
| 	n.logThreshold = threshold | ||||
| 	n.init() | ||||
| } | ||||
|  | ||||
| // SetLogOutput changes the file where log messages are written. | ||||
| func (n *Notepad) SetLogOutput(handle io.Writer) { | ||||
| 	n.logHandle = handle | ||||
| 	n.init() | ||||
| } | ||||
|  | ||||
| // GetStdoutThreshold returns the defined Treshold for the log logger. | ||||
| func (n *Notepad) GetLogThreshold() Threshold { | ||||
| 	return n.logThreshold | ||||
| } | ||||
|  | ||||
| // SetStdoutThreshold changes the threshold above which messages are written to the | ||||
| // standard output. | ||||
| func (n *Notepad) SetStdoutThreshold(threshold Threshold) { | ||||
| 	n.stdoutThreshold = threshold | ||||
| 	n.init() | ||||
| } | ||||
|  | ||||
| // GetStdoutThreshold returns the Treshold for the stdout logger. | ||||
| func (n *Notepad) GetStdoutThreshold() Threshold { | ||||
| 	return n.stdoutThreshold | ||||
| } | ||||
|  | ||||
| // SetPrefix changes the prefix used by the notepad. Prefixes are displayed between | ||||
| // brackets at the beginning of the line. An empty prefix won't be displayed at all. | ||||
| func (n *Notepad) SetPrefix(prefix string) { | ||||
| 	if len(prefix) != 0 { | ||||
| 		n.prefix = "[" + prefix + "] " | ||||
| 	} else { | ||||
| 		n.prefix = "" | ||||
| 	} | ||||
| 	n.init() | ||||
| } | ||||
|  | ||||
| // SetFlags choose which flags the logger will display (after prefix and message | ||||
| // level). See the package log for more informations on this. | ||||
| func (n *Notepad) SetFlags(flags int) { | ||||
| 	n.flags = flags | ||||
| 	n.init() | ||||
| } | ||||
|  | ||||
| // Feedback writes plainly to the outHandle while | ||||
| // logging with the standard extra information (date, file, etc). | ||||
| type Feedback struct { | ||||
| 	out *log.Logger | ||||
| 	log *log.Logger | ||||
| } | ||||
|  | ||||
| func (fb *Feedback) Println(v ...interface{}) { | ||||
| 	fb.output(fmt.Sprintln(v...)) | ||||
| } | ||||
|  | ||||
| func (fb *Feedback) Printf(format string, v ...interface{}) { | ||||
| 	fb.output(fmt.Sprintf(format, v...)) | ||||
| } | ||||
|  | ||||
| func (fb *Feedback) Print(v ...interface{}) { | ||||
| 	fb.output(fmt.Sprint(v...)) | ||||
| } | ||||
|  | ||||
| func (fb *Feedback) output(s string) { | ||||
| 	if fb.out != nil { | ||||
| 		fb.out.Output(2, s) | ||||
| 	} | ||||
| 	if fb.log != nil { | ||||
| 		fb.log.Output(2, s) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										3
									
								
								vendor/github.com/spf13/viper/.editorconfig
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/spf13/viper/.editorconfig
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -13,3 +13,6 @@ indent_style = tab | ||||
|  | ||||
| [{Makefile,*.mk}] | ||||
| indent_style = tab | ||||
|  | ||||
| [*.nix] | ||||
| indent_size = 2 | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/spf13/viper/.envrc
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/spf13/viper/.envrc
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then | ||||
|   source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" | ||||
| fi | ||||
| use flake . --impure | ||||
							
								
								
									
										3
									
								
								vendor/github.com/spf13/viper/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/spf13/viper/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,4 +1,7 @@ | ||||
| /.devenv/ | ||||
| /.direnv/ | ||||
| /.idea/ | ||||
| /.pre-commit-config.yaml | ||||
| /bin/ | ||||
| /build/ | ||||
| /var/ | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/spf13/viper/.yamlignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/spf13/viper/.yamlignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| # TODO: FIXME | ||||
| /.github/ | ||||
							
								
								
									
										6
									
								
								vendor/github.com/spf13/viper/.yamllint.yaml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/spf13/viper/.yamllint.yaml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| ignore-from-file: [.gitignore, .yamlignore] | ||||
|  | ||||
| extends: default | ||||
|  | ||||
| rules: | ||||
|   line-length: disable | ||||
							
								
								
									
										47
									
								
								vendor/github.com/spf13/viper/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										47
									
								
								vendor/github.com/spf13/viper/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -16,7 +16,7 @@ endif | ||||
|  | ||||
| # Dependency versions | ||||
| GOTESTSUM_VERSION = 1.9.0 | ||||
| GOLANGCI_VERSION = 1.52.2 | ||||
| GOLANGCI_VERSION = 1.53.3 | ||||
|  | ||||
| # Add the ability to override some variables | ||||
| # Use with care | ||||
| @@ -29,11 +29,6 @@ clear: ## Clear the working area and the project | ||||
| .PHONY: check | ||||
| check: test lint ## Run tests and linters | ||||
|  | ||||
| bin/gotestsum: bin/gotestsum-${GOTESTSUM_VERSION} | ||||
| 	@ln -sf gotestsum-${GOTESTSUM_VERSION} bin/gotestsum | ||||
| bin/gotestsum-${GOTESTSUM_VERSION}: | ||||
| 	@mkdir -p bin | ||||
| 	curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum-${GOTESTSUM_VERSION} && chmod +x ./bin/gotestsum-${GOTESTSUM_VERSION} | ||||
|  | ||||
| TEST_PKGS ?= ./... | ||||
| .PHONY: test | ||||
| @@ -44,20 +39,36 @@ test: bin/gotestsum ## Run tests | ||||
| 	@mkdir -p ${BUILD_DIR} | ||||
| 	bin/gotestsum --no-summary=skipped --junitfile ${BUILD_DIR}/coverage.xml --format ${TEST_FORMAT} -- -race -coverprofile=${BUILD_DIR}/coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...) | ||||
|  | ||||
| bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION} | ||||
| 	@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint | ||||
| bin/golangci-lint-${GOLANGCI_VERSION}: | ||||
| 	@mkdir -p bin | ||||
| 	curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION} | ||||
| 	@mv bin/golangci-lint "$@" | ||||
|  | ||||
| .PHONY: lint | ||||
| lint: bin/golangci-lint ## Run linter | ||||
| 	bin/golangci-lint run | ||||
| lint: lint-go lint-yaml | ||||
| lint: ## Run linters | ||||
|  | ||||
| .PHONY: fix | ||||
| fix: bin/golangci-lint ## Fix lint violations | ||||
| 	bin/golangci-lint run --fix | ||||
| .PHONY: lint-go | ||||
| lint-go: | ||||
| 	golangci-lint run $(if ${CI},--out-format github-actions,) | ||||
|  | ||||
| .PHONY: lint-yaml | ||||
| lint-yaml: | ||||
| 	yamllint $(if ${CI},-f github,) --no-warnings . | ||||
|  | ||||
| .PHONY: fmt | ||||
| fmt: ## Format code | ||||
| 	golangci-lint run --fix | ||||
|  | ||||
| deps: bin/golangci-lint bin/gotestsum yamllint | ||||
| deps: ## Install dependencies | ||||
|  | ||||
| bin/gotestsum: | ||||
| 	@mkdir -p bin | ||||
| 	curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum && chmod +x ./bin/gotestsum | ||||
|  | ||||
| bin/golangci-lint: | ||||
| 	@mkdir -p bin | ||||
| 	curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- v${GOLANGCI_VERSION} | ||||
|  | ||||
| .PHONY: yamllint | ||||
| yamllint: | ||||
| 	pip3 install --user yamllint | ||||
|  | ||||
| # Add custom targets here | ||||
| -include custom.mk | ||||
|   | ||||
							
								
								
									
										61
									
								
								vendor/github.com/spf13/viper/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										61
									
								
								vendor/github.com/spf13/viper/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -11,7 +11,7 @@ | ||||
| [](https://github.com/spf13/viper/actions?query=workflow%3ACI) | ||||
| [](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||||
| [](https://goreportcard.com/report/github.com/spf13/viper) | ||||
|  | ||||
|  | ||||
| [](https://pkg.go.dev/mod/github.com/spf13/viper) | ||||
|  | ||||
| **Go configuration with fangs!** | ||||
| @@ -30,6 +30,7 @@ Many Go projects are built using Viper including: | ||||
| * [Meshery](https://github.com/meshery/meshery) | ||||
| * [Bearer](https://github.com/bearer/bearer) | ||||
| * [Coder](https://github.com/coder/coder) | ||||
| * [Vitess](https://vitess.io/) | ||||
|  | ||||
|  | ||||
| ## Install | ||||
| @@ -140,7 +141,7 @@ if err := viper.ReadInConfig(); err != nil { | ||||
| // Config file found and successfully parsed | ||||
| ``` | ||||
|  | ||||
| *NOTE [since 1.6]:* You can also have a file without an extension and specify the format programmaticaly. For those configuration files that lie in the home of the user without any extension like `.bashrc` | ||||
| *NOTE [since 1.6]:* You can also have a file without an extension and specify the format programmatically. For those configuration files that lie in the home of the user without any extension like `.bashrc` | ||||
|  | ||||
| ### Writing Config Files | ||||
|  | ||||
| @@ -221,6 +222,7 @@ These could be from a command line flag, or from your own application logic. | ||||
| ```go | ||||
| viper.Set("Verbose", true) | ||||
| viper.Set("LogFile", LogFile) | ||||
| viper.Set("host.port", 5899)   // set subset | ||||
| ``` | ||||
|  | ||||
| ### Registering and Using Aliases | ||||
| @@ -487,6 +489,15 @@ err := viper.ReadRemoteConfig() | ||||
|  | ||||
| Of course, you're allowed to use `SecureRemoteProvider` also | ||||
|  | ||||
|  | ||||
| #### NATS | ||||
|  | ||||
| ```go | ||||
| viper.AddRemoteProvider("nats", "nats://127.0.0.1:4222", "myapp.config") | ||||
| viper.SetConfigType("json") | ||||
| err := viper.ReadRemoteConfig() | ||||
| ``` | ||||
|  | ||||
| ### Remote Key/Value Store Example - Encrypted | ||||
|  | ||||
| ```go | ||||
| @@ -534,19 +545,19 @@ go func(){ | ||||
| In Viper, there are a few ways to get a value depending on the value’s type. | ||||
| The following functions and methods exist: | ||||
|  | ||||
|  * `Get(key string) : interface{}` | ||||
|  * `Get(key string) : any` | ||||
|  * `GetBool(key string) : bool` | ||||
|  * `GetFloat64(key string) : float64` | ||||
|  * `GetInt(key string) : int` | ||||
|  * `GetIntSlice(key string) : []int` | ||||
|  * `GetString(key string) : string` | ||||
|  * `GetStringMap(key string) : map[string]interface{}` | ||||
|  * `GetStringMap(key string) : map[string]any` | ||||
|  * `GetStringMapString(key string) : map[string]string` | ||||
|  * `GetStringSlice(key string) : []string` | ||||
|  * `GetTime(key string) : time.Time` | ||||
|  * `GetDuration(key string) : time.Duration` | ||||
|  * `IsSet(key string) : bool` | ||||
|  * `AllSettings() : map[string]interface{}` | ||||
|  * `AllSettings() : map[string]any` | ||||
|  | ||||
| One important thing to recognize is that each Get function will return a zero | ||||
| value if it’s not found. To check if a given key exists, the `IsSet()` method | ||||
| @@ -709,8 +720,8 @@ etc. | ||||
|  | ||||
| There are two methods to do this: | ||||
|  | ||||
|  * `Unmarshal(rawVal interface{}) : error` | ||||
|  * `UnmarshalKey(key string, rawVal interface{}) : error` | ||||
|  * `Unmarshal(rawVal any) : error` | ||||
|  * `UnmarshalKey(key string, rawVal any) : error` | ||||
|  | ||||
| Example: | ||||
|  | ||||
| @@ -735,9 +746,9 @@ you have to change the delimiter: | ||||
| ```go | ||||
| v := viper.NewWithOptions(viper.KeyDelimiter("::")) | ||||
|  | ||||
| v.SetDefault("chart::values", map[string]interface{}{ | ||||
| 	"ingress": map[string]interface{}{ | ||||
| 		"annotations": map[string]interface{}{ | ||||
| v.SetDefault("chart::values", map[string]any{ | ||||
| 	"ingress": map[string]any{ | ||||
| 		"annotations": map[string]any{ | ||||
| 			"traefik.frontend.rule.type":                 "PathPrefix", | ||||
| 			"traefik.ingress.kubernetes.io/ssl-redirect": "true", | ||||
| 		}, | ||||
| @@ -746,7 +757,7 @@ v.SetDefault("chart::values", map[string]interface{}{ | ||||
|  | ||||
| type config struct { | ||||
| 	Chart struct{ | ||||
| 		Values map[string]interface{} | ||||
| 		Values map[string]any | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -882,3 +893,31 @@ No, you will need to synchronize access to the viper yourself (for example by us | ||||
| ## Troubleshooting | ||||
|  | ||||
| See [TROUBLESHOOTING.md](TROUBLESHOOTING.md). | ||||
|  | ||||
| ## Development | ||||
|  | ||||
| **For an optimal developer experience, it is recommended to install [Nix](https://nixos.org/download.html) and [direnv](https://direnv.net/docs/installation.html).** | ||||
|  | ||||
| _Alternatively, install [Go](https://go.dev/dl/) on your computer then run `make deps` to install the rest of the dependencies._ | ||||
|  | ||||
| Run the test suite: | ||||
|  | ||||
| ```shell | ||||
| make test | ||||
| ``` | ||||
|  | ||||
| Run linters: | ||||
|  | ||||
| ```shell | ||||
| make lint # pass -j option to run them in parallel | ||||
| ``` | ||||
|  | ||||
| Some linter violations can automatically be fixed: | ||||
|  | ||||
| ```shell | ||||
| make fmt | ||||
| ``` | ||||
|  | ||||
| ## License | ||||
|  | ||||
| The project is licensed under the [MIT License](LICENSE). | ||||
|   | ||||
							
								
								
									
										11
									
								
								vendor/github.com/spf13/viper/experimental_logger.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								vendor/github.com/spf13/viper/experimental_logger.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,11 +0,0 @@ | ||||
| //go:build viper_logger | ||||
| // +build viper_logger | ||||
|  | ||||
| package viper | ||||
|  | ||||
| // WithLogger sets a custom logger. | ||||
| func WithLogger(l Logger) Option { | ||||
| 	return optionFunc(func(v *Viper) { | ||||
| 		v.logger = l | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										2
									
								
								vendor/github.com/spf13/viper/flags.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/spf13/viper/flags.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -30,7 +30,7 @@ func (p pflagValueSet) VisitAll(fn func(flag FlagValue)) { | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // pflagValue is a wrapper aroung *pflag.flag | ||||
| // pflagValue is a wrapper around *pflag.flag | ||||
| // that implements FlagValue | ||||
| type pflagValue struct { | ||||
| 	flag *pflag.Flag | ||||
|   | ||||
							
								
								
									
										255
									
								
								vendor/github.com/spf13/viper/flake.lock
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										255
									
								
								vendor/github.com/spf13/viper/flake.lock
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,255 @@ | ||||
| { | ||||
|   "nodes": { | ||||
|     "devenv": { | ||||
|       "inputs": { | ||||
|         "flake-compat": "flake-compat", | ||||
|         "nix": "nix", | ||||
|         "nixpkgs": "nixpkgs", | ||||
|         "pre-commit-hooks": "pre-commit-hooks" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1687972261, | ||||
|         "narHash": "sha256-+mxvZfwMVoaZYETmuQWqTi/7T9UKoAE+WpdSQkOVJ2g=", | ||||
|         "owner": "cachix", | ||||
|         "repo": "devenv", | ||||
|         "rev": "e85df562088573305e55906eaa964341f8cb0d9f", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "cachix", | ||||
|         "repo": "devenv", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-compat": { | ||||
|       "flake": false, | ||||
|       "locked": { | ||||
|         "lastModified": 1673956053, | ||||
|         "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", | ||||
|         "owner": "edolstra", | ||||
|         "repo": "flake-compat", | ||||
|         "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "edolstra", | ||||
|         "repo": "flake-compat", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-parts": { | ||||
|       "inputs": { | ||||
|         "nixpkgs-lib": "nixpkgs-lib" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1687762428, | ||||
|         "narHash": "sha256-DIf7mi45PKo+s8dOYF+UlXHzE0Wl/+k3tXUyAoAnoGE=", | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "flake-parts", | ||||
|         "rev": "37dd7bb15791c86d55c5121740a1887ab55ee836", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "flake-parts", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "flake-utils": { | ||||
|       "locked": { | ||||
|         "lastModified": 1667395993, | ||||
|         "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", | ||||
|         "owner": "numtide", | ||||
|         "repo": "flake-utils", | ||||
|         "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "numtide", | ||||
|         "repo": "flake-utils", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "gitignore": { | ||||
|       "inputs": { | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "pre-commit-hooks", | ||||
|           "nixpkgs" | ||||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1660459072, | ||||
|         "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "gitignore.nix", | ||||
|         "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "gitignore.nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "lowdown-src": { | ||||
|       "flake": false, | ||||
|       "locked": { | ||||
|         "lastModified": 1633514407, | ||||
|         "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", | ||||
|         "owner": "kristapsdz", | ||||
|         "repo": "lowdown", | ||||
|         "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "kristapsdz", | ||||
|         "repo": "lowdown", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nix": { | ||||
|       "inputs": { | ||||
|         "lowdown-src": "lowdown-src", | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "nixpkgs" | ||||
|         ], | ||||
|         "nixpkgs-regression": "nixpkgs-regression" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1676545802, | ||||
|         "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=", | ||||
|         "owner": "domenkozar", | ||||
|         "repo": "nix", | ||||
|         "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "domenkozar", | ||||
|         "ref": "relaxed-flakes", | ||||
|         "repo": "nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs": { | ||||
|       "locked": { | ||||
|         "lastModified": 1678875422, | ||||
|         "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixpkgs-unstable", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-lib": { | ||||
|       "locked": { | ||||
|         "dir": "lib", | ||||
|         "lastModified": 1685564631, | ||||
|         "narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "dir": "lib", | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixos-unstable", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-regression": { | ||||
|       "locked": { | ||||
|         "lastModified": 1643052045, | ||||
|         "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs-stable": { | ||||
|       "locked": { | ||||
|         "lastModified": 1678872516, | ||||
|         "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixos-22.11", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "nixpkgs_2": { | ||||
|       "locked": { | ||||
|         "lastModified": 1687886075, | ||||
|         "narHash": "sha256-PeayJDDDy+uw1Ats4moZnRdL1OFuZm1Tj+KiHlD67+o=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "a565059a348422af5af9026b5174dc5c0dcefdae", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "NixOS", | ||||
|         "ref": "nixpkgs-unstable", | ||||
|         "repo": "nixpkgs", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "pre-commit-hooks": { | ||||
|       "inputs": { | ||||
|         "flake-compat": [ | ||||
|           "devenv", | ||||
|           "flake-compat" | ||||
|         ], | ||||
|         "flake-utils": "flake-utils", | ||||
|         "gitignore": "gitignore", | ||||
|         "nixpkgs": [ | ||||
|           "devenv", | ||||
|           "nixpkgs" | ||||
|         ], | ||||
|         "nixpkgs-stable": "nixpkgs-stable" | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1686050334, | ||||
|         "narHash": "sha256-R0mczWjDzBpIvM3XXhO908X5e2CQqjyh/gFbwZk/7/Q=", | ||||
|         "owner": "cachix", | ||||
|         "repo": "pre-commit-hooks.nix", | ||||
|         "rev": "6881eb2ae5d8a3516e34714e7a90d9d95914c4dc", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "cachix", | ||||
|         "repo": "pre-commit-hooks.nix", | ||||
|         "type": "github" | ||||
|       } | ||||
|     }, | ||||
|     "root": { | ||||
|       "inputs": { | ||||
|         "devenv": "devenv", | ||||
|         "flake-parts": "flake-parts", | ||||
|         "nixpkgs": "nixpkgs_2" | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
|   "root": "root", | ||||
|   "version": 7 | ||||
| } | ||||
							
								
								
									
										56
									
								
								vendor/github.com/spf13/viper/flake.nix
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								vendor/github.com/spf13/viper/flake.nix
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| { | ||||
|   description = "Viper"; | ||||
|  | ||||
|   inputs = { | ||||
|     nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||||
|     flake-parts.url = "github:hercules-ci/flake-parts"; | ||||
|     devenv.url = "github:cachix/devenv"; | ||||
|   }; | ||||
|  | ||||
|   outputs = inputs@{ flake-parts, ... }: | ||||
|     flake-parts.lib.mkFlake { inherit inputs; } { | ||||
|       imports = [ | ||||
|         inputs.devenv.flakeModule | ||||
|       ]; | ||||
|  | ||||
|       systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; | ||||
|  | ||||
|       perSystem = { config, self', inputs', pkgs, system, ... }: rec { | ||||
|         devenv.shells = { | ||||
|           default = { | ||||
|             languages = { | ||||
|               go.enable = true; | ||||
|             }; | ||||
|  | ||||
|             pre-commit.hooks = { | ||||
|               nixpkgs-fmt.enable = true; | ||||
|               yamllint.enable = true; | ||||
|             }; | ||||
|  | ||||
|             packages = with pkgs; [ | ||||
|               gnumake | ||||
|  | ||||
|               golangci-lint | ||||
|               yamllint | ||||
|             ]; | ||||
|  | ||||
|             scripts = { | ||||
|               versions.exec = '' | ||||
|                 go version | ||||
|                 golangci-lint version | ||||
|               ''; | ||||
|             }; | ||||
|  | ||||
|             enterShell = '' | ||||
|               versions | ||||
|             ''; | ||||
|  | ||||
|             # https://github.com/cachix/devenv/issues/528#issuecomment-1556108767 | ||||
|             containers = pkgs.lib.mkForce { }; | ||||
|           }; | ||||
|  | ||||
|           ci = devenv.shells.default; | ||||
|         }; | ||||
|       }; | ||||
|     }; | ||||
| } | ||||
							
								
								
									
										65
									
								
								vendor/github.com/spf13/viper/fs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										65
									
								
								vendor/github.com/spf13/viper/fs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,65 +0,0 @@ | ||||
| //go:build go1.16 && finder | ||||
| // +build go1.16,finder | ||||
|  | ||||
| package viper | ||||
|  | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"io/fs" | ||||
| 	"path" | ||||
| ) | ||||
|  | ||||
| type finder struct { | ||||
| 	paths      []string | ||||
| 	fileNames  []string | ||||
| 	extensions []string | ||||
|  | ||||
| 	withoutExtension bool | ||||
| } | ||||
|  | ||||
| func (f finder) Find(fsys fs.FS) (string, error) { | ||||
| 	for _, searchPath := range f.paths { | ||||
| 		for _, fileName := range f.fileNames { | ||||
| 			for _, extension := range f.extensions { | ||||
| 				filePath := path.Join(searchPath, fileName+"."+extension) | ||||
|  | ||||
| 				ok, err := fileExists(fsys, filePath) | ||||
| 				if err != nil { | ||||
| 					return "", err | ||||
| 				} | ||||
|  | ||||
| 				if ok { | ||||
| 					return filePath, nil | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if f.withoutExtension { | ||||
| 				filePath := path.Join(searchPath, fileName) | ||||
|  | ||||
| 				ok, err := fileExists(fsys, filePath) | ||||
| 				if err != nil { | ||||
| 					return "", err | ||||
| 				} | ||||
|  | ||||
| 				if ok { | ||||
| 					return filePath, nil | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return "", nil | ||||
| } | ||||
|  | ||||
| func fileExists(fsys fs.FS, filePath string) (bool, error) { | ||||
| 	fileInfo, err := fs.Stat(fsys, filePath) | ||||
| 	if err == nil { | ||||
| 		return !fileInfo.IsDir(), nil | ||||
| 	} | ||||
|  | ||||
| 	if errors.Is(err, fs.ErrNotExist) { | ||||
| 		return false, nil | ||||
| 	} | ||||
|  | ||||
| 	return false, err | ||||
| } | ||||
							
								
								
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/decoder.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/decoder.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -5,9 +5,9 @@ import ( | ||||
| ) | ||||
|  | ||||
| // Decoder decodes the contents of b into v. | ||||
| // It's primarily used for decoding contents of a file into a map[string]interface{}. | ||||
| // It's primarily used for decoding contents of a file into a map[string]any. | ||||
| type Decoder interface { | ||||
| 	Decode(b []byte, v map[string]interface{}) error | ||||
| 	Decode(b []byte, v map[string]any) error | ||||
| } | ||||
|  | ||||
| const ( | ||||
| @@ -48,7 +48,7 @@ func (e *DecoderRegistry) RegisterDecoder(format string, enc Decoder) error { | ||||
| } | ||||
|  | ||||
| // Decode calls the underlying Decoder based on the format. | ||||
| func (e *DecoderRegistry) Decode(format string, b []byte, v map[string]interface{}) error { | ||||
| func (e *DecoderRegistry) Decode(format string, b []byte, v map[string]any) error { | ||||
| 	e.mu.RLock() | ||||
| 	decoder, ok := e.decoders[format] | ||||
| 	e.mu.RUnlock() | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/dotenv/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/dotenv/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -15,8 +15,8 @@ const keyDelimiter = "_" | ||||
| // (commonly called as dotenv format). | ||||
| type Codec struct{} | ||||
|  | ||||
| func (Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| 	flattened := map[string]interface{}{} | ||||
| func (Codec) Encode(v map[string]any) ([]byte, error) { | ||||
| 	flattened := map[string]any{} | ||||
|  | ||||
| 	flattened = flattenAndMergeMap(flattened, v, "", keyDelimiter) | ||||
|  | ||||
| @@ -40,7 +40,7 @@ func (Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| 	return buf.Bytes(), nil | ||||
| } | ||||
|  | ||||
| func (Codec) Decode(b []byte, v map[string]interface{}) error { | ||||
| func (Codec) Decode(b []byte, v map[string]any) error { | ||||
| 	var buf bytes.Buffer | ||||
|  | ||||
| 	_, err := buf.Write(b) | ||||
|   | ||||
							
								
								
									
										16
									
								
								vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -7,27 +7,27 @@ import ( | ||||
| ) | ||||
|  | ||||
| // flattenAndMergeMap recursively flattens the given map into a new map | ||||
| // Code is based on the function with the same name in tha main package. | ||||
| // Code is based on the function with the same name in the main package. | ||||
| // TODO: move it to a common place | ||||
| func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{}, prefix string, delimiter string) map[string]interface{} { | ||||
| func flattenAndMergeMap(shadow map[string]any, m map[string]any, prefix string, delimiter string) map[string]any { | ||||
| 	if shadow != nil && prefix != "" && shadow[prefix] != nil { | ||||
| 		// prefix is shadowed => nothing more to flatten | ||||
| 		return shadow | ||||
| 	} | ||||
| 	if shadow == nil { | ||||
| 		shadow = make(map[string]interface{}) | ||||
| 		shadow = make(map[string]any) | ||||
| 	} | ||||
|  | ||||
| 	var m2 map[string]interface{} | ||||
| 	var m2 map[string]any | ||||
| 	if prefix != "" { | ||||
| 		prefix += delimiter | ||||
| 	} | ||||
| 	for k, val := range m { | ||||
| 		fullKey := prefix + k | ||||
| 		switch val.(type) { | ||||
| 		case map[string]interface{}: | ||||
| 			m2 = val.(map[string]interface{}) | ||||
| 		case map[interface{}]interface{}: | ||||
| 		switch val := val.(type) { | ||||
| 		case map[string]any: | ||||
| 			m2 = val | ||||
| 		case map[any]any: | ||||
| 			m2 = cast.ToStringMap(val) | ||||
| 		default: | ||||
| 			// immediate value | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/encoder.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/encoder.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -5,9 +5,9 @@ import ( | ||||
| ) | ||||
|  | ||||
| // Encoder encodes the contents of v into a byte representation. | ||||
| // It's primarily used for encoding a map[string]interface{} into a file format. | ||||
| // It's primarily used for encoding a map[string]any into a file format. | ||||
| type Encoder interface { | ||||
| 	Encode(v map[string]interface{}) ([]byte, error) | ||||
| 	Encode(v map[string]any) ([]byte, error) | ||||
| } | ||||
|  | ||||
| const ( | ||||
| @@ -47,7 +47,7 @@ func (e *EncoderRegistry) RegisterEncoder(format string, enc Encoder) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (e *EncoderRegistry) Encode(format string, v map[string]interface{}) ([]byte, error) { | ||||
| func (e *EncoderRegistry) Encode(format string, v map[string]any) ([]byte, error) { | ||||
| 	e.mu.RLock() | ||||
| 	encoder, ok := e.encoders[format] | ||||
| 	e.mu.RUnlock() | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/spf13/viper/internal/encoding/hcl/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/spf13/viper/internal/encoding/hcl/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -12,7 +12,7 @@ import ( | ||||
| // TODO: add printer config to the codec? | ||||
| type Codec struct{} | ||||
|  | ||||
| func (Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| func (Codec) Encode(v map[string]any) ([]byte, error) { | ||||
| 	b, err := json.Marshal(v) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -35,6 +35,6 @@ func (Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| 	return buf.Bytes(), nil | ||||
| } | ||||
|  | ||||
| func (Codec) Decode(b []byte, v map[string]interface{}) error { | ||||
| func (Codec) Decode(b []byte, v map[string]any) error { | ||||
| 	return hcl.Unmarshal(b, &v) | ||||
| } | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/ini/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/ini/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,11 +19,11 @@ type Codec struct { | ||||
| 	LoadOptions  LoadOptions | ||||
| } | ||||
|  | ||||
| func (c Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| func (c Codec) Encode(v map[string]any) ([]byte, error) { | ||||
| 	cfg := ini.Empty() | ||||
| 	ini.PrettyFormat = false | ||||
|  | ||||
| 	flattened := map[string]interface{}{} | ||||
| 	flattened := map[string]any{} | ||||
|  | ||||
| 	flattened = flattenAndMergeMap(flattened, v, "", c.keyDelimiter()) | ||||
|  | ||||
| @@ -62,7 +62,7 @@ func (c Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| 	return buf.Bytes(), nil | ||||
| } | ||||
|  | ||||
| func (c Codec) Decode(b []byte, v map[string]interface{}) error { | ||||
| func (c Codec) Decode(b []byte, v map[string]any) error { | ||||
| 	cfg := ini.Empty(c.LoadOptions) | ||||
|  | ||||
| 	err := cfg.Append(b) | ||||
|   | ||||
							
								
								
									
										24
									
								
								vendor/github.com/spf13/viper/internal/encoding/ini/map_utils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								vendor/github.com/spf13/viper/internal/encoding/ini/map_utils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -15,22 +15,22 @@ import ( | ||||
| // In case intermediate keys do not exist, or map to a non-map value, | ||||
| // a new map is created and inserted, and the search continues from there: | ||||
| // the initial map "m" may be modified! | ||||
| func deepSearch(m map[string]interface{}, path []string) map[string]interface{} { | ||||
| func deepSearch(m map[string]any, path []string) map[string]any { | ||||
| 	for _, k := range path { | ||||
| 		m2, ok := m[k] | ||||
| 		if !ok { | ||||
| 			// intermediate key does not exist | ||||
| 			// => create it and continue from there | ||||
| 			m3 := make(map[string]interface{}) | ||||
| 			m3 := make(map[string]any) | ||||
| 			m[k] = m3 | ||||
| 			m = m3 | ||||
| 			continue | ||||
| 		} | ||||
| 		m3, ok := m2.(map[string]interface{}) | ||||
| 		m3, ok := m2.(map[string]any) | ||||
| 		if !ok { | ||||
| 			// intermediate key is a value | ||||
| 			// => replace with a new map | ||||
| 			m3 = make(map[string]interface{}) | ||||
| 			m3 = make(map[string]any) | ||||
| 			m[k] = m3 | ||||
| 		} | ||||
| 		// continue search from here | ||||
| @@ -40,27 +40,27 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{} | ||||
| } | ||||
|  | ||||
| // flattenAndMergeMap recursively flattens the given map into a new map | ||||
| // Code is based on the function with the same name in tha main package. | ||||
| // Code is based on the function with the same name in the main package. | ||||
| // TODO: move it to a common place | ||||
| func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{}, prefix string, delimiter string) map[string]interface{} { | ||||
| func flattenAndMergeMap(shadow map[string]any, m map[string]any, prefix string, delimiter string) map[string]any { | ||||
| 	if shadow != nil && prefix != "" && shadow[prefix] != nil { | ||||
| 		// prefix is shadowed => nothing more to flatten | ||||
| 		return shadow | ||||
| 	} | ||||
| 	if shadow == nil { | ||||
| 		shadow = make(map[string]interface{}) | ||||
| 		shadow = make(map[string]any) | ||||
| 	} | ||||
|  | ||||
| 	var m2 map[string]interface{} | ||||
| 	var m2 map[string]any | ||||
| 	if prefix != "" { | ||||
| 		prefix += delimiter | ||||
| 	} | ||||
| 	for k, val := range m { | ||||
| 		fullKey := prefix + k | ||||
| 		switch val.(type) { | ||||
| 		case map[string]interface{}: | ||||
| 			m2 = val.(map[string]interface{}) | ||||
| 		case map[interface{}]interface{}: | ||||
| 		switch val := val.(type) { | ||||
| 		case map[string]any: | ||||
| 			m2 = val | ||||
| 		case map[any]any: | ||||
| 			m2 = cast.ToStringMap(val) | ||||
| 		default: | ||||
| 			// immediate value | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/javaproperties/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/spf13/viper/internal/encoding/javaproperties/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,12 +20,12 @@ type Codec struct { | ||||
| 	Properties *properties.Properties | ||||
| } | ||||
|  | ||||
| func (c *Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| func (c *Codec) Encode(v map[string]any) ([]byte, error) { | ||||
| 	if c.Properties == nil { | ||||
| 		c.Properties = properties.NewProperties() | ||||
| 	} | ||||
|  | ||||
| 	flattened := map[string]interface{}{} | ||||
| 	flattened := map[string]any{} | ||||
|  | ||||
| 	flattened = flattenAndMergeMap(flattened, v, "", c.keyDelimiter()) | ||||
|  | ||||
| @@ -54,7 +54,7 @@ func (c *Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| 	return buf.Bytes(), nil | ||||
| } | ||||
|  | ||||
| func (c *Codec) Decode(b []byte, v map[string]interface{}) error { | ||||
| func (c *Codec) Decode(b []byte, v map[string]any) error { | ||||
| 	var err error | ||||
| 	c.Properties, err = properties.Load(b, properties.UTF8) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										24
									
								
								vendor/github.com/spf13/viper/internal/encoding/javaproperties/map_utils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								vendor/github.com/spf13/viper/internal/encoding/javaproperties/map_utils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -15,22 +15,22 @@ import ( | ||||
| // In case intermediate keys do not exist, or map to a non-map value, | ||||
| // a new map is created and inserted, and the search continues from there: | ||||
| // the initial map "m" may be modified! | ||||
| func deepSearch(m map[string]interface{}, path []string) map[string]interface{} { | ||||
| func deepSearch(m map[string]any, path []string) map[string]any { | ||||
| 	for _, k := range path { | ||||
| 		m2, ok := m[k] | ||||
| 		if !ok { | ||||
| 			// intermediate key does not exist | ||||
| 			// => create it and continue from there | ||||
| 			m3 := make(map[string]interface{}) | ||||
| 			m3 := make(map[string]any) | ||||
| 			m[k] = m3 | ||||
| 			m = m3 | ||||
| 			continue | ||||
| 		} | ||||
| 		m3, ok := m2.(map[string]interface{}) | ||||
| 		m3, ok := m2.(map[string]any) | ||||
| 		if !ok { | ||||
| 			// intermediate key is a value | ||||
| 			// => replace with a new map | ||||
| 			m3 = make(map[string]interface{}) | ||||
| 			m3 = make(map[string]any) | ||||
| 			m[k] = m3 | ||||
| 		} | ||||
| 		// continue search from here | ||||
| @@ -40,27 +40,27 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{} | ||||
| } | ||||
|  | ||||
| // flattenAndMergeMap recursively flattens the given map into a new map | ||||
| // Code is based on the function with the same name in tha main package. | ||||
| // Code is based on the function with the same name in the main package. | ||||
| // TODO: move it to a common place | ||||
| func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{}, prefix string, delimiter string) map[string]interface{} { | ||||
| func flattenAndMergeMap(shadow map[string]any, m map[string]any, prefix string, delimiter string) map[string]any { | ||||
| 	if shadow != nil && prefix != "" && shadow[prefix] != nil { | ||||
| 		// prefix is shadowed => nothing more to flatten | ||||
| 		return shadow | ||||
| 	} | ||||
| 	if shadow == nil { | ||||
| 		shadow = make(map[string]interface{}) | ||||
| 		shadow = make(map[string]any) | ||||
| 	} | ||||
|  | ||||
| 	var m2 map[string]interface{} | ||||
| 	var m2 map[string]any | ||||
| 	if prefix != "" { | ||||
| 		prefix += delimiter | ||||
| 	} | ||||
| 	for k, val := range m { | ||||
| 		fullKey := prefix + k | ||||
| 		switch val.(type) { | ||||
| 		case map[string]interface{}: | ||||
| 			m2 = val.(map[string]interface{}) | ||||
| 		case map[interface{}]interface{}: | ||||
| 		switch val := val.(type) { | ||||
| 		case map[string]any: | ||||
| 			m2 = val | ||||
| 		case map[any]any: | ||||
| 			m2 = cast.ToStringMap(val) | ||||
| 		default: | ||||
| 			// immediate value | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/spf13/viper/internal/encoding/json/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/spf13/viper/internal/encoding/json/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -7,11 +7,11 @@ import ( | ||||
| // Codec implements the encoding.Encoder and encoding.Decoder interfaces for JSON encoding. | ||||
| type Codec struct{} | ||||
|  | ||||
| func (Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| func (Codec) Encode(v map[string]any) ([]byte, error) { | ||||
| 	// TODO: expose prefix and indent in the Codec as setting? | ||||
| 	return json.MarshalIndent(v, "", "  ") | ||||
| } | ||||
|  | ||||
| func (Codec) Decode(b []byte, v map[string]interface{}) error { | ||||
| func (Codec) Decode(b []byte, v map[string]any) error { | ||||
| 	return json.Unmarshal(b, &v) | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/spf13/viper/internal/encoding/toml/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/spf13/viper/internal/encoding/toml/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -7,10 +7,10 @@ import ( | ||||
| // Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding. | ||||
| type Codec struct{} | ||||
|  | ||||
| func (Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| func (Codec) Encode(v map[string]any) ([]byte, error) { | ||||
| 	return toml.Marshal(v) | ||||
| } | ||||
|  | ||||
| func (Codec) Decode(b []byte, v map[string]interface{}) error { | ||||
| func (Codec) Decode(b []byte, v map[string]any) error { | ||||
| 	return toml.Unmarshal(b, &v) | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/spf13/viper/internal/encoding/yaml/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/spf13/viper/internal/encoding/yaml/codec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -5,10 +5,10 @@ import "gopkg.in/yaml.v3" | ||||
| // Codec implements the encoding.Encoder and encoding.Decoder interfaces for YAML encoding. | ||||
| type Codec struct{} | ||||
|  | ||||
| func (Codec) Encode(v map[string]interface{}) ([]byte, error) { | ||||
| func (Codec) Encode(v map[string]any) ([]byte, error) { | ||||
| 	return yaml.Marshal(v) | ||||
| } | ||||
|  | ||||
| func (Codec) Decode(b []byte, v map[string]interface{}) error { | ||||
| func (Codec) Decode(b []byte, v map[string]any) error { | ||||
| 	return yaml.Unmarshal(b, &v) | ||||
| } | ||||
|   | ||||
							
								
								
									
										59
									
								
								vendor/github.com/spf13/viper/logger.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										59
									
								
								vendor/github.com/spf13/viper/logger.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,77 +1,68 @@ | ||||
| package viper | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"context" | ||||
|  | ||||
| 	jww "github.com/spf13/jwalterweatherman" | ||||
| 	slog "github.com/sagikazarmark/slog-shim" | ||||
| ) | ||||
|  | ||||
| // Logger is a unified interface for various logging use cases and practices, including: | ||||
| //   - leveled logging | ||||
| //   - structured logging | ||||
| // | ||||
| // Deprecated: use `log/slog` instead. | ||||
| type Logger interface { | ||||
| 	// Trace logs a Trace event. | ||||
| 	// | ||||
| 	// Even more fine-grained information than Debug events. | ||||
| 	// Loggers not supporting this level should fall back to Debug. | ||||
| 	Trace(msg string, keyvals ...interface{}) | ||||
| 	Trace(msg string, keyvals ...any) | ||||
|  | ||||
| 	// Debug logs a Debug event. | ||||
| 	// | ||||
| 	// A verbose series of information events. | ||||
| 	// They are useful when debugging the system. | ||||
| 	Debug(msg string, keyvals ...interface{}) | ||||
| 	Debug(msg string, keyvals ...any) | ||||
|  | ||||
| 	// Info logs an Info event. | ||||
| 	// | ||||
| 	// General information about what's happening inside the system. | ||||
| 	Info(msg string, keyvals ...interface{}) | ||||
| 	Info(msg string, keyvals ...any) | ||||
|  | ||||
| 	// Warn logs a Warn(ing) event. | ||||
| 	// | ||||
| 	// Non-critical events that should be looked at. | ||||
| 	Warn(msg string, keyvals ...interface{}) | ||||
| 	Warn(msg string, keyvals ...any) | ||||
|  | ||||
| 	// Error logs an Error event. | ||||
| 	// | ||||
| 	// Critical events that require immediate attention. | ||||
| 	// Loggers commonly provide Fatal and Panic levels above Error level, | ||||
| 	// but exiting and panicing is out of scope for a logging library. | ||||
| 	Error(msg string, keyvals ...interface{}) | ||||
| 	// but exiting and panicking is out of scope for a logging library. | ||||
| 	Error(msg string, keyvals ...any) | ||||
| } | ||||
|  | ||||
| type jwwLogger struct{} | ||||
|  | ||||
| func (jwwLogger) Trace(msg string, keyvals ...interface{}) { | ||||
| 	jww.TRACE.Printf(jwwLogMessage(msg, keyvals...)) | ||||
| // WithLogger sets a custom logger. | ||||
| func WithLogger(l *slog.Logger) Option { | ||||
| 	return optionFunc(func(v *Viper) { | ||||
| 		v.logger = l | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func (jwwLogger) Debug(msg string, keyvals ...interface{}) { | ||||
| 	jww.DEBUG.Printf(jwwLogMessage(msg, keyvals...)) | ||||
| type discardHandler struct{} | ||||
|  | ||||
| func (n *discardHandler) Enabled(_ context.Context, _ slog.Level) bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func (jwwLogger) Info(msg string, keyvals ...interface{}) { | ||||
| 	jww.INFO.Printf(jwwLogMessage(msg, keyvals...)) | ||||
| func (n *discardHandler) Handle(_ context.Context, _ slog.Record) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (jwwLogger) Warn(msg string, keyvals ...interface{}) { | ||||
| 	jww.WARN.Printf(jwwLogMessage(msg, keyvals...)) | ||||
| func (n *discardHandler) WithAttrs(_ []slog.Attr) slog.Handler { | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (jwwLogger) Error(msg string, keyvals ...interface{}) { | ||||
| 	jww.ERROR.Printf(jwwLogMessage(msg, keyvals...)) | ||||
| } | ||||
|  | ||||
| func jwwLogMessage(msg string, keyvals ...interface{}) string { | ||||
| 	out := msg | ||||
|  | ||||
| 	if len(keyvals) > 0 && len(keyvals)%2 == 1 { | ||||
| 		keyvals = append(keyvals, nil) | ||||
| 	} | ||||
|  | ||||
| 	for i := 0; i <= len(keyvals)-2; i += 2 { | ||||
| 		out = fmt.Sprintf("%s %v=%v", out, keyvals[i], keyvals[i+1]) | ||||
| 	} | ||||
|  | ||||
| 	return out | ||||
| func (n *discardHandler) WithGroup(_ string) slog.Handler { | ||||
| 	return n | ||||
| } | ||||
|   | ||||
							
								
								
									
										45
									
								
								vendor/github.com/spf13/viper/util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										45
									
								
								vendor/github.com/spf13/viper/util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -18,6 +18,7 @@ import ( | ||||
| 	"strings" | ||||
| 	"unicode" | ||||
|  | ||||
| 	slog "github.com/sagikazarmark/slog-shim" | ||||
| 	"github.com/spf13/cast" | ||||
| ) | ||||
|  | ||||
| @@ -38,11 +39,11 @@ func (pe ConfigParseError) Unwrap() error { | ||||
|  | ||||
| // toCaseInsensitiveValue checks if the value is a  map; | ||||
| // if so, create a copy and lower-case the keys recursively. | ||||
| func toCaseInsensitiveValue(value interface{}) interface{} { | ||||
| func toCaseInsensitiveValue(value any) any { | ||||
| 	switch v := value.(type) { | ||||
| 	case map[interface{}]interface{}: | ||||
| 	case map[any]any: | ||||
| 		value = copyAndInsensitiviseMap(cast.ToStringMap(v)) | ||||
| 	case map[string]interface{}: | ||||
| 	case map[string]any: | ||||
| 		value = copyAndInsensitiviseMap(v) | ||||
| 	} | ||||
|  | ||||
| @@ -51,15 +52,15 @@ func toCaseInsensitiveValue(value interface{}) interface{} { | ||||
|  | ||||
| // copyAndInsensitiviseMap behaves like insensitiviseMap, but creates a copy of | ||||
| // any map it makes case insensitive. | ||||
| func copyAndInsensitiviseMap(m map[string]interface{}) map[string]interface{} { | ||||
| 	nm := make(map[string]interface{}) | ||||
| func copyAndInsensitiviseMap(m map[string]any) map[string]any { | ||||
| 	nm := make(map[string]any) | ||||
|  | ||||
| 	for key, val := range m { | ||||
| 		lkey := strings.ToLower(key) | ||||
| 		switch v := val.(type) { | ||||
| 		case map[interface{}]interface{}: | ||||
| 		case map[any]any: | ||||
| 			nm[lkey] = copyAndInsensitiviseMap(cast.ToStringMap(v)) | ||||
| 		case map[string]interface{}: | ||||
| 		case map[string]any: | ||||
| 			nm[lkey] = copyAndInsensitiviseMap(v) | ||||
| 		default: | ||||
| 			nm[lkey] = v | ||||
| @@ -69,23 +70,23 @@ func copyAndInsensitiviseMap(m map[string]interface{}) map[string]interface{} { | ||||
| 	return nm | ||||
| } | ||||
|  | ||||
| func insensitiviseVal(val interface{}) interface{} { | ||||
| 	switch val.(type) { | ||||
| 	case map[interface{}]interface{}: | ||||
| func insensitiviseVal(val any) any { | ||||
| 	switch v := val.(type) { | ||||
| 	case map[any]any: | ||||
| 		// nested map: cast and recursively insensitivise | ||||
| 		val = cast.ToStringMap(val) | ||||
| 		insensitiviseMap(val.(map[string]interface{})) | ||||
| 	case map[string]interface{}: | ||||
| 		insensitiviseMap(val.(map[string]any)) | ||||
| 	case map[string]any: | ||||
| 		// nested map: recursively insensitivise | ||||
| 		insensitiviseMap(val.(map[string]interface{})) | ||||
| 	case []interface{}: | ||||
| 		insensitiviseMap(v) | ||||
| 	case []any: | ||||
| 		// nested array: recursively insensitivise | ||||
| 		insensitiveArray(val.([]interface{})) | ||||
| 		insensitiveArray(v) | ||||
| 	} | ||||
| 	return val | ||||
| } | ||||
|  | ||||
| func insensitiviseMap(m map[string]interface{}) { | ||||
| func insensitiviseMap(m map[string]any) { | ||||
| 	for key, val := range m { | ||||
| 		val = insensitiviseVal(val) | ||||
| 		lower := strings.ToLower(key) | ||||
| @@ -98,13 +99,13 @@ func insensitiviseMap(m map[string]interface{}) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func insensitiveArray(a []interface{}) { | ||||
| func insensitiveArray(a []any) { | ||||
| 	for i, val := range a { | ||||
| 		a[i] = insensitiviseVal(val) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func absPathify(logger Logger, inPath string) string { | ||||
| func absPathify(logger *slog.Logger, inPath string) string { | ||||
| 	logger.Info("trying to resolve absolute path", "path", inPath) | ||||
|  | ||||
| 	if inPath == "$HOME" || strings.HasPrefix(inPath, "$HOME"+string(os.PathSeparator)) { | ||||
| @@ -197,22 +198,22 @@ func parseSizeInBytes(sizeStr string) uint { | ||||
| // In case intermediate keys do not exist, or map to a non-map value, | ||||
| // a new map is created and inserted, and the search continues from there: | ||||
| // the initial map "m" may be modified! | ||||
| func deepSearch(m map[string]interface{}, path []string) map[string]interface{} { | ||||
| func deepSearch(m map[string]any, path []string) map[string]any { | ||||
| 	for _, k := range path { | ||||
| 		m2, ok := m[k] | ||||
| 		if !ok { | ||||
| 			// intermediate key does not exist | ||||
| 			// => create it and continue from there | ||||
| 			m3 := make(map[string]interface{}) | ||||
| 			m3 := make(map[string]any) | ||||
| 			m[k] = m3 | ||||
| 			m = m3 | ||||
| 			continue | ||||
| 		} | ||||
| 		m3, ok := m2.(map[string]interface{}) | ||||
| 		m3, ok := m2.(map[string]any) | ||||
| 		if !ok { | ||||
| 			// intermediate key is a value | ||||
| 			// => replace with a new map | ||||
| 			m3 = make(map[string]interface{}) | ||||
| 			m3 = make(map[string]any) | ||||
| 			m[k] = m3 | ||||
| 		} | ||||
| 		// continue search from here | ||||
|   | ||||
							
								
								
									
										243
									
								
								vendor/github.com/spf13/viper/viper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										243
									
								
								vendor/github.com/spf13/viper/viper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -35,6 +35,7 @@ import ( | ||||
|  | ||||
| 	"github.com/fsnotify/fsnotify" | ||||
| 	"github.com/mitchellh/mapstructure" | ||||
| 	slog "github.com/sagikazarmark/slog-shim" | ||||
| 	"github.com/spf13/afero" | ||||
| 	"github.com/spf13/cast" | ||||
| 	"github.com/spf13/pflag" | ||||
| @@ -206,10 +207,10 @@ type Viper struct { | ||||
| 	allowEmptyEnv       bool | ||||
|  | ||||
| 	parents        []string | ||||
| 	config         map[string]interface{} | ||||
| 	override       map[string]interface{} | ||||
| 	defaults       map[string]interface{} | ||||
| 	kvstore        map[string]interface{} | ||||
| 	config         map[string]any | ||||
| 	override       map[string]any | ||||
| 	defaults       map[string]any | ||||
| 	kvstore        map[string]any | ||||
| 	pflags         map[string]FlagValue | ||||
| 	env            map[string][]string | ||||
| 	aliases        map[string]string | ||||
| @@ -217,7 +218,7 @@ type Viper struct { | ||||
|  | ||||
| 	onConfigChange func(fsnotify.Event) | ||||
|  | ||||
| 	logger Logger | ||||
| 	logger *slog.Logger | ||||
|  | ||||
| 	// TODO: should probably be protected with a mutex | ||||
| 	encoderRegistry *encoding.EncoderRegistry | ||||
| @@ -231,16 +232,16 @@ func New() *Viper { | ||||
| 	v.configName = "config" | ||||
| 	v.configPermissions = os.FileMode(0o644) | ||||
| 	v.fs = afero.NewOsFs() | ||||
| 	v.config = make(map[string]interface{}) | ||||
| 	v.config = make(map[string]any) | ||||
| 	v.parents = []string{} | ||||
| 	v.override = make(map[string]interface{}) | ||||
| 	v.defaults = make(map[string]interface{}) | ||||
| 	v.kvstore = make(map[string]interface{}) | ||||
| 	v.override = make(map[string]any) | ||||
| 	v.defaults = make(map[string]any) | ||||
| 	v.kvstore = make(map[string]any) | ||||
| 	v.pflags = make(map[string]FlagValue) | ||||
| 	v.env = make(map[string][]string) | ||||
| 	v.aliases = make(map[string]string) | ||||
| 	v.typeByDefValue = false | ||||
| 	v.logger = jwwLogger{} | ||||
| 	v.logger = slog.New(&discardHandler{}) | ||||
|  | ||||
| 	v.resetEncoding() | ||||
|  | ||||
| @@ -301,7 +302,7 @@ func NewWithOptions(opts ...Option) *Viper { | ||||
| func Reset() { | ||||
| 	v = New() | ||||
| 	SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl", "tfvars", "dotenv", "env", "ini"} | ||||
| 	SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore"} | ||||
| 	SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore", "nats"} | ||||
| } | ||||
|  | ||||
| // TODO: make this lazy initialization instead | ||||
| @@ -420,7 +421,7 @@ type RemoteProvider interface { | ||||
| var SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl", "tfvars", "dotenv", "env", "ini"} | ||||
|  | ||||
| // SupportedRemoteProviders are universally supported remote providers. | ||||
| var SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore"} | ||||
| var SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore", "nats"} | ||||
|  | ||||
| // OnConfigChange sets the event handler that is called when a config file changes. | ||||
| func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) } | ||||
| @@ -523,6 +524,12 @@ func (v *Viper) SetEnvPrefix(in string) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func GetEnvPrefix() string { return v.GetEnvPrefix() } | ||||
|  | ||||
| func (v *Viper) GetEnvPrefix() string { | ||||
| 	return v.envPrefix | ||||
| } | ||||
|  | ||||
| func (v *Viper) mergeWithEnvPrefix(in string) string { | ||||
| 	if v.envPrefix != "" { | ||||
| 		return strings.ToUpper(v.envPrefix + "_" + in) | ||||
| @@ -578,8 +585,8 @@ func (v *Viper) AddConfigPath(in string) { | ||||
|  | ||||
| // AddRemoteProvider adds a remote configuration source. | ||||
| // Remote Providers are searched in the order they are added. | ||||
| // provider is a string value: "etcd", "etcd3", "consul" or "firestore" are currently supported. | ||||
| // endpoint is the url.  etcd requires http://ip:port  consul requires ip:port | ||||
| // provider is a string value: "etcd", "etcd3", "consul", "firestore" or "nats" are currently supported. | ||||
| // endpoint is the url.  etcd requires http://ip:port, consul requires ip:port, nats requires nats://ip:port | ||||
| // path is the path in the k/v store to retrieve configuration | ||||
| // To retrieve a config file called myapp.json from /configs/myapp.json | ||||
| // you should set path to /configs and set config name (SetConfigName()) to | ||||
| @@ -609,7 +616,7 @@ func (v *Viper) AddRemoteProvider(provider, endpoint, path string) error { | ||||
|  | ||||
| // AddSecureRemoteProvider adds a remote configuration source. | ||||
| // Secure Remote Providers are searched in the order they are added. | ||||
| // provider is a string value: "etcd", "etcd3", "consul" or "firestore" are currently supported. | ||||
| // provider is a string value: "etcd", "etcd3", "consul", "firestore" or "nats" are currently supported. | ||||
| // endpoint is the url.  etcd requires http://ip:port  consul requires ip:port | ||||
| // secretkeyring is the filepath to your openpgp secret keyring.  e.g. /etc/secrets/myring.gpg | ||||
| // path is the path in the k/v store to retrieve configuration | ||||
| @@ -653,7 +660,7 @@ func (v *Viper) providerPathExists(p *defaultRemoteProvider) bool { | ||||
| // searchMap recursively searches for a value for path in source map. | ||||
| // Returns nil if not found. | ||||
| // Note: This assumes that the path entries and map keys are lower cased. | ||||
| func (v *Viper) searchMap(source map[string]interface{}, path []string) interface{} { | ||||
| func (v *Viper) searchMap(source map[string]any, path []string) any { | ||||
| 	if len(path) == 0 { | ||||
| 		return source | ||||
| 	} | ||||
| @@ -666,13 +673,13 @@ func (v *Viper) searchMap(source map[string]interface{}, path []string) interfac | ||||
| 		} | ||||
|  | ||||
| 		// Nested case | ||||
| 		switch next.(type) { | ||||
| 		case map[interface{}]interface{}: | ||||
| 		switch next := next.(type) { | ||||
| 		case map[any]any: | ||||
| 			return v.searchMap(cast.ToStringMap(next), path[1:]) | ||||
| 		case map[string]interface{}: | ||||
| 		case map[string]any: | ||||
| 			// Type assertion is safe here since it is only reached | ||||
| 			// if the type of `next` is the same as the type being asserted | ||||
| 			return v.searchMap(next.(map[string]interface{}), path[1:]) | ||||
| 			return v.searchMap(next, path[1:]) | ||||
| 		default: | ||||
| 			// got a value but nested key expected, return "nil" for not found | ||||
| 			return nil | ||||
| @@ -692,7 +699,7 @@ func (v *Viper) searchMap(source map[string]interface{}, path []string) interfac | ||||
| // in their keys). | ||||
| // | ||||
| // Note: This assumes that the path entries and map keys are lower cased. | ||||
| func (v *Viper) searchIndexableWithPathPrefixes(source interface{}, path []string) interface{} { | ||||
| func (v *Viper) searchIndexableWithPathPrefixes(source any, path []string) any { | ||||
| 	if len(path) == 0 { | ||||
| 		return source | ||||
| 	} | ||||
| @@ -701,11 +708,11 @@ func (v *Viper) searchIndexableWithPathPrefixes(source interface{}, path []strin | ||||
| 	for i := len(path); i > 0; i-- { | ||||
| 		prefixKey := strings.ToLower(strings.Join(path[0:i], v.keyDelim)) | ||||
|  | ||||
| 		var val interface{} | ||||
| 		var val any | ||||
| 		switch sourceIndexable := source.(type) { | ||||
| 		case []interface{}: | ||||
| 		case []any: | ||||
| 			val = v.searchSliceWithPathPrefixes(sourceIndexable, prefixKey, i, path) | ||||
| 		case map[string]interface{}: | ||||
| 		case map[string]any: | ||||
| 			val = v.searchMapWithPathPrefixes(sourceIndexable, prefixKey, i, path) | ||||
| 		} | ||||
| 		if val != nil { | ||||
| @@ -722,11 +729,11 @@ func (v *Viper) searchIndexableWithPathPrefixes(source interface{}, path []strin | ||||
| // This function is part of the searchIndexableWithPathPrefixes recurring search and | ||||
| // should not be called directly from functions other than searchIndexableWithPathPrefixes. | ||||
| func (v *Viper) searchSliceWithPathPrefixes( | ||||
| 	sourceSlice []interface{}, | ||||
| 	sourceSlice []any, | ||||
| 	prefixKey string, | ||||
| 	pathIndex int, | ||||
| 	path []string, | ||||
| ) interface{} { | ||||
| ) any { | ||||
| 	// if the prefixKey is not a number or it is out of bounds of the slice | ||||
| 	index, err := strconv.Atoi(prefixKey) | ||||
| 	if err != nil || len(sourceSlice) <= index { | ||||
| @@ -741,9 +748,9 @@ func (v *Viper) searchSliceWithPathPrefixes( | ||||
| 	} | ||||
|  | ||||
| 	switch n := next.(type) { | ||||
| 	case map[interface{}]interface{}: | ||||
| 	case map[any]any: | ||||
| 		return v.searchIndexableWithPathPrefixes(cast.ToStringMap(n), path[pathIndex:]) | ||||
| 	case map[string]interface{}, []interface{}: | ||||
| 	case map[string]any, []any: | ||||
| 		return v.searchIndexableWithPathPrefixes(n, path[pathIndex:]) | ||||
| 	default: | ||||
| 		// got a value but nested key expected, do nothing and look for next prefix | ||||
| @@ -758,11 +765,11 @@ func (v *Viper) searchSliceWithPathPrefixes( | ||||
| // This function is part of the searchIndexableWithPathPrefixes recurring search and | ||||
| // should not be called directly from functions other than searchIndexableWithPathPrefixes. | ||||
| func (v *Viper) searchMapWithPathPrefixes( | ||||
| 	sourceMap map[string]interface{}, | ||||
| 	sourceMap map[string]any, | ||||
| 	prefixKey string, | ||||
| 	pathIndex int, | ||||
| 	path []string, | ||||
| ) interface{} { | ||||
| ) any { | ||||
| 	next, ok := sourceMap[prefixKey] | ||||
| 	if !ok { | ||||
| 		return nil | ||||
| @@ -775,9 +782,9 @@ func (v *Viper) searchMapWithPathPrefixes( | ||||
|  | ||||
| 	// Nested case | ||||
| 	switch n := next.(type) { | ||||
| 	case map[interface{}]interface{}: | ||||
| 	case map[any]any: | ||||
| 		return v.searchIndexableWithPathPrefixes(cast.ToStringMap(n), path[pathIndex:]) | ||||
| 	case map[string]interface{}, []interface{}: | ||||
| 	case map[string]any, []any: | ||||
| 		return v.searchIndexableWithPathPrefixes(n, path[pathIndex:]) | ||||
| 	default: | ||||
| 		// got a value but nested key expected, do nothing and look for next prefix | ||||
| @@ -792,8 +799,8 @@ func (v *Viper) searchMapWithPathPrefixes( | ||||
| // e.g., if "foo.bar" has a value in the given map, it “shadows” | ||||
| // | ||||
| //	"foo.bar.baz" in a lower-priority map | ||||
| func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]interface{}) string { | ||||
| 	var parentVal interface{} | ||||
| func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]any) string { | ||||
| 	var parentVal any | ||||
| 	for i := 1; i < len(path); i++ { | ||||
| 		parentVal = v.searchMap(m, path[0:i]) | ||||
| 		if parentVal == nil { | ||||
| @@ -801,9 +808,9 @@ func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]interface{}) | ||||
| 			return "" | ||||
| 		} | ||||
| 		switch parentVal.(type) { | ||||
| 		case map[interface{}]interface{}: | ||||
| 		case map[any]any: | ||||
| 			continue | ||||
| 		case map[string]interface{}: | ||||
| 		case map[string]any: | ||||
| 			continue | ||||
| 		default: | ||||
| 			// parentVal is a regular value which shadows "path" | ||||
| @@ -818,9 +825,9 @@ func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]interface{}) | ||||
| // e.g., if "foo.bar" has a value in the given map, it “shadows” | ||||
| // | ||||
| //	"foo.bar.baz" in a lower-priority map | ||||
| func (v *Viper) isPathShadowedInFlatMap(path []string, mi interface{}) string { | ||||
| func (v *Viper) isPathShadowedInFlatMap(path []string, mi any) string { | ||||
| 	// unify input map | ||||
| 	var m map[string]interface{} | ||||
| 	var m map[string]any | ||||
| 	switch mi.(type) { | ||||
| 	case map[string]string, map[string]FlagValue: | ||||
| 		m = cast.ToStringMap(mi) | ||||
| @@ -887,9 +894,9 @@ func GetViper() *Viper { | ||||
| // override, flag, env, config file, key/value store, default | ||||
| // | ||||
| // Get returns an interface. For a specific value use one of the Get____ methods. | ||||
| func Get(key string) interface{} { return v.Get(key) } | ||||
| func Get(key string) any { return v.Get(key) } | ||||
|  | ||||
| func (v *Viper) Get(key string) interface{} { | ||||
| func (v *Viper) Get(key string) any { | ||||
| 	lcaseKey := strings.ToLower(key) | ||||
| 	val := v.find(lcaseKey, true) | ||||
| 	if val == nil { | ||||
| @@ -1059,9 +1066,9 @@ func (v *Viper) GetStringSlice(key string) []string { | ||||
| } | ||||
|  | ||||
| // GetStringMap returns the value associated with the key as a map of interfaces. | ||||
| func GetStringMap(key string) map[string]interface{} { return v.GetStringMap(key) } | ||||
| func GetStringMap(key string) map[string]any { return v.GetStringMap(key) } | ||||
|  | ||||
| func (v *Viper) GetStringMap(key string) map[string]interface{} { | ||||
| func (v *Viper) GetStringMap(key string) map[string]any { | ||||
| 	return cast.ToStringMap(v.Get(key)) | ||||
| } | ||||
|  | ||||
| @@ -1089,27 +1096,27 @@ func (v *Viper) GetSizeInBytes(key string) uint { | ||||
| } | ||||
|  | ||||
| // UnmarshalKey takes a single key and unmarshals it into a Struct. | ||||
| func UnmarshalKey(key string, rawVal interface{}, opts ...DecoderConfigOption) error { | ||||
| func UnmarshalKey(key string, rawVal any, opts ...DecoderConfigOption) error { | ||||
| 	return v.UnmarshalKey(key, rawVal, opts...) | ||||
| } | ||||
|  | ||||
| func (v *Viper) UnmarshalKey(key string, rawVal interface{}, opts ...DecoderConfigOption) error { | ||||
| func (v *Viper) UnmarshalKey(key string, rawVal any, opts ...DecoderConfigOption) error { | ||||
| 	return decode(v.Get(key), defaultDecoderConfig(rawVal, opts...)) | ||||
| } | ||||
|  | ||||
| // Unmarshal unmarshals the config into a Struct. Make sure that the tags | ||||
| // on the fields of the structure are properly set. | ||||
| func Unmarshal(rawVal interface{}, opts ...DecoderConfigOption) error { | ||||
| func Unmarshal(rawVal any, opts ...DecoderConfigOption) error { | ||||
| 	return v.Unmarshal(rawVal, opts...) | ||||
| } | ||||
|  | ||||
| func (v *Viper) Unmarshal(rawVal interface{}, opts ...DecoderConfigOption) error { | ||||
| func (v *Viper) Unmarshal(rawVal any, opts ...DecoderConfigOption) error { | ||||
| 	return decode(v.AllSettings(), defaultDecoderConfig(rawVal, opts...)) | ||||
| } | ||||
|  | ||||
| // defaultDecoderConfig returns default mapstructure.DecoderConfig with support | ||||
| // of time.Duration values & string slices | ||||
| func defaultDecoderConfig(output interface{}, opts ...DecoderConfigOption) *mapstructure.DecoderConfig { | ||||
| func defaultDecoderConfig(output any, opts ...DecoderConfigOption) *mapstructure.DecoderConfig { | ||||
| 	c := &mapstructure.DecoderConfig{ | ||||
| 		Metadata:         nil, | ||||
| 		Result:           output, | ||||
| @@ -1126,7 +1133,7 @@ func defaultDecoderConfig(output interface{}, opts ...DecoderConfigOption) *maps | ||||
| } | ||||
|  | ||||
| // A wrapper around mapstructure.Decode that mimics the WeakDecode functionality | ||||
| func decode(input interface{}, config *mapstructure.DecoderConfig) error { | ||||
| func decode(input any, config *mapstructure.DecoderConfig) error { | ||||
| 	decoder, err := mapstructure.NewDecoder(config) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| @@ -1136,11 +1143,11 @@ func decode(input interface{}, config *mapstructure.DecoderConfig) error { | ||||
|  | ||||
| // UnmarshalExact unmarshals the config into a Struct, erroring if a field is nonexistent | ||||
| // in the destination struct. | ||||
| func UnmarshalExact(rawVal interface{}, opts ...DecoderConfigOption) error { | ||||
| func UnmarshalExact(rawVal any, opts ...DecoderConfigOption) error { | ||||
| 	return v.UnmarshalExact(rawVal, opts...) | ||||
| } | ||||
|  | ||||
| func (v *Viper) UnmarshalExact(rawVal interface{}, opts ...DecoderConfigOption) error { | ||||
| func (v *Viper) UnmarshalExact(rawVal any, opts ...DecoderConfigOption) error { | ||||
| 	config := defaultDecoderConfig(rawVal, opts...) | ||||
| 	config.ErrorUnused = true | ||||
|  | ||||
| @@ -1237,9 +1244,9 @@ func (v *Viper) MustBindEnv(input ...string) { | ||||
| // corresponds to a flag, the flag's default value is returned. | ||||
| // | ||||
| // Note: this assumes a lower-cased key given. | ||||
| func (v *Viper) find(lcaseKey string, flagDefault bool) interface{} { | ||||
| func (v *Viper) find(lcaseKey string, flagDefault bool) any { | ||||
| 	var ( | ||||
| 		val    interface{} | ||||
| 		val    any | ||||
| 		exists bool | ||||
| 		path   = strings.Split(lcaseKey, v.keyDelim) | ||||
| 		nested = len(path) > 1 | ||||
| @@ -1398,46 +1405,46 @@ func readAsCSV(val string) ([]string, error) { | ||||
| } | ||||
|  | ||||
| // mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/master/string_to_string.go#L79 | ||||
| // alterations are: errors are swallowed, map[string]interface{} is returned in order to enable cast.ToStringMap | ||||
| func stringToStringConv(val string) interface{} { | ||||
| // alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap | ||||
| func stringToStringConv(val string) any { | ||||
| 	val = strings.Trim(val, "[]") | ||||
| 	// An empty string would cause an empty map | ||||
| 	if len(val) == 0 { | ||||
| 		return map[string]interface{}{} | ||||
| 		return map[string]any{} | ||||
| 	} | ||||
| 	r := csv.NewReader(strings.NewReader(val)) | ||||
| 	ss, err := r.Read() | ||||
| 	if err != nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	out := make(map[string]interface{}, len(ss)) | ||||
| 	out := make(map[string]any, len(ss)) | ||||
| 	for _, pair := range ss { | ||||
| 		kv := strings.SplitN(pair, "=", 2) | ||||
| 		if len(kv) != 2 { | ||||
| 		k, vv, found := strings.Cut(pair, "=") | ||||
| 		if !found { | ||||
| 			return nil | ||||
| 		} | ||||
| 		out[kv[0]] = kv[1] | ||||
| 		out[k] = vv | ||||
| 	} | ||||
| 	return out | ||||
| } | ||||
|  | ||||
| // mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/d5e0c0615acee7028e1e2740a11102313be88de1/string_to_int.go#L68 | ||||
| // alterations are: errors are swallowed, map[string]interface{} is returned in order to enable cast.ToStringMap | ||||
| func stringToIntConv(val string) interface{} { | ||||
| // alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap | ||||
| func stringToIntConv(val string) any { | ||||
| 	val = strings.Trim(val, "[]") | ||||
| 	// An empty string would cause an empty map | ||||
| 	if len(val) == 0 { | ||||
| 		return map[string]interface{}{} | ||||
| 		return map[string]any{} | ||||
| 	} | ||||
| 	ss := strings.Split(val, ",") | ||||
| 	out := make(map[string]interface{}, len(ss)) | ||||
| 	out := make(map[string]any, len(ss)) | ||||
| 	for _, pair := range ss { | ||||
| 		kv := strings.SplitN(pair, "=", 2) | ||||
| 		if len(kv) != 2 { | ||||
| 		k, vv, found := strings.Cut(pair, "=") | ||||
| 		if !found { | ||||
| 			return nil | ||||
| 		} | ||||
| 		var err error | ||||
| 		out[kv[0]], err = strconv.Atoi(kv[1]) | ||||
| 		out[k], err = strconv.Atoi(vv) | ||||
| 		if err != nil { | ||||
| 			return nil | ||||
| 		} | ||||
| @@ -1538,9 +1545,9 @@ func (v *Viper) InConfig(key string) bool { | ||||
| // SetDefault sets the default value for this key. | ||||
| // SetDefault is case-insensitive for a key. | ||||
| // Default only used when no value is provided by the user via flag, config or ENV. | ||||
| func SetDefault(key string, value interface{}) { v.SetDefault(key, value) } | ||||
| func SetDefault(key string, value any) { v.SetDefault(key, value) } | ||||
|  | ||||
| func (v *Viper) SetDefault(key string, value interface{}) { | ||||
| func (v *Viper) SetDefault(key string, value any) { | ||||
| 	// If alias passed in, then set the proper default | ||||
| 	key = v.realKey(strings.ToLower(key)) | ||||
| 	value = toCaseInsensitiveValue(value) | ||||
| @@ -1557,9 +1564,9 @@ func (v *Viper) SetDefault(key string, value interface{}) { | ||||
| // Set is case-insensitive for a key. | ||||
| // Will be used instead of values obtained via | ||||
| // flags, config file, ENV, default, or key/value store. | ||||
| func Set(key string, value interface{}) { v.Set(key, value) } | ||||
| func Set(key string, value any) { v.Set(key, value) } | ||||
|  | ||||
| func (v *Viper) Set(key string, value interface{}) { | ||||
| func (v *Viper) Set(key string, value any) { | ||||
| 	// If alias passed in, then set the proper override | ||||
| 	key = v.realKey(strings.ToLower(key)) | ||||
| 	value = toCaseInsensitiveValue(value) | ||||
| @@ -1593,7 +1600,7 @@ func (v *Viper) ReadInConfig() error { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	config := make(map[string]interface{}) | ||||
| 	config := make(map[string]any) | ||||
|  | ||||
| 	err = v.unmarshalReader(bytes.NewReader(file), config) | ||||
| 	if err != nil { | ||||
| @@ -1631,7 +1638,7 @@ func (v *Viper) MergeInConfig() error { | ||||
| func ReadConfig(in io.Reader) error { return v.ReadConfig(in) } | ||||
|  | ||||
| func (v *Viper) ReadConfig(in io.Reader) error { | ||||
| 	v.config = make(map[string]interface{}) | ||||
| 	v.config = make(map[string]any) | ||||
| 	return v.unmarshalReader(in, v.config) | ||||
| } | ||||
|  | ||||
| @@ -1639,7 +1646,7 @@ func (v *Viper) ReadConfig(in io.Reader) error { | ||||
| func MergeConfig(in io.Reader) error { return v.MergeConfig(in) } | ||||
|  | ||||
| func (v *Viper) MergeConfig(in io.Reader) error { | ||||
| 	cfg := make(map[string]interface{}) | ||||
| 	cfg := make(map[string]any) | ||||
| 	if err := v.unmarshalReader(in, cfg); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -1648,11 +1655,11 @@ func (v *Viper) MergeConfig(in io.Reader) error { | ||||
|  | ||||
| // MergeConfigMap merges the configuration from the map given with an existing config. | ||||
| // Note that the map given may be modified. | ||||
| func MergeConfigMap(cfg map[string]interface{}) error { return v.MergeConfigMap(cfg) } | ||||
| func MergeConfigMap(cfg map[string]any) error { return v.MergeConfigMap(cfg) } | ||||
|  | ||||
| func (v *Viper) MergeConfigMap(cfg map[string]interface{}) error { | ||||
| func (v *Viper) MergeConfigMap(cfg map[string]any) error { | ||||
| 	if v.config == nil { | ||||
| 		v.config = make(map[string]interface{}) | ||||
| 		v.config = make(map[string]any) | ||||
| 	} | ||||
| 	insensitiviseMap(cfg) | ||||
| 	mergeMaps(cfg, v.config, nil) | ||||
| @@ -1717,7 +1724,7 @@ func (v *Viper) writeConfig(filename string, force bool) error { | ||||
| 		return UnsupportedConfigError(configType) | ||||
| 	} | ||||
| 	if v.config == nil { | ||||
| 		v.config = make(map[string]interface{}) | ||||
| 		v.config = make(map[string]any) | ||||
| 	} | ||||
| 	flags := os.O_CREATE | os.O_TRUNC | os.O_WRONLY | ||||
| 	if !force { | ||||
| @@ -1738,11 +1745,11 @@ func (v *Viper) writeConfig(filename string, force bool) error { | ||||
|  | ||||
| // Unmarshal a Reader into a map. | ||||
| // Should probably be an unexported function. | ||||
| func unmarshalReader(in io.Reader, c map[string]interface{}) error { | ||||
| func unmarshalReader(in io.Reader, c map[string]any) error { | ||||
| 	return v.unmarshalReader(in, c) | ||||
| } | ||||
|  | ||||
| func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error { | ||||
| func (v *Viper) unmarshalReader(in io.Reader, c map[string]any) error { | ||||
| 	buf := new(bytes.Buffer) | ||||
| 	buf.ReadFrom(in) | ||||
|  | ||||
| @@ -1776,7 +1783,7 @@ func (v *Viper) marshalWriter(f afero.File, configType string) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func keyExists(k string, m map[string]interface{}) string { | ||||
| func keyExists(k string, m map[string]any) string { | ||||
| 	lk := strings.ToLower(k) | ||||
| 	for mk := range m { | ||||
| 		lmk := strings.ToLower(mk) | ||||
| @@ -1788,33 +1795,33 @@ func keyExists(k string, m map[string]interface{}) string { | ||||
| } | ||||
|  | ||||
| func castToMapStringInterface( | ||||
| 	src map[interface{}]interface{}, | ||||
| ) map[string]interface{} { | ||||
| 	tgt := map[string]interface{}{} | ||||
| 	src map[any]any, | ||||
| ) map[string]any { | ||||
| 	tgt := map[string]any{} | ||||
| 	for k, v := range src { | ||||
| 		tgt[fmt.Sprintf("%v", k)] = v | ||||
| 	} | ||||
| 	return tgt | ||||
| } | ||||
|  | ||||
| func castMapStringSliceToMapInterface(src map[string][]string) map[string]interface{} { | ||||
| 	tgt := map[string]interface{}{} | ||||
| func castMapStringSliceToMapInterface(src map[string][]string) map[string]any { | ||||
| 	tgt := map[string]any{} | ||||
| 	for k, v := range src { | ||||
| 		tgt[k] = v | ||||
| 	} | ||||
| 	return tgt | ||||
| } | ||||
|  | ||||
| func castMapStringToMapInterface(src map[string]string) map[string]interface{} { | ||||
| 	tgt := map[string]interface{}{} | ||||
| func castMapStringToMapInterface(src map[string]string) map[string]any { | ||||
| 	tgt := map[string]any{} | ||||
| 	for k, v := range src { | ||||
| 		tgt[k] = v | ||||
| 	} | ||||
| 	return tgt | ||||
| } | ||||
|  | ||||
| func castMapFlagToMapInterface(src map[string]FlagValue) map[string]interface{} { | ||||
| 	tgt := map[string]interface{}{} | ||||
| func castMapFlagToMapInterface(src map[string]FlagValue) map[string]any { | ||||
| 	tgt := map[string]any{} | ||||
| 	for k, v := range src { | ||||
| 		tgt[k] = v | ||||
| 	} | ||||
| @@ -1822,17 +1829,15 @@ func castMapFlagToMapInterface(src map[string]FlagValue) map[string]interface{} | ||||
| } | ||||
|  | ||||
| // mergeMaps merges two maps. The `itgt` parameter is for handling go-yaml's | ||||
| // insistence on parsing nested structures as `map[interface{}]interface{}` | ||||
| // insistence on parsing nested structures as `map[any]any` | ||||
| // instead of using a `string` as the key for nest structures beyond one level | ||||
| // deep. Both map types are supported as there is a go-yaml fork that uses | ||||
| // `map[string]interface{}` instead. | ||||
| func mergeMaps( | ||||
| 	src, tgt map[string]interface{}, itgt map[interface{}]interface{}, | ||||
| ) { | ||||
| // `map[string]any` instead. | ||||
| func mergeMaps(src, tgt map[string]any, itgt map[any]any) { | ||||
| 	for sk, sv := range src { | ||||
| 		tk := keyExists(sk, tgt) | ||||
| 		if tk == "" { | ||||
| 			v.logger.Trace("", "tk", "\"\"", fmt.Sprintf("tgt[%s]", sk), sv) | ||||
| 			v.logger.Debug("", "tk", "\"\"", fmt.Sprintf("tgt[%s]", sk), sv) | ||||
| 			tgt[sk] = sv | ||||
| 			if itgt != nil { | ||||
| 				itgt[sk] = sv | ||||
| @@ -1842,7 +1847,7 @@ func mergeMaps( | ||||
|  | ||||
| 		tv, ok := tgt[tk] | ||||
| 		if !ok { | ||||
| 			v.logger.Trace("", fmt.Sprintf("ok[%s]", tk), false, fmt.Sprintf("tgt[%s]", sk), sv) | ||||
| 			v.logger.Debug("", fmt.Sprintf("ok[%s]", tk), false, fmt.Sprintf("tgt[%s]", sk), sv) | ||||
| 			tgt[sk] = sv | ||||
| 			if itgt != nil { | ||||
| 				itgt[sk] = sv | ||||
| @@ -1853,7 +1858,7 @@ func mergeMaps( | ||||
| 		svType := reflect.TypeOf(sv) | ||||
| 		tvType := reflect.TypeOf(tv) | ||||
|  | ||||
| 		v.logger.Trace( | ||||
| 		v.logger.Debug( | ||||
| 			"processing", | ||||
| 			"key", sk, | ||||
| 			"st", svType, | ||||
| @@ -1863,12 +1868,12 @@ func mergeMaps( | ||||
| 		) | ||||
|  | ||||
| 		switch ttv := tv.(type) { | ||||
| 		case map[interface{}]interface{}: | ||||
| 			v.logger.Trace("merging maps (must convert)") | ||||
| 			tsv, ok := sv.(map[interface{}]interface{}) | ||||
| 		case map[any]any: | ||||
| 			v.logger.Debug("merging maps (must convert)") | ||||
| 			tsv, ok := sv.(map[any]any) | ||||
| 			if !ok { | ||||
| 				v.logger.Error( | ||||
| 					"Could not cast sv to map[interface{}]interface{}", | ||||
| 					"Could not cast sv to map[any]any", | ||||
| 					"key", sk, | ||||
| 					"st", svType, | ||||
| 					"tt", tvType, | ||||
| @@ -1881,12 +1886,12 @@ func mergeMaps( | ||||
| 			ssv := castToMapStringInterface(tsv) | ||||
| 			stv := castToMapStringInterface(ttv) | ||||
| 			mergeMaps(ssv, stv, ttv) | ||||
| 		case map[string]interface{}: | ||||
| 			v.logger.Trace("merging maps") | ||||
| 			tsv, ok := sv.(map[string]interface{}) | ||||
| 		case map[string]any: | ||||
| 			v.logger.Debug("merging maps") | ||||
| 			tsv, ok := sv.(map[string]any) | ||||
| 			if !ok { | ||||
| 				v.logger.Error( | ||||
| 					"Could not cast sv to map[string]interface{}", | ||||
| 					"Could not cast sv to map[string]any", | ||||
| 					"key", sk, | ||||
| 					"st", svType, | ||||
| 					"tt", tvType, | ||||
| @@ -1897,7 +1902,7 @@ func mergeMaps( | ||||
| 			} | ||||
| 			mergeMaps(tsv, ttv, nil) | ||||
| 		default: | ||||
| 			v.logger.Trace("setting value") | ||||
| 			v.logger.Debug("setting value") | ||||
| 			tgt[tk] = sv | ||||
| 			if itgt != nil { | ||||
| 				itgt[tk] = sv | ||||
| @@ -1948,7 +1953,7 @@ func (v *Viper) getKeyValueConfig() error { | ||||
| 	return RemoteConfigError("No Files Found") | ||||
| } | ||||
|  | ||||
| func (v *Viper) getRemoteConfig(provider RemoteProvider) (map[string]interface{}, error) { | ||||
| func (v *Viper) getRemoteConfig(provider RemoteProvider) (map[string]any, error) { | ||||
| 	reader, err := RemoteConfig.Get(provider) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -1997,7 +2002,7 @@ func (v *Viper) watchKeyValueConfig() error { | ||||
| 	return RemoteConfigError("No Files Found") | ||||
| } | ||||
|  | ||||
| func (v *Viper) watchRemoteConfig(provider RemoteProvider) (map[string]interface{}, error) { | ||||
| func (v *Viper) watchRemoteConfig(provider RemoteProvider) (map[string]any, error) { | ||||
| 	reader, err := RemoteConfig.Watch(provider) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -2036,7 +2041,7 @@ func (v *Viper) AllKeys() []string { | ||||
| //     it is skipped. | ||||
| // | ||||
| // The resulting set of paths is merged to the given shadow set at the same time. | ||||
| func (v *Viper) flattenAndMergeMap(shadow map[string]bool, m map[string]interface{}, prefix string) map[string]bool { | ||||
| func (v *Viper) flattenAndMergeMap(shadow map[string]bool, m map[string]any, prefix string) map[string]bool { | ||||
| 	if shadow != nil && prefix != "" && shadow[prefix] { | ||||
| 		// prefix is shadowed => nothing more to flatten | ||||
| 		return shadow | ||||
| @@ -2045,16 +2050,16 @@ func (v *Viper) flattenAndMergeMap(shadow map[string]bool, m map[string]interfac | ||||
| 		shadow = make(map[string]bool) | ||||
| 	} | ||||
|  | ||||
| 	var m2 map[string]interface{} | ||||
| 	var m2 map[string]any | ||||
| 	if prefix != "" { | ||||
| 		prefix += v.keyDelim | ||||
| 	} | ||||
| 	for k, val := range m { | ||||
| 		fullKey := prefix + k | ||||
| 		switch val.(type) { | ||||
| 		case map[string]interface{}: | ||||
| 			m2 = val.(map[string]interface{}) | ||||
| 		case map[interface{}]interface{}: | ||||
| 		switch val := val.(type) { | ||||
| 		case map[string]any: | ||||
| 			m2 = val | ||||
| 		case map[any]any: | ||||
| 			m2 = cast.ToStringMap(val) | ||||
| 		default: | ||||
| 			// immediate value | ||||
| @@ -2069,7 +2074,7 @@ func (v *Viper) flattenAndMergeMap(shadow map[string]bool, m map[string]interfac | ||||
|  | ||||
| // mergeFlatMap merges the given maps, excluding values of the second map | ||||
| // shadowed by values from the first map. | ||||
| func (v *Viper) mergeFlatMap(shadow map[string]bool, m map[string]interface{}) map[string]bool { | ||||
| func (v *Viper) mergeFlatMap(shadow map[string]bool, m map[string]any) map[string]bool { | ||||
| 	// scan keys | ||||
| outer: | ||||
| 	for k := range m { | ||||
| @@ -2089,11 +2094,11 @@ outer: | ||||
| 	return shadow | ||||
| } | ||||
|  | ||||
| // AllSettings merges all settings and returns them as a map[string]interface{}. | ||||
| func AllSettings() map[string]interface{} { return v.AllSettings() } | ||||
| // AllSettings merges all settings and returns them as a map[string]any. | ||||
| func AllSettings() map[string]any { return v.AllSettings() } | ||||
|  | ||||
| func (v *Viper) AllSettings() map[string]interface{} { | ||||
| 	m := map[string]interface{}{} | ||||
| func (v *Viper) AllSettings() map[string]any { | ||||
| 	m := map[string]any{} | ||||
| 	// start from the list of keys, and construct the map one value at a time | ||||
| 	for _, k := range v.AllKeys() { | ||||
| 		value := v.Get(k) | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/github.com/spf13/viper/viper_go1_15.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/spf13/viper/viper_go1_15.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,5 +1,4 @@ | ||||
| //go:build !go1.16 || !finder | ||||
| // +build !go1.16 !finder | ||||
| //go:build !finder | ||||
|  | ||||
| package viper | ||||
|  | ||||
|   | ||||
							
								
								
									
										28
									
								
								vendor/github.com/spf13/viper/viper_go1_16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/spf13/viper/viper_go1_16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,32 +1,38 @@ | ||||
| //go:build go1.16 && finder | ||||
| // +build go1.16,finder | ||||
| //go:build finder | ||||
|  | ||||
| package viper | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/spf13/afero" | ||||
| 	"github.com/sagikazarmark/locafero" | ||||
| ) | ||||
|  | ||||
| // Search all configPaths for any config file. | ||||
| // Returns the first path that exists (and is a config file). | ||||
| func (v *Viper) findConfigFile() (string, error) { | ||||
| 	finder := finder{ | ||||
| 		paths:            v.configPaths, | ||||
| 		fileNames:        []string{v.configName}, | ||||
| 		extensions:       SupportedExts, | ||||
| 		withoutExtension: v.configType != "", | ||||
| 	var names []string | ||||
|  | ||||
| 	if v.configType != "" { | ||||
| 		names = locafero.NameWithOptionalExtensions(v.configName, SupportedExts...) | ||||
| 	} else { | ||||
| 		names = locafero.NameWithExtensions(v.configName, SupportedExts...) | ||||
| 	} | ||||
|  | ||||
| 	file, err := finder.Find(afero.NewIOFS(v.fs)) | ||||
| 	finder := locafero.Finder{ | ||||
| 		Paths: v.configPaths, | ||||
| 		Names: names, | ||||
| 		Type:  locafero.FileTypeFile, | ||||
| 	} | ||||
|  | ||||
| 	results, err := finder.Find(v.fs) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
|  | ||||
| 	if file == "" { | ||||
| 	if len(results) == 0 { | ||||
| 		return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)} | ||||
| 	} | ||||
|  | ||||
| 	return file, nil | ||||
| 	return results[0], nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										1
									
								
								vendor/github.com/spf13/viper/watch.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/github.com/spf13/viper/watch.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,5 +1,4 @@ | ||||
| //go:build darwin || dragonfly || freebsd || openbsd || linux || netbsd || solaris || windows | ||||
| // +build darwin dragonfly freebsd openbsd linux netbsd solaris windows | ||||
|  | ||||
| package viper | ||||
|  | ||||
|   | ||||
							
								
								
									
										1
									
								
								vendor/github.com/spf13/viper/watch_unsupported.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/github.com/spf13/viper/watch_unsupported.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,5 +1,4 @@ | ||||
| //go:build appengine || (!darwin && !dragonfly && !freebsd && !openbsd && !linux && !netbsd && !solaris && !windows) | ||||
| // +build appengine !darwin,!dragonfly,!freebsd,!openbsd,!linux,!netbsd,!solaris,!windows | ||||
|  | ||||
| package viper | ||||
|  | ||||
|   | ||||
							
								
								
									
										15
									
								
								vendor/go.uber.org/multierr/.codecov.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								vendor/go.uber.org/multierr/.codecov.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| coverage: | ||||
|   range: 80..100 | ||||
|   round: down | ||||
|   precision: 2 | ||||
|  | ||||
|   status: | ||||
|     project:                   # measuring the overall project coverage | ||||
|       default:                 # context, you can create multiple ones with custom titles | ||||
|         enabled: yes           # must be yes|true to enable this status | ||||
|         target: 100            # specify the target coverage for each commit status | ||||
|                                #   option: "auto" (must increase from parent commit or pull request base) | ||||
|                                #   option: "X%" a static target percentage to hit | ||||
|         if_not_found: success  # if parent is not found report status as success, error, or failure | ||||
|         if_ci_failed: error    # if ci fails report status as success, error, or failure | ||||
|  | ||||
							
								
								
									
										4
									
								
								vendor/go.uber.org/multierr/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								vendor/go.uber.org/multierr/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| /vendor | ||||
| cover.html | ||||
| cover.out | ||||
| /bin | ||||
							
								
								
									
										95
									
								
								vendor/go.uber.org/multierr/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								vendor/go.uber.org/multierr/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,95 @@ | ||||
| Releases | ||||
| ======== | ||||
|  | ||||
| v1.11.0 (2023-03-28) | ||||
| ==================== | ||||
| -   `Errors` now supports any error that implements multiple-error | ||||
|     interface. | ||||
| -   Add `Every` function to allow checking if all errors in the chain | ||||
|     satisfies `errors.Is` against the target error. | ||||
|  | ||||
| v1.10.0 (2023-03-08) | ||||
| ==================== | ||||
|  | ||||
| -   Comply with Go 1.20's multiple-error interface. | ||||
| -   Drop Go 1.18 support. | ||||
|     Per the support policy, only Go 1.19 and 1.20 are supported now. | ||||
| -   Drop all non-test external dependencies. | ||||
|  | ||||
| v1.9.0 (2022-12-12) | ||||
| =================== | ||||
|  | ||||
| -   Add `AppendFunc` that allow passsing functions to similar to | ||||
|     `AppendInvoke`. | ||||
|  | ||||
| -   Bump up yaml.v3 dependency to 3.0.1. | ||||
|  | ||||
| v1.8.0 (2022-02-28) | ||||
| =================== | ||||
|  | ||||
| -   `Combine`: perform zero allocations when there are no errors. | ||||
|  | ||||
|  | ||||
| v1.7.0 (2021-05-06) | ||||
| =================== | ||||
|  | ||||
| -   Add `AppendInvoke` to append into errors from `defer` blocks. | ||||
|  | ||||
|  | ||||
| v1.6.0 (2020-09-14) | ||||
| =================== | ||||
|  | ||||
| -   Actually drop library dependency on development-time tooling. | ||||
|  | ||||
|  | ||||
| v1.5.0 (2020-02-24) | ||||
| =================== | ||||
|  | ||||
| -   Drop library dependency on development-time tooling. | ||||
|  | ||||
|  | ||||
| v1.4.0 (2019-11-04) | ||||
| =================== | ||||
|  | ||||
| -   Add `AppendInto` function to more ergonomically build errors inside a | ||||
|     loop. | ||||
|  | ||||
|  | ||||
| v1.3.0 (2019-10-29) | ||||
| =================== | ||||
|  | ||||
| -   Switch to Go modules. | ||||
|  | ||||
|  | ||||
| v1.2.0 (2019-09-26) | ||||
| =================== | ||||
|  | ||||
| -   Support extracting and matching against wrapped errors with `errors.As` | ||||
|     and `errors.Is`. | ||||
|  | ||||
|  | ||||
| v1.1.0 (2017-06-30) | ||||
| =================== | ||||
|  | ||||
| -   Added an `Errors(error) []error` function to extract the underlying list of | ||||
|     errors for a multierr error. | ||||
|  | ||||
|  | ||||
| v1.0.0 (2017-05-31) | ||||
| =================== | ||||
|  | ||||
| No changes since v0.2.0. This release is committing to making no breaking | ||||
| changes to the current API in the 1.X series. | ||||
|  | ||||
|  | ||||
| v0.2.0 (2017-04-11) | ||||
| =================== | ||||
|  | ||||
| -   Repeatedly appending to the same error is now faster due to fewer | ||||
|     allocations. | ||||
|  | ||||
|  | ||||
| v0.1.0 (2017-31-03) | ||||
| =================== | ||||
|  | ||||
| -   Initial release | ||||
							
								
								
									
										19
									
								
								vendor/go.uber.org/multierr/LICENSE.txt
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								vendor/go.uber.org/multierr/LICENSE.txt
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| Copyright (c) 2017-2021 Uber Technologies, Inc. | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in | ||||
| all copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
| THE SOFTWARE. | ||||
							
								
								
									
										38
									
								
								vendor/go.uber.org/multierr/Makefile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								vendor/go.uber.org/multierr/Makefile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| # Directory to put `go install`ed binaries in. | ||||
| export GOBIN ?= $(shell pwd)/bin | ||||
|  | ||||
| GO_FILES := $(shell \ | ||||
| 	find . '(' -path '*/.*' -o -path './vendor' ')' -prune \ | ||||
| 	-o -name '*.go' -print | cut -b3-) | ||||
|  | ||||
| .PHONY: build | ||||
| build: | ||||
| 	go build ./... | ||||
|  | ||||
| .PHONY: test | ||||
| test: | ||||
| 	go test -race ./... | ||||
|  | ||||
| .PHONY: gofmt | ||||
| gofmt: | ||||
| 	$(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX)) | ||||
| 	@gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true | ||||
| 	@[ ! -s "$(FMT_LOG)" ] || (echo "gofmt failed:" | cat - $(FMT_LOG) && false) | ||||
|  | ||||
| .PHONY: golint | ||||
| golint: | ||||
| 	@cd tools && go install golang.org/x/lint/golint | ||||
| 	@$(GOBIN)/golint ./... | ||||
|  | ||||
| .PHONY: staticcheck | ||||
| staticcheck: | ||||
| 	@cd tools && go install honnef.co/go/tools/cmd/staticcheck | ||||
| 	@$(GOBIN)/staticcheck ./... | ||||
|  | ||||
| .PHONY: lint | ||||
| lint: gofmt golint staticcheck | ||||
|  | ||||
| .PHONY: cover | ||||
| cover: | ||||
| 	go test -race -coverprofile=cover.out -coverpkg=./... -v ./... | ||||
| 	go tool cover -html=cover.out -o cover.html | ||||
							
								
								
									
										43
									
								
								vendor/go.uber.org/multierr/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								vendor/go.uber.org/multierr/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| # multierr [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] | ||||
|  | ||||
| `multierr` allows combining one or more Go `error`s together. | ||||
|  | ||||
| ## Features | ||||
|  | ||||
| - **Idiomatic**: | ||||
|   multierr follows best practices in Go, and keeps your code idiomatic. | ||||
|     - It keeps the underlying error type hidden, | ||||
|       allowing you to deal in `error` values exclusively. | ||||
|     - It provides APIs to safely append into an error from a `defer` statement. | ||||
| - **Performant**: | ||||
|   multierr is optimized for performance: | ||||
|     - It avoids allocations where possible. | ||||
|     - It utilizes slice resizing semantics to optimize common cases | ||||
|       like appending into the same error object from a loop. | ||||
| - **Interoperable**: | ||||
|   multierr interoperates with the Go standard library's error APIs seamlessly: | ||||
|     - The `errors.Is` and `errors.As` functions *just work*. | ||||
| - **Lightweight**: | ||||
|   multierr comes with virtually no dependencies. | ||||
|  | ||||
| ## Installation | ||||
|  | ||||
| ```bash | ||||
| go get -u go.uber.org/multierr@latest | ||||
| ``` | ||||
|  | ||||
| ## Status | ||||
|  | ||||
| Stable: No breaking changes will be made before 2.0. | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
|  | ||||
| Released under the [MIT License]. | ||||
|  | ||||
| [MIT License]: LICENSE.txt | ||||
| [doc-img]: https://pkg.go.dev/badge/go.uber.org/multierr | ||||
| [doc]: https://pkg.go.dev/go.uber.org/multierr | ||||
| [ci-img]: https://github.com/uber-go/multierr/actions/workflows/go.yml/badge.svg | ||||
| [cov-img]: https://codecov.io/gh/uber-go/multierr/branch/master/graph/badge.svg | ||||
| [ci]: https://github.com/uber-go/multierr/actions/workflows/go.yml | ||||
| [cov]: https://codecov.io/gh/uber-go/multierr | ||||
							
								
								
									
										646
									
								
								vendor/go.uber.org/multierr/error.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										646
									
								
								vendor/go.uber.org/multierr/error.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,646 @@ | ||||
| // Copyright (c) 2017-2023 Uber Technologies, Inc. | ||||
| // | ||||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| // of this software and associated documentation files (the "Software"), to deal | ||||
| // in the Software without restriction, including without limitation the rights | ||||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| // copies of the Software, and to permit persons to whom the Software is | ||||
| // furnished to do so, subject to the following conditions: | ||||
| // | ||||
| // The above copyright notice and this permission notice shall be included in | ||||
| // all copies or substantial portions of the Software. | ||||
| // | ||||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
| // THE SOFTWARE. | ||||
|  | ||||
| // Package multierr allows combining one or more errors together. | ||||
| // | ||||
| // # Overview | ||||
| // | ||||
| // Errors can be combined with the use of the Combine function. | ||||
| // | ||||
| //	multierr.Combine( | ||||
| //		reader.Close(), | ||||
| //		writer.Close(), | ||||
| //		conn.Close(), | ||||
| //	) | ||||
| // | ||||
| // If only two errors are being combined, the Append function may be used | ||||
| // instead. | ||||
| // | ||||
| //	err = multierr.Append(reader.Close(), writer.Close()) | ||||
| // | ||||
| // The underlying list of errors for a returned error object may be retrieved | ||||
| // with the Errors function. | ||||
| // | ||||
| //	errors := multierr.Errors(err) | ||||
| //	if len(errors) > 0 { | ||||
| //		fmt.Println("The following errors occurred:", errors) | ||||
| //	} | ||||
| // | ||||
| // # Appending from a loop | ||||
| // | ||||
| // You sometimes need to append into an error from a loop. | ||||
| // | ||||
| //	var err error | ||||
| //	for _, item := range items { | ||||
| //		err = multierr.Append(err, process(item)) | ||||
| //	} | ||||
| // | ||||
| // Cases like this may require knowledge of whether an individual instance | ||||
| // failed. This usually requires introduction of a new variable. | ||||
| // | ||||
| //	var err error | ||||
| //	for _, item := range items { | ||||
| //		if perr := process(item); perr != nil { | ||||
| //			log.Warn("skipping item", item) | ||||
| //			err = multierr.Append(err, perr) | ||||
| //		} | ||||
| //	} | ||||
| // | ||||
| // multierr includes AppendInto to simplify cases like this. | ||||
| // | ||||
| //	var err error | ||||
| //	for _, item := range items { | ||||
| //		if multierr.AppendInto(&err, process(item)) { | ||||
| //			log.Warn("skipping item", item) | ||||
| //		} | ||||
| //	} | ||||
| // | ||||
| // This will append the error into the err variable, and return true if that | ||||
| // individual error was non-nil. | ||||
| // | ||||
| // See [AppendInto] for more information. | ||||
| // | ||||
| // # Deferred Functions | ||||
| // | ||||
| // Go makes it possible to modify the return value of a function in a defer | ||||
| // block if the function was using named returns. This makes it possible to | ||||
| // record resource cleanup failures from deferred blocks. | ||||
| // | ||||
| //	func sendRequest(req Request) (err error) { | ||||
| //		conn, err := openConnection() | ||||
| //		if err != nil { | ||||
| //			return err | ||||
| //		} | ||||
| //		defer func() { | ||||
| //			err = multierr.Append(err, conn.Close()) | ||||
| //		}() | ||||
| //		// ... | ||||
| //	} | ||||
| // | ||||
| // multierr provides the Invoker type and AppendInvoke function to make cases | ||||
| // like the above simpler and obviate the need for a closure. The following is | ||||
| // roughly equivalent to the example above. | ||||
| // | ||||
| //	func sendRequest(req Request) (err error) { | ||||
| //		conn, err := openConnection() | ||||
| //		if err != nil { | ||||
| //			return err | ||||
| //		} | ||||
| //		defer multierr.AppendInvoke(&err, multierr.Close(conn)) | ||||
| //		// ... | ||||
| //	} | ||||
| // | ||||
| // See [AppendInvoke] and [Invoker] for more information. | ||||
| // | ||||
| // NOTE: If you're modifying an error from inside a defer, you MUST use a named | ||||
| // return value for that function. | ||||
| // | ||||
| // # Advanced Usage | ||||
| // | ||||
| // Errors returned by Combine and Append MAY implement the following | ||||
| // interface. | ||||
| // | ||||
| //	type errorGroup interface { | ||||
| //		// Returns a slice containing the underlying list of errors. | ||||
| //		// | ||||
| //		// This slice MUST NOT be modified by the caller. | ||||
| //		Errors() []error | ||||
| //	} | ||||
| // | ||||
| // Note that if you need access to list of errors behind a multierr error, you | ||||
| // should prefer using the Errors function. That said, if you need cheap | ||||
| // read-only access to the underlying errors slice, you can attempt to cast | ||||
| // the error to this interface. You MUST handle the failure case gracefully | ||||
| // because errors returned by Combine and Append are not guaranteed to | ||||
| // implement this interface. | ||||
| // | ||||
| //	var errors []error | ||||
| //	group, ok := err.(errorGroup) | ||||
| //	if ok { | ||||
| //		errors = group.Errors() | ||||
| //	} else { | ||||
| //		errors = []error{err} | ||||
| //	} | ||||
| package multierr // import "go.uber.org/multierr" | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"sync/atomic" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// Separator for single-line error messages. | ||||
| 	_singlelineSeparator = []byte("; ") | ||||
|  | ||||
| 	// Prefix for multi-line messages | ||||
| 	_multilinePrefix = []byte("the following errors occurred:") | ||||
|  | ||||
| 	// Prefix for the first and following lines of an item in a list of | ||||
| 	// multi-line error messages. | ||||
| 	// | ||||
| 	// For example, if a single item is: | ||||
| 	// | ||||
| 	// 	foo | ||||
| 	// 	bar | ||||
| 	// | ||||
| 	// It will become, | ||||
| 	// | ||||
| 	// 	 -  foo | ||||
| 	// 	    bar | ||||
| 	_multilineSeparator = []byte("\n -  ") | ||||
| 	_multilineIndent    = []byte("    ") | ||||
| ) | ||||
|  | ||||
| // _bufferPool is a pool of bytes.Buffers. | ||||
| var _bufferPool = sync.Pool{ | ||||
| 	New: func() interface{} { | ||||
| 		return &bytes.Buffer{} | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| type errorGroup interface { | ||||
| 	Errors() []error | ||||
| } | ||||
|  | ||||
| // Errors returns a slice containing zero or more errors that the supplied | ||||
| // error is composed of. If the error is nil, a nil slice is returned. | ||||
| // | ||||
| //	err := multierr.Append(r.Close(), w.Close()) | ||||
| //	errors := multierr.Errors(err) | ||||
| // | ||||
| // If the error is not composed of other errors, the returned slice contains | ||||
| // just the error that was passed in. | ||||
| // | ||||
| // Callers of this function are free to modify the returned slice. | ||||
| func Errors(err error) []error { | ||||
| 	return extractErrors(err) | ||||
| } | ||||
|  | ||||
| // multiError is an error that holds one or more errors. | ||||
| // | ||||
| // An instance of this is guaranteed to be non-empty and flattened. That is, | ||||
| // none of the errors inside multiError are other multiErrors. | ||||
| // | ||||
| // multiError formats to a semi-colon delimited list of error messages with | ||||
| // %v and with a more readable multi-line format with %+v. | ||||
| type multiError struct { | ||||
| 	copyNeeded atomic.Bool | ||||
| 	errors     []error | ||||
| } | ||||
|  | ||||
| // Errors returns the list of underlying errors. | ||||
| // | ||||
| // This slice MUST NOT be modified. | ||||
| func (merr *multiError) Errors() []error { | ||||
| 	if merr == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return merr.errors | ||||
| } | ||||
|  | ||||
| func (merr *multiError) Error() string { | ||||
| 	if merr == nil { | ||||
| 		return "" | ||||
| 	} | ||||
|  | ||||
| 	buff := _bufferPool.Get().(*bytes.Buffer) | ||||
| 	buff.Reset() | ||||
|  | ||||
| 	merr.writeSingleline(buff) | ||||
|  | ||||
| 	result := buff.String() | ||||
| 	_bufferPool.Put(buff) | ||||
| 	return result | ||||
| } | ||||
|  | ||||
| // Every compares every error in the given err against the given target error | ||||
| // using [errors.Is], and returns true only if every comparison returned true. | ||||
| func Every(err error, target error) bool { | ||||
| 	for _, e := range extractErrors(err) { | ||||
| 		if !errors.Is(e, target) { | ||||
| 			return false | ||||
| 		} | ||||
| 	} | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| func (merr *multiError) Format(f fmt.State, c rune) { | ||||
| 	if c == 'v' && f.Flag('+') { | ||||
| 		merr.writeMultiline(f) | ||||
| 	} else { | ||||
| 		merr.writeSingleline(f) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (merr *multiError) writeSingleline(w io.Writer) { | ||||
| 	first := true | ||||
| 	for _, item := range merr.errors { | ||||
| 		if first { | ||||
| 			first = false | ||||
| 		} else { | ||||
| 			w.Write(_singlelineSeparator) | ||||
| 		} | ||||
| 		io.WriteString(w, item.Error()) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (merr *multiError) writeMultiline(w io.Writer) { | ||||
| 	w.Write(_multilinePrefix) | ||||
| 	for _, item := range merr.errors { | ||||
| 		w.Write(_multilineSeparator) | ||||
| 		writePrefixLine(w, _multilineIndent, fmt.Sprintf("%+v", item)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Writes s to the writer with the given prefix added before each line after | ||||
| // the first. | ||||
| func writePrefixLine(w io.Writer, prefix []byte, s string) { | ||||
| 	first := true | ||||
| 	for len(s) > 0 { | ||||
| 		if first { | ||||
| 			first = false | ||||
| 		} else { | ||||
| 			w.Write(prefix) | ||||
| 		} | ||||
|  | ||||
| 		idx := strings.IndexByte(s, '\n') | ||||
| 		if idx < 0 { | ||||
| 			idx = len(s) - 1 | ||||
| 		} | ||||
|  | ||||
| 		io.WriteString(w, s[:idx+1]) | ||||
| 		s = s[idx+1:] | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type inspectResult struct { | ||||
| 	// Number of top-level non-nil errors | ||||
| 	Count int | ||||
|  | ||||
| 	// Total number of errors including multiErrors | ||||
| 	Capacity int | ||||
|  | ||||
| 	// Index of the first non-nil error in the list. Value is meaningless if | ||||
| 	// Count is zero. | ||||
| 	FirstErrorIdx int | ||||
|  | ||||
| 	// Whether the list contains at least one multiError | ||||
| 	ContainsMultiError bool | ||||
| } | ||||
|  | ||||
| // Inspects the given slice of errors so that we can efficiently allocate | ||||
| // space for it. | ||||
| func inspect(errors []error) (res inspectResult) { | ||||
| 	first := true | ||||
| 	for i, err := range errors { | ||||
| 		if err == nil { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		res.Count++ | ||||
| 		if first { | ||||
| 			first = false | ||||
| 			res.FirstErrorIdx = i | ||||
| 		} | ||||
|  | ||||
| 		if merr, ok := err.(*multiError); ok { | ||||
| 			res.Capacity += len(merr.errors) | ||||
| 			res.ContainsMultiError = true | ||||
| 		} else { | ||||
| 			res.Capacity++ | ||||
| 		} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // fromSlice converts the given list of errors into a single error. | ||||
| func fromSlice(errors []error) error { | ||||
| 	// Don't pay to inspect small slices. | ||||
| 	switch len(errors) { | ||||
| 	case 0: | ||||
| 		return nil | ||||
| 	case 1: | ||||
| 		return errors[0] | ||||
| 	} | ||||
|  | ||||
| 	res := inspect(errors) | ||||
| 	switch res.Count { | ||||
| 	case 0: | ||||
| 		return nil | ||||
| 	case 1: | ||||
| 		// only one non-nil entry | ||||
| 		return errors[res.FirstErrorIdx] | ||||
| 	case len(errors): | ||||
| 		if !res.ContainsMultiError { | ||||
| 			// Error list is flat. Make a copy of it | ||||
| 			// Otherwise "errors" escapes to the heap | ||||
| 			// unconditionally for all other cases. | ||||
| 			// This lets us optimize for the "no errors" case. | ||||
| 			out := append(([]error)(nil), errors...) | ||||
| 			return &multiError{errors: out} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	nonNilErrs := make([]error, 0, res.Capacity) | ||||
| 	for _, err := range errors[res.FirstErrorIdx:] { | ||||
| 		if err == nil { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		if nested, ok := err.(*multiError); ok { | ||||
| 			nonNilErrs = append(nonNilErrs, nested.errors...) | ||||
| 		} else { | ||||
| 			nonNilErrs = append(nonNilErrs, err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return &multiError{errors: nonNilErrs} | ||||
| } | ||||
|  | ||||
| // Combine combines the passed errors into a single error. | ||||
| // | ||||
| // If zero arguments were passed or if all items are nil, a nil error is | ||||
| // returned. | ||||
| // | ||||
| //	Combine(nil, nil)  // == nil | ||||
| // | ||||
| // If only a single error was passed, it is returned as-is. | ||||
| // | ||||
| //	Combine(err)  // == err | ||||
| // | ||||
| // Combine skips over nil arguments so this function may be used to combine | ||||
| // together errors from operations that fail independently of each other. | ||||
| // | ||||
| //	multierr.Combine( | ||||
| //		reader.Close(), | ||||
| //		writer.Close(), | ||||
| //		pipe.Close(), | ||||
| //	) | ||||
| // | ||||
| // If any of the passed errors is a multierr error, it will be flattened along | ||||
| // with the other errors. | ||||
| // | ||||
| //	multierr.Combine(multierr.Combine(err1, err2), err3) | ||||
| //	// is the same as | ||||
| //	multierr.Combine(err1, err2, err3) | ||||
| // | ||||
| // The returned error formats into a readable multi-line error message if | ||||
| // formatted with %+v. | ||||
| // | ||||
| //	fmt.Sprintf("%+v", multierr.Combine(err1, err2)) | ||||
| func Combine(errors ...error) error { | ||||
| 	return fromSlice(errors) | ||||
| } | ||||
|  | ||||
| // Append appends the given errors together. Either value may be nil. | ||||
| // | ||||
| // This function is a specialization of Combine for the common case where | ||||
| // there are only two errors. | ||||
| // | ||||
| //	err = multierr.Append(reader.Close(), writer.Close()) | ||||
| // | ||||
| // The following pattern may also be used to record failure of deferred | ||||
| // operations without losing information about the original error. | ||||
| // | ||||
| //	func doSomething(..) (err error) { | ||||
| //		f := acquireResource() | ||||
| //		defer func() { | ||||
| //			err = multierr.Append(err, f.Close()) | ||||
| //		}() | ||||
| // | ||||
| // Note that the variable MUST be a named return to append an error to it from | ||||
| // the defer statement. See also [AppendInvoke]. | ||||
| func Append(left error, right error) error { | ||||
| 	switch { | ||||
| 	case left == nil: | ||||
| 		return right | ||||
| 	case right == nil: | ||||
| 		return left | ||||
| 	} | ||||
|  | ||||
| 	if _, ok := right.(*multiError); !ok { | ||||
| 		if l, ok := left.(*multiError); ok && !l.copyNeeded.Swap(true) { | ||||
| 			// Common case where the error on the left is constantly being | ||||
| 			// appended to. | ||||
| 			errs := append(l.errors, right) | ||||
| 			return &multiError{errors: errs} | ||||
| 		} else if !ok { | ||||
| 			// Both errors are single errors. | ||||
| 			return &multiError{errors: []error{left, right}} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Either right or both, left and right, are multiErrors. Rely on usual | ||||
| 	// expensive logic. | ||||
| 	errors := [2]error{left, right} | ||||
| 	return fromSlice(errors[0:]) | ||||
| } | ||||
|  | ||||
| // AppendInto appends an error into the destination of an error pointer and | ||||
| // returns whether the error being appended was non-nil. | ||||
| // | ||||
| //	var err error | ||||
| //	multierr.AppendInto(&err, r.Close()) | ||||
| //	multierr.AppendInto(&err, w.Close()) | ||||
| // | ||||
| // The above is equivalent to, | ||||
| // | ||||
| //	err := multierr.Append(r.Close(), w.Close()) | ||||
| // | ||||
| // As AppendInto reports whether the provided error was non-nil, it may be | ||||
| // used to build a multierr error in a loop more ergonomically. For example: | ||||
| // | ||||
| //	var err error | ||||
| //	for line := range lines { | ||||
| //		var item Item | ||||
| //		if multierr.AppendInto(&err, parse(line, &item)) { | ||||
| //			continue | ||||
| //		} | ||||
| //		items = append(items, item) | ||||
| //	} | ||||
| // | ||||
| // Compare this with a version that relies solely on Append: | ||||
| // | ||||
| //	var err error | ||||
| //	for line := range lines { | ||||
| //		var item Item | ||||
| //		if parseErr := parse(line, &item); parseErr != nil { | ||||
| //			err = multierr.Append(err, parseErr) | ||||
| //			continue | ||||
| //		} | ||||
| //		items = append(items, item) | ||||
| //	} | ||||
| func AppendInto(into *error, err error) (errored bool) { | ||||
| 	if into == nil { | ||||
| 		// We panic if 'into' is nil. This is not documented above | ||||
| 		// because suggesting that the pointer must be non-nil may | ||||
| 		// confuse users into thinking that the error that it points | ||||
| 		// to must be non-nil. | ||||
| 		panic("misuse of multierr.AppendInto: into pointer must not be nil") | ||||
| 	} | ||||
|  | ||||
| 	if err == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	*into = Append(*into, err) | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // Invoker is an operation that may fail with an error. Use it with | ||||
| // AppendInvoke to append the result of calling the function into an error. | ||||
| // This allows you to conveniently defer capture of failing operations. | ||||
| // | ||||
| // See also, [Close] and [Invoke]. | ||||
| type Invoker interface { | ||||
| 	Invoke() error | ||||
| } | ||||
|  | ||||
| // Invoke wraps a function which may fail with an error to match the Invoker | ||||
| // interface. Use it to supply functions matching this signature to | ||||
| // AppendInvoke. | ||||
| // | ||||
| // For example, | ||||
| // | ||||
| //	func processReader(r io.Reader) (err error) { | ||||
| //		scanner := bufio.NewScanner(r) | ||||
| //		defer multierr.AppendInvoke(&err, multierr.Invoke(scanner.Err)) | ||||
| //		for scanner.Scan() { | ||||
| //			// ... | ||||
| //		} | ||||
| //		// ... | ||||
| //	} | ||||
| // | ||||
| // In this example, the following line will construct the Invoker right away, | ||||
| // but defer the invocation of scanner.Err() until the function returns. | ||||
| // | ||||
| //	defer multierr.AppendInvoke(&err, multierr.Invoke(scanner.Err)) | ||||
| // | ||||
| // Note that the error you're appending to from the defer statement MUST be a | ||||
| // named return. | ||||
| type Invoke func() error | ||||
|  | ||||
| // Invoke calls the supplied function and returns its result. | ||||
| func (i Invoke) Invoke() error { return i() } | ||||
|  | ||||
| // Close builds an Invoker that closes the provided io.Closer. Use it with | ||||
| // AppendInvoke to close io.Closers and append their results into an error. | ||||
| // | ||||
| // For example, | ||||
| // | ||||
| //	func processFile(path string) (err error) { | ||||
| //		f, err := os.Open(path) | ||||
| //		if err != nil { | ||||
| //			return err | ||||
| //		} | ||||
| //		defer multierr.AppendInvoke(&err, multierr.Close(f)) | ||||
| //		return processReader(f) | ||||
| //	} | ||||
| // | ||||
| // In this example, multierr.Close will construct the Invoker right away, but | ||||
| // defer the invocation of f.Close until the function returns. | ||||
| // | ||||
| //	defer multierr.AppendInvoke(&err, multierr.Close(f)) | ||||
| // | ||||
| // Note that the error you're appending to from the defer statement MUST be a | ||||
| // named return. | ||||
| func Close(closer io.Closer) Invoker { | ||||
| 	return Invoke(closer.Close) | ||||
| } | ||||
|  | ||||
| // AppendInvoke appends the result of calling the given Invoker into the | ||||
| // provided error pointer. Use it with named returns to safely defer | ||||
| // invocation of fallible operations until a function returns, and capture the | ||||
| // resulting errors. | ||||
| // | ||||
| //	func doSomething(...) (err error) { | ||||
| //		// ... | ||||
| //		f, err := openFile(..) | ||||
| //		if err != nil { | ||||
| //			return err | ||||
| //		} | ||||
| // | ||||
| //		// multierr will call f.Close() when this function returns and | ||||
| //		// if the operation fails, its append its error into the | ||||
| //		// returned error. | ||||
| //		defer multierr.AppendInvoke(&err, multierr.Close(f)) | ||||
| // | ||||
| //		scanner := bufio.NewScanner(f) | ||||
| //		// Similarly, this scheduled scanner.Err to be called and | ||||
| //		// inspected when the function returns and append its error | ||||
| //		// into the returned error. | ||||
| //		defer multierr.AppendInvoke(&err, multierr.Invoke(scanner.Err)) | ||||
| // | ||||
| //		// ... | ||||
| //	} | ||||
| // | ||||
| // NOTE: If used with a defer, the error variable MUST be a named return. | ||||
| // | ||||
| // Without defer, AppendInvoke behaves exactly like AppendInto. | ||||
| // | ||||
| //	err := // ... | ||||
| //	multierr.AppendInvoke(&err, mutltierr.Invoke(foo)) | ||||
| // | ||||
| //	// ...is roughly equivalent to... | ||||
| // | ||||
| //	err := // ... | ||||
| //	multierr.AppendInto(&err, foo()) | ||||
| // | ||||
| // The advantage of the indirection introduced by Invoker is to make it easy | ||||
| // to defer the invocation of a function. Without this indirection, the | ||||
| // invoked function will be evaluated at the time of the defer block rather | ||||
| // than when the function returns. | ||||
| // | ||||
| //	// BAD: This is likely not what the caller intended. This will evaluate | ||||
| //	// foo() right away and append its result into the error when the | ||||
| //	// function returns. | ||||
| //	defer multierr.AppendInto(&err, foo()) | ||||
| // | ||||
| //	// GOOD: This will defer invocation of foo unutil the function returns. | ||||
| //	defer multierr.AppendInvoke(&err, multierr.Invoke(foo)) | ||||
| // | ||||
| // multierr provides a few Invoker implementations out of the box for | ||||
| // convenience. See [Invoker] for more information. | ||||
| func AppendInvoke(into *error, invoker Invoker) { | ||||
| 	AppendInto(into, invoker.Invoke()) | ||||
| } | ||||
|  | ||||
| // AppendFunc is a shorthand for [AppendInvoke]. | ||||
| // It allows using function or method value directly | ||||
| // without having to wrap it into an [Invoker] interface. | ||||
| // | ||||
| //	func doSomething(...) (err error) { | ||||
| //		w, err := startWorker(...) | ||||
| //		if err != nil { | ||||
| //			return err | ||||
| //		} | ||||
| // | ||||
| //		// multierr will call w.Stop() when this function returns and | ||||
| //		// if the operation fails, it appends its error into the | ||||
| //		// returned error. | ||||
| //		defer multierr.AppendFunc(&err, w.Stop) | ||||
| //	} | ||||
| func AppendFunc(into *error, fn func() error) { | ||||
| 	AppendInvoke(into, Invoke(fn)) | ||||
| } | ||||
							
								
								
									
										48
									
								
								vendor/go.uber.org/multierr/error_post_go120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								vendor/go.uber.org/multierr/error_post_go120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| // Copyright (c) 2017-2023 Uber Technologies, Inc. | ||||
| // | ||||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| // of this software and associated documentation files (the "Software"), to deal | ||||
| // in the Software without restriction, including without limitation the rights | ||||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| // copies of the Software, and to permit persons to whom the Software is | ||||
| // furnished to do so, subject to the following conditions: | ||||
| // | ||||
| // The above copyright notice and this permission notice shall be included in | ||||
| // all copies or substantial portions of the Software. | ||||
| // | ||||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
| // THE SOFTWARE. | ||||
|  | ||||
| //go:build go1.20 | ||||
| // +build go1.20 | ||||
|  | ||||
| package multierr | ||||
|  | ||||
| // Unwrap returns a list of errors wrapped by this multierr. | ||||
| func (merr *multiError) Unwrap() []error { | ||||
| 	return merr.Errors() | ||||
| } | ||||
|  | ||||
| type multipleErrors interface { | ||||
| 	Unwrap() []error | ||||
| } | ||||
|  | ||||
| func extractErrors(err error) []error { | ||||
| 	if err == nil { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	// check if the given err is an Unwrapable error that | ||||
| 	// implements multipleErrors interface. | ||||
| 	eg, ok := err.(multipleErrors) | ||||
| 	if !ok { | ||||
| 		return []error{err} | ||||
| 	} | ||||
|  | ||||
| 	return append(([]error)(nil), eg.Unwrap()...) | ||||
| } | ||||
							
								
								
									
										79
									
								
								vendor/go.uber.org/multierr/error_pre_go120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								vendor/go.uber.org/multierr/error_pre_go120.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,79 @@ | ||||
| // Copyright (c) 2017-2023 Uber Technologies, Inc. | ||||
| // | ||||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| // of this software and associated documentation files (the "Software"), to deal | ||||
| // in the Software without restriction, including without limitation the rights | ||||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| // copies of the Software, and to permit persons to whom the Software is | ||||
| // furnished to do so, subject to the following conditions: | ||||
| // | ||||
| // The above copyright notice and this permission notice shall be included in | ||||
| // all copies or substantial portions of the Software. | ||||
| // | ||||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
| // THE SOFTWARE. | ||||
|  | ||||
| //go:build !go1.20 | ||||
| // +build !go1.20 | ||||
|  | ||||
| package multierr | ||||
|  | ||||
| import "errors" | ||||
|  | ||||
| // Versions of Go before 1.20 did not support the Unwrap() []error method. | ||||
| // This provides a similar behavior by implementing the Is(..) and As(..) | ||||
| // methods. | ||||
| // See the errors.Join proposal for details: | ||||
| // https://github.com/golang/go/issues/53435 | ||||
|  | ||||
| // As attempts to find the first error in the error list that matches the type | ||||
| // of the value that target points to. | ||||
| // | ||||
| // This function allows errors.As to traverse the values stored on the | ||||
| // multierr error. | ||||
| func (merr *multiError) As(target interface{}) bool { | ||||
| 	for _, err := range merr.Errors() { | ||||
| 		if errors.As(err, target) { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // Is attempts to match the provided error against errors in the error list. | ||||
| // | ||||
| // This function allows errors.Is to traverse the values stored on the | ||||
| // multierr error. | ||||
| func (merr *multiError) Is(target error) bool { | ||||
| 	for _, err := range merr.Errors() { | ||||
| 		if errors.Is(err, target) { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func extractErrors(err error) []error { | ||||
| 	if err == nil { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	// Note that we're casting to multiError, not errorGroup. Our contract is | ||||
| 	// that returned errors MAY implement errorGroup. Errors, however, only | ||||
| 	// has special behavior for multierr-specific error objects. | ||||
| 	// | ||||
| 	// This behavior can be expanded in the future but I think it's prudent to | ||||
| 	// start with as little as possible in terms of contract and possibility | ||||
| 	// of misuse. | ||||
| 	eg, ok := err.(*multiError) | ||||
| 	if !ok { | ||||
| 		return []error{err} | ||||
| 	} | ||||
|  | ||||
| 	return append(([]error)(nil), eg.Errors()...) | ||||
| } | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 kardolus
					kardolus