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

МоТно ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ Π² связкС:

Π Π°Π±ΠΎΡ‚Π° с Ρ€Π°Π·Π»ΠΈΡ‡Π½Ρ‹ΠΌΠΈ Ρ„Π°ΠΉΠ»Π°ΠΌΠΈ

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