code
stringlengths
10
1.34M
language
stringclasses
1 value
// 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. // RIPEMD-160 block step. // In its own file so that a faster assembly or C version // can be substituted easily. package ripemd160 // work buffer indices and...
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 otr implements the Off The Record protocol as specified in // http://www.cypherpunks.ca/otr/Protocol-v2-3.1.0.html package otr import ( "bytes" "c...
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. // This file implements the Socialist Millionaires Protocol as described in // http://www.cypherpunks.ca/otr/Protocol-v2-3.1.0.html. The protocol // specificati...
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 clearsign generates and processes OpenPGP, clear-signed data. See // RFC 4880, section 7. // // Clearsigned messages are cryptographically signed, bu...
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 s2k implements the various OpenPGP string-to-key transforms as // specified in RFC 4800 section 3.7.1. package s2k import ( "code.google.com/p/go.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 openpgp implements high level operations on OpenPGP messages. package openpgp import ( "code.google.com/p/go.crypto/openpgp/armor" "code.google.co...
Go
// Copyright 2013 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 packet import ( "bytes" "image" "image/jpeg" "io" "io/ioutil" ) const UserAttrImageSubpacket = 1 // UserAttribute is capable of storing other 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 packet import ( "code.google.com/p/go.crypto/openpgp/errors" "code.google.com/p/go.crypto/openpgp/s2k" "crypto" "encoding/binary" "io" "strconv" ...
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 packet import ( "code.google.com/p/go.crypto/openpgp/errors" "code.google.com/p/go.crypto/openpgp/s2k" "crypto" "crypto/dsa" "crypto/rsa" "encodi...
Go
// Copyright 2013 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 packet import ( "crypto" "crypto/md5" "crypto/rsa" "encoding/binary" "fmt" "hash" "io" "math/big" "strconv" "time" "code.google.com/p/go.cr...
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 packet import ( "code.google.com/p/go.crypto/openpgp/errors" "crypto/cipher" "crypto/sha1" "crypto/subtle" "hash" "io" "strconv" ) // Symmetric...
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 packet import ( "bytes" "code.google.com/p/go.crypto/openpgp/elgamal" "code.google.com/p/go.crypto/openpgp/errors" "crypto" "crypto/dsa" "crypto/...
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 packet import ( "code.google.com/p/go.crypto/openpgp/errors" "compress/bzip2" "compress/flate" "compress/zlib" "io" "strconv" ) // Compressed re...
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 packet import ( "bytes" "code.google.com/p/go.crypto/openpgp/elgamal" "code.google.com/p/go.crypto/openpgp/errors" "code.google.com/p/go.crypto/ope...
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 packet import ( "code.google.com/p/go.crypto/openpgp/elgamal" "code.google.com/p/go.crypto/openpgp/errors" "crypto/rsa" "encoding/binary" "io" "m...
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. // OpenPGP CFB Mode. http://tools.ietf.org/html/rfc4880#section-13.9 package packet import ( "crypto/cipher" ) type ocfbEncrypter struct { b cipher.B...
Go
// Copyright 2013 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 packet import ( "crypto" "encoding/binary" "fmt" "io" "strconv" "time" "code.google.com/p/go.crypto/openpgp/errors" "code.google.com/p/go.cryp...
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 packet import ( "io" "io/ioutil" "strings" ) // UserId contains text that is intended to represent the name and email // address of the key holder....
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 packet import ( "code.google.com/p/go.crypto/openpgp/errors" "io" ) // Reader reads packets from an io.Reader and allows packets to be 'unread' so /...
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 packet import ( "bytes" "code.google.com/p/go.crypto/openpgp/errors" "code.google.com/p/go.crypto/openpgp/s2k" "crypto/cipher" "io" "strconv" ) ...
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 packet import ( "encoding/binary" "io" ) // LiteralData represents an encrypted file. See RFC 4880, section 5.9. type LiteralData struct { IsBinary...
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 packet implements parsing and serialization of OpenPGP packets, as // specified in RFC 4880. package packet import ( "bufio" "code.google.com/p/go...
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 packet import ( "bytes" "code.google.com/p/go.crypto/openpgp/errors" "io" "io/ioutil" ) // OpaquePacket represents an OpenPGP packet as raw, unpar...
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 packet import ( "crypto" "crypto/rand" "io" "time" ) // Config collects a number of parameters along with sensible defaults. // A nil *Config is v...
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 errors contains common error types for the OpenPGP packages. package errors import ( "strconv" ) // A StructuralError is returned when OpenPGP dat...
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 openpgp import ( "code.google.com/p/go.crypto/openpgp/armor" "code.google.com/p/go.crypto/openpgp/errors" "code.google.com/p/go.crypto/openpgp/packe...
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 elgamal implements ElGamal encryption, suitable for OpenPGP, // as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on // Discret...
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 armor import ( "encoding/base64" "io" ) var armorHeaderSep = []byte(": ") var blockEnd = []byte("\n=") var newline = []byte("\n") var armorEndOfLine...
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 armor implements OpenPGP ASCII Armor, see RFC 4880. OpenPGP Armor is // very similar to PEM except that it has an additional CRC checksum. package ar...
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 openpgp import ( "code.google.com/p/go.crypto/openpgp/armor" "code.google.com/p/go.crypto/openpgp/errors" "code.google.com/p/go.crypto/openpgp/packe...
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 openpgp import "hash" // NewCanonicalTextHash reformats text written to it into the canonical // form and then applies the hash h. See RFC 4880, sect...
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 bcrypt implements Provos and Mazières's bcrypt adaptive hashing // algorithm. See http://www.usenix.org/event/usenix99/provos/provos.pdf package bcry...
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 bcrypt import "encoding/base64" const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" var bcEncoding = base64.NewEncodi...
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 pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0. A key derivation function is useful when encrypting data...
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 twofish implements Bruce Schneier's Twofish encryption algorithm. package twofish // Twofish is defined in http://www.schneier.com/paper-twofish-pap...
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 ssh import ( "crypto" "crypto/rand" "fmt" "io" "sync" _ "crypto/sha1" _ "crypto/sha256" _ "crypto/sha512" ) // These are string constants in ...
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 ssh import ( "errors" "fmt" "io" "math/rand" "net" "strconv" "strings" "sync" "time" ) // Listen requests the remote peer open a listening so...
Go
// Copyright 2013 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 ssh import ( "crypto" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "errors" "io" "math/big" ) const ( kexAlgoDH1SHA1 = "diffie-hellman-grou...
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 ssh import ( "io" "sync" ) // buffer provides a linked list buffer for data exchange // between producer and consumer. Theoretically the buffer is /...
Go
// Copyright 2013 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 ssh import ( "encoding/binary" "fmt" "io" "log" "sync" "sync/atomic" ) // debugMux, if set, causes messages in the connection protocol to be // ...
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 ssh import ( "bytes" "errors" "fmt" "io" "net" "sort" "time" ) // These constants from [PROTOCOL.certkeys] represent the algorithm names // for...
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. // This package contains integration tests for the // code.google.com/p/go.crypto/ssh package. package 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. // +build linux,!appengine darwin // Package terminal provides support functions for dealing with terminals, as // commonly found on UNIX systems. // // Puttin...
Go
// Copyright 2013 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 darwin package terminal import "syscall" const ioctlReadTermios = syscall.TIOCGETA const ioctlWriteTermios = syscall.TIOCSETA
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 terminal import ( "io" "sync" "unicode/utf8" ) // EscapeCodes contains escape sequences that can be written to the terminal in // order to achieve ...
Go
// Copyright 2013 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 linux package terminal import "syscall" const ioctlReadTermios = syscall.TCGETS const ioctlWriteTermios = syscall.TCSETS
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 windows // Package terminal provides support functions for dealing with terminals, as // commonly found on UNIX systems. // // Putting a terminal int...
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 ssh import ( "bytes" "errors" "fmt" "io" ) // clientAuthenticate authenticates with the remote server. See RFC 4252. func (c *connection) clientAu...
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 ssh // Session implements an interactive session described in // "RFC 4254, section 6". import ( "bytes" "errors" "fmt" "io" "io/ioutil" "sync" ...
Go
// Copyright 2014 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 agent import ( "bytes" "crypto/rand" "crypto/subtle" "errors" "fmt" "sync" "code.google.com/p/go.crypto/ssh" ) type privKey struct { signer ...
Go
// Copyright 2014 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 agent import ( "errors" "io" "net" "sync" "code.google.com/p/go.crypto/ssh" ) // RequestAgentForwarding sets up agent forwarding for the session...
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 agent import ( "crypto/rsa" "encoding/binary" "fmt" "io" "log" "math/big" "code.google.com/p/go.crypto/ssh" ) // Server wraps an Agent and use...
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 agent implements a client to an ssh-agent daemon. References: [PROTOCOL.agent]: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCO...
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 ssh // Message authentication support import ( "crypto/hmac" "crypto/sha1" "hash" ) type macMode struct { keySize int new func(key []byte) h...
Go
// Copyright 2013 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 ssh import ( "crypto/rand" "errors" "fmt" "io" "log" "net" "sync" ) // debugHandshake, if set, prints messages sent and received. Key // excha...
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 ssh import ( "bytes" "encoding/binary" "errors" "fmt" "io" "math/big" "reflect" "strconv" ) // These are SSH message type numbers. They are sc...
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 ssh import ( "bytes" "crypto" "crypto/dsa" "crypto/ecdsa" "crypto/elliptic" "crypto/rsa" "crypto/x509" "encoding/asn1" "encoding/base64" "enc...
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 ssh import ( "bufio" "errors" "io" ) const ( gcmCipherID = "aes128-gcm@openssh.com" ) // packetConn represents a transport that implements packet...
Go
// Copyright 2013 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 ssh import ( "fmt" "net" ) // OpenChannelError is returned if the other side rejects an // OpenChannel request. type OpenChannelError struct { Reas...
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 ssh import ( "crypto/aes" "crypto/cipher" "crypto/rc4" "crypto/subtle" "encoding/binary" "errors" "fmt" "hash" "io" ) const ( packetSizeMult...
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 ssh import ( "encoding/binary" "errors" "fmt" "io" "log" "sync" ) const ( minPacketLength = 9 // channelMaxPacket contains the maximum number ...
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 ssh import ( "bytes" "errors" "fmt" "io" "net" ) // The Permissions type holds fine-grained permissions that are // specific to a user or a speci...
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 ssh implements an SSH client and server. SSH is a transport security protocol, an authentication protocol and a family of application protocols. The...
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 ssh import ( "errors" "fmt" "net" "sync" ) // Client implements a traditional SSH client that supports shells, // subprocesses, port forwarding an...
Go
// Copyright 2013 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 ocsp parses OCSP responses as specified in RFC 2560. OCSP responses // are signed messages attesting to the validity of a certificate for a small // ...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package // // Copyright 2012 Julien Schmidt. All rights reserved. // http://www.julienschmidt.com // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can o...
Go
package constants const ( EXIT_SUCCESS = 0; EXIT_NO_CONFIG; // config file not found or couldn't be read EXIT_CONFIG_PARSE; // failed to parse the config file EXIT_CANT_LISTEN; )
Go
package main import ( "bytes"; "os"; "io"; "fmt"; "strings"; "strconv"; "container/vector"; "math"; "http"; "flag"; "expvar"; "json"; . "./constants"; _ "./httplog" ) type Point struct { x float; y float; } type Config struct { Address string; CustomLog string; LogFormat []strin...
Go
package httplog import ( "io"; "os"; ) type Logger struct { log *os.File; } // Creates a new Logger func New(logfile string) (*Logger, os.Error) { // TODO: config option for setting logfile perms // TODO: need to close this file on exit log, err := os.Open(logfile, os.O_WRONLY|os.O_CREAT|os.O_APPEND, 7...
Go
package insert import ( "sort" "container/list" ) type Inserter interface { Insert(int) } type IntList struct { list []int } func (il IntList)Insert(x int) { pos := sort.SearchInts(il.list, x) il.list = append(il.list, 0) for i := len(il.list)-1; i > pos; i-- { il.list[i] = il.list[i-1] } il.list[...
Go
package synth import ( "code.google.com/p/jra-go/wav" ) // current limits: always runs at 44.1 khz, always processes // frames of 100 ms const SamplesPerSecond = 44100 const frameTime = 100 / Sample(1000) // 100 ms const frameLength = int(SamplesPerSecond * frameTime) type Sample float32 type Hertz float32 type Fr...
Go
package main import ( "os" "code.google.com/p/jra-go/synth" "code.google.com/p/jra-go/wav" ) func main() { w := new(wav.Wav) w.Channels = 1 w.SamplesPerSecond = synth.SamplesPerSecond w.Samples[wav.Mono] = make([]wav.Sample8, w.SamplesPerSecond*5) freq := synth.Hertz(400) fs := synth.NewFrameSource() sw ...
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. // This package provides an io.Reader that returns data, // simulating a network connection of a certain speed. package linkio import ( "io" "time" ) // A L...
Go
package bcd /* typedef unsigned short int ushort; ushort nativeAdd(ushort a, ushort b) { ushort c; asm ("add %%dl, %%al; daa" :"=a"(c) :"d"(b),"a"(a) ); return c; } */ import "C" import ( "fmt" ) type Bcd int func ToBcd(a uint) Bcd { if (a > 9999) { panic("numb...
Go
package wav import ( "encoding/binary" "io" ) const BitsPerSample = 8 type Sample8 uint8 type Wav struct { SamplesPerSecond int Channels int Samples [maxChannels][]Sample8 } const Mono = 0 const Left = 0 const Right = 1 const maxChannels = 2 func (w *Wav) Write(wr io.Writer) (err error) { //...
Go
package main import ( "os" "code.google.com/p/jra-go/wav" ) func main() { w := new(wav.Wav) w.Channels = 1 w.SamplesPerSecond = 44100 w.Samples[wav.Mono] = make([]wav.Sample8, w.SamplesPerSecond*5) // put in a square wave halfWave := 1000 high := wav.Sample8(255) low := wav.Sample8(0) value := low for...
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 autocon type autoConsumer struct { worker func(chan interface{}) consumers []chan interface{} ch chan interface{} } func NewAutoConsumer(...
Go
package main import ( "errors" "flag" "fmt" "io" "log" "net" "net/http" "os" "os/exec" "sync" "syscall" "time" ) var verbose *bool = flag.Bool("verbose", false, "log every transaction") var listenFD *int = flag.Int("listenFD", 0, "the already-open fd to listen on (internal use only)") func init() { log....
Go
package main import ( "code.google.com/p/jra-go/insert" "flag" "fmt" "math/rand" "time" ) var linear *bool = flag.Bool("linear", false, "do linear insert") var linked *bool = flag.Bool("linked", false, "do linked list insert") func do(f func(int)) { } func main() { flag.Parse() var l insert.Inserter if *l...
Go
package main import ( "fmt" "io" "os" "code.google.com/p/jra-go/ebml" ) func main() { if len(os.Args) != 2 { fmt.Fprintf(os.Stderr, "usage: dumpmk filename") os.Exit(1) } filename := os.Args[1] f, err := os.Open(filename) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %v: %v", filename, err) ...
Go
package main import ( "code.google.com/p/x-go-binding/ui" "code.google.com/p/x-go-binding/ui/x11" "flag" "fmt" "image" "image/draw" "image/jpeg" "image/png" "log" "net/http" "os" "time" ) var game *bool = flag.Bool("game", false, "make it playable") var rocketPos int var rocketLimit int var origin image....
Go
package main import ( "code.google.com/p/jra-go/linkio" "fmt" "io" "log" "net" "net/http" "net/http/httputil" "net/url" "strings" "time" ) var gLink *linkio.Link func init() { gLink = linkio.NewLink(56 /* kbps */) } func loghit(r *http.Request, code int) { log.Printf("%v %v %v", r.Method, r.RequestURI, ...
Go
// Copyright 2009 Jeff R. Allen. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file of the Go // distribution. package main import ( "encoding/gob" "exp/terminal" "flag" "fmt" "io" "log" "net" "os" ) type connCmd int const ( Listen co...
Go
// Copyright 2009 Jeff R. Allen. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file of the Go // distribution. package main import ( "encoding/gob" "encoding/json" "flag" "io" "log" "net" "os" "runtime" "time" ) var managers map[string...
Go
package main import ( "bufio" "crypto/rand" "flag" "fmt" "io" "io/ioutil" "log" "os" "runtime" "strconv" "strings" "syscall" "time" "code.google.com/p/jra-go/jpu" ) const intro = ` It's a moonless night, you're lucky. Cutting your way through the barbed wire fence, you've made your way into the compou...
Go
// This package implements Jeff's Processing Unit, an // 8-bit, memory-mapped IO processor. package jpu import ( "bufio" "fmt" "io" "strconv" "strings" ) const NumReg int = 10 type Instruction byte const ( InsHalt Instruction = iota // halt = 0, so that uninit memory (0) causes a halt InsNop InsMemReg InsR...
Go
package ebml import ( "bufio" "errors" "fmt" "io" "io/ioutil" ) var BadVint = errors.New("badly formatted Vint") type Vint uint64 func expecting(exp, got Vint) error { return errors.New(fmt.Sprintf("expecting id %d, got id %d", exp, got)) } func (m *Master) readVint() (x Vint, err error) { x = 0 var b byte...
Go
/* * jQuery File Upload Plugin GAE Go Example 3.1.0 * https://github.com/blueimp/jQuery-File-Upload * * Copyright 2011, Sebastian Tschan * https://blueimp.net * * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT */ package app import ( "appengine" "appengine/blobstore" "appengine/i...
Go
// Copyright 2012 The Gorilla 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 schema import ( "errors" "fmt" "reflect" ) // NewDecoder returns a new Decoder. func NewDecoder() *Decoder { return &Decoder{cache: newCache(...
Go
// Copyright 2012 The Gorilla 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 schema import ( "reflect" "strconv" ) type Converter func(string) reflect.Value var ( invalidValue = reflect.Value{} boolType = reflect....
Go
// Copyright 2012 The Gorilla 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 schema import ( "errors" "reflect" "strconv" "strings" "sync" ) var invalidPath = errors.New("schema: invalid path") // newCache returns a ...
Go
// Copyright 2012 The Gorilla 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 gorilla/schema fills a struct with form values. The basic usage is really simple. Given this struct: type Person struct { Name string Ph...
Go