code
stringlengths
10
1.34M
language
stringclasses
1 value
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "errors" "fmt" "io" "os" "runtime" "strings" "sync" "time" "github.lab/syndtr/goleveldb/l...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "runtime" "sync" "github.lab/syndtr/goleveldb/leveldb/iterator" "github.lab/syndtr/goleveldb/l...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb const ( kNumLevels = 7 // Level-0 compaction is started when we hit this many files. kL0_CompactionTrigg...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package memdb provides in-memory key/value database implementation. package memdb import ( "math/rand" "sync" "github...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "github.lab/syndtr/goleveldb/leveldb/cache" "github.lab/syndtr/goleveldb/leveldb/filter" "github...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "errors" "sync" "time" "github.lab/syndtr/goleveldb/leveldb/memdb" ) var ( errTransactExitin...
Go
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "sync/atomic" "github.lab/syndtr/goleveldb/leveldb/journal" "github.lab/syndtr/goleveldb/leveld...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "github.lab/syndtr/goleveldb/leveldb/filter" ) type iFilter struct { filter.Filter } func (f iF...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "fmt" "sync/atomic" "github.lab/syndtr/goleveldb/leveldb/journal" "github.lab/syndtr/goleveldb...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "errors" "runtime" "github.lab/syndtr/goleveldb/leveldb/comparer" "github.lab/syndtr/goleveldb...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package comparer import "bytes" type bytesComparer struct{} func (bytesComparer) Compare(a, b []byte) int { return bytes....
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package comparer provides interface and implementation for ordering // sets of data. package comparer // BasicComparer is...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package filter import ( "github.lab/syndtr/goleveldb/leveldb/util" ) func bloomHash(key []byte) uint32 { return util.Hash...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package filter provides interface and implementation of probabilistic // data structure. // // The filter is resposible fo...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "encoding/binary" "errors" "github.lab/syndtr/goleveldb/leveldb/memdb" ) var ( errBatchTooSho...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "github.lab/syndtr/goleveldb/leveldb/iterator" "github.lab/syndtr/goleveldb/leveldb/opt" "github...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "bufio" "encoding/binary" "errors" "io" ) var errCorruptManifest = errors.New("leveldb: corrup...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package opt provides sets of options used by LevelDB. package opt import ( "github.lab/syndtr/goleveldb/leveldb/cache" ...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package table allows read and write sorted key/value. package table import ( "encoding/binary" ) /* Table: Table is co...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package table import ( "encoding/binary" "errors" "fmt" "io" "code.google.com/p/snappy-go/snappy" "github.lab/syndtr...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package table import ( "encoding/binary" "errors" "fmt" "io" "sort" "strings" "code.google.com/p/snappy-go/snappy" ...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "encoding/binary" "fmt" ) type vType int func (t vType) String() string { switch t { case tDe...
Go
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package util provides utilities used throughout leveldb. package util import ( "errors" ) var ( ErrNotFound = errors.N...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package util // This a copy of Go std bytes.Buffer with some modification // and some features stripped. import ( "bytes" "io" ) // A Buffer is a variable-...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package util import ( "bytes" "encoding/binary" ) // Hash return hash of the given data. func Hash(data []byte, seed uint...
Go
// Copyright 2011 The LevelDB-Go Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package util import ( "hash/crc32" ) var table = crc32.MakeTable(crc32.Castagnoli) // CRC is a CRC-32 checksum computed using Castagnoli's polyno...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package leveldb provides implementation of LevelDB key/value database. // // Create or open a database: // // db, err := l...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import "github.lab/syndtr/goleveldb/leveldb/comparer" type iComparer struct { cmp comparer.Comparer } fun...
Go
package main import ( "fmt" "github.lab/syndtr/goleveldb/leveldb" "strconv" "time" ) func main() { db, err := leveldb.OpenFile("/usr/local/leveldbdata", nil) if nil != err { fmt.Println(err) } for i := 0; i < 10; i++ { nano := time.Now().Nanosecond() db.Put([]byte("ceshi"+strconv.Itoa(nano)), []byte("...
Go
package main import ( "bufio" "bytes" "flag" "fmt" "os" "os/exec" "path/filepath" "github.com/syndtr/goleveldb/leveldb/storage" ) var ( filename string child bool ) func init() { flag.StringVar(&filename, "filename", filepath.Join(os.TempDir(), "goleveldb_filelock_test"), "Filename used for testing") ...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "time" "github.com/syndtr/goleveldb/leveldb/memdb" "github.com/syndtr/goleveldb/leveldb/opt" ) ...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "errors" "io" "os" "sync" "sync/atomic" "github.com/syndtr/goleveldb/leveldb/iterator" "git...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "sort" "sync/atomic" "github.com/syndtr/goleveldb/leveldb/cache" "github.com/syndtr/goleveldb/...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package iterator import ( "github.com/syndtr/goleveldb/leveldb/util" ) // IteratorIndexer is the interface that wraps Comm...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package iterator provides interface and implementation to traverse over // contents of a database. package iterator impor...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package iterator import ( "errors" "github.com/syndtr/goleveldb/leveldb/comparer" "github.com/syndtr/goleveldb/leveldb/u...
Go
// Copyright 2011 The LevelDB-Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Taken from: https://code.google.com/p/leveldb-go/source/browse/leveldb/record/record.go?r=1d5ccbe03246da926391ee12d1c6caae054ff4b0 // License, author...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "errors" "sync/atomic" "unsafe" "github.com/syndtr/goleveldb/leveldb/iterator" "github.com/sy...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "fmt" "sort" "github.com/syndtr/goleveldb/leveldb/storage" ) func shorten(str string) string {...
Go
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package storage import ( "bytes" "os" "sync" "github.com/syndtr/goleveldb/leveldb/util" ) const typeShift = 3 type me...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reservefs. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package storage import ( "errors" "fmt" "io/ioutil" "os" "path/filepath" "runtime" "strconv" "strings" "sync" "ti...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package storage provides storage abstraction for LevelDB. package storage import ( "errors" "io" "github.com/syndtr/g...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package storage import ( "os" "path/filepath" ) type plan9FileLock struct { f *os.File } func (fl *plan9FileLock) relea...
Go
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package storage import ( "syscall" "unsafe" ) var ( modkernel32 = syscall.NewLazyDLL("kernel32.dll") procMoveFileExW =...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // +build darwin freebsd linux netbsd openbsd package storage import ( "os" "syscall" ) type unixFileLock struct { f *o...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "errors" "fmt" "io" "os" "runtime" "strings" "sync" "time" "github.com/syndtr/goleveldb/l...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "runtime" "sync" "github.com/syndtr/goleveldb/leveldb/iterator" "github.com/syndtr/goleveldb/l...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb const ( kNumLevels = 7 // Level-0 compaction is started when we hit this many files. kL0_CompactionTrigg...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package memdb provides in-memory key/value database implementation. package memdb import ( "math/rand" "sync" "github...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "github.com/syndtr/goleveldb/leveldb/cache" "github.com/syndtr/goleveldb/leveldb/filter" "github...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "errors" "sync" "time" "github.com/syndtr/goleveldb/leveldb/memdb" ) var ( errTransactExitin...
Go
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "sync/atomic" "github.com/syndtr/goleveldb/leveldb/journal" "github.com/syndtr/goleveldb/leveld...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "github.com/syndtr/goleveldb/leveldb/filter" ) type iFilter struct { filter.Filter } func (f iF...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "fmt" "sync/atomic" "github.com/syndtr/goleveldb/leveldb/journal" "github.com/syndtr/goleveldb...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "errors" "runtime" "github.com/syndtr/goleveldb/leveldb/comparer" "github.com/syndtr/goleveldb...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package comparer import "bytes" type bytesComparer struct{} func (bytesComparer) Compare(a, b []byte) int { return bytes....
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package comparer provides interface and implementation for ordering // sets of data. package comparer // BasicComparer is...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package filter import ( "github.com/syndtr/goleveldb/leveldb/util" ) func bloomHash(key []byte) uint32 { return util.Hash...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package filter provides interface and implementation of probabilistic // data structure. // // The filter is resposible fo...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "encoding/binary" "errors" "github.com/syndtr/goleveldb/leveldb/memdb" ) var ( errBatchTooSho...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "github.com/syndtr/goleveldb/leveldb/iterator" "github.com/syndtr/goleveldb/leveldb/opt" "github...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "bufio" "encoding/binary" "errors" "io" ) var errCorruptManifest = errors.New("leveldb: corrup...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package opt provides sets of options used by LevelDB. package opt import ( "github.com/syndtr/goleveldb/leveldb/cache" ...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package table allows read and write sorted key/value. package table import ( "encoding/binary" ) /* Table: Table is co...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package table import ( "encoding/binary" "errors" "fmt" "io" "code.google.com/p/snappy-go/snappy" "github.com/syndtr...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package table import ( "encoding/binary" "errors" "fmt" "io" "sort" "strings" "code.google.com/p/snappy-go/snappy" ...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import ( "encoding/binary" "fmt" ) type vType int func (t vType) String() string { switch t { case tDe...
Go
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package util provides utilities used throughout leveldb. package util import ( "errors" ) var ( ErrNotFound = errors.N...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package util // This a copy of Go std bytes.Buffer with some modification // and some features stripped. import ( "bytes" "io" ) // A Buffer is a variable-...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package util import ( "bytes" "encoding/binary" ) // Hash return hash of the given data. func Hash(data []byte, seed uint...
Go
// Copyright 2011 The LevelDB-Go Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package util import ( "hash/crc32" ) var table = crc32.MakeTable(crc32.Castagnoli) // CRC is a CRC-32 checksum computed using Castagnoli's polyno...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package leveldb provides implementation of LevelDB key/value database. // // Create or open a database: // // db, err := l...
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package leveldb import "github.com/syndtr/goleveldb/leveldb/comparer" type iComparer struct { cmp comparer.Comparer } fun...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package newmath is a trivial example package. package newmath // Sqrt returns an approximation to the square root of x. func Sqrt(x float64) float64 { // ...
Go
// ----------------------------------------------------------------------------- // G O L A N G S P E C I F I C A T I O N // ----------------------------------------------------------------------------- // NAME // // xymonc.go - xymon client by Go language. // // REVISION HISTORY // 12/30/201...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Hello is a trivial example of a main package. package main import ( "fmt" "code.google.com/p/xymon/xymonlib" ) func main() { fmt.Printf("Hello, world...
Go
package main import( "github.com/spf13/cobra" "fmt" "strings" ) func main() { // var echoTimes int var cmdPrint = &cobra.Command{ Use: "print [string to print]", Short: "Print anything to the screen", Long: `print is for printing anything back to the screen. For many years peop...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import "../stdio" func main() { stdio.Stdout.WriteString(stdio.Greeting + "\n") }
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* A trivial example of wrapping a C library in Go. For a more complex example and explanation, see ../gmp/gmp.go. */ package stdio /* #include <stdio.h> #in...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore // Compute Fibonacci numbers with two goroutines // that pass integers back and forth. No actual // concurrency, just threads and synchroniz...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore // Pass numbers along a chain of threads. package main import ( "../stdio" "runtime" "strconv" ) const N = 10 const R = 5 func link(le...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore // Run the game of life in C using Go for parallelization. package main import ( "." "flag" "fmt" ) const MAXDIM = 100 var dim = flag....
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package life // #include "life.h" import "C" import "unsafe" func Run(gen, x, y int, a []int) { n := make([]int, x*y) for i := 0; i < gen; i++ { C.Step(...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This file contains test cases for cgo. package cgotest /* // issue 1222 typedef union { long align; } xxpthread_mutex_t; struct ibv_async_event { union...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest // const char *greeting = "hello, world"; import "C" import ( "reflect" "testing" "unsafe" ) const greeting = "hello, world" type testPa...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This file contains test cases for cgo. package cgotest /* int base_symbol = 0; #define alias_one base_symbol #define alias_two base_symbol */ import "C" ...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Basic test cases for cgo. package cgotest /* #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <errno.h> #define SHIFT(x, y) ((x)<<(...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest /* #include <windows.h> unsigned int sleep(unsigned int seconds) { Sleep(1000 * seconds); return 0; } */ import "C"
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest import "C" //export exportbyte func exportbyte() byte { return 0 } //export exportbool func exportbool() bool { return false } //export e...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package backdoor func LockedOSThread() bool // in runtime.c
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest /* #include <unistd.h> unsigned int sleep(unsigned int seconds); extern void BackgroundSleep(int); void twoSleep(int); */ import "C" import...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest /* void callback(void *f); void callGoFoo(void); */ import "C" import ( "./backdoor" "runtime" "testing" "unsafe" ) // nestedCall calls i...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest /* // Mac OS X's gcc will generate scattered relocation 2/1 for // this function on Darwin/386, and 8l couldn't handle it. // this example is ...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest // Test that cgo reserves enough stack space during cgo call. // See http://golang.org/issue/3945 for details. // #include <stdio.h> // // vo...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest import "testing" // extern void BackIntoGo(void); // void IntoC(void); import "C" //export BackIntoGo func BackIntoGo() { x := 1 for i :=...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest /* #include <stdio.h> typedef unsigned char Uint8; typedef unsigned short Uint16; typedef enum { MOD1 = 0x0000, MODX = 0x8000 } SDLMod; ty...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest /* #include <stdlib.h> */ import "C" import ( "os" "runtime" "testing" "unsafe" ) // This is really an os package test but here for conven...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgotest import "C" //export ReturnIntLong func ReturnIntLong() (int, C.long) { return 1, 2 }
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import "." func main() { cgosotest.Test() }
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgosotest /* #cgo LDFLAGS: -L. -lcgosotest void sofunc(void); */ import "C" func Test() { C.sofunc() } //export goCallback func goCallback() { }
Go