Skip to content

quangdangfit/gosdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go development toolkit

Common lib in golang (datbase wrapper, logger, ...)

###Logger:
Call in first line of main func:

package main
import (
    ...
    "github.com/quangdangfit/gosdk/utils/logger"
)

func main(){
    logger.Initialize(config.Config.Production)
    ...
}

###Mgo wrapper:

 package main
 import (
    ...
    "gopkg.in/mgo.v2/bson"
    db "github.com/quangdangfit/gosdk/database"
 )
 
 func main(){
     dbConfig := db.DBConfig{
     		Hosts:        "localhost:27017",
     		AuthDatabase: "admin",
     		AuthUserName: "",
     		AuthPassword: "",
     		Database:     "testdb",
     	}
     
     db := db.Connect(dbConfig)
    
     //Define model           
     type Brand struct {
         Code string `json:"code" bson:"code"`
         Name string `json:"name" bson:"name"`
     }

     var results = []Brand{}
     collectionName := "brand"
     filter := bson.M{"code": "code"}
     
     err = db.FindMany(collectionName, filter, "_id", &results)
     if err != nil {
        ...
     }
 }

About

Software Development Kit for Golang

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages