Files & Databases
Π‘ΠΏΠΈΡΠΎΠΊ
Π Π°Π±ΠΎΡΠ° Ρ Π±Π°Π·Π°ΠΌΠΈ
db orm (mssql, postgres, sqlite3,..) https://github.com/jinzhu/gorm
MongoDB driver (old fork?): https://github.com/globalsign/mgo
MongoDB official driver: go get go.mongodb.org/mongo-driver
Tarantool DB driver: https://github.com/tarantool/go-tarantool
ΠΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π² ΡΠ²ΡΠ·ΠΊΠ΅:
ΠΠΎΡΡΡΠΎΠ΅Π½ΠΈΠ΅ SQL-Π·Π°ΠΏΡΠΎΡΠΎΠ² Ρ Prepared Statement: https://github.com/Masterminds/squirrel
ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ SQL-Π·Π°ΠΏΡΠΎΡΠΎΠ² ΠΊ Π±Π°Π·Π°ΠΌ: https://github.com/jmoiron/sqlx
Π Π°Π±ΠΎΡΠ° Ρ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠΌΠΈ ΡΠ°ΠΉΠ»Π°ΠΌΠΈ
xml parse&create: https://github.com/beevik/etree
parse dynamic or unknown json structure: https://github.com/Jeffail/gabs
yaml https://github.com/shopify-graveyard/yaml
sourcemap: https://gopkg.in/sourcemap.v1
json (Π΅ΡΡΡ ΠΈ "encoding/json", Ρ Π· Π² ΡΠ΅ΠΌ ΡΠ°Π·Π½ΠΈΡΠ° ΠΈ ΠΊΠ°ΠΊΠΈΠ΅ ΠΏΡΠ΅ΠΈΠΌΡΡΠ΅ΡΡΠ²Π°, ΠΊΡΠΎΠΌΠ΅ ΡΠΊΠΎΡΠΎΡΡΠΈ): https://github.com/json-iterator/go
ΠΡΠΈΠΌΠ΅ΡΡ
MongoDB
import (
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
// initMongo β Initialize MongoDB Client
func initMongo(ctx context.Context) *mongo.Client {
// MongoDB https://www.digitalocean.com/community/tutorials/how-to-use-go-with-mongodb-using-the-mongodb-go-driver-ru
mongoClientOptions := options.Client().ApplyURI("mongodb://localhost:27017/")
client, err := mongo.Connect(ctx, mongoClientOptions)
if err != nil {
return nil
}
// Check Connect
err = client.Ping(ctx, nil)
if err != nil {
return nil
}
return client
}
// Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΡ storer ΠΈ Π² Π½Π΅ΠΉ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ sources
client := initMongo(context.TODO())
var collection := client.Database("storer").Collection("sources")
Last updated