Hello, This's a Golang web forum!
GolangWebDev
GolangWebDev
246 1 1

Hello, This's a Golang web forum!

This site is build with golang and bolt.

Go for Web Development

With enhanced memory performance and support for several IDEs, Go powers fast and scalable web applications.

Go Hello

package main

import "fmt"

func main() {
	fmt.Println("Hello, world!")
}

Bolt Database

Bolt is an embedded key/value database for Go, which is a pure Go key/value store inspired by Howard Chu's LMDB project

Bolt Hello

db.Update(func(tx *bolt.Tx) error {
	b := tx.Bucket([]byte("MyBucket"))
	err := b.Put([]byte("answer"), []byte("42"))
	return err
})

db.View(func(tx *bolt.Tx) error {
	b := tx.Bucket([]byte("MyBucket"))
	v := b.Get([]byte("answer"))
	fmt.Printf("The answer is: %s\n", v)
	return nil
})
1

See Also


Discussion (1)

GolangWebDev
admin Jun 01, 2022 02:50 UTC

Bolt allows only one read-write transaction at a time, this site all CRUD are use transaction.

// Start a writable transaction.
tx, err := db.Begin(true)
if err != nil {
    return err
}
defer tx.Rollback()

// Use the transaction...
_, err := tx.CreateBucket([]byte("MyBucket"))
if err != nil {
    return err
}

// Commit the transaction and check for error.
if err := tx.Commit(); err != nil {
    return err
}
0
Login Topics