{"id":134429,"date":"2020-07-20T04:28:38","date_gmt":"2020-07-19T20:28:38","guid":{"rendered":"http:\/\/4563.org\/?p=134429"},"modified":"2020-07-20T04:28:38","modified_gmt":"2020-07-19T20:28:38","slug":"%e9%97%ae%e4%b8%80%e4%b8%aa-flag-%e6%a0%87%e5%87%86%e5%ba%93%e7%9a%84%e7%94%a8%e6%b3%95%e9%97%ae%e9%a2%98%ef%bc%8c-var-%e5%87%bd%e6%95%b0%e5%a3%b0%e6%98%8e%e5%8f%82%e6%95%b0%e6%98%af-value-%e7%b1%bb","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=134429","title":{"rendered":"\u95ee\u4e00\u4e2a flag \u6807\u51c6\u5e93\u7684\u7528\u6cd5\u95ee\u9898\uff0c Var \u51fd\u6570\u58f0\u660e\u53c2\u6570\u662f Value \u7c7b\u578b\uff0c\u4f46\u662f\u7528\u7684\u65f6\u5019\u5374\u9700\u8981\u4f20\u9012\u4e00\u4e2a *Value \u7c7b\u578b\u7684\u53c2\u6570"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u95ee\u4e00\u4e2a flag \u6807\u51c6\u5e93\u7684\u7528\u6cd5\u95ee\u9898\uff0c Var \u51fd\u6570\u58f0\u660e\u53c2\u6570\u662f Value \u7c7b\u578b\uff0c\u4f46\u662f\u7528\u7684\u65f6\u5019\u5374\u9700\u8981\u4f20\u9012\u4e00\u4e2a *Value \u7c7b\u578b\u7684\u53c2\u6570               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : asilin <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6700\u8fd1\u5728\u770b\u4e00\u4e9b\u5f00\u6e90 go \u9879\u76ee\u65f6\uff0c\u53d1\u73b0\u5927\u5bb6\u4f7f\u7528 flag \u6807\u51c6\u5e93\u5904\u7406\u53c2\u6570\u65f6\uff0c\u7528 flag.Var(&amp;a, &#8230;) \u6765\u8bbe\u7f6e\u547d\u4ee4\u884c\u53c2\u6570\uff0c\u4f46\u662f\u6211\u67e5\u627e flag \u6807\u51c6\u5e93\u65f6\uff0c\u53d1\u73b0\u6700\u7ec8\u8c03\u7528\u7684\u662f:<\/p>\n<p>unc Var(value Value, name string, usage string) &#8211;&gt; CommandLine.Var(value, name, usage) &#8211;&gt; func (f *FlagSet) Var(value Value, name string, usage string)<\/p>\n<p>\u6240\u4ee5\u6709\u4e9b\u7591\u95ee\uff0c\u4e3a\u4ec0\u4e48\u65b9\u6cd5\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f Value \u7c7b\u578b\uff0c\u800c\u8c03\u7528\u65f6\u5374\u9700\u8981 *Value \u7c7b\u578b\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2526650\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sdrzlyz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8220;`<br \/>type Value interface {<br \/> String() string<br \/> Set(string) error<br \/>}<\/p>\n<p>\u6ce8\u610f\uff0cValue \u662f\u4e00\u4e2a interface\uff0c\u8981\u6c42\u5b9e\u73b0 Set \u65b9\u6cd5.<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50<br \/>type A string<\/p>\n<p>func (a A) Set(str string){<br \/> a = A(str)<br \/>}<\/p>\n<p>type B string<\/p>\n<p>func (b *B) Set(str string) {<br \/> *b = B(str)<br \/>}<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2526652\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : useben <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8c03\u7528\u65f6\u5e76\u4e0d\u662f\u4f20\u5165 *Value \u7c7b\u578b, \u800c\u662f\u5b9e\u73b0\u4e86 Value \u63a5\u53e3\u7684\u5bf9\u8c61\u7684\u6307\u9488, \u56e0\u4e3a\u53c2\u6570 Value \u662f\u63a5\u53e3\u7c7b\u578b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2526654\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : asilin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6240\u4ee5\u8bf4\uff0c\u63a5\u53e3\u7c7b\u578b\u53ef\u4ee5\u662f\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u6216\u8005\u662f\u4e00\u4e2a\u6307\u9488\u7c7b\u578b\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u4e00\u4e2a flag \u6807\u51c6\u5e93\u7684\u7528\u6cd5\u95ee\u9898&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/134429"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=134429"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/134429\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=134429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=134429"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=134429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}