title: How to write to a file in golang
body: <p>i am trying to write to to a file. i read the whole content of the file and now i want to change the content of the file based on some word that i have got from the file. but when i check, the content of the file, it is still the same and it has not change. this is what i used</p>
  
  <pre><code>if strings.Contains(string(read), sam) {
      fmt.Println("this file contain that word")
      temp := strings.ToUpper(sam)
      fmt.Println(temp)
      err := ioutil.WriteFile(fi.Name(), []byte(temp), 0644)
  } else {
      fmt.Println(" the word is not in the file")
  }
  </code></pre>