In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "basic knowledge points commonly used by Golang". The explanation content in this article is simple and clear, and is easy to learn and understand. Please follow the ideas of Xiaobian to study and learn the "basic knowledge points commonly used by Golang" together.
File 1. Create file os.Create(filename)2. Open file 1) Read only os.OpenFile(filename, os.O_RDONLY, os.ModePerm)2) Write f, err := os.OpenFile(filename, os.O_WRONLY, os.ModePerm)3) Append os.OpenFile(filename, os.O_APPEND)| os.O_WRONLY, os.ModeAppend)3. Determine whether the file exists if _, err := os.Stat (filename); os.IsNotExist(err) { f, _ = os.Create (filename)}4. Write file//Write method Write f.Write ([]byte(content))//Writestring method writes f.WriteString(content) request 1.Get request resp, err := http.Get(url)//close connection defer resp.Body.Close()//read content body, err := ioutil.ReadAll (resp.Body)2.Post request resp, err : = http.Post (url,"application/x-www-form-urlencoded",strings.NewReader("name=1&pwd=2")//close connection defer resp.Body.Close()//read content body, err := ioutil.ReadAll (resp.Body) Time 1. Timestamp time.Now().Unix()2. Date conversion time.Now().Local().Format ("2006-01-02 15:04:05.000")3. Timer t := time.Tick (1 * time.Second)go onTime(t) encryption Md5 encryption h := md5.New()h.Write ([]byte(s))hex.EncodeToString (h.Sum(nil))JSON//convert data to json string json.Marshal(data)//parse jsondata := make (map[string]interface{})json.Unmarshal ([]byte(body), &data) database mysql operation type User struct{ Id int Name string}rows, err : = db.Query ("SELECT id,name FROM users")var u Userfor rows.Next(){ rows.Scan (&u.Id, &u.Name)} Thank you for reading, the above is the content of "Golang commonly used basic knowledge points", after learning this article, I believe you have a deeper understanding of Golang commonly used basic knowledge points, the specific use of the situation still needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.