<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## 安裝 ``` go get -u github.com/gorilla/schema ``` ## 實例 ### simple demo ``` import "github.com/gorilla/schema" type Person struct { Name string `schema:"name"` // 支持schema標簽 Phone string `schema:"-"` // - 表示此字段不進行綁定 } // 請求參數映射 values := map[string][]string{ "Name": {"Alex"}, "Phone": {"13399999999"}, } person := new(Person) decoder := schema.NewDecoder() decoder.Decode(person, values) ``` ### 結合 http ``` type Person struct { Name string `schema:"name,required"` // custom name, must be supplied Phone string `schema:"phone"` // custom name Admin bool `schema:"-"` // this field is never set } var Decoder = schema.NewDecoder() func MyHandler2(w http.ResponseWriter, r *http.Request) { r.ParseForm() var person Person e := Decoder.Decode(&person, r.PostForm) if e != nil { w.Write([]byte(e.Error())) } fmt.Printf("%+v\n", person) // {Name: Phone:123 Admin:false} w.Write([]byte("success")) } ``` ``` curl -X POST -d "name=cpj&phone=123" http://localhost:9090 -> success curl -X POST -d "phone=123" http://localhost:9090 -> name is empty ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看