Skip to content

Instantly share code, notes, and snippets.

View BNPrashanth's full-sized avatar

Prashanth BNPrashanth

  • Colombo, Sri Lanka
View GitHub Profile
public static void main(String[] args) {
// Code here..
}
class Ano {
public static void main(String[] args) {
System.out.println("Loosu AK");
}
}
@BNPrashanth
BNPrashanth / helper.go
Last active April 18, 2019 09:19
Learnings Gist
package utils
import (
"fmt"
"log"
"os"
"path/filepath"
)
// GeneralLogger exported
generalLog, err := os.OpenFile(absPath+"/general-log.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
GeneralLogger = log.New(generalLog, "General Logger:\t", log.Ldate|log.Ltime|log.Lshortfile)
ErrorLogger = log.New(generalLog, "Error Logger:\t", log.Ldate|log.Ltime|log.Lshortfile)
package main
import (
u "go-logger/src/utils"
)
func main() {
// Strting the Application
u.GeneralLogger.Println("Starting..")
func Download(url string, filename string, timeout int64) *u.ErrorResponse {
u.GeneralLogger.Println("Downloading", url, "...")
client := http.Client{
Timeout: time.Duration(timeout * int64(time.Second)),
}
resp, err := client.Get(url)
if err != nil {
u.ErrorLogger.Println("Cannot download file from the given url", err)
return u.ReturnErrorResponse(err, "Cannot download file from the given url")
}
func WriteLanguageFiles(csvFilePath string) *u.ErrorResponse {
csvFile, err := os.Open(csvFilePath)
if err != nil {
u.ErrorLogger.Println("Cannot open file:"+csvFilePath, err)
return u.ReturnErrorResponse(err, "Cannot open file:"+csvFilePath)
}
csvFileContent, err := csv.NewReader(csvFile).ReadAll()
for i, lang := range csvFileContent[0][1:] {
package utils
import (
"fmt"
"log"
"os"
"path/filepath"
)
// ErrorResponse exported
package services
import (
"encoding/csv"
"encoding/json"
"errors"
u "gsheet-to-json-csv/src/utils"
"io/ioutil"
"net/http"
"os"