Sending HTTP Request with Golang 
            
              
                
                  Last renew: April 7, 2022 pm
                
              
            
            
              The way to send a HTTP request with golang 注:本文仅为个人学习笔记,无任何版权。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 package  mainimport  ("encoding/base64" "github.com/imroc/req/v3" "github.com/jltorresm/otpgo" "github.com/jltorresm/otpgo/config" func  main () "wang.tianchen333@gmail.comHENNGECHALLENGE003" ,"wang.tianchen333@gmail.com"  +":"  + token"basic "  + base64.StdEncoding.EncodeToString([]byte (token1))"https://gist.github.com/xiaogeamadeus/ad9d74723a99a882c850eabb66c51d9d" ,"wang.tianchen333@gmail.com" ,"golang" }"Authorization" , auto,"Content-Type" , "application/json" ,)."https://api.challenge.hennge.com/challenges/003" )type  User struct  {string  `json:"github_url"` string  `json:"contact_email"` string  `json:"solution_language"` 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2022 /03 /12  20 : 53 : 40.763848  DEBUG [ req]  GET https: : authority:  api.challenge.hennge.com: method:  GET: path:  /challenges/003 : scheme:  https:  Mozilla/5.0  (Macintosh; Intel Mac OS X 10 _15_7) AppleWebKit/537.36  (KHTML,  like Gecko) Chrome/97.0 .4692 .71  Safari/537.36 :  gzip: status:  403 :  application/json:  68 :  Sat,  12  Mar 2022  11 : 53 : 42  GMT:  2492 fed6-b665-4 d3e-becb-0532 ed6fb218:  https: :  Content-Type, X-Amz-Date, Authorization, X-Api-Key, X-Amz-Security-Token:  MissingAuthenticationTokenException:  O3p3EH04NjMFdIQ=:  GET, OPTIONS, POST, PUT:  Error from cloudfront:  1.1  e2f427863e6bdb72ad8bed72b596d81e.cloudfront.net (CloudFront):  OSL50-P1:  nLWbqmaTIGAh2btKEQOFDkk5LDTgu6DBtboJS9a-OCPfaEZ08ubPqQ=={ "message" :  "User is not authorized to access this resource" } 
1 "github_url" : "https://gist.github.com/xiaogeamadeus/ad9d74723a99a882c850eabb66c51d9d" ,"contact_email" : "wang.tianchen333@gmail.com" ,"solution_language" : "golang" 
1 {"github_url" :"https://gist.github.com/hennge/b859bd12e7a7fb418141" ,"contact_email" :"ninja@example.com" ,"solution_language" :"golang" }