2021年4月10日星期六

how to read and get data from txt file using golang

I have a txt file , In this file I need only int value , how can I get this value ?

txt file - Profit = 10 at the Time of ->04-06-2021 20:21:59

I am getting this file by using this code ..!

    func Profit() string {      TargetClosePrice := 110      ontickerPrice := 100      Time := time.Now()      totalProfit := TargetClosePrice - ontickerPrice      str := strconv.Itoa(totalProfit)      value := `Profit = ` + str + ` at the Time of ->` + Time.Format("01-02-2006 15:04:05") + "\n"        data, err := os.OpenFile("Profit.txt", os.O_APPEND, 0644)      if err != nil {          log.Fatal("whoops", err)      }      io.Copy(data, strings.NewReader(value))      return str  }   

but now I need only 10 from txt file..? how can I get ?

https://stackoverflow.com/questions/67041081/how-to-read-and-get-data-from-txt-file-using-golang April 11, 2021 at 11:04AM

没有评论:

发表评论