gitlines / golang-snippets

Useful snippets/functions for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go Report Card Build Status

golang-snippets

Some useful functions.

Subpackages

files

http

Install

go get -u github.com/peeyushsrj/golang-snippets/...

Example

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.")
	}
}

About

Useful snippets/functions for Go


Languages

Language:Go 100.0%