MENU

Fun & Interesting

This is the correct way to write and read files in Golang - Go basics

Mahmoud - MightyTuts 1,189 8 months ago
Video Not Working? Fix It Now

In this video, we dive into the fundamental concepts of handling files in Go, a powerful yet straightforward language. We start with the basics of reading and writing strings to files and gradually move towards more complex operations like handling JSON data and managing concurrent writes from multiple goroutines. You'll learn how to create, open, and close files, write strings and lines, and read files in buffered fashion. We also explore advanced topics such as safely writing to files from multiple goroutines, simulating a real-world scenario of logging data from various microservices. Whether you're a beginner or looking to refine your Go skills, this tutorial offers a comprehensive introduction to file handling in Go. Don't forget to check out the blog post linked below for detailed code snippets and further explanations. Enjoy coding! Blog Post: https://mightytuts.com/blog/golang-reading-writing-files/ Timestamps: 0:00 - Introduction 1:38 - Write string to file 06:10 - Read string from file 09:57 - Save lines to file 14:38 - Read lines from file 19:45 - Saving JSON data 25:24 - Saving to file from 100 go routines concurrently 34:55 - Outro Tools I use: - Helix Editor - Zellij terminal mux - Kitty terminal - Catpuccin Mocha everywhere - Mac mini M2 ====================================== #golang #go-tutorial #leangolang #google #programming #web 🌐 www.rovn.ai 🌐 www.mightytuts.com 𝒳 https://twitter.com/mightymoud 🧑🏼‍💻 Github https://github.com/mightymoud

Comment