mirror of
				https://github.com/NVIDIA/nvidia-container-toolkit
				synced 2025-06-26 18:18:24 +00:00 
			
		
		
		
	Update vendoring
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
		
							parent
							
								
									b23e3ea13a
								
							
						
					
					
						commit
						da3226745c
					
				
							
								
								
									
										1
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								go.mod
									
									
									
									
									
								
							| @ -11,7 +11,6 @@ require ( | ||||
| 	github.com/pelletier/go-toml v1.9.4 | ||||
| 	github.com/sirupsen/logrus v1.8.1 | ||||
| 	github.com/stretchr/testify v1.7.0 | ||||
| 	github.com/tsaikd/KDGoLib v0.0.0-20191001134900-7f3cf518e07d | ||||
| 	github.com/urfave/cli/v2 v2.3.0 | ||||
| 	golang.org/x/mod v0.5.0 | ||||
| 	golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 | ||||
|  | ||||
							
								
								
									
										15
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								go.sum
									
									
									
									
									
								
							| @ -214,7 +214,6 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH | ||||
| github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= | ||||
| github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= | ||||
| github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= | ||||
| github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= | ||||
| github.com/container-orchestrated-devices/container-device-interface v0.0.0-20220111162300-46367ec063fd/go.mod h1:YqXyXS/oVW3ix0IHVXitKBq3RZoCF8ccm5RPmRBraUI= | ||||
| github.com/container-orchestrated-devices/container-device-interface v0.3.1-0.20220224133719-e5457123010b h1:QmL39oNzTgkl9iU7cTT2NyMcJErrZpxYhmYddYIYSz0= | ||||
| github.com/container-orchestrated-devices/container-device-interface v0.3.1-0.20220224133719-e5457123010b/go.mod h1:E1zcucIkq9P3eyNmY+68dBQsTcsXJh9cgRo2IVNScKQ= | ||||
| @ -461,7 +460,6 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG | ||||
| github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= | ||||
| github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= | ||||
| github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= | ||||
| github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= | ||||
| github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= | ||||
| github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= | ||||
| github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= | ||||
| @ -477,7 +475,6 @@ github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh | ||||
| github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= | ||||
| github.com/go-redis/redis v6.15.8+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= | ||||
| github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= | ||||
| github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= | ||||
| github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= | ||||
| github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= | ||||
| github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= | ||||
| @ -624,7 +621,6 @@ github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7 | ||||
| github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= | ||||
| github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= | ||||
| github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= | ||||
| github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= | ||||
| github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= | ||||
| github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | ||||
| github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | ||||
| @ -678,7 +674,6 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX | ||||
| github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= | ||||
| github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= | ||||
| github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= | ||||
| github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= | ||||
| github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= | ||||
| github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= | ||||
| github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= | ||||
| @ -749,7 +744,6 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V | ||||
| github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= | ||||
| github.com/julz/importas v0.0.0-20210419104244-841f0c0fe66d/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= | ||||
| github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= | ||||
| github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= | ||||
| github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= | ||||
| github.com/kevinburke/ssh_config v1.1.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= | ||||
| github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= | ||||
| @ -787,7 +781,6 @@ github.com/ldez/gomoddirectives v0.2.2/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdB | ||||
| github.com/ldez/tagliatelle v0.2.0/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88= | ||||
| github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJiIbETBPTl9ATXQag= | ||||
| github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= | ||||
| github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= | ||||
| github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= | ||||
| github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= | ||||
| github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= | ||||
| @ -805,7 +798,6 @@ github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7 | ||||
| github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= | ||||
| github.com/maratori/testpackage v1.0.1/go.mod h1:ddKdw+XG0Phzhx8BFDTKgpWP4i7MpApTE5fXSKAqwDU= | ||||
| github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= | ||||
| github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11/go.mod h1:Ah2dBMoxZEqk118as2T4u4fjfXarE0pPnMJaArZQZsI= | ||||
| github.com/matoous/godox v0.0.0-20210227103229-6504466cf951/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s= | ||||
| github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= | ||||
| github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= | ||||
| @ -907,7 +899,6 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA | ||||
| github.com/nishanths/exhaustive v0.2.3/go.mod h1:bhIX678Nx8inLM9PbpvK1yv6oGtoP8BfaIeMzgBNKvc= | ||||
| github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= | ||||
| github.com/nishanths/predeclared v0.2.1/go.mod h1:HvkGJcA3naj4lOwnFXFDkFxVtSqQMB9sbB1usJ+xjQE= | ||||
| github.com/nlopes/slack v0.6.0/go.mod h1:JzQ9m3PMAqcpeCam7UaHSuBuupz7CmpjehYMayT6YOk= | ||||
| github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= | ||||
| github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= | ||||
| github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= | ||||
| @ -989,7 +980,6 @@ github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJ | ||||
| github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= | ||||
| github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= | ||||
| github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= | ||||
| github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= | ||||
| github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= | ||||
| github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= | ||||
| github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= | ||||
| @ -1178,9 +1168,6 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1 | ||||
| github.com/tomarrell/wrapcheck/v2 v2.4.0/go.mod h1:68bQ/eJg55BROaRTbMjC7vuhL2OgfoG8bLp9ZyoBfyY= | ||||
| github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= | ||||
| github.com/tommy-muehle/go-mnd/v2 v2.4.0/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= | ||||
| github.com/tsaikd/KDGoLib v0.0.0-20191001134900-7f3cf518e07d h1:hq9X/cf03C5rCx9yWhY7eMHiNxmhTMJAc5DQBq9BfnI= | ||||
| github.com/tsaikd/KDGoLib v0.0.0-20191001134900-7f3cf518e07d/go.mod h1:oFPCwcQpP90RVZxlBdgPN+iu2tPkboPUa4xaVEI6pO4= | ||||
| github.com/tsaikd/govalidator v0.0.0-20161031084447-986f2244fc69/go.mod h1:yJymgtZhuWi1Ih5t37Ej381BGZFZvlb9YMTwBxB/QjU= | ||||
| github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= | ||||
| github.com/u-root/uio v0.0.0-20210528114334-82958018845c/go.mod h1:LpEX5FO/cB+WF4TYGY1V5qktpaZLkKkSegbr0V4eYXA= | ||||
| github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= | ||||
| @ -1586,7 +1573,6 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||||
| golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| @ -1620,7 +1606,6 @@ golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtn | ||||
| golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20190916130336-e45ffcd953cc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20191001123449-8b695b21ef34/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
|  | ||||
							
								
								
									
										165
									
								
								vendor/github.com/tsaikd/KDGoLib/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										165
									
								
								vendor/github.com/tsaikd/KDGoLib/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,165 +0,0 @@ | ||||
| GNU LESSER GENERAL PUBLIC LICENSE | ||||
|                        Version 3, 29 June 2007 | ||||
| 
 | ||||
|  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | ||||
|  Everyone is permitted to copy and distribute verbatim copies | ||||
|  of this license document, but changing it is not allowed. | ||||
| 
 | ||||
| 
 | ||||
|   This version of the GNU Lesser General Public License incorporates | ||||
| the terms and conditions of version 3 of the GNU General Public | ||||
| License, supplemented by the additional permissions listed below. | ||||
| 
 | ||||
|   0. Additional Definitions. | ||||
| 
 | ||||
|   As used herein, "this License" refers to version 3 of the GNU Lesser | ||||
| General Public License, and the "GNU GPL" refers to version 3 of the GNU | ||||
| General Public License. | ||||
| 
 | ||||
|   "The Library" refers to a covered work governed by this License, | ||||
| other than an Application or a Combined Work as defined below. | ||||
| 
 | ||||
|   An "Application" is any work that makes use of an interface provided | ||||
| by the Library, but which is not otherwise based on the Library. | ||||
| Defining a subclass of a class defined by the Library is deemed a mode | ||||
| of using an interface provided by the Library. | ||||
| 
 | ||||
|   A "Combined Work" is a work produced by combining or linking an | ||||
| Application with the Library.  The particular version of the Library | ||||
| with which the Combined Work was made is also called the "Linked | ||||
| Version". | ||||
| 
 | ||||
|   The "Minimal Corresponding Source" for a Combined Work means the | ||||
| Corresponding Source for the Combined Work, excluding any source code | ||||
| for portions of the Combined Work that, considered in isolation, are | ||||
| based on the Application, and not on the Linked Version. | ||||
| 
 | ||||
|   The "Corresponding Application Code" for a Combined Work means the | ||||
| object code and/or source code for the Application, including any data | ||||
| and utility programs needed for reproducing the Combined Work from the | ||||
| Application, but excluding the System Libraries of the Combined Work. | ||||
| 
 | ||||
|   1. Exception to Section 3 of the GNU GPL. | ||||
| 
 | ||||
|   You may convey a covered work under sections 3 and 4 of this License | ||||
| without being bound by section 3 of the GNU GPL. | ||||
| 
 | ||||
|   2. Conveying Modified Versions. | ||||
| 
 | ||||
|   If you modify a copy of the Library, and, in your modifications, a | ||||
| facility refers to a function or data to be supplied by an Application | ||||
| that uses the facility (other than as an argument passed when the | ||||
| facility is invoked), then you may convey a copy of the modified | ||||
| version: | ||||
| 
 | ||||
|    a) under this License, provided that you make a good faith effort to | ||||
|    ensure that, in the event an Application does not supply the | ||||
|    function or data, the facility still operates, and performs | ||||
|    whatever part of its purpose remains meaningful, or | ||||
| 
 | ||||
|    b) under the GNU GPL, with none of the additional permissions of | ||||
|    this License applicable to that copy. | ||||
| 
 | ||||
|   3. Object Code Incorporating Material from Library Header Files. | ||||
| 
 | ||||
|   The object code form of an Application may incorporate material from | ||||
| a header file that is part of the Library.  You may convey such object | ||||
| code under terms of your choice, provided that, if the incorporated | ||||
| material is not limited to numerical parameters, data structure | ||||
| layouts and accessors, or small macros, inline functions and templates | ||||
| (ten or fewer lines in length), you do both of the following: | ||||
| 
 | ||||
|    a) Give prominent notice with each copy of the object code that the | ||||
|    Library is used in it and that the Library and its use are | ||||
|    covered by this License. | ||||
| 
 | ||||
|    b) Accompany the object code with a copy of the GNU GPL and this license | ||||
|    document. | ||||
| 
 | ||||
|   4. Combined Works. | ||||
| 
 | ||||
|   You may convey a Combined Work under terms of your choice that, | ||||
| taken together, effectively do not restrict modification of the | ||||
| portions of the Library contained in the Combined Work and reverse | ||||
| engineering for debugging such modifications, if you also do each of | ||||
| the following: | ||||
| 
 | ||||
|    a) Give prominent notice with each copy of the Combined Work that | ||||
|    the Library is used in it and that the Library and its use are | ||||
|    covered by this License. | ||||
| 
 | ||||
|    b) Accompany the Combined Work with a copy of the GNU GPL and this license | ||||
|    document. | ||||
| 
 | ||||
|    c) For a Combined Work that displays copyright notices during | ||||
|    execution, include the copyright notice for the Library among | ||||
|    these notices, as well as a reference directing the user to the | ||||
|    copies of the GNU GPL and this license document. | ||||
| 
 | ||||
|    d) Do one of the following: | ||||
| 
 | ||||
|        0) Convey the Minimal Corresponding Source under the terms of this | ||||
|        License, and the Corresponding Application Code in a form | ||||
|        suitable for, and under terms that permit, the user to | ||||
|        recombine or relink the Application with a modified version of | ||||
|        the Linked Version to produce a modified Combined Work, in the | ||||
|        manner specified by section 6 of the GNU GPL for conveying | ||||
|        Corresponding Source. | ||||
| 
 | ||||
|        1) Use a suitable shared library mechanism for linking with the | ||||
|        Library.  A suitable mechanism is one that (a) uses at run time | ||||
|        a copy of the Library already present on the user's computer | ||||
|        system, and (b) will operate properly with a modified version | ||||
|        of the Library that is interface-compatible with the Linked | ||||
|        Version. | ||||
| 
 | ||||
|    e) Provide Installation Information, but only if you would otherwise | ||||
|    be required to provide such information under section 6 of the | ||||
|    GNU GPL, and only to the extent that such information is | ||||
|    necessary to install and execute a modified version of the | ||||
|    Combined Work produced by recombining or relinking the | ||||
|    Application with a modified version of the Linked Version. (If | ||||
|    you use option 4d0, the Installation Information must accompany | ||||
|    the Minimal Corresponding Source and Corresponding Application | ||||
|    Code. If you use option 4d1, you must provide the Installation | ||||
|    Information in the manner specified by section 6 of the GNU GPL | ||||
|    for conveying Corresponding Source.) | ||||
| 
 | ||||
|   5. Combined Libraries. | ||||
| 
 | ||||
|   You may place library facilities that are a work based on the | ||||
| Library side by side in a single library together with other library | ||||
| facilities that are not Applications and are not covered by this | ||||
| License, and convey such a combined library under terms of your | ||||
| choice, if you do both of the following: | ||||
| 
 | ||||
|    a) Accompany the combined library with a copy of the same work based | ||||
|    on the Library, uncombined with any other library facilities, | ||||
|    conveyed under the terms of this License. | ||||
| 
 | ||||
|    b) Give prominent notice with the combined library that part of it | ||||
|    is a work based on the Library, and explaining where to find the | ||||
|    accompanying uncombined form of the same work. | ||||
| 
 | ||||
|   6. Revised Versions of the GNU Lesser General Public License. | ||||
| 
 | ||||
|   The Free Software Foundation may publish revised and/or new versions | ||||
| of the GNU Lesser General Public License from time to time. Such new | ||||
| versions will be similar in spirit to the present version, but may | ||||
| differ in detail to address new problems or concerns. | ||||
| 
 | ||||
|   Each version is given a distinguishing version number. If the | ||||
| Library as you received it specifies that a certain numbered version | ||||
| of the GNU Lesser General Public License "or any later version" | ||||
| applies to it, you have the option of following the terms and | ||||
| conditions either of that published version or of any later version | ||||
| published by the Free Software Foundation. If the Library as you | ||||
| received it does not specify a version number of the GNU Lesser | ||||
| General Public License, you may choose any version of the GNU Lesser | ||||
| General Public License ever published by the Free Software Foundation. | ||||
| 
 | ||||
|   If the Library as you received it specifies that a proxy can decide | ||||
| whether future versions of the GNU Lesser General Public License shall | ||||
| apply, that proxy's public statement of acceptance of any version is | ||||
| permanent authorization for you to choose that version for the | ||||
| Library. | ||||
							
								
								
									
										88
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ConsoleFormatter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ConsoleFormatter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,88 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"time" | ||||
| ) | ||||
| 
 | ||||
| // NewConsoleFormatter create JSONErrorFormatter instance
 | ||||
| func NewConsoleFormatter(seperator string) *ConsoleFormatter { | ||||
| 	return &ConsoleFormatter{ | ||||
| 		Seperator: seperator, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // ConsoleFormatter used to format error object in console readable
 | ||||
| type ConsoleFormatter struct { | ||||
| 	// seperator between errors, e.g. "; " will output "err1; err2; err3"
 | ||||
| 	Seperator string | ||||
| 	// output timestamp for prefix, e.g.  "2006-01-02 15:04:05 "
 | ||||
| 	TimeFormat string | ||||
| 	// show error position with long filename
 | ||||
| 	LongFile bool | ||||
| 	// show error position with short filename
 | ||||
| 	ShortFile bool | ||||
| 	// show error position with line number, work with LongFile or ShortFile
 | ||||
| 	Line bool | ||||
| 	// replace package name for securify
 | ||||
| 	ReplacePackages map[string]string | ||||
| } | ||||
| 
 | ||||
| // Format error object
 | ||||
| func (t *ConsoleFormatter) Format(errin error) (errtext string, err error) { | ||||
| 	return t.FormatSkip(errin, 1) | ||||
| } | ||||
| 
 | ||||
| // FormatSkip trace error line and format object
 | ||||
| func (t *ConsoleFormatter) FormatSkip(errin error, skip int) (errtext string, err error) { | ||||
| 	errobj := castErrorObject(nil, skip+1, errin) | ||||
| 	if errobj == nil { | ||||
| 		return "", nil | ||||
| 	} | ||||
| 
 | ||||
| 	buffer := &bytes.Buffer{} | ||||
| 
 | ||||
| 	if t.TimeFormat != "" { | ||||
| 		if _, errio := buffer.WriteString(time.Now().Format(t.TimeFormat)); errio != nil { | ||||
| 			return buffer.String(), errio | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if t.LongFile || t.ShortFile { | ||||
| 		if _, errio := WriteCallInfo(buffer, errobj, t.LongFile, t.Line, t.ReplacePackages); errio != nil { | ||||
| 			return buffer.String(), errio | ||||
| 		} | ||||
| 		if _, errio := buffer.WriteString(" "); errio != nil { | ||||
| 			return buffer.String(), errio | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if t.Seperator == "" { | ||||
| 		if _, errio := buffer.WriteString(getErrorText(errin)); errio != nil { | ||||
| 			return buffer.String(), errio | ||||
| 		} | ||||
| 		return buffer.String(), nil | ||||
| 	} | ||||
| 
 | ||||
| 	firstError := true | ||||
| 	if walkerr := WalkErrors(errobj, func(errloop ErrorObject) (stop bool, walkerr error) { | ||||
| 		if !firstError { | ||||
| 			if _, errio := buffer.WriteString(t.Seperator); errio != nil { | ||||
| 				return true, errio | ||||
| 			} | ||||
| 		} | ||||
| 		firstError = false | ||||
| 
 | ||||
| 		if _, errio := buffer.WriteString(getErrorText(errloop)); errio != nil { | ||||
| 			return true, errio | ||||
| 		} | ||||
| 		return false, nil | ||||
| 	}); walkerr != nil { | ||||
| 		return buffer.String(), walkerr | ||||
| 	} | ||||
| 
 | ||||
| 	return buffer.String(), nil | ||||
| } | ||||
| 
 | ||||
| var _ ErrorFormatter = &ConsoleFormatter{} | ||||
| var _ TraceFormatter = &ConsoleFormatter{} | ||||
							
								
								
									
										113
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorFactory.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										113
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorFactory.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,113 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"sort" | ||||
| ) | ||||
| 
 | ||||
| // ErrorFactory is used for create or check ErrorObject
 | ||||
| type ErrorFactory interface { | ||||
| 	Error() string | ||||
| 	Name() string | ||||
| 
 | ||||
| 	New(err error, params ...interface{}) ErrorObject | ||||
| 	Match(err error) bool | ||||
| 	In(err error) bool | ||||
| } | ||||
| 
 | ||||
| type errorFactory struct { | ||||
| 	errtext string | ||||
| 	name    string | ||||
| } | ||||
| 
 | ||||
| var namedFactories = map[string]ErrorFactory{} | ||||
| 
 | ||||
| // AllNamedFactories return all named factories
 | ||||
| func AllNamedFactories() map[string]ErrorFactory { | ||||
| 	return namedFactories | ||||
| } | ||||
| 
 | ||||
| // AllSortedNamedFactories return all sorted named factories
 | ||||
| // NOTE: this is slow for sorting in runtime
 | ||||
| func AllSortedNamedFactories() []ErrorFactory { | ||||
| 	sorter := newSorter(namedFactories) | ||||
| 	sort.Sort(sorter) | ||||
| 	return sorter.data | ||||
| } | ||||
| 
 | ||||
| // NewFactory return new ErrorFactory instance
 | ||||
| func NewFactory(errtext string) ErrorFactory { | ||||
| 	callinfo, _ := RuntimeCaller(1) | ||||
| 	return NewNamedFactory(callinfo.PackageName()+"->"+errtext, errtext) | ||||
| } | ||||
| 
 | ||||
| // NewNamedFactory return new ErrorFactory instance with factory name, panic if name duplicated
 | ||||
| func NewNamedFactory(name string, errtext string) ErrorFactory { | ||||
| 	if _, ok := namedFactories[name]; ok { | ||||
| 		panic(fmt.Errorf("error factory name duplicated: %q", name)) | ||||
| 	} | ||||
| 	factory := &errorFactory{ | ||||
| 		errtext: errtext, | ||||
| 		name:    name, | ||||
| 	} | ||||
| 	namedFactories[name] = factory | ||||
| 	return factory | ||||
| } | ||||
| 
 | ||||
| // FactoryOf return factory of error, return nil if not factory found
 | ||||
| func FactoryOf(err error) ErrorFactory { | ||||
| 	errobj := castErrorObject(nil, 1, err) | ||||
| 	if errobj == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return errobj.Factory() | ||||
| } | ||||
| 
 | ||||
| func (t errorFactory) Error() string { | ||||
| 	return t.errtext | ||||
| } | ||||
| 
 | ||||
| func (t errorFactory) Name() string { | ||||
| 	return t.name | ||||
| } | ||||
| 
 | ||||
| func (t *errorFactory) New(parent error, params ...interface{}) ErrorObject { | ||||
| 	errobj := castErrorObject(t, 1, fmt.Errorf(t.errtext, params...)) | ||||
| 	errobj.SetParent(castErrorObject(nil, 1, parent)) | ||||
| 	return errobj | ||||
| } | ||||
| 
 | ||||
| func (t *errorFactory) Match(err error) bool { | ||||
| 	if t == nil || err == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 
 | ||||
| 	errcomp := castErrorObject(nil, 1, err) | ||||
| 	if errcomp == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 
 | ||||
| 	return errcomp.Factory() == t | ||||
| } | ||||
| 
 | ||||
| func (t *errorFactory) In(err error) bool { | ||||
| 	if t == nil || err == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 
 | ||||
| 	exist := false | ||||
| 
 | ||||
| 	if errtmp := WalkErrors(castErrorObject(nil, 1, err), func(errcomp ErrorObject) (stop bool, walkerr error) { | ||||
| 		if errcomp.Factory() == t { | ||||
| 			exist = true | ||||
| 			return true, nil | ||||
| 		} | ||||
| 		return false, nil | ||||
| 	}); errtmp != nil { | ||||
| 		panic(errtmp) | ||||
| 	} | ||||
| 
 | ||||
| 	return exist | ||||
| } | ||||
| 
 | ||||
| var _ ErrorFactory = (*errorFactory)(nil) | ||||
							
								
								
									
										12
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorFormatter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorFormatter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,12 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| // ErrorFormatter to format error
 | ||||
| type ErrorFormatter interface { | ||||
| 	Format(error) (string, error) | ||||
| } | ||||
| 
 | ||||
| // TraceFormatter to trace error occur line formatter
 | ||||
| type TraceFormatter interface { | ||||
| 	ErrorFormatter | ||||
| 	FormatSkip(errin error, skip int) (string, error) | ||||
| } | ||||
							
								
								
									
										57
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorJSON.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										57
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorJSON.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,57 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| import ( | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| // ErrorJSON is a helper struct for display error
 | ||||
| type ErrorJSON struct { | ||||
| 	ErrorPath      string          `json:"errorpath,omitempty"` | ||||
| 	ErrorMsg       string          `json:"error,omitempty"` | ||||
| 	ErrorMsgs      []string        `json:"errors,omitempty"` | ||||
| 	ErrorFactories map[string]bool `json:"errfac,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // NewJSON create ErrorJSON
 | ||||
| func NewJSON(err error) (*ErrorJSON, error) { | ||||
| 	return newJSON(1, err) | ||||
| } | ||||
| 
 | ||||
| func newJSON(skip int, err error) (*ErrorJSON, error) { | ||||
| 	errobj := castErrorObject(nil, skip+1, err) | ||||
| 	if errobj == nil { | ||||
| 		return nil, nil | ||||
| 	} | ||||
| 
 | ||||
| 	errors := []string{} | ||||
| 	facs := map[string]bool{} | ||||
| 	if err := WalkErrors(errobj, func(errcomp ErrorObject) (stop bool, walkerr error) { | ||||
| 		errors = append(errors, getErrorText(errcomp)) | ||||
| 		factory := errcomp.Factory() | ||||
| 		if factory != nil { | ||||
| 			if !strings.Contains(factory.Name(), "->") { | ||||
| 				facs[factory.Name()] = true | ||||
| 			} | ||||
| 		} | ||||
| 		return false, nil | ||||
| 	}); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return &ErrorJSON{ | ||||
| 		ErrorPath:      errobj.PackageName() + "/" + errobj.FileName() + ":" + strconv.Itoa(errobj.Line()), | ||||
| 		ErrorMsg:       getErrorText(errobj), | ||||
| 		ErrorMsgs:      errors, | ||||
| 		ErrorFactories: facs, | ||||
| 	}, nil | ||||
| } | ||||
| 
 | ||||
| func (t *ErrorJSON) Error() string { | ||||
| 	if t == nil { | ||||
| 		return "" | ||||
| 	} | ||||
| 	return t.ErrorMsg | ||||
| } | ||||
| 
 | ||||
| var _ error = (*ErrorJSON)(nil) | ||||
							
								
								
									
										133
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorObject.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										133
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorObject.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,133 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 
 | ||||
| 	"github.com/tsaikd/KDGoLib/runtimecaller" | ||||
| ) | ||||
| 
 | ||||
| // errors
 | ||||
| var ( | ||||
| 	ErrorWalkLoop = NewFactory("detect error component parents loop when walking") | ||||
| ) | ||||
| 
 | ||||
| // New return a new ErrorObject object
 | ||||
| func New(text string, errs ...error) ErrorObject { | ||||
| 	if text != "" { | ||||
| 		errs = append([]error{errors.New(text)}, errs...) | ||||
| 	} | ||||
| 	return NewErrorsSkip(1, errs...) | ||||
| } | ||||
| 
 | ||||
| // NewErrors return ErrorObject that contains all input errors
 | ||||
| func NewErrors(errs ...error) ErrorObject { | ||||
| 	return NewErrorsSkip(1, errs...) | ||||
| } | ||||
| 
 | ||||
| // NewErrorsSkip return ErrorObject, skip function call
 | ||||
| func NewErrorsSkip(skip int, errs ...error) ErrorObject { | ||||
| 	var errcomp ErrorObject | ||||
| 	var errtmp ErrorObject | ||||
| 	for i, size := 0, len(errs); i < size; i++ { | ||||
| 		errtmp = castErrorObject(nil, skip+1, errs[i]) | ||||
| 		if errtmp == nil { | ||||
| 			continue | ||||
| 		} | ||||
| 
 | ||||
| 		if errcomp == nil { | ||||
| 			errcomp = errtmp | ||||
| 			continue | ||||
| 		} | ||||
| 
 | ||||
| 		if err := AddParent(errcomp, errtmp); err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
| 	return errcomp | ||||
| } | ||||
| 
 | ||||
| // ErrorObject is a rich error interface
 | ||||
| type ErrorObject interface { | ||||
| 	Error() string | ||||
| 	Factory() ErrorFactory | ||||
| 	Parent() ErrorObject | ||||
| 	SetParent(parent ErrorObject) ErrorObject | ||||
| 	runtimecaller.CallInfo | ||||
| } | ||||
| 
 | ||||
| type errorObject struct { | ||||
| 	errtext string | ||||
| 	factory ErrorFactory | ||||
| 	parent  ErrorObject | ||||
| 	runtimecaller.CallInfo | ||||
| } | ||||
| 
 | ||||
| func castErrorObject(factory ErrorFactory, skip int, err error) ErrorObject { | ||||
| 	if err == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	switch err.(type) { | ||||
| 	case errorObject: | ||||
| 		res := err.(errorObject) | ||||
| 		return &res | ||||
| 	case *errorObject: | ||||
| 		return err.(*errorObject) | ||||
| 	case ErrorObject: | ||||
| 		return err.(ErrorObject) | ||||
| 	default: | ||||
| 		callinfo, _ := RuntimeCaller(skip + 1) | ||||
| 		return &errorObject{ | ||||
| 			errtext:  err.Error(), | ||||
| 			factory:  factory, | ||||
| 			CallInfo: callinfo, | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func getErrorText(errin error) string { | ||||
| 	errobj, ok := errin.(*errorObject) | ||||
| 	if ok { | ||||
| 		return errobj.errtext | ||||
| 	} | ||||
| 	return errin.Error() | ||||
| } | ||||
| 
 | ||||
| func (t errorObject) Error() string { | ||||
| 	errtext, _ := errorObjectFormatter.Format(&t) | ||||
| 	return errtext | ||||
| } | ||||
| 
 | ||||
| func (t *errorObject) Factory() ErrorFactory { | ||||
| 	if t == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return t.factory | ||||
| } | ||||
| 
 | ||||
| func (t *errorObject) Parent() ErrorObject { | ||||
| 	if t == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return t.parent | ||||
| } | ||||
| 
 | ||||
| func (t *errorObject) SetParent(parent ErrorObject) ErrorObject { | ||||
| 	if t == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	if t == parent { | ||||
| 		return t | ||||
| 	} | ||||
| 	t.parent = parent | ||||
| 	return t | ||||
| } | ||||
| 
 | ||||
| func (t *errorObject) MarshalJSON() ([]byte, error) { | ||||
| 	return MarshalJSON(t) | ||||
| } | ||||
| 
 | ||||
| var _ ErrorObject = (*errorObject)(nil) | ||||
| 
 | ||||
| var errorObjectFormatter = ErrorFormatter(&ConsoleFormatter{ | ||||
| 	Seperator: "; ", | ||||
| }) | ||||
							
								
								
									
										88
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorObjectUtil.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/ErrorObjectUtil.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,88 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| import "encoding/json" | ||||
| 
 | ||||
| // WalkFunc is a callback for WalkErrors
 | ||||
| type WalkFunc func(errcomp ErrorObject) (stop bool, err error) | ||||
| 
 | ||||
| // WalkErrors walk from base error through all parents
 | ||||
| // return ErrorWalkLoop if detected loop
 | ||||
| func WalkErrors(base ErrorObject, walkFunc WalkFunc) (err error) { | ||||
| 	if base == nil { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	loopCheckMap := map[ErrorObject]bool{} | ||||
| 	for base != nil { | ||||
| 		if _, exist := loopCheckMap[base]; exist { | ||||
| 			return ErrorWalkLoop.New(nil) | ||||
| 		} | ||||
| 		loopCheckMap[base] = true | ||||
| 
 | ||||
| 		stop, walkerr := walkFunc(base) | ||||
| 		if walkerr != nil { | ||||
| 			return walkerr | ||||
| 		} | ||||
| 		if stop { | ||||
| 			return | ||||
| 		} | ||||
| 
 | ||||
| 		base = base.Parent() | ||||
| 	} | ||||
| 
 | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // Length count number of ErrorObject and all parents, return -1 if error
 | ||||
| func Length(base ErrorObject) int { | ||||
| 	length := 0 | ||||
| 	if err := WalkErrors(base, func(errcomp ErrorObject) (stop bool, walkerr error) { | ||||
| 		length++ | ||||
| 		return false, nil | ||||
| 	}); err != nil { | ||||
| 		return -1 | ||||
| 	} | ||||
| 	return length | ||||
| } | ||||
| 
 | ||||
| // AddParent add parent to errobj
 | ||||
| func AddParent(errobj ErrorObject, parent ErrorObject) error { | ||||
| 	if errobj == nil || parent == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 
 | ||||
| 	// set parent if not exist
 | ||||
| 	if errobj.Parent() == nil { | ||||
| 		errobj.SetParent(parent) | ||||
| 		return nil | ||||
| 	} | ||||
| 
 | ||||
| 	// find oldest parent to set
 | ||||
| 	base := errobj | ||||
| 	if err := WalkErrors(base.Parent(), func(errcomp ErrorObject) (stop bool, walkerr error) { | ||||
| 		// already in parent tree
 | ||||
| 		if errcomp == parent { | ||||
| 			base = nil | ||||
| 			return true, nil | ||||
| 		} | ||||
| 		base = errcomp | ||||
| 		return false, nil | ||||
| 	}); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if base != nil { | ||||
| 		base.SetParent(parent) | ||||
| 	} | ||||
| 
 | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| // MarshalJSON marshal error to json
 | ||||
| func MarshalJSON(errobj error) ([]byte, error) { | ||||
| 	errjson, err := newJSON(1, errobj) | ||||
| 	if errjson == nil || err != nil { | ||||
| 		return []byte(""), err | ||||
| 	} | ||||
| 	return json.Marshal(errjson) | ||||
| } | ||||
							
								
								
									
										37
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/JSONFormatter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										37
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/JSONFormatter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,37 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| ) | ||||
| 
 | ||||
| // NewJSONFormatter create JSONFormatter instance
 | ||||
| func NewJSONFormatter() *JSONFormatter { | ||||
| 	return &JSONFormatter{} | ||||
| } | ||||
| 
 | ||||
| // JSONFormatter used to format error to json
 | ||||
| type JSONFormatter struct{} | ||||
| 
 | ||||
| // Format error to json
 | ||||
| func (t *JSONFormatter) Format(errin error) (errtext string, err error) { | ||||
| 	return t.FormatSkip(errin, 1) | ||||
| } | ||||
| 
 | ||||
| // FormatSkip trace error line and format to json
 | ||||
| func (t *JSONFormatter) FormatSkip(errin error, skip int) (errtext string, err error) { | ||||
| 	errjson, err := newJSON(skip+1, errin) | ||||
| 	if errjson == nil || err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 
 | ||||
| 	buffer := &bytes.Buffer{} | ||||
| 	if err = json.NewEncoder(buffer).Encode(errjson); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	return buffer.String(), nil | ||||
| } | ||||
| 
 | ||||
| var _ ErrorFormatter = &JSONFormatter{} | ||||
| var _ TraceFormatter = &JSONFormatter{} | ||||
							
								
								
									
										88
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,88 +0,0 @@ | ||||
| errutil | ||||
| ======= | ||||
| 
 | ||||
| An error handling helper, providing more APIs than built-in package (errors, fmt), and compatible with go error interface | ||||
| 
 | ||||
| ## Why use errutil instead of built-in errors and fmt | ||||
| 
 | ||||
| [](https://milkr.io/tsaikd/Go-lang-error-handling) | ||||
| 
 | ||||
| * https://milkr.io/tsaikd/Go-lang-error-handling | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| * Import package from master branch | ||||
| 
 | ||||
| ``` | ||||
| import "github.com/tsaikd/KDGoLib/errutil" | ||||
| ``` | ||||
| 
 | ||||
| * Declare error factory | ||||
| 
 | ||||
| ``` | ||||
| var ErrorOccurWithReason = errutil.NewFactory("An error occur, reason: %q") | ||||
| ``` | ||||
| 
 | ||||
| * Return error with factory | ||||
| 
 | ||||
| ``` | ||||
| func doSomething() (err error) { | ||||
| 	// do something | ||||
| 
 | ||||
| 	// return error with factory, | ||||
| 	// first argument is parent error, | ||||
| 	// the others are used for factory | ||||
| 	return ErrorOccurWithReason.New(nil, "some reason here") | ||||
| } | ||||
| ``` | ||||
| 
 | ||||
| * Handle errors | ||||
| 
 | ||||
| ``` | ||||
| func errorHandlingForOneCase() { | ||||
| 	if err := doSomething(); err != nil { | ||||
| 		if ErrorOccurWithReason.In(err) { | ||||
| 			// handling expected error | ||||
| 			return | ||||
| 		} | ||||
| 
 | ||||
| 		// handling unexpected error | ||||
| 		return | ||||
| 	} | ||||
| } | ||||
| ``` | ||||
| 
 | ||||
| ``` | ||||
| func errorHandlingForMultipleCases() { | ||||
| 	if err := doSomething(); err != nil { | ||||
| 		switch errutil.FactoryOf(err) { | ||||
| 		case ErrorOccurWithReason: | ||||
| 			// handling expected error | ||||
| 			return | ||||
| 		default: | ||||
| 			// handling unexpected error | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| ``` | ||||
| 
 | ||||
| ## Optional usage | ||||
| 
 | ||||
| * Import from v1 branch | ||||
| 
 | ||||
| ``` | ||||
| import "gopkg.in/tsaikd/KDGoLib.v1/errutil" | ||||
| ``` | ||||
| 
 | ||||
| * Use like built-in errors package | ||||
|   * bad case because all errors should be exported for catching by other package | ||||
| 
 | ||||
| ``` | ||||
| func doSomething() (err error) { | ||||
| 	// do something | ||||
| 
 | ||||
| 	// return error with factory | ||||
| 	return errutil.New("An error occur") | ||||
| } | ||||
| ``` | ||||
							
								
								
									
										86
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/RuntimeCaller.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										86
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/RuntimeCaller.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,86 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"io" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 
 | ||||
| 	"github.com/tsaikd/KDGoLib/runtimecaller" | ||||
| ) | ||||
| 
 | ||||
| // DefaultRuntimeCallerFilter use for filter error stack info
 | ||||
| var DefaultRuntimeCallerFilter = []runtimecaller.Filter{} | ||||
| 
 | ||||
| func init() { | ||||
| 	DefaultRuntimeCallerFilter = append( | ||||
| 		runtimecaller.FilterCommons, | ||||
| 		RuntimeCallerFilterStopErrutilPackage, | ||||
| 		RuntimeCallerFilterStopSQLUtilPackage, | ||||
| 	) | ||||
| } | ||||
| 
 | ||||
| // AddRuntimeCallerFilter add filters to DefaultRuntimeCallerFilter for RuntimeCaller()
 | ||||
| func AddRuntimeCallerFilter(filters ...runtimecaller.Filter) { | ||||
| 	DefaultRuntimeCallerFilter = append(DefaultRuntimeCallerFilter, filters...) | ||||
| } | ||||
| 
 | ||||
| // RuntimeCallerFilterStopErrutilPackage filter CallInfo to stop after reach KDGoLib/errutil package
 | ||||
| func RuntimeCallerFilterStopErrutilPackage(callinfo runtimecaller.CallInfo) (valid bool, stop bool) { | ||||
| 	if callinfo.PackageName() == "github.com/tsaikd/KDGoLib/errutil" { | ||||
| 		return false, true | ||||
| 	} | ||||
| 	return true, false | ||||
| } | ||||
| 
 | ||||
| // RuntimeCallerFilterStopSQLUtilPackage filter CallInfo to stop after reach KDGoLib/sqlutil package
 | ||||
| func RuntimeCallerFilterStopSQLUtilPackage(callinfo runtimecaller.CallInfo) (valid bool, stop bool) { | ||||
| 	if callinfo.PackageName() == "github.com/tsaikd/KDGoLib/sqlutil" { | ||||
| 		return false, true | ||||
| 	} | ||||
| 	return true, false | ||||
| } | ||||
| 
 | ||||
| // RuntimeCaller wrap runtimecaller.GetByFilters() with DefaultRuntimeCallerFilter
 | ||||
| func RuntimeCaller(skip int, extraFilters ...runtimecaller.Filter) (callinfo runtimecaller.CallInfo, ok bool) { | ||||
| 	filters := append(DefaultRuntimeCallerFilter, extraFilters...) | ||||
| 	return runtimecaller.GetByFilters(skip+1, filters...) | ||||
| } | ||||
| 
 | ||||
| // WriteCallInfo write readable callinfo with options
 | ||||
| func WriteCallInfo( | ||||
| 	output io.Writer, | ||||
| 	callinfo runtimecaller.CallInfo, | ||||
| 	longFile bool, | ||||
| 	line bool, | ||||
| 	replacePackages map[string]string, | ||||
| ) (n int, err error) { | ||||
| 	buffer := &bytes.Buffer{} | ||||
| 	if longFile { | ||||
| 		pkgname := replacePackage(replacePackages, callinfo.PackageName()) | ||||
| 		if _, err = buffer.WriteString(pkgname + "/" + callinfo.FileName()); err != nil { | ||||
| 			return | ||||
| 		} | ||||
| 	} else { | ||||
| 		if _, err = buffer.WriteString(callinfo.FileName()); err != nil { | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 	if line { | ||||
| 		if _, err = buffer.WriteString(":" + strconv.Itoa(callinfo.Line())); err != nil { | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 	return output.Write([]byte(buffer.String())) | ||||
| } | ||||
| 
 | ||||
| func replacePackage(replacePackages map[string]string, pkgname string) (replaced string) { | ||||
| 	replaced = pkgname | ||||
| 	if replacePackages == nil { | ||||
| 		return | ||||
| 	} | ||||
| 	for src, tar := range replacePackages { | ||||
| 		replaced = strings.Replace(replaced, src, tar, -1) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										127
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/logger.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										127
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/logger.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,127 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"os" | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| // LoggerType declare general log types
 | ||||
| type LoggerType interface { | ||||
| 	Debug(v ...interface{}) | ||||
| 	Print(v ...interface{}) | ||||
| 	Error(v ...interface{}) | ||||
| 	Trace(errin error) | ||||
| 	TraceSkip(errin error, skip int) | ||||
| } | ||||
| 
 | ||||
| // Logger return default LoggerType instance
 | ||||
| func Logger() LoggerType { | ||||
| 	return defaultLogger | ||||
| } | ||||
| 
 | ||||
| // NewLogger create LoggerType instance
 | ||||
| func NewLogger(opt LoggerOptions) LoggerType { | ||||
| 	opt.check() | ||||
| 	return loggerImpl{ | ||||
| 		opt: opt, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // LoggerOptions for Logger
 | ||||
| type LoggerOptions struct { | ||||
| 	DefaultOutput   io.Writer | ||||
| 	ErrorOutput     io.Writer | ||||
| 	HideFile        bool | ||||
| 	ShortFile       bool | ||||
| 	HideLine        bool | ||||
| 	ReplacePackages map[string]string | ||||
| 	TraceFormatter  TraceFormatter | ||||
| } | ||||
| 
 | ||||
| func (t *LoggerOptions) check() { | ||||
| 	if t.DefaultOutput == nil { | ||||
| 		t.DefaultOutput = os.Stdout | ||||
| 	} | ||||
| 	if t.ErrorOutput == nil { | ||||
| 		t.ErrorOutput = os.Stderr | ||||
| 	} | ||||
| 	if t.TraceFormatter == nil { | ||||
| 		t.TraceFormatter = &ConsoleFormatter{ | ||||
| 			Seperator:  "; ", | ||||
| 			TimeFormat: "2006-01-02 15:04:05 ", | ||||
| 			LongFile:   true, | ||||
| 			Line:       true, | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| var defaultLogger = NewLogger(LoggerOptions{}) | ||||
| 
 | ||||
| // SetDefaultLogger set default LoggerType
 | ||||
| func SetDefaultLogger(logger LoggerType) { | ||||
| 	defaultLogger = logger | ||||
| } | ||||
| 
 | ||||
| type loggerImpl struct { | ||||
| 	opt LoggerOptions | ||||
| } | ||||
| 
 | ||||
| func (t loggerImpl) Debug(v ...interface{}) { | ||||
| 	t.log(t.opt.DefaultOutput, 1, v...) | ||||
| } | ||||
| 
 | ||||
| func (t loggerImpl) Print(v ...interface{}) { | ||||
| 	t.log(t.opt.DefaultOutput, 1, v...) | ||||
| } | ||||
| 
 | ||||
| func (t loggerImpl) Error(v ...interface{}) { | ||||
| 	t.log(t.opt.ErrorOutput, 1, v...) | ||||
| } | ||||
| 
 | ||||
| func (t loggerImpl) log(output io.Writer, skip int, v ...interface{}) { | ||||
| 	errtext := fmt.Sprint(v...) | ||||
| 	if errtext == "" { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	opt := t.opt | ||||
| 	if !opt.HideFile { | ||||
| 		buffer := &bytes.Buffer{} | ||||
| 		callinfo, _ := RuntimeCaller(skip + 1) | ||||
| 		if _, err := WriteCallInfo(buffer, callinfo, !opt.ShortFile, !opt.HideLine, opt.ReplacePackages); err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 		errtext = buffer.String() + " " + errtext | ||||
| 	} | ||||
| 
 | ||||
| 	if !strings.HasSuffix(errtext, "\n") { | ||||
| 		errtext += "\n" | ||||
| 	} | ||||
| 	if _, err := output.Write([]byte(errtext)); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (t loggerImpl) Trace(errin error) { | ||||
| 	TraceSkip(errin, 1) | ||||
| } | ||||
| 
 | ||||
| func (t loggerImpl) TraceSkip(errin error, skip int) { | ||||
| 	var errtext string | ||||
| 	var errfmt error | ||||
| 	if errtext, errfmt = t.opt.TraceFormatter.FormatSkip(errin, skip+1); errfmt != nil { | ||||
| 		panic(errfmt) | ||||
| 	} | ||||
| 	if errtext == "" { | ||||
| 		return | ||||
| 	} | ||||
| 	if !strings.HasSuffix(errtext, "\n") { | ||||
| 		errtext += "\n" | ||||
| 	} | ||||
| 	if _, errfmt = t.opt.ErrorOutput.Write([]byte(errtext)); errfmt != nil { | ||||
| 		panic(errfmt) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										27
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/sort.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/sort.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,27 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| func newSorter(factoryMap map[string]ErrorFactory) *sorter { | ||||
| 	data := []ErrorFactory{} | ||||
| 	for _, factory := range factoryMap { | ||||
| 		data = append(data, factory) | ||||
| 	} | ||||
| 	return &sorter{ | ||||
| 		data: data, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| type sorter struct { | ||||
| 	data []ErrorFactory | ||||
| } | ||||
| 
 | ||||
| func (t sorter) Len() int { | ||||
| 	return len(t.data) | ||||
| } | ||||
| 
 | ||||
| func (t sorter) Swap(i int, j int) { | ||||
| 	t.data[i], t.data[j] = t.data[j], t.data[i] | ||||
| } | ||||
| 
 | ||||
| func (t sorter) Less(i int, j int) bool { | ||||
| 	return t.data[i].Name() < t.data[j].Name() | ||||
| } | ||||
							
								
								
									
										19
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/trace.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/trace.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,19 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| // Trace error stack, output to default ErrorFormatter, panic if output error
 | ||||
| func Trace(errin error) { | ||||
| 	TraceSkip(errin, 1) | ||||
| } | ||||
| 
 | ||||
| // TraceWrap trace errin and wrap with wraperr only if errin != nil
 | ||||
| func TraceWrap(errin error, wraperr error) { | ||||
| 	if errin != nil { | ||||
| 		errs := NewErrorsSkip(1, wraperr, errin) | ||||
| 		TraceSkip(errs, 1) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // TraceSkip error stack, output to default ErrorFormatter, skip n function calls, panic if output error
 | ||||
| func TraceSkip(errin error, skip int) { | ||||
| 	Logger().TraceSkip(errin, 1) | ||||
| } | ||||
							
								
								
									
										19
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/tsaikd/KDGoLib/errutil/util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,19 +0,0 @@ | ||||
| package errutil | ||||
| 
 | ||||
| // ContainErrorFunc check error contain error by custom equalFunc
 | ||||
| func ContainErrorFunc(err error, equalFunc func(error) bool) bool { | ||||
| 	errobj := castErrorObject(nil, 1, err) | ||||
| 	contain := false | ||||
| 
 | ||||
| 	if walkerr := WalkErrors(errobj, func(errcomp ErrorObject) (stop bool, walkerr error) { | ||||
| 		if equalFunc(errcomp) { | ||||
| 			contain = true | ||||
| 			return true, nil | ||||
| 		} | ||||
| 		return false, nil | ||||
| 	}); walkerr != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 
 | ||||
| 	return contain | ||||
| } | ||||
							
								
								
									
										106
									
								
								vendor/github.com/tsaikd/KDGoLib/logrusutil/ConsoleLogFormatter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										106
									
								
								vendor/github.com/tsaikd/KDGoLib/logrusutil/ConsoleLogFormatter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,106 +0,0 @@ | ||||
| package logrusutil | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/tsaikd/KDGoLib/errutil" | ||||
| 	"github.com/tsaikd/KDGoLib/runtimecaller" | ||||
| ) | ||||
| 
 | ||||
| // flags
 | ||||
| const ( | ||||
| 	Llongfile = 1 << iota | ||||
| 	Lshortfile | ||||
| 	Ltime | ||||
| 	Llevel | ||||
| 	LstdFlags = Ltime | Lshortfile | Llevel | ||||
| ) | ||||
| 
 | ||||
| // ConsoleLogFormatter suitable formatter for console
 | ||||
| type ConsoleLogFormatter struct { | ||||
| 	TimestampFormat      string | ||||
| 	Flag                 int | ||||
| 	CallerOffset         int | ||||
| 	RuntimeCallerFilters []runtimecaller.Filter | ||||
| } | ||||
| 
 | ||||
| func addspace(text string, addspaceflag bool) (string, bool) { | ||||
| 	if addspaceflag { | ||||
| 		return " " + text, true | ||||
| 	} | ||||
| 	return text, true | ||||
| } | ||||
| 
 | ||||
| func filterLogrusRuntimeCaller(callinfo runtimecaller.CallInfo) (valid bool, stop bool) { | ||||
| 	return !strings.Contains(callinfo.PackageName(), "github.com/sirupsen/logrus"), false | ||||
| } | ||||
| 
 | ||||
| // Format output logrus entry
 | ||||
| func (t *ConsoleLogFormatter) Format(entry *logrus.Entry) (data []byte, err error) { | ||||
| 	buffer := bytes.Buffer{} | ||||
| 	addspaceflag := false | ||||
| 
 | ||||
| 	if t.Flag == 0 { | ||||
| 		t.Flag = LstdFlags | ||||
| 	} | ||||
| 
 | ||||
| 	if t.TimestampFormat == "" { | ||||
| 		t.TimestampFormat = time.RFC3339 | ||||
| 	} | ||||
| 
 | ||||
| 	if t.Flag&Ltime != 0 { | ||||
| 		timetext := entry.Time.Format(t.TimestampFormat) | ||||
| 		timetext, addspaceflag = addspace(timetext, addspaceflag) | ||||
| 		if _, err = buffer.WriteString(timetext); err != nil { | ||||
| 			err = errutil.New("write timestamp to buffer failed", err) | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if t.Flag&(Lshortfile|Llongfile) != 0 { | ||||
| 		var filelinetext string | ||||
| 		filters := append([]runtimecaller.Filter{filterLogrusRuntimeCaller}, t.RuntimeCallerFilters...) | ||||
| 		if callinfo, ok := errutil.RuntimeCaller(1+t.CallerOffset, filters...); ok { | ||||
| 			if t.Flag&Lshortfile != 0 { | ||||
| 				filelinetext = fmt.Sprintf("%s:%d", callinfo.FileName(), callinfo.Line()) | ||||
| 			} else { | ||||
| 				filelinetext = fmt.Sprintf("%s/%s:%d", callinfo.PackageName(), callinfo.FileName(), callinfo.Line()) | ||||
| 			} | ||||
| 
 | ||||
| 			filelinetext, addspaceflag = addspace(filelinetext, addspaceflag) | ||||
| 		} | ||||
| 
 | ||||
| 		if _, err = buffer.WriteString(filelinetext); err != nil { | ||||
| 			err = errutil.New("write fileline to buffer failed", err) | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if t.Flag&Llevel != 0 { | ||||
| 		leveltext := fmt.Sprintf("[%s]", entry.Level.String()) | ||||
| 		leveltext, addspaceflag = addspace(leveltext, addspaceflag) | ||||
| 		if _, err = buffer.WriteString(leveltext); err != nil { | ||||
| 			err = errutil.New("write level to buffer failed", err) | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	message := entry.Message | ||||
| 	message, _ = addspace(message, addspaceflag) | ||||
| 	if _, err = buffer.WriteString(message); err != nil { | ||||
| 		err = errutil.New("write message to buffer failed", err) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if err = buffer.WriteByte('\n'); err != nil { | ||||
| 		err = errutil.New("write newline to buffer failed", err) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	data = buffer.Bytes() | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										17
									
								
								vendor/github.com/tsaikd/KDGoLib/logrusutil/ConsoleLogger.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								vendor/github.com/tsaikd/KDGoLib/logrusutil/ConsoleLogger.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,17 +0,0 @@ | ||||
| package logrusutil | ||||
| 
 | ||||
| import ( | ||||
| 	"os" | ||||
| 
 | ||||
| 	"github.com/sirupsen/logrus" | ||||
| ) | ||||
| 
 | ||||
| // NewConsoleLogger create new Logger with ConsoleLogFormatter
 | ||||
| func NewConsoleLogger() *logrus.Logger { | ||||
| 	return &logrus.Logger{ | ||||
| 		Out:       os.Stdout, | ||||
| 		Formatter: &ConsoleLogFormatter{}, | ||||
| 		Hooks:     make(logrus.LevelHooks), | ||||
| 		Level:     logrus.InfoLevel, | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										17
									
								
								vendor/github.com/tsaikd/KDGoLib/logrusutil/stack.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								vendor/github.com/tsaikd/KDGoLib/logrusutil/stack.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,17 +0,0 @@ | ||||
| package logrusutil | ||||
| 
 | ||||
| import "github.com/sirupsen/logrus" | ||||
| 
 | ||||
| // StackLogLevel temporary change log level and return recover function
 | ||||
| func StackLogLevel(logger *logrus.Logger, level logrus.Level) (recover func()) { | ||||
| 	if logger.Level == level { | ||||
| 		return func() {} | ||||
| 	} | ||||
| 
 | ||||
| 	originLevel := logger.Level | ||||
| 	logger.Level = level | ||||
| 
 | ||||
| 	return func() { | ||||
| 		logger.Level = originLevel | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										75
									
								
								vendor/github.com/tsaikd/KDGoLib/runtimecaller/callinfo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										75
									
								
								vendor/github.com/tsaikd/KDGoLib/runtimecaller/callinfo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,75 +0,0 @@ | ||||
| package runtimecaller | ||||
| 
 | ||||
| import "runtime" | ||||
| 
 | ||||
| // CallInfo contains runtime caller information
 | ||||
| type CallInfo interface { | ||||
| 	// builtin data
 | ||||
| 	PC() uintptr | ||||
| 	FilePath() string | ||||
| 	Line() int | ||||
| 
 | ||||
| 	// extra info after some process
 | ||||
| 	PCFunc() *runtime.Func | ||||
| 	PackageName() string | ||||
| 	FileDir() string | ||||
| 	FileName() string | ||||
| 	FuncName() string | ||||
| } | ||||
| 
 | ||||
| // CallInfoImpl implement CallInfo
 | ||||
| type CallInfoImpl struct { | ||||
| 	// builtin data
 | ||||
| 	pc       uintptr | ||||
| 	filePath string | ||||
| 	line     int | ||||
| 
 | ||||
| 	// extra info after some process
 | ||||
| 	pcFunc      *runtime.Func | ||||
| 	packageName string | ||||
| 	fileDir     string | ||||
| 	fileName    string | ||||
| 	funcName    string | ||||
| } | ||||
| 
 | ||||
| // PC return CallInfo data
 | ||||
| func (t CallInfoImpl) PC() uintptr { | ||||
| 	return t.pc | ||||
| } | ||||
| 
 | ||||
| // FilePath return CallInfo data
 | ||||
| func (t CallInfoImpl) FilePath() string { | ||||
| 	return t.filePath | ||||
| } | ||||
| 
 | ||||
| // Line return CallInfo data
 | ||||
| func (t CallInfoImpl) Line() int { | ||||
| 	return t.line | ||||
| } | ||||
| 
 | ||||
| // PCFunc return CallInfo data
 | ||||
| func (t CallInfoImpl) PCFunc() *runtime.Func { | ||||
| 	return t.pcFunc | ||||
| } | ||||
| 
 | ||||
| // PackageName return CallInfo data
 | ||||
| func (t CallInfoImpl) PackageName() string { | ||||
| 	return t.packageName | ||||
| } | ||||
| 
 | ||||
| // FileDir return CallInfo data
 | ||||
| func (t CallInfoImpl) FileDir() string { | ||||
| 	return t.fileDir | ||||
| } | ||||
| 
 | ||||
| // FileName return CallInfo data
 | ||||
| func (t CallInfoImpl) FileName() string { | ||||
| 	return t.fileName | ||||
| } | ||||
| 
 | ||||
| // FuncName return CallInfo data
 | ||||
| func (t CallInfoImpl) FuncName() string { | ||||
| 	return t.funcName | ||||
| } | ||||
| 
 | ||||
| var _ = CallInfo(CallInfoImpl{}) | ||||
							
								
								
									
										26
									
								
								vendor/github.com/tsaikd/KDGoLib/runtimecaller/filter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								vendor/github.com/tsaikd/KDGoLib/runtimecaller/filter.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,26 +0,0 @@ | ||||
| package runtimecaller | ||||
| 
 | ||||
| import "strings" | ||||
| 
 | ||||
| // Filter use to filter runtime.Caller result
 | ||||
| type Filter func(callinfo CallInfo) (valid bool, stop bool) | ||||
| 
 | ||||
| // FilterCommons contains all common filters
 | ||||
| var FilterCommons = []Filter{ | ||||
| 	FilterOnlyGoSource, | ||||
| 	FilterStopRuntimeCallerPackage, | ||||
| } | ||||
| 
 | ||||
| // FilterOnlyGoSource filter CallInfo FileName end with ".go"
 | ||||
| func FilterOnlyGoSource(callinfo CallInfo) (valid bool, stop bool) { | ||||
| 	filename := strings.ToLower(callinfo.FileName()) | ||||
| 	return strings.HasSuffix(filename, ".go"), false | ||||
| } | ||||
| 
 | ||||
| // FilterStopRuntimeCallerPackage filter CallInfo to stop after reach KDGoLib/runtimecaller package
 | ||||
| func FilterStopRuntimeCallerPackage(callinfo CallInfo) (valid bool, stop bool) { | ||||
| 	if callinfo.PackageName() == "github.com/tsaikd/KDGoLib/runtimecaller" { | ||||
| 		return false, true | ||||
| 	} | ||||
| 	return true, false | ||||
| } | ||||
							
								
								
									
										92
									
								
								vendor/github.com/tsaikd/KDGoLib/runtimecaller/runtimeCaller.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										92
									
								
								vendor/github.com/tsaikd/KDGoLib/runtimecaller/runtimeCaller.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1,92 +0,0 @@ | ||||
| package runtimecaller | ||||
| 
 | ||||
| import ( | ||||
| 	"path" | ||||
| 	"runtime" | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| // GetByFilters return CallInfo until all filters are valid
 | ||||
| func GetByFilters(skip int, filters ...Filter) (callinfo CallInfo, ok bool) { | ||||
| 	filters = append(FilterCommons, filters...) | ||||
| 	for { | ||||
| 		skip++ | ||||
| 
 | ||||
| 		if callinfo, ok = retrieveCallInfo(skip); !ok { | ||||
| 			return | ||||
| 		} | ||||
| 
 | ||||
| 		valid, stop := filterAll(callinfo, filters...) | ||||
| 		if valid { | ||||
| 			return callinfo, true | ||||
| 		} | ||||
| 		if stop { | ||||
| 			return callinfo, false | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // ListByFilters return all CallInfo stack for all filters are valid
 | ||||
| func ListByFilters(skip int, filters ...Filter) (callinfos []CallInfo) { | ||||
| 	filters = append(FilterCommons, filters...) | ||||
| 	for { | ||||
| 		var callinfo CallInfo | ||||
| 		var ok bool | ||||
| 		skip++ | ||||
| 
 | ||||
| 		if callinfo, ok = retrieveCallInfo(skip); !ok { | ||||
| 			return | ||||
| 		} | ||||
| 
 | ||||
| 		valid, stop := filterAll(callinfo, filters...) | ||||
| 		if valid { | ||||
| 			callinfos = append(callinfos, callinfo) | ||||
| 		} | ||||
| 		if stop { | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // http://stackoverflow.com/questions/25262754/how-to-get-name-of-current-package-in-go
 | ||||
| func retrieveCallInfo(skip int) (result CallInfo, ok bool) { | ||||
| 	callinfo := CallInfoImpl{} | ||||
| 
 | ||||
| 	if callinfo.pc, callinfo.filePath, callinfo.line, ok = runtime.Caller(skip + 1); !ok { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	callinfo.fileDir, callinfo.fileName = path.Split(callinfo.filePath) | ||||
| 	callinfo.pcFunc = runtime.FuncForPC(callinfo.pc) | ||||
| 
 | ||||
| 	parts := strings.Split(callinfo.pcFunc.Name(), ".") | ||||
| 	pl := len(parts) | ||||
| 	if pl < 1 { | ||||
| 		return result, false | ||||
| 	} | ||||
| 	callinfo.funcName = parts[pl-1] | ||||
| 
 | ||||
| 	if pl >= 2 && parts[pl-2] != "" && parts[pl-2][0] == '(' { | ||||
| 		callinfo.funcName = parts[pl-2] + "." + callinfo.funcName | ||||
| 		callinfo.packageName = strings.Join(parts[0:pl-2], ".") | ||||
| 	} else { | ||||
| 		callinfo.packageName = strings.Join(parts[0:pl-1], ".") | ||||
| 	} | ||||
| 
 | ||||
| 	return callinfo, true | ||||
| } | ||||
| 
 | ||||
| func filterAll(callinfo CallInfo, filters ...Filter) (allvalid bool, onestop bool) { | ||||
| 	allvalid = true | ||||
| 	for _, filter := range filters { | ||||
| 		valid, stop := filter(callinfo) | ||||
| 		allvalid = allvalid && valid | ||||
| 		if stop { | ||||
| 			return allvalid, true | ||||
| 		} | ||||
| 		if !allvalid { | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										5
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							| @ -58,11 +58,6 @@ github.com/stretchr/testify/assert | ||||
| github.com/stretchr/testify/require | ||||
| # github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 | ||||
| github.com/syndtr/gocapability/capability | ||||
| # github.com/tsaikd/KDGoLib v0.0.0-20191001134900-7f3cf518e07d | ||||
| ## explicit | ||||
| github.com/tsaikd/KDGoLib/errutil | ||||
| github.com/tsaikd/KDGoLib/logrusutil | ||||
| github.com/tsaikd/KDGoLib/runtimecaller | ||||
| # github.com/urfave/cli/v2 v2.3.0 | ||||
| ## explicit | ||||
| github.com/urfave/cli/v2 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user