My scrapbook about almost anything I stumble upon in my tech world. If you find anything useful don't forget to give thumbs-up :)


Thursday, October 6, 2022

Golang - Listing Directory Content

Once again, another os operation which we usually done via `ls` (*nix) or `dir` (windows) can be done in Golang as well.  Golang package "os" offer so many os level operations which we can use to achieve our target. Listing a directory content is pretty obvious step in day to day life and the same can be done via `os.ReadDir` function, let's explore how to - 

go run read-dir.go
Directory: /tmp
IsDir Name
false RandomWords
false com.adobe.acrobat.rna.RdrCefBrowserLock.DC
false com.adobe.reader.rna.0.1f5.DC
false com.adobe.reader.rna.1af6.1f5
true powerlog

Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group

No comments:

Post a Comment


The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.