{"id":1104,"date":"2022-01-16T11:09:31","date_gmt":"2022-01-16T03:09:31","guid":{"rendered":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104"},"modified":"2022-01-17T22:50:55","modified_gmt":"2022-01-17T14:50:55","slug":"tagpassword-mask","status":"publish","type":"post","link":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104","title":{"rendered":"\u7528tag\u5be6\u4f5cPassword Mask"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u6211\u5176\u5be6\u6eff\u9a5a\u8a1d\u76ee\u524d\u597d\u50cf\u6c92\u6709\u4efb\u4f55library\u6709\u5be6\u4f5c\u9019\u500b\uff0c\u6216\u8005\u6709\u4f46\u662f\u6211\u627e\u4e0d\u5230\uff0c\u6240\u4ee5\u6211\u5c31\u5be6\u4f5c\u4e86\u4e00\u500b\u3002\u5225\u770b\u9019\u529f\u80fd\u770b\u8d77\u4f86\u5f88\u5c0f\u5de7\u7c21\u55ae\uff0c\u9019\u500b\u9700\u8981\u5c0dreflect\u6709\u76f8\u7576\u7684\u8a8d\u8b58\uff0c\u6240\u4ee5\u628a\u88fd\u4f5c\u5fc3\u5f97\u8a18\u9304\u4e0b\u4f86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6210\u54c1\u7db2\u5740<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/Rayer\/hood\">https:\/\/github.com\/Rayer\/hood<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u9700\u6c42<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u5e38\u6211\u5011server boot up\u7684\u6642\u5019\u9700\u8981\u5370\u51fa\u5f88\u591alog\uff0c\u6709\u6642\u5019\u7121\u53ef\u907f\u514d\u7684\u8981\u628a\u6574\u500bconfig\u7d66\u5370\u5230log\u4e0a\uff0c\u9019\u6a23\u6703\u7522\u751f\u4e00\u500b\u554f\u984c\uff1a\u8981\u662fconfig\u5167\u542b\u654f\u611f\u8cc7\u8a0a\uff0c\u5982\u5e33\u865f\u8ddf\u5bc6\u78bc\uff0c\u9019\u5c31\u6703\u7522\u751f\u4e00\u4e9b\u8cc7\u5b89\u554f\u984c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"go\" class=\"language-go\">log.Infof(\"bootup with config : %+v\", config)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5370\u51fa\u4f86\u5c31\u6703\u50cf\u9019\u6a23\uff08\u6a19\u6e96\u7684<code>%+v<\/code>\u6703\u5370\u51fa\u4f86\u7684\u683c\u5f0f\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"script\" class=\"language-script\">{Host:192.168.1.1 User:username Password:mypassword123}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><br>\u986f\u7136\uff0c\u9019\u662f\u4e0d\u592a\u6070\u7576\u7684\uff0c\u6240\u4ee5\u6211\u5011\u7e3d\u6b78\u4f86\u8b1b\u6709\u5e7e\u7a2e\u4f5c\u6cd5<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li> \u628a\u4ed6\u8f49json\u518d\u5370\uff0c\u628a\u654f\u611f\u7684\u5730\u65b9\u7528 <code>json:\"-\"<\/code>\u8b93\u4ed6\u4e0d\u88ab\u5370\u51fa\u4f86<\/li><li>\u5be6\u4f5c <code>func String() string<\/code>\uff0c\u628a\u654f\u611f\u8cc7\u6599\u624b\u52d5by key\u62b9\u9664\u6389<br><\/li><\/ol>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u904elog\u6709log\u7684\u683c\u5f0f\uff0c\u5c24\u5176\u7cfb\u7d71\u4e2d\u8981\u662f\u9810\u671f\u7528go struct\u539f\u751f\u683c\u5f0fparse\u4e00\u4e9bwarning\u7684\u8a71\uff0c\u66f4\u6539log\u683c\u5f0f\u4e26\u4e0d\u6070\u7576\uff0c\u6240\u4ee51\u4e0d\u662f\u500b\u597d\u65b9\u6cd5\u3002\u81f3\u65bc2\uff0c\u624b\u52d5\u5be6\u5728\u662f&#8230;.\u4e0d\u662f\u5f88\u8a0e\u559c\uff0c\u6cc1\u4e14\u8981\u662f\u4e4b\u5f8c\u6a5f\u654f\u8cc7\u6599\u591a\u4e86\uff0c\u52a0\u90fd\u52a0\u4e0d\u5b8c\u4e5f\u5bb9\u6613\u907a\u6f0f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u6700\u597d\u7684\u65b9\u6cd5\u61c9\u8a72\u662f\uff1atag\u5728Config\u9019\u500bstruct\u7684field\u88e1\u9762\uff0c\u4f86\u5ba3\u544a\u54ea\u4e9b\u662f\u654f\u611f\u8cc7\u6599\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"go\" class=\"language-go\">type Config struct {\n    Host     string\n    User     string `confidential:\"1,1\"`\n    Password string `confidential:\"2,2\"`\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u904e\u5982\u679c\u8981\u66f4\u6539\u70ba\u6578\u773e\u591a\u4ee5<code>%v<\/code> <code>%+v<\/code>\u5370\u51fa\u7684\u5730\u65b9\uff0c\u4e5f\u4e0d\u662f\u5f88\u73fe\u5be6\uff0c\u6240\u4ee5override <code>func String() string<\/code> \u8b93\u4ed6\u80fd\u5728\u4e0a\u9762\u63d0\u5230\u7684\u5730\u65b9\u81ea\u52d5\u5370\u51faconsealed\u7684\u8cc7\u6599\u662f\u6700\u597d\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u53ef\u80fd\u7684\u6210\u54c1\u5927\u6982\u5c31\u9577\u9019\u6a23<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"go\" class=\"language-go\">type ConfigWithTag struct {\n    Host     string\n    User     string `confidential:\"1,1\"`\n    Password string `confidential:\"2,2\"`\n}\n\nfunc (c ConfigWithTag) String() string {\n    ret, _ := hood.PrintConfidentialData(c)\n    return ret\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5be6\u4f5c<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u5c0dtag\u64cd\u4f5c\uff0c\u57fa\u672c\u4e0a\u90fd\u8dd1\u4e0d\u6389<code>reflect<\/code>\u3002\u53d6\u4e00\u500bfield\u4e0a\u9762\u7684tag\u5176\u5be6\u662f\u4e00\u4ef6\u6eff\u9ebb\u7169\u7684\u4e8b\u60c5\uff0c\u4ed6\u4e5f\u4e0d\u6703\u5e6b\u4f60parse\u88e1\u9762\u7684value\u3002\u662f\u6709\u4e00\u4e9blibrary\u5e6b\u4f60\u4f5c\u9019\u65b9\u9762\u7684\u4e8b\u60c5\uff0c\u6bd4\u65b9\u8aaa<a href=\"https:\/\/github.com\/fatih\/structtag\">https:\/\/github.com\/fatih\/structtag<\/a>\uff0c\u4e0d\u904e\u9019\u6b21\u5c31\u5148\u7528\u539f\u751f\u7684\u65b9\u6cd5\u4f86\u5be6\u4f5c\uff0c\u7562\u7adf\u96d6\u7136\u9ebb\u7169\uff0c\u4f46\u662f\u5176\u5be6\u9019\u500b\u5834\u666f\u9084\u6c92\u6709\u8907\u96dc\u5230\u9700\u8981\u75283rd party\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u6211\u5011\u770b\u4e00\u4e0b\u539f\u751f\u7684<code>%+v<\/code>\u662f\u9577\u4ec0\u9ebc\u6a23\u5b50<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"script\" class=\"language-script\">{Host:192.168.1.1 User:username Password:mypassword123}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u6211\u5011\u76ee\u6a19\u662f\u8f38\u51fa\u7684\u6a23\u5b50\u8ddf\u4ed6\u4e00\u81f4\uff0c\u5927\u6982\u6703\u50cf <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"script\" class=\"language-script\">{Host:192.168.1.1 User:******** Password:*************}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Go\u7684reflect\u6709\u53d6\u578b\u5225\u8ddf\u53d6\u503c\u5169\u500b\uff0c\u5206\u5225\u662f<code>.TypeOf()<\/code>\u4ee5\u53ca<code>.ValueOf()<\/code>\u3002\u4e0d\u904e\uff0c\u53d6\u578b\u5225\u624d\u6709tag\u8cc7\u8a0a\uff0c\u6240\u4ee5\u8981\u662f\u4ee5tag\u4f86\u6539\u503c\u7684\u8a71\uff0c\u90a3\u6211\u5011\u5169\u8005\u90fd\u8981\u53d6\u51fa\u4f86\uff0c\u7136\u5f8c\u5169\u8005\u53ef\u4ee5\u7528<code>.Field(i)<\/code>\u4f86\u6e9d\u901a\u3002\u4ee5type\u53d6\u5230\u7684field\u6703\u6709tag\u8cc7\u8a0a\uff0c\u4ee5value\u53d6\u5230\u7684field\u624d\u6703\u6709\u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u53c8\u8981\u53d6\u503c\u53c8\u8981\u53d6tag\u7684\u8a71\uff0c\u5927\u81f4\u4e0a\u6703\u770b\u8d77\u4f86\u50cf\u4e0b\u9762\u9019\u6a23<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"go\" class=\"language-go\">ift := reflect.TypeOf(binding)\nifv := reflect.ValueOf(binding)\n\nfor i := 0; i &lt; ift.NumField(); i++ {\n\ttag := ift.Field(i).Tag\n\tvalue := ifv.Field(i).Interface()\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d<code>Interface()<\/code>\u56de\u50b3<code>interface{}<\/code>\uff0c\u5982\u679c\u78ba\u5b9a\u578b\u5225\u7684\u8a71\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4ee5\u8a72\u578b\u5225\u53d6\u503c\uff0c\u6bd4\u65b9\u8aaa<code>String()<\/code>\u3002\u4e0d\u904e\u5728\u6211\u5011\u9019\u4f8b\u5b50\u4f86\u8b1b\uff0c\u7167\u6a23\u7528interface\u5373\u53ef\u3002\u9996\u5148\uff0c\u6211\u5011\u53ef\u4ee5\u5148\u628a\u6709tag\u8ddf\u6c92tag\u7684field\u5206\u985e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"go\" class=\"language-go\">if tagContent, exists := field.Tag.Lookup(\"confidential\"); exists {\n\t\/\/\u6709tag\n\t} else {\n\t\/\/\u7121tag\uff0c\u76f4\u63a5\u5370\u51fa\u4f86\n\t...\n\t{\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6574\u500b\u6c7a\u7b56\u6a39\u61c9\u8a72\u662f\u985e\u4f3c\u9019\u6a23<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u82e5\u6709tag:<br><ol>\n\t\t\t<li>\u6aa2\u67e5\u662f\u5426tag\u5728string\u4e0a<\/li>\n\t\t\t<li>\u6e96\u5099\u5370\u51fa\u8ddf<code>fmt.Printf(\"%+v\")<\/code>\u76f8\u5bb9\u7684\u683c\u5f0f<\/li>\n\t\t<\/ol><\/li><li>\u82e5\u6c92\u6709tag<br><ol>\n\t\t\t<li>\u6aa2\u67e5\u578b\u5225\u662f\u5426struct\uff0c\u662f\u7684\u8a71\u5c0d\u4ed6\u57f7\u884crecursive<\/li>\n\t\t\t<li>\u5176\u4ed6\u578b\u5225\u76f4\u63a5\u7528<code>fmt.Sprintf<\/code>\u5370\u51fa\u76f8\u5bb9\u683c\u5f0f<br><\/li>\n\t\t<\/ol><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5269\u4e0b\u5c31\u662f\u7c21\u55ae\u7684parse\u7684\u554f\u984c\u4e86 \u53ef\u4ee5\u53c3\u8003 <a href=\"https:\/\/github.com\/Rayer\/hood\/blob\/c7a9fb4d33da569ac3e330672e9712d11c50e88b\/hood.go\">https:\/\/github.com\/Rayer\/hood\/blob\/c7a9fb4d33da569ac3e330672e9712d11c50e88b\/hood.go<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u88e1\u9762\u7684code\u5dee\u4e0d\u591a\u9577\u9019\u6a23<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"go\" class=\"language-go\">func PrintConfidentialData(binding interface{}) (string, error) {\n\tift := reflect.TypeOf(binding)\n\tifv := reflect.ValueOf(binding)\n\tvar kvString []string\n\n\tfor i := 0; i &lt; ifv.NumField(); i++ {\n\t\tfield := ift.Field(i)\n\t\tif tagContent, exists := field.Tag.Lookup(\"confidential\"); exists {\n\t\t\tvalueField := ifv.Field(i)\n\t\t\tif valueField.Kind() != reflect.String {\n\t\t\t\treturn \"\", fmt.Errorf(\"confidental tag can be only applied on string\")\n\t\t\t}\n\t\t\tvalues := strings.Split(tagContent, \",\")\n\n\t\t\tkeepFirst := 0\n\t\t\tvar err error\n\t\t\tif len(values) &gt; 0 &amp;&amp; strings.Trim(values[0], \" \") != \"\" {\n\t\t\t\tkeepFirst, err = strconv.Atoi(strings.Trim(values[0], \" \"))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn \"\", fmt.Errorf(\"confidental value can only be integer\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tkeepTail := 0\n\t\t\tif len(values) &gt; 1 {\n\t\t\t\tkeepTail, err = strconv.Atoi(strings.Trim(values[1], \" \"))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn \"\", fmt.Errorf(\"confidental value can only be integer\")\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tret := \"\"\n\n\t\t\tvalue := valueField.String()\n\t\t\tif len(value) &lt; keepFirst &amp;&amp; len(value) &lt; keepTail {\n\t\t\t\tret = value\n\t\t\t} else {\n\t\t\t\tfor i := 0; i &lt; len(value); i++ {\n\t\t\t\t\tif i &lt; keepFirst || i &gt;= len(value)-keepTail {\n\t\t\t\t\t\tret += string(value[i])\n\t\t\t\t\t} else {\n\t\t\t\t\t\tret += \"*\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tkvString = append(kvString, fmt.Sprintf(\"%v:%v\", field.Name, ret))\n\n\t\t} else {\n\t\t\tt := field.Type\n\t\t\tif t.Kind() == reflect.Struct {\n\t\t\t\tinner, err := PrintConfidentialData(ifv.Field(i).Interface())\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn \"\", err\n\t\t\t\t}\n\t\t\t\tkvString = append(kvString, inner)\n\t\t\t} else {\n\t\t\t\tkvString = append(kvString, fmt.Sprintf(\"%v:%v\", field.Name, ifv.Field(i).Interface()))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"{\" + strings.Join(kvString, \" \") + \"}\", nil\n}\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u5176\u5be6\u6eff\u9a5a\u8a1d\u76ee\u524d\u597d\u50cf\u6c92\u6709\u4efb\u4f55library\u6709\u5be6\u4f5c\u9019\u500b\uff0c\u6216\u8005\u6709\u4f46\u662f\u6211\u627e\u4e0d\u5230\uff0c\u6240\u4ee5\u6211\u5c31\u5be6\u4f5c\u4e86\u4e00\u500b\u3002\u5225\u770b\u9019\u529f\u80fd\u770b\u8d77\u4f86\u5f88\u5c0f\u5de7\u7c21\u55ae\uff0c\u9019\u500b\u9700\u8981\u5c0dreflect\u6709\u76f8\u7576\u7684\u8a8d\u8b58\uff0c\u6240\u4ee5\u628a\u88fd\u4f5c\u5fc3\u5f97\u8a18\u9304\u4e0b\u4f86\u3002 \u6210\u54c1\u7db2\u5740 https:\/\/github.com\/Rayer\/hood \u9700\u6c42 \u901a\u5e38\u6211\u5011server boot up\u7684\u6642\u5019\u9700\u8981\u5370\u51fa\u5f88\u591alog\uff0c\u6709\u6642\u5019\u7121\u53ef\u907f\u514d\u7684\u8981\u628a\u6574\u500bconfig\u7d66\u5370\u5230log\u4e0a\uff0c\u9019\u6a23\u6703\u7522\u751f\u4e00\u500b\u554f\u984c\uff1a\u8981\u662fconfig\u5167\u542b\u654f\u611f\u8cc7\u8a0a\uff0c\u5982\u5e33\u865f\u8ddf\u5bc6\u78bc\uff0c\u9019\u5c31\u6703\u7522\u751f\u4e00\u4e9b\u8cc7\u5b89\u554f\u984c\uff1a \u5370\u51fa\u4f86\u5c31\u6703\u50cf\u9019\u6a23\uff08\u6a19\u6e96\u7684%+v\u6703\u5370\u51fa\u4f86\u7684\u683c\u5f0f\uff09 \u986f\u7136\uff0c\u9019\u662f\u4e0d\u592a\u6070\u7576\u7684\uff0c\u6240\u4ee5\u6211\u5011\u7e3d\u6b78\u4f86\u8b1b\u6709\u5e7e\u7a2e\u4f5c\u6cd5 \u628a\u4ed6\u8f49json\u518d\u5370\uff0c\u628a\u654f\u611f\u7684\u5730\u65b9\u7528 json:&#8221;-&#8220;\u8b93\u4ed6\u4e0d\u88ab\u5370\u51fa\u4f86 \u5be6\u4f5c func String() string\uff0c\u628a\u654f\u611f\u8cc7\u6599\u624b\u52d5by key\u62b9\u9664\u6389<\/p>\n","protected":false},"author":1,"featured_media":1119,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"link","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[38,84],"tags":[86,165,164],"class_list":["post-1104","post","type-post","status-publish","format-link","has-post-thumbnail","hentry","category-code","category-84","tag-golang","tag-reflect","tag-struct","post_format-post-format-link"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u7528tag\u5be6\u4f5cPassword Mask - Fox Nest<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rayer.idv.tw\/blog\/?p=1104\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7528tag\u5be6\u4f5cPassword Mask - Fox Nest\" \/>\n<meta property=\"og:description\" content=\"\u6211\u5176\u5be6\u6eff\u9a5a\u8a1d\u76ee\u524d\u597d\u50cf\u6c92\u6709\u4efb\u4f55library\u6709\u5be6\u4f5c\u9019\u500b\uff0c\u6216\u8005\u6709\u4f46\u662f\u6211\u627e\u4e0d\u5230\uff0c\u6240\u4ee5\u6211\u5c31\u5be6\u4f5c\u4e86\u4e00\u500b\u3002\u5225\u770b\u9019\u529f\u80fd\u770b\u8d77\u4f86\u5f88\u5c0f\u5de7\u7c21\u55ae\uff0c\u9019\u500b\u9700\u8981\u5c0dreflect\u6709\u76f8\u7576\u7684\u8a8d\u8b58\uff0c\u6240\u4ee5\u628a\u88fd\u4f5c\u5fc3\u5f97\u8a18\u9304\u4e0b\u4f86\u3002 \u6210\u54c1\u7db2\u5740 https:\/\/github.com\/Rayer\/hood \u9700\u6c42 \u901a\u5e38\u6211\u5011server boot up\u7684\u6642\u5019\u9700\u8981\u5370\u51fa\u5f88\u591alog\uff0c\u6709\u6642\u5019\u7121\u53ef\u907f\u514d\u7684\u8981\u628a\u6574\u500bconfig\u7d66\u5370\u5230log\u4e0a\uff0c\u9019\u6a23\u6703\u7522\u751f\u4e00\u500b\u554f\u984c\uff1a\u8981\u662fconfig\u5167\u542b\u654f\u611f\u8cc7\u8a0a\uff0c\u5982\u5e33\u865f\u8ddf\u5bc6\u78bc\uff0c\u9019\u5c31\u6703\u7522\u751f\u4e00\u4e9b\u8cc7\u5b89\u554f\u984c\uff1a \u5370\u51fa\u4f86\u5c31\u6703\u50cf\u9019\u6a23\uff08\u6a19\u6e96\u7684%+v\u6703\u5370\u51fa\u4f86\u7684\u683c\u5f0f\uff09 \u986f\u7136\uff0c\u9019\u662f\u4e0d\u592a\u6070\u7576\u7684\uff0c\u6240\u4ee5\u6211\u5011\u7e3d\u6b78\u4f86\u8b1b\u6709\u5e7e\u7a2e\u4f5c\u6cd5 \u628a\u4ed6\u8f49json\u518d\u5370\uff0c\u628a\u654f\u611f\u7684\u5730\u65b9\u7528 json:&quot;-&quot;\u8b93\u4ed6\u4e0d\u88ab\u5370\u51fa\u4f86 \u5be6\u4f5c func String() string\uff0c\u628a\u654f\u611f\u8cc7\u6599\u624b\u52d5by key\u62b9\u9664\u6389\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rayer.idv.tw\/blog\/?p=1104\" \/>\n<meta property=\"og:site_name\" content=\"Fox Nest\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-16T03:09:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-17T14:50:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/01\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"1067\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rayer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Rayer\" \/>\n<meta name=\"twitter:site\" content=\"@Rayer\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rayer\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104\"},\"author\":{\"name\":\"Rayer\",\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/#\\\/schema\\\/person\\\/498379badb270198fef0edd6b06a5bd7\"},\"headline\":\"\u7528tag\u5be6\u4f5cPassword Mask\",\"datePublished\":\"2022-01-16T03:09:31+00:00\",\"dateModified\":\"2022-01-17T14:50:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104\"},\"wordCount\":88,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/#\\\/schema\\\/person\\\/498379badb270198fef0edd6b06a5bd7\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.rayer.idv.tw\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1\",\"keywords\":[\"golang\",\"reflect\",\"struct\"],\"articleSection\":[\"\u5beb\u5bebCode\",\"\u6280\u8853\"],\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104\",\"url\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104\",\"name\":\"\u7528tag\u5be6\u4f5cPassword Mask - Fox Nest\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.rayer.idv.tw\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1\",\"datePublished\":\"2022-01-16T03:09:31+00:00\",\"dateModified\":\"2022-01-17T14:50:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.rayer.idv.tw\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.rayer.idv.tw\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1\",\"width\":1600,\"height\":1067,\"caption\":\"Password box in Internet Browser on Computer Screen\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?p=1104#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9801\",\"item\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7528tag\u5be6\u4f5cPassword Mask\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/\",\"name\":\"Fox Nest\",\"description\":\"\u6709\u6642\u5019\u7e3d\u60f3\u6709\u500b\u5730\u65b9\u653e\u653e\u96a8\u624b\u4e82\u5beb\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/#\\\/schema\\\/person\\\/498379badb270198fef0edd6b06a5bd7\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.rayer.idv.tw\\\/blog\\\/#\\\/schema\\\/person\\\/498379badb270198fef0edd6b06a5bd7\",\"name\":\"Rayer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/www.rayer.idv.tw\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/564120_490926324264770_332274456_n.jpg?fit=800%2C600&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.rayer.idv.tw\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/564120_490926324264770_332274456_n.jpg?fit=800%2C600&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.rayer.idv.tw\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/564120_490926324264770_332274456_n.jpg?fit=800%2C600&ssl=1\",\"width\":800,\"height\":600,\"caption\":\"Rayer\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/www.rayer.idv.tw\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/564120_490926324264770_332274456_n.jpg?fit=800%2C600&ssl=1\"},\"sameAs\":[\"https:\\\/\\\/www.rayer.idv.tw\",\"https:\\\/\\\/x.com\\\/Rayer\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7528tag\u5be6\u4f5cPassword Mask - Fox Nest","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104","og_locale":"zh_TW","og_type":"article","og_title":"\u7528tag\u5be6\u4f5cPassword Mask - Fox Nest","og_description":"\u6211\u5176\u5be6\u6eff\u9a5a\u8a1d\u76ee\u524d\u597d\u50cf\u6c92\u6709\u4efb\u4f55library\u6709\u5be6\u4f5c\u9019\u500b\uff0c\u6216\u8005\u6709\u4f46\u662f\u6211\u627e\u4e0d\u5230\uff0c\u6240\u4ee5\u6211\u5c31\u5be6\u4f5c\u4e86\u4e00\u500b\u3002\u5225\u770b\u9019\u529f\u80fd\u770b\u8d77\u4f86\u5f88\u5c0f\u5de7\u7c21\u55ae\uff0c\u9019\u500b\u9700\u8981\u5c0dreflect\u6709\u76f8\u7576\u7684\u8a8d\u8b58\uff0c\u6240\u4ee5\u628a\u88fd\u4f5c\u5fc3\u5f97\u8a18\u9304\u4e0b\u4f86\u3002 \u6210\u54c1\u7db2\u5740 https:\/\/github.com\/Rayer\/hood \u9700\u6c42 \u901a\u5e38\u6211\u5011server boot up\u7684\u6642\u5019\u9700\u8981\u5370\u51fa\u5f88\u591alog\uff0c\u6709\u6642\u5019\u7121\u53ef\u907f\u514d\u7684\u8981\u628a\u6574\u500bconfig\u7d66\u5370\u5230log\u4e0a\uff0c\u9019\u6a23\u6703\u7522\u751f\u4e00\u500b\u554f\u984c\uff1a\u8981\u662fconfig\u5167\u542b\u654f\u611f\u8cc7\u8a0a\uff0c\u5982\u5e33\u865f\u8ddf\u5bc6\u78bc\uff0c\u9019\u5c31\u6703\u7522\u751f\u4e00\u4e9b\u8cc7\u5b89\u554f\u984c\uff1a \u5370\u51fa\u4f86\u5c31\u6703\u50cf\u9019\u6a23\uff08\u6a19\u6e96\u7684%+v\u6703\u5370\u51fa\u4f86\u7684\u683c\u5f0f\uff09 \u986f\u7136\uff0c\u9019\u662f\u4e0d\u592a\u6070\u7576\u7684\uff0c\u6240\u4ee5\u6211\u5011\u7e3d\u6b78\u4f86\u8b1b\u6709\u5e7e\u7a2e\u4f5c\u6cd5 \u628a\u4ed6\u8f49json\u518d\u5370\uff0c\u628a\u654f\u611f\u7684\u5730\u65b9\u7528 json:\"-\"\u8b93\u4ed6\u4e0d\u88ab\u5370\u51fa\u4f86 \u5be6\u4f5c func String() string\uff0c\u628a\u654f\u611f\u8cc7\u6599\u624b\u52d5by key\u62b9\u9664\u6389","og_url":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104","og_site_name":"Fox Nest","article_published_time":"2022-01-16T03:09:31+00:00","article_modified_time":"2022-01-17T14:50:55+00:00","og_image":[{"width":1600,"height":1067,"url":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/01\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1","type":"image\/jpeg"}],"author":"Rayer","twitter_card":"summary_large_image","twitter_creator":"@Rayer","twitter_site":"@Rayer","twitter_misc":{"\u4f5c\u8005:":"Rayer","\u9810\u4f30\u95b1\u8b80\u6642\u9593":"3 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104#article","isPartOf":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104"},"author":{"name":"Rayer","@id":"https:\/\/www.rayer.idv.tw\/blog\/#\/schema\/person\/498379badb270198fef0edd6b06a5bd7"},"headline":"\u7528tag\u5be6\u4f5cPassword Mask","datePublished":"2022-01-16T03:09:31+00:00","dateModified":"2022-01-17T14:50:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104"},"wordCount":88,"commentCount":0,"publisher":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/#\/schema\/person\/498379badb270198fef0edd6b06a5bd7"},"image":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/01\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1","keywords":["golang","reflect","struct"],"articleSection":["\u5beb\u5bebCode","\u6280\u8853"],"inLanguage":"zh-TW","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rayer.idv.tw\/blog\/?p=1104#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104","url":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104","name":"\u7528tag\u5be6\u4f5cPassword Mask - Fox Nest","isPartOf":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104#primaryimage"},"image":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/01\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1","datePublished":"2022-01-16T03:09:31+00:00","dateModified":"2022-01-17T14:50:55+00:00","breadcrumb":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rayer.idv.tw\/blog\/?p=1104"]}]},{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104#primaryimage","url":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/01\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/01\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1","width":1600,"height":1067,"caption":"Password box in Internet Browser on Computer Screen"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rayer.idv.tw\/blog\/?p=1104#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9801","item":"https:\/\/www.rayer.idv.tw\/blog"},{"@type":"ListItem","position":2,"name":"\u7528tag\u5be6\u4f5cPassword Mask"}]},{"@type":"WebSite","@id":"https:\/\/www.rayer.idv.tw\/blog\/#website","url":"https:\/\/www.rayer.idv.tw\/blog\/","name":"Fox Nest","description":"\u6709\u6642\u5019\u7e3d\u60f3\u6709\u500b\u5730\u65b9\u653e\u653e\u96a8\u624b\u4e82\u5beb","publisher":{"@id":"https:\/\/www.rayer.idv.tw\/blog\/#\/schema\/person\/498379badb270198fef0edd6b06a5bd7"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rayer.idv.tw\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":["Person","Organization"],"@id":"https:\/\/www.rayer.idv.tw\/blog\/#\/schema\/person\/498379badb270198fef0edd6b06a5bd7","name":"Rayer","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/02\/564120_490926324264770_332274456_n.jpg?fit=800%2C600&ssl=1","url":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/02\/564120_490926324264770_332274456_n.jpg?fit=800%2C600&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/02\/564120_490926324264770_332274456_n.jpg?fit=800%2C600&ssl=1","width":800,"height":600,"caption":"Rayer"},"logo":{"@id":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/02\/564120_490926324264770_332274456_n.jpg?fit=800%2C600&ssl=1"},"sameAs":["https:\/\/www.rayer.idv.tw","https:\/\/x.com\/Rayer"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.rayer.idv.tw\/blog\/wp-content\/uploads\/2022\/01\/35373360_password-box-in-internet-browser-on-computer-screen.jpg?fit=1600%2C1067&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pacpZ9-hO","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1104"}],"version-history":[{"count":4,"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1104\/revisions"}],"predecessor-version":[{"id":1112,"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1104\/revisions\/1112"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=\/wp\/v2\/media\/1119"}],"wp:attachment":[{"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rayer.idv.tw\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}