code stringlengths 10 1.34M | language stringclasses 1
value |
|---|---|
package eg
// This file defines the AST rewriting pass.
// Most of it was plundered directly from
// $GOROOT/src/cmd/gofmt/rewrite.go (after convergent evolution).
import (
"fmt"
"go/ast"
"go/token"
"os"
"reflect"
"sort"
"strconv"
"strings"
"code.google.com/p/go.tools/astutil"
"code.google.com/p/go.tools/g... | Go |
// Package eg implements the example-based refactoring tool whose
// command-line is defined in code.google.com/p/go.tools/cmd/eg.
package eg
import (
"bytes"
"fmt"
"go/ast"
"go/printer"
"go/token"
"os"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/types"
)
const Help = `
This tool im... | 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 present
import (
"errors"
"regexp"
"strconv"
"unicode/utf8"
)
// This file is stolen from go/src/cmd/godoc/codewalk.go.
// It's an evaluator for t... | 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 present
import (
"fmt"
"log"
"net/url"
"strings"
)
func init() {
Register("link", parseLink)
}
type Link struct {
URL *url.URL
Label string
... | 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 present
import (
"fmt"
"strings"
)
func init() {
Register("iframe", parseIframe)
}
type Iframe struct {
URL string
Width int
Height int
}
... | Go |
package present
import (
"errors"
"html/template"
"path/filepath"
"strings"
)
func init() {
Register("html", parseHTML)
}
func parseHTML(ctx *Context, fileName string, lineno int, text string) (Elem, error) {
p := strings.Fields(text)
if len(p) != 2 {
return nil, errors.New("invalid .html args")
}
name :=... | 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 present
import (
"fmt"
"strings"
)
func init() {
Register("image", parseImage)
}
type Image struct {
URL string
Width int
Height int
}
fun... | 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 present
import (
"bufio"
"bytes"
"fmt"
"html/template"
"path/filepath"
"regexp"
"strconv"
"strings"
)
// Is the playground available?
var Play... | 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 present
import (
"bytes"
"html"
"html/template"
"strings"
"unicode"
"unicode/utf8"
)
/*
Fonts are demarcated by an initial and final char brack... | 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 present
import (
"bufio"
"bytes"
"errors"
"fmt"
"html/template"
"io"
"io/ioutil"
"log"
"net/url"
"regexp"
"strings"
"time"
"unicode"
"uni... | 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.
/*
The present file format
Present files have the following format. The first non-blank non-comment
line is the title, so the header looks like
Title of doc... | Go |
package typeapply
import (
"reflect"
"sync"
)
var (
typeMutex sync.Mutex
// tmap stores a map for every target type (the
// argument type of the function passed to Do).
// For each target type, we use this to cache
// information about how to traverse values
// of all types that have been passed to Do
// (a... | Go |
// The fakenet package provides a way to turn a regular io.ReadWriter
// into a net.Conn, including support for timeouts.
package fakenet
import (
"io"
"net"
"time"
)
type Addr string
func (a Addr) Network() string {
return "fakenet"
}
func (a Addr) String() string {
return "fakenet:" + string(a)
}
// we've g... | Go |
package fakenet
import (
"errors"
"io"
"runtime"
"sync"
"time"
)
// A ChanReader reads from a chan []byte to
// satisfy Read requests.
type ChanReader struct {
mu sync.Mutex
buf []byte
c <-chan []byte
closedCh chan bool
closed bool
}
// NewChanReader creates a new ChanReader that
// rea... | Go |
package fakenet
import (
"io"
"net"
)
type listener struct {
addr net.Addr
closedCh chan bool
conns chan net.Conn
}
// NewListener creates a new net.Listener and returns a channel on which
// it reads connections and gives to callers of Accept. The Listener
// returns addr for its address (or Addr("fake... | Go |
// The parallel package provides a way of running functions
// concurrently while limiting the maximum number
// running at once.
package parallel
import (
"fmt"
"sync"
)
// Run represents a number of functions running concurrently.
type Run struct {
limiter chan struct{}
done chan error
err chan error
w... | Go |
package loopback
import (
"errors"
"io"
"net"
"time"
)
// NetPipe creates a synchronous, in-memory, full duplex
// network connection; both ends implement the net.Conn interface.
// The opt0 options apply to the traffic from c0 to c1;
// the opt1 options apply to the traffic from c1 to c0.
func NetPipe(opt0, opt1... | Go |
package loopback
import (
"code.google.com/p/rog-go/fakenet"
"io"
"net"
)
// Dial is the same as net.Dial except that it also recognises
// networks with the prefix "loopback:"; it removes
// the prefix, dials the original network, and then applies
// the given loopback Options. Incoming data has inOpts
// applied... | Go |
package loopback
import (
"errors"
"io"
"log"
"sync"
"time"
)
// TODO implement CloseWithError.
// BUG close propagates faster than latency time.
// send close as a block with nil data.
type block struct {
// t holds the time that the block is due to emerge into the
// input queue.
t time.Time
data []byt... | Go |
package loopback
import (
"bytes"
"errors"
"fmt"
"io"
"strings"
"time"
"unicode"
)
var errEmpty = errors.New("empty")
func parseNetwork(net string) (inOpts, outOpts Options, actualNet string, err error) {
if net == "" {
err = errors.New("empty network name")
return
}
if net[0] != '[' {
actualNet = ne... | Go |
// The ncrpc package layers client-server and server-client
// RPC interfaces on top of netchan.
package ncrpc
import (
"code.google.com/p/rog-go/ncnet"
"errors"
"fmt"
"io"
"log"
"net"
"net/rpc"
"netchan"
"sync"
)
type Server struct {
Exporter *netchan.Exporter
RPCServer *rpc.Server
mu sync.Mutex
... | Go |
package reverse
import (
"bufio"
"errors"
"io"
)
const maxBufSize = 64 * 1024
// Scanner presents the same interface as bufio.Scanner
// except it scans tokens in reverse from the end of
// a file instead of forwards from the beginning.
//
// It may not work correctly if the split function can return an
// error ... | Go |
package values
import (
"fmt"
"reflect"
)
// A Lens can transform from values of type T to values
// of type T1. It can be reversed to transform in the
// other direction, and be combined with other Lenses.
//
type Lens struct {
f, finv func(reflect.Value) (reflect.Value, error)
t, t1 reflect.Type
}
func okTra... | Go |
package values
import (
"errors"
"reflect"
)
// NewConst returns a Value of type t which always returns the value v,
// and gives an error when set.
func NewConst(val interface{}, t reflect.Type) Value {
if t == nil {
return &constValue{reflect.ValueOf(val)}
}
v := &constValue{reflect.New(t).Elem()}
v.val.Set... | Go |
// The values package provides multiple-writer,
// multiple-listener access to changing values.
// It also provides (through the Transform function
// and the Lens type) the facility to have multiple,
// mutually updating views of the same value.
//
package values
import (
"reflect"
"sync"
)
// A Value represents a... | Go |
package values
import (
"errors"
"fmt"
)
// Float64ToString returns a Lens which transforms from float64
// to string. The given formats are used to effect the conversion;
// fmt.Sprintf(printf, x) is used to convert the float64 value x to string;
// fmt.Sscanf(s, scanf, &x) is used to scan the string s into the fl... | Go |
package client
import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"runtime"
"strings"
"sync"
//"log"
"bytes"
plan9 "code.google.com/p/rog-go/new9p"
)
func getuser() string { return os.Getenv("USER") }
type Fid struct {
c *Conn
qid plan9.Qid
fid uint32
mode uint8
flags uint8 // fOpen | fAlloc... | Go |
package client
import (
"errors"
plan9 "code.google.com/p/rog-go/new9p"
)
type Fsys struct {
Root *Fid
}
func (c *Conn) Auth(uname, aname string) (*Fid, error) {
afid, err := c.getfid()
if err != nil {
return nil, err
}
afid.flags |= fPending
tx := &plan9.Fcall{Type: plan9.Tauth, Afid: afid.fid, Uname: un... | Go |
package client
import (
"net"
"os"
)
func Dial(network, addr string) (*Conn, error) {
c, err := net.Dial(network, addr)
if err != nil {
return nil, err
}
return NewConn(c)
}
func DialService(service string) (*Conn, error) {
ns := os.Getenv("NAMESPACE")
if ns == "" {
return nil, Error("unknown name space"... | Go |
package client
import (
"fmt"
"io"
"log"
"os"
"sync"
plan9 "code.google.com/p/rog-go/new9p"
)
type Error string
func (e Error) Error() string { return string(e) }
type Conn struct {
rwc io.ReadWriteCloser
err error
tagmap map[uint16]chan *plan9.Fcall
freetag map[uint16]bool
freefid map[uint32]b... | Go |
package client
import (
"code.google.com/p/rog-go/new9p/seq"
"container/list"
"io"
"log"
"sync"
)
type readResult struct {
buf []byte
err error
}
type streamReader struct {
c chan readResult
reply chan bool
buf []byte
done bool
}
func (cr *streamReader) Read(buf []byte) (int, error) {
if cr.done ... | Go |
package client
import (
"errors"
"fmt"
//"log"
plan9 "code.google.com/p/rog-go/new9p"
"code.google.com/p/rog-go/new9p/seq"
"container/list"
)
func (fid *Fid) File() seq.File {
return (*file9p)(fid)
}
type file9p Fid
type filesys9p Conn
type seq9p struct {
c *Conn
tag uint16
err error
// access to the r... | Go |
package client
import (
plan9 "code.google.com/p/rog-go/new9p"
"code.google.com/p/rog-go/new9p/seq"
"errors"
"fmt"
"io"
"strings"
)
type Ns struct {
Root *NsFile
Dot *NsFile
}
type NsFile struct {
offset int64
f seq.File
}
type nsResultType bool
type OpResults []seq.Result
func (OpResults) Rtype() ... | Go |
package plan9
import (
"fmt"
"io"
"strconv"
)
type ProtocolError string
func (e ProtocolError) Error() string {
return string(e)
}
const (
STATMAX = 65535
)
type Dir struct {
Type uint16
Dev uint32
Qid Qid
Mode Perm
Atime uint32
Mtime uint32
Length uint64
Name string
Uid string
Gid ... | Go |
package plan9
import (
"fmt"
"io"
)
const (
IOHDRSIZE = 24
)
type Fcall struct {
Type uint8
Tag uint16
Fid uint32 // All T messages except Tversion, Tflush, Tbegin and Tend
Msize uint32 // Tversion, Rversion
Version string // Tversion, Rversion
Oldtag uint16 // Tflush
Ename string ... | Go |
package plan9
const (
VERSION9P = "9P2000"
MAXWELEM = 16
OREAD = 0
OWRITE = 1
ORDWR = 2
OEXEC = 3
OTRUNC = 16
OCEXEC = 32
ORCLOSE = 64
ODIRECT = 128
ONONBLOCK = 256
OEXCL = 0x1000
OLOCK = 0x2000
OAPPEND = 0x4000
AEXIST = 0
AEXEC = 1
AWRITE = 2
AREAD = 4
QTDIR... | Go |
package main
import (
"fmt"
"io"
"os"
"code.google.com/p/goplan9/plan9"
"code.google.com/p/goplan9/plan9/client"
)
func main() {
fsys, err := client.MountService("acme")
if err != nil {
panic(err)
}
fid, err := fsys.Open("index", plan9.OREAD)
if err != nil {
panic(err)
}
fid.Write([]byte("hello, wo... | Go |
package main
import (
g9p "code.google.com/p/rog-go/new9p"
g9pc "code.google.com/p/rog-go/new9p/client"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
)
var old = flag.Bool("old", false, "use old 9p operations")
var fs *g9pc.Fsys
var ns *g9pc.Ns
var sum = make(chan int64)
func main() {
log.SetOutput(nullWriter{})... | Go |
package main
// An interactive client for 9P servers.
import (
"bufio"
g9p "code.google.com/p/rog-go/new9p"
g9pc "code.google.com/p/rog-go/new9p/client"
"code.google.com/p/rog-go/new9p/seq"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path"
"strconv"
"strings"
)
var addr = flag.String("addr", "127.0.0.1:56... | Go |
package seq
import (
plan9 "code.google.com/p/rog-go/new9p"
"errors"
)
type Req interface {
Ttype() interface{}
}
type Result interface {
Rtype() interface{}
}
type CompositeReq interface {
Req
Do(seq *Sequencer, f File) error // executes action. must result in one result.
}
type BasicReq interface {
Req
b... | Go |
package seq
import (
"bytes"
"fmt"
"log"
"runtime"
"sync"
)
type mainSeq struct {
mu sync.Mutex
newRequest chan<- seqRequest
newSeq <-chan Sequence
newFs chan<- FileSys
currSeq Sequence
shutdown bool
done chan error
reentrantCheck chan bool
}
type Sequencer struct {
error ... | Go |
package plan9
func gbit8(b []byte) (uint8, []byte) {
return uint8(b[0]), b[1:]
}
func gbool(b []byte) (bool, []byte) {
return b[0] != 0, b[1:]
}
func gbit16(b []byte) (uint16, []byte) {
return uint16(b[0]) | uint16(b[1])<<8, b[2:]
}
func gbit32(b []byte) (uint32, []byte) {
return uint32(b[0]) | uint32(b[1])<<8 ... | Go |
package breader
import (
"io"
"io/ioutil"
"os"
)
type bufferedReader struct {
req chan []byte
reply chan int
tmpf *os.File
error error
}
const ioUnit = 16 * 1024
// NewReader continually reads from in and buffers the data
// inside a temporary file (created with ioutil.TempFile(dir, prefix)).
// It return... | Go |
// The stringfs package provides a way to recursively encode the
// data in a directory as a string, and to extract the contents later.
package stringfs
import (
"bytes"
"encoding/binary"
"encoding/gob"
"errors"
"os"
"strings"
"sync"
)
// The file system encoding uses gob to encode the
// metadata.
// It takes... | Go |
// The deepcopy package implements deep copying of arbitrary
// data structures, making sure that self references and shared pointers
// are preserved.
package deepcopy
import (
"fmt"
"reflect"
"sync"
"unsafe"
)
// basic copy algorithm:
// 1) recursively scan object, building up a list of all allocated
// memory ... | Go |
// +build ignore
package main
import (
"errors"
"fmt"
"os"
"local/foo.bar"
)
func errorHandler(err *error) {}
// doScan does the real work for scanning without a format string.
func doScan(a []interface{}) (numProcessed int, err error) {
defer errorHandler(&err)
return
}
func main() {
testProg()
}
func te... | Go |
package main
import (
"fmt"
"go/token"
"reflect"
"unsafe"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/oracle"
)
func (ctxt *context) callees(inst *ssa.Call) ([]*ssa.Function, error) {
pos := ctxt.lprog.Fset.Position(inst.Pos())
if pos.Line <= 0 {
return nil, fmt.Errorf("no position")
}... | Go |
package main
import (
"errors"
"flag"
"fmt"
"io"
"log"
"os"
"regexp"
"go/token"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/oracle"
"github.com/davecgh/go-spew/spew"
)
var spewConf = spew.ConfigState{
Inden... | Go |
package key
// Mapping holds a set of unique keys corresponding
// to Hasher values.
type Mapping struct {
keys map[uint64]*entry
}
// Hasher represents a value that can be used as a map key.
type Hasher interface {
Hashcode() uint64
Equals(m Hasher) bool
}
type entry struct {
mkey Hasher
key Key
next *entry
... | Go |
// Timestamp recording (for debugging).
package stamp
import (
"bytes"
"fmt"
"sort"
"sync"
"time"
)
type stamp struct {
msg string
t int64
}
var mu sync.Mutex
type stampVector []stamp
var stamps = make(stampVector, 0, 100)
// AddTime records a timestamp at the given time.
func AddTime(msg string, t int64... | Go |
//
package filemarshal
import (
"code.google.com/p/rog-go/typeapply"
"errors"
"io"
"io/ioutil"
"os"
)
// A File holds on-disk storage.
type File struct {
Name string // The name of the file.
file *os.File
}
// NewFile creates a new file referring to f,
// which should be seekable (i.e. not a pipe
// or netwo... | Go |
package gobrpc
import (
"code.google.com/p/rog-go/exp/filemarshal"
"io"
"net/rpc"
)
type clientCodec struct {
c io.Closer
enc filemarshal.Encoder
dec filemarshal.Decoder
}
func NewClientCodec(conn io.ReadWriteCloser, enc filemarshal.Encoder, dec filemarshal.Decoder) rpc.ClientCodec {
return &clientCodec{con... | Go |
package main
import (
"encoding/json"
"fmt"
"os"
"sort"
"time"
)
type Stat struct {
Delay time.Duration
Connect time.Duration
Latency []time.Duration
Error string `json:"omitempty"`
}
type Info struct {
Stats []Stat
Total time.Duration
}
func main() {
var info Info
err := json.NewDecoder(os.Stdin).... | Go |
package main
import (
"bytes"
"code.google.com/p/rog-go/exp/go/ast"
"code.google.com/p/rog-go/exp/go/parser"
"code.google.com/p/rog-go/exp/go/printer"
"code.google.com/p/rog-go/exp/go/token"
"code.google.com/p/rog-go/exp/go/types"
"errors"
"flag"
"fmt"
"go/build"
"io/ioutil"
"os"
"path/filepath"
"runtime... | Go |
package main
import (
"code.google.com/p/goplan9/plan9/acme"
"fmt"
"io"
"os"
"os/user"
"strconv"
"strings"
)
type acmeFile struct {
name string
body []byte
offset int
runeOffset int
}
func acmeCurrentFile() (*acmeFile, error) {
win, err := acmeCurrentWin()
if err != nil {
return nil, e... | 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.
/*
Godef prints the source location of definitions in Go programs.
Usage:
godef [-t] [-a] [-A] [-o offset] [-i] [-f file][-acme] [expr]
File specifies the ... | Go |
// The gosym command manipulates symbols in Go source code.
// It supports the following commands:
//
// gosym short
//
// The short command reads lines from standard input
// in short or long format (see the list command) and
// prints them in short format:
// file-position name new-name
// The file-position field h... | Go |
package main
import (
"code.google.com/p/rog-go/exp/go/ast"
"code.google.com/p/rog-go/exp/go/token"
"fmt"
"regexp"
"strconv"
"strings"
)
type symLine struct {
pos token.Position // file address of identifier; addr.Offset is zero.
referPos token.Position // file address of referred-to identifier.
long ... | Go |
package test
import "other"
func %test test X func+%X() {
%test test x var+%x := 0
for %test test i var+%i := 0; %test test i var%i < %test test x var%x; %test test i var%i++ {
%test test i var+%i := %test test i var%i
%test test x var%x += %test test i var%i
}
other.%test other Println func%Println(%test test... | Go |
package main
import (
"code.google.com/p/rog-go/exp/go/ast"
"code.google.com/p/rog-go/exp/go/sym"
"code.google.com/p/rog-go/exp/go/token"
"fmt"
"log"
)
type writeCmd struct {
*context
// lines holds all input lines.
lines map[token.Position]*symLine
// symPkgs holds packages that are mentioned in input
//... | Go |
package main
import (
"code.google.com/p/rog-go/exp/go/ast"
"code.google.com/p/rog-go/exp/go/sym"
"code.google.com/p/rog-go/exp/go/types"
"flag"
"fmt"
"log"
"strings"
"unicode"
)
type listCmd struct {
all bool
verbose bool
printType bool
kinds string
ctxt *context
}
var listAbout = `
go... | Go |
package main
import (
"bufio"
"code.google.com/p/rog-go/exp/go/token"
"fmt"
"io"
"log"
"os"
"strings"
"unicode"
)
func readLines(f func(sl *symLine) error) error {
r := bufio.NewReader(os.Stdin)
for {
line, isPrefix, err := r.ReadLine()
if err == io.EOF {
break
}
if err != nil {
return fmt.Err... | 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 main
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/format"
"go/parser"
"go/scanner"
"go/token"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"so... | Go |
package main
import (
"fmt"
"go/ast"
"go/token"
"log"
"path"
"strconv"
"strings"
)
func init() {
register(causeFix)
register(maskFix)
register(newFix)
}
const errgoPkgPath = "github.com/juju/errgo"
var maskFix = fix{
"errgo-mask",
"2014-02-10",
errgoMask,
`wrap all returned errors; use errgo for all e... | 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 main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"os"
"path"
"reflect"
"strconv"
"strings"
)
type fix struct {
name string
date string ... | 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 main
import (
"fmt"
"go/ast"
"go/token"
"os"
"reflect"
"strings"
)
// Partial type checker.
//
// The fact that it is partial is very important... | 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.
/*
Fix finds Go programs that use old APIs and rewrites them to use
newer ones. After you update to a new Go release, fix helps make
the necessary changes to y... | Go |
// ulimit -n 30000
package main
import (
"bytes"
"code.google.com/p/go.net/websocket"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
"strconv"
"sync"
"time"
)
func echoServer(ws *websocket.Conn) {
io.Copy(ws, ws)
}
type Stat struct {
Delay time.Duration
Connect time.Duration
Latency []time.Duratio... | Go |
package abc
import (
"container/vector"
"fmt"
"os"
"reflect"
"strconv"
"strings"
"text/scanner"
)
type Type struct {
Name string
Mux bool
Test func(interface{}) bool
}
var StringT = &Type{
"string",
true,
IsType(""),
}
type Gender bool
const (
Male = Gender(false)
Female = Gender(true)
)
type So... | Go |
package abc
import (
"fmt"
"sync"
)
var StatusT = &Type{
"status",
true,
IsType((*StatusManager)(nil)),
}
type StatusManager struct {
lock sync.Mutex
running int
waiting int
wakeup chan bool
}
type Status struct {
m *StatusManager
}
func (m *StatusManager) Go(fn func(status *Status)) {
m.lock.Lock()... | Go |
package abc
import (
"container/vector"
"fmt"
"strconv"
)
// transform ADT into a set of commands
type tContext struct {
*context
cmds *vector.Vector
}
func (ctxt *context) transform(a *assign, cmds *vector.Vector) {
tctxt := &tContext{context: ctxt, cmds: cmds}
tctxt.transformAssign(a)
fmt.Println("done tr... | Go |
package basic
import (
"code.google.com/p/rog-go/exp/abc"
"io"
"os"
)
func init() {
abc.Register("stdin", map[string]abc.Socket{
"out": abc.Socket{FdT, abc.Male},
}, makeStdin)
}
func makeStdin(_ *abc.Status, args map[string]interface{}) abc.Widget {
out := NewFd()
args["out"].(chan interface{}) <- out
if ... | Go |
package basic
import (
"code.google.com/p/rog-go/exp/abc"
"io"
)
func Use() {
}
// male side sends reader (or nil if it has no preference);
// female replies with the actual fd to use (or nil if there's been an error)
var FdT = &abc.Type{"fd", false, func(x interface{}) (ok bool) { _, ok = x.(Fd); return }}
type ... | Go |
package basic
import (
"code.google.com/p/rog-go/exp/abc"
"os"
)
func init() {
abc.Register("stdout", map[string]abc.Socket{
"1": abc.Socket{FdT, abc.Female},
}, makeStdout)
}
func makeStdout(_ *abc.Status, args map[string]interface{}) abc.Widget {
in := args["1"].(Fd)
in.PutWriter(os.Stdout)
return nil
}
| Go |
package basic
import (
"code.google.com/p/rog-go/exp/abc"
)
func init() {
abc.Register("rot13", map[string]abc.Socket{
"out": abc.Socket{FdT, abc.Male},
"1": abc.Socket{FdT, abc.Female},
}, makeRot13)
}
func makeRot13(_ *abc.Status, args map[string]interface{}) abc.Widget {
in := args["1"].(Fd)
out := NewF... | Go |
package basic
import (
"code.google.com/p/rog-go/exp/abc"
"io"
"os"
)
func init() {
abc.Register("read", map[string]abc.Socket{
"1": abc.Socket{abc.StringT, abc.Female},
"out": abc.Socket{FdT, abc.Male},
}, makeRead)
}
func makeRead(_ *abc.Status, args map[string]interface{}) abc.Widget {
f := args["1"].... | Go |
package basic
import (
"code.google.com/p/rog-go/exp/abc"
"strings"
)
func init() {
abc.Register("echo", map[string]abc.Socket{
"1": abc.Socket{abc.StringT, abc.Female},
"out": abc.Socket{FdT, abc.Male},
}, makeEcho)
}
func makeEcho(_ *abc.Status, args map[string]interface{}) abc.Widget {
s := args["1"].(s... | Go |
package basic
import (
"code.google.com/p/rog-go/exp/abc"
"os"
)
func init() {
abc.Register("write", map[string]abc.Socket{
"1": abc.Socket{FdT, abc.Female},
"2": abc.Socket{abc.StringT, abc.Female},
}, makeWrite)
}
func makeWrite(_ *abc.Status, args map[string]interface{}) abc.Widget {
in := args["1"].(Fd)... | Go |
package main
import "abc/audio"
import "testing"
var tests = []testing.Test {
testing.Test{ "audio.TestParserWithPipes", audio.TestParserWithPipes },
testing.Test{ "audio.TestConversion", audio.TestConversion },
}
var benchmarks = []testing.Benchmark {
}
func main() {
testing.Main(tests);
testing.RunBenchmarks(b... | Go |
package audio
import (
"fmt"
)
type Buffer interface {
Len() int
Zero(i0, i1 int)
Copy(i0 int, src Buffer, j0, j1 int)
Slice(i0, i1 int) Buffer
GetFormat() Format
}
type ContiguousFloat32Buffer interface {
Buffer
AsFloat32Buf() Float32Buf
AllocFromFloat32Buf(buf Float32Buf) ContiguousFloat32Buffer
}
type F... | Go |
package audio
import (
"fmt"
)
type Buffer interface {
Len() int
Zero(i0, i1 int)
Copy(i0 int, src Buffer, j0, j1 int)
Slice(i0, i1 int) Buffer
GetFormat() Format
}
type ContiguousFloat32Buffer interface {
Buffer
AsFloat32Buf() Float32Buf
AllocFromFloat32Buf(buf Float32Buf) ContiguousFloat32Buffer
}
type F... | Go |
package audio
import (
"fmt"
"sync"
)
type RingBufWidget struct {
minr0 int64 // minimum offset of any reader, in elements (but no reader can be more than maxsize behind r1, so r1 - minr0 <= maxsize)
r1 int64 // offset of max sample in buffer + 1.
samples Buffer
size int // current capacity of buffer ... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
"strconv"
)
type EnvelopeWidget struct {
Format
read func(b Float32Buf, t int64) int64
t0, a, d, s, r Time
sustainlev float32
}
func init() {
Register("envelope", wOutput, map[string]abc.Socket{
"start": abc.Socket{TimeT, abc.Female},
... | Go |
// +build ignore
package audio
import (
"code.google.com/p/rog-go/exp/abc"
)
func init() {
abc.Register("output", map[string]abc.Socket{
"audio", abc.Socket{SamplesT, abc.Female},
"1": abc.Socket{SamplesT, abc.Female},
"2": abc.Socket{abc.StringT, abc.Female},
}, makeOutput)
}
func makeOutput(args map[stri... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
"fmt"
)
// a simplified, 1-reader ring buffer that can
// deal with reads greater than the buffer size.
type DelayWidget struct {
Format
buf Buffer
size int
delay Time
r0 int64 // time of sample in buffer
input Widget
eofpos int64
eof ... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
"fmt"
"strconv"
"strings"
"os"
)
type Time struct {
t int64
real bool // real time (in nanoseconds) ?
}
func init() {
abc.Register("time", map[string]abc.Socket{
"1": abc.Socket{abc.StringT, abc.Female},
"out": abc.Socket{TimeT, abc.Male},
}... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
)
func init() {
abc.Register("auwrite", map[string]abc.Socket{
"out": abc.Socket{basic.Fd, abc.Male},
"1": abc.Socket{SamplesT, abc.Female},
}, makeWrite)
}
func makeWrite(args map[string]interface{}) abc.Widget {
out := basic.NewFd()
args["out"].(... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
"os"
"fmt"
"io"
"encoding/binary"
"reflect"
"strings"
)
func init() {
Register("readwav", wInput, map[string]abc.Socket{
"out": abc.Socket{SamplesT, abc.Male},
"1": abc.Socket{abc.StringT, abc.Female},
}, makeWavReader)
Register("writewav", wOu... | Go |
package audio
import (
"bytes"
"fmt"
)
var indentLevel int
func un(_ bool, rets ... interface{}) {
if x := recover(); x != nil {
panic(x)
}
indentLevel--
if Debug {
s := ""
if len(rets) > 0 {
s = " -> " + fmt.Sprint(rets...)
}
fmt.Printf("%s}%s\n", indent(), s)
}
}
func log(f string, args ... int... | Go |
package audio
import (
"fmt"
)
type ConverterWidget struct {
outfmt Format
infmt Format
input Widget
}
// conversions, in order of application
// type - float32 -> int16 & vice versa (punt for now)
// num channels - use permute
// layout
// sample rate - punt for now
func Converter(input Widget, f Format) (w *C... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
)
func init() {
abc.Register("auread", map[string]abc.Socket{
"out": abc.Socket{SamplesT, abc.Male},
"1": abc.Socket{basic.Fd, abc.Female},
}, makeRead)
}
func makeRead(args map[string]interface{}) abc.Widget {
var r sampleReader
r.Init(args["1"].(... | Go |
package audio
import "code.google.com/p/rog-go/exp/abc"
type MultiplierWidget struct {
Format
eof bool
buf ContiguousFloat32Buffer
w0, w1 Widget
}
func init() {
Register("multiply", wProc, map[string]abc.Socket{
"out": abc.Socket{SamplesT, abc.Male},
"1": abc.Socket{SamplesT, abc.Female},
"2": a... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
"bufio"
"fmt"
"os"
)
type GraphWidget struct {
Format
input Widget
}
func init() {
Register("graph", wOutput, map[string]abc.Socket{
"1": abc.Socket{SamplesT, abc.Female},
}, makeGraph)
}
func makeGraph(status *abc.Status, args map[string]interface... | Go |
package audio
type Format struct {
NumChans int // number of channels (0 if unset)
Rate int // samples per second (0 if unset)
Layout int
Type int
}
type Formatted interface {
GetFormat(name string) Format
}
type FormatSetter interface {
SetFormat(f Format)
}
const Unspecified = 0
// layouts (earlier are... | Go |
package audio
import "code.google.com/p/rog-go/exp/abc"
type PermuteWidget struct {
Format
input Widget
p []int
buf Buffer
permute func(b0, b1 Buffer, p []int)
}
func init() {
Register("permute", wProc, map[string]abc.Socket{
"out": abc.Socket{SamplesT, abc.Male},
"1": abc.Socket{SamplesT, abc.Fem... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
)
func init() {
abc.Register("input", map[string]abc.Socket{
"audio", abc.Socket{SamplesT, abc.Female},
"out": abc.Socket{SamplesT, abc.Male},
"1": abc.Socket{abc.StringT, abc.Female},
}, makeInput)
}
func makeInput(args map[string]interface{}) abc... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
"fmt"
"strings"
"sync"
)
var SamplesT = &abc.Type{"samples", false, abc.IsType((*node)(nil))}
var AudioEnvT = &abc.Type{"audio", true, abc.IsType((*context)(nil))}
var TimeT = &abc.Type{"time", true, abc.IsType(Time{})}
type widgetKind int
const (
wInpu... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
"strconv"
)
func init() {
Register("mix", wProc, map[string]abc.Socket{
"out": abc.Socket{SamplesT, abc.Male},
"1": abc.Socket{SamplesT, abc.Female},
"2": abc.Socket{SamplesT, abc.Female},
}, makeMixer)
}
type MixWidget struct {
Format
buf ... | Go |
package audio
import (
"code.google.com/p/rog-go/exp/abc"
"fmt"
"math"
"os"
"strconv"
)
// phaser stolen from audacity.
// audacity-src-1.3.12-beta/src/effects/Phaser.cpp
type PhaserWidget struct {
Format
input Widget
// parameters
freq, startphase, fb, drywet float32
depth, stages int
//... | Go |
package audio
import (
"math"
"strconv"
"code.google.com/p/rog-go/exp/abc"
)
type waveWidget struct {
freq float64
samples []float32
Format
}
func SinWave(freq float64, rate int) (w *waveWidget) {
w = &waveWidget{}
w.Rate = rate
w.NumChans = 1
w.Type = Float32Type
w.Layout = Interleaved
w.freq = freq
... | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.