Some useful functions.
- Read line by line from file pointer
- Read line by line from file path
- List files in a directory
- Get filename from URL
- Append text to file
- Anonymous visit website via socks5 client (Pre-requisite: tor must be installed)
go get -u github.com/peeyushsrj/golang-snippets/...
package main
import (
"fmt"
"log"
"os"
files "github.com/peeyushsrj/golang-snippets/files"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Please specify the directory")
fmt.Println("Usage: [path]\n")
return
}
basePath := os.Args[1]
if _, err := os.Stat(basePath); err == nil {
fileNames, err := files.BrowseXFiles(".md", basePath)
if err != nil {
log.Fatal(1)
}
fmt.Println(fileNames)
} else {
fmt.Println("The input path doesn't exist.")
}
}