SilkyFalcon

Generation

generate functionWed, 07 Dec 2022

open every file in a specific folder than open all of them and write "Coded by Inventex" to the first line as a comment

package main import ( "bufio" "fmt" "io/ioutil" "os" ) func main() { files, err := ioutil.ReadDir("./") if err != nil { fmt.Println(err) os.Exit(1) } for _, f := range files { if f.Name()[0] == "." { continue } file, _ := os.Open(f.Name()) writer := bufio.NewWriter(file) writer.WriteString("// Coded by Inventex\n") writer.Flush() file.Close() } }

Questions about programming?Chat with your personal AI assistant