-
Setup Go cross-compile using Dave Cheney's instructions & package.
-
Copy the
myapp.conf
file to/etc/init/myapp.conf
. Change the name of the service to whatever you want to call it. -
Change the name parameter in
myapp.conf
to your application's name. -
Change the
script
/end script
block to whatever you need to startup your app.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
func foo() { kajsd hkasjdh kasjhd aksjhd kasjhd kjahsd kjahsd kajshd kajhsd kasjhd kajshd kajshd kajshd kajshd kasjdh kajshd kasjhd | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package myapp | |
// Tx represents a transaction in the application. | |
type Tx struct { | |
*sql.Tx | |
} | |
// User retrieves a user by ID. | |
func (tx *Tx) User(id int) (*User, error) { | |
u := &User{tx: tx} |
It's better to simply return the errors that occur from Tx.CreateBucket()
and Bucket.Put()
because they will rollback the transaction and the error will be returned from DB.Update()
. Then you can just check the error from DB.Update()
.
The DB.Update()
can also fail (e.g. the disk write may fail) so you should always check the return error from it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"log" | |
"github.com/benbjohnson/myapp" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sequentially insert 1M key/value pairs (in 1000 record batches). | |
$ bolt bench --count 1000000 --batch-size 1000 | |
# Write 3.939999671s (3.939us/op) (253871 op/sec) | |
# Read 1.003326413s (40ns/op) (25000000 op/sec) | |
--------- | |
# Randomly insert 1M key/value pairs (in 1000 record batches). | |
$ bolt bench --count 1000000 --batch-size 1000 --write-mode rnd | |
# Write 56.84787703s (56.847us/op) (17591 op/sec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package store | |
import ( | |
"fmt" | |
"github.com/boltdb/bolt" | |
) | |
// reap removes sessions older than a given duration. | |
// This function assumes that all session data is stored in a "sessions" bucket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go get github.com/benbjohnson/megajson | |
$ go test -test.bench=. github.com/benbjohnson/megajson/... | |
BenchmarkScanNumber 50000000 55.3 ns/op 54.25 MB/s | |
BenchmarkScanString 20000000 95.3 ns/op 104.92 MB/s | |
BenchmarkScanLongString 5000000 460 ns/op 123.79 MB/s | |
BenchmarkScanEscapedString 20000000 141 ns/op 127.27 MB/s | |
BenchmarkReadString 20000000 146 ns/op 68.36 MB/s | |
BenchmarkReadLongString 5000000 533 ns/op 106.76 MB/s | |
BenchmarkReadInt 50000000 58.9 ns/op 84.86 MB/s | |
BenchmarkReadFloat64 10000000 154 ns/op 103.63 MB/s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/binary" | |
"log" | |
"time" | |
"github.com/boltdb/bolt" | |
) |