コード例 #1
0
func main() {
	const filename = "manual_test_program.go"

	for _, explicitClose := range []bool{false, true} {
		r, err := mmap.Open(filename)
		if err != nil {
			log.Fatalf("Open: %v", err)
		}
		if explicitClose {
			r.Close()
		} else {
			// Leak the *mmap.ReaderAt returned by mmap.Open. The finalizer
			// should pick it up, if finalizers run at all.
		}
	}

	println("Finished all explicit Close calls.")
	println("Creating and collecting garbage.")
	println("Look for two munmap log messages.")
	println("Hit Ctrl-C to exit.")

	rng := rand.New(rand.NewSource(1))
	now := time.Now()
	for {
		garbage = make([]byte, rng.Intn(1<<20))
		if time.Since(now) > 1*time.Second {
			now = time.Now()
			print(".")
		}
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: crisadamo/SimpleDB
func GetDataFrom(file string) []int32 {
	fr, err := mmap.Open(file)
	if err != nil {
		fmt.Printf("got error msg: %s", err)
	}

	data := reflectionMapping(fr, 4)
	fr.Close()
	return data
}