code
stringlengths
10
1.34M
language
stringclasses
1 value
// Tideland Common Go Library - Cells // // Copyright (C) 2010-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. // A framework for event and behavior based applications. // // Cell behaviors are defined based on an interface and can be ...
Go
// Tideland Common Go Library - Web // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package web //-------------------- // IMPORTS //-------------------- import ( "code.google.com/p/tcgl/applog" "code.google...
Go
// Tideland Common Go Library - Web // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package web //-------------------- // IMPORTS //-------------------- import ( "net/http" "path/filepath" "strings" ) //-...
Go
// Tideland Common Go Library - Web // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package web //-------------------- // IMPORTS //-------------------- import ( "encoding/gob" "fmt" "io" "io/ioutil" "ne...
Go
// Tideland Common Go Library - Web // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package web //-------------------- // IMPORTS //-------------------- import ( "bytes" "encoding/gob" "encoding/json" "er...
Go
// Tideland Common Go Library - Web // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. // The web package provides a framework for a component based web development. // // It is intended as a convenience to build ...
Go
// Tideland Common Go Library - Monitoring // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package monitoring //-------------------- // IMPORTS //-------------------- import ( "fmt" "io" "os" "time" ) //...
Go
// Tideland Common Go Library - Monitoring // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. // The monitoring package support three kinds of system monitoring. // // They are helpful to understand what's happeni...
Go
// Tideland Common Go Library - Redis - Result Sets // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package redis //-------------------- // IMPORTS //-------------------- import ( "errors" "fmt" "strconv"...
Go
// Tideland Common Go Library - Redis - Utilities // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package redis //-------------------- // IMPORTS //-------------------- import ( "fmt" "strings" ) //-------...
Go
// Tideland Common Go Library - Redis - Unified Request Protocol // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package redis //-------------------- // IMPORTS //-------------------- import ( "bufio" "code...
Go
// Tideland Common Go Library - Redis - Subscription // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package redis //-------------------- // IMPORTS //-------------------- import "runtime" //----------------...
Go
// Tideland Common Go Library - Redis // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. package redis //-------------------- // IMPORTS //-------------------- import ( "code.google.com/p/tcgl/util" "fmt" "ti...
Go
// Tideland Common Go Library - Redis // // Copyright (C) 2009-2012 Frank Mueller / Oldenburg / Germany // // All rights reserved. Use of this source code is governed // by the new BSD license. // A simple but powerful client for accessing the Redis database. // // After establishing a connection using NewRedisDatab...
Go
// Copyright 2013 <chaishushan{AT}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 main import ( "errors" "log" "net" "net/rpc" "code.google.com/p/protorpc" "code.google.com/p/protorpc/service.pb" "code.google.com/...
Go
// Copyright 2013 <chaishushan{AT}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 main import ( "fmt" "log" "net/rpc" "code.google.com/p/protorpc" "code.google.com/p/protorpc/service.pb" "code.google.com/p/goprotob...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. // The freetype package provides a convenient AP...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. // The raster package provides an anti-aliasing ...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package raster import ( "image" "image/color"...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package raster import ( "fmt" "math" ) // A ...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package raster // Two points are considered pra...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package truetype // Hinting is the policy for s...
Go
// Copyright 2012 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package truetype // This file implements a True...
Go
// Copyright 2012 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package truetype // The Truetype opcodes are su...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. // Package truetype provides a parser for the TT...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package main import ( "bufio" "fmt" "image" ...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package main import ( "bufio" "flag" "fmt" ...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. // This program visualizes the quadratic approxi...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package main import ( "bufio" "fmt" "image" ...
Go
// Copyright 2010 The Freetype-Go Authors. All rights reserved. // Use of this source code is governed by your choice of either the // FreeType License or the GNU General Public License version 2 (or // any later version), both of which can be found in the LICENSE file. package main import ( "flag" "fmt" "io/iouti...
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
package main import ( "encoding/json" "errors" "flag" "fmt" "io/ioutil" "log" "net" "net/http" "os" "os/exec" "path" "runtime" "code.google.com/p/goauth2/oauth" "code.google.com/p/google-api-go-client/youtube/v3" ) var ( clientSecretsFile = flag.String("secrets", "client_secrets.json", "Client Secrets...
Go
package operation import ( "code.google.com/p/weed-fs/go/storage" "code.google.com/p/weed-fs/go/util" "encoding/json" "errors" _ "fmt" "net/url" ) type Location struct { Url string `json:"url"` PublicUrl string `json:"publicUrl"` } type LookupResult struct { Locations []Location `json:"locations"` Err...
Go
package operation import ( "bytes" "encoding/json" "errors" "fmt" "io" "io/ioutil" "log" "mime" "mime/multipart" "net/http" "net/textproto" "path/filepath" "strings" ) type UploadResult struct { Size int Error string } var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"") func Upload...
Go
package operation import ( "code.google.com/p/weed-fs/go/storage" "code.google.com/p/weed-fs/go/topology" "code.google.com/p/weed-fs/go/util" "encoding/json" "errors" "net/url" ) type AllocateVolumeResult struct { Error string } func AllocateVolume(dn *topology.DataNode, vid storage.VolumeId, repType storage....
Go
package operation import ( "log" "net/http" ) func Delete(url string) error { req, err := http.NewRequest("DELETE", url, nil) if err != nil { log.Println("failing to delete", url) return err } _, err = http.DefaultClient.Do(req) return err }
Go
package sequence import ( "encoding/gob" "log" "os" "path" "sync" ) const ( FileIdSaveInterval = 10000 ) type Sequencer interface { NextFileId(count int) (uint64, int) } type SequencerImpl struct { dir string fileName string volumeLock sync.Mutex sequenceLock sync.Mutex FileIdSequence uint64 fi...
Go
package replication import ( "code.google.com/p/weed-fs/go/operation" "code.google.com/p/weed-fs/go/storage" "code.google.com/p/weed-fs/go/topology" "errors" "fmt" "log" "math/rand" "sync" ) /* This package is created to resolve these replica placement issues: 1. growth factor for each replica level, e.g., ad...
Go
package replication import ( "bytes" "code.google.com/p/weed-fs/go/operation" "code.google.com/p/weed-fs/go/storage" "log" "net/http" "strconv" ) func ReplicatedWrite(masterNode string, s *storage.Store, volumeId storage.VolumeId, needle *storage.Needle, r *http.Request) (size uint32, errorStatus string) { ret...
Go
package topology import ( "code.google.com/p/weed-fs/go/storage" "log" ) type NodeId string type Node interface { Id() NodeId String() string FreeSpace() int ReserveOneVolume(r int, vid storage.VolumeId, dataCenter string) (bool, *DataNode) UpAdjustMaxVolumeCountDelta(maxVolumeCountDelta int) UpAdjustVolumeCo...
Go
package topology import ( "strconv" "time" ) type Rack struct { NodeImpl } func NewRack(id string) *Rack { r := &Rack{} r.id = NodeId(id) r.nodeType = "Rack" r.children = make(map[NodeId]Node) r.NodeImpl.value = r return r } func (r *Rack) FindDataNode(ip string, port int) *DataNode { for _, c := range r....
Go
package topology import ( "encoding/xml" ) type loc struct { dcName string rackName string } type rack struct { Name string `xml:"name,attr"` Ips []string `xml:"Ip"` } type dataCenter struct { Name string `xml:"name,attr"` Racks []rack `xml:"Rack"` } type topology struct { DataCenters []dataCenter `xml:...
Go
package topology import ( "code.google.com/p/weed-fs/go/storage" "errors" "log" "math/rand" "sync" ) type VolumeLayout struct { repType storage.ReplicationType vid2location map[storage.VolumeId]*VolumeLocationList writables []storage.VolumeId // transient array of writable volume id pulse ...
Go
package topology import ( "code.google.com/p/weed-fs/go/storage" "code.google.com/p/weed-fs/go/util" "encoding/json" "errors" "log" "net/url" "time" ) func batchVacuumVolumeCheck(vl *VolumeLayout, vid storage.VolumeId, locationlist *VolumeLocationList, garbageThreshold string) bool { ch := make(chan bool, loc...
Go
package topology import ( "code.google.com/p/weed-fs/go/storage" "log" "math/rand" "time" ) func (t *Topology) StartRefreshWritableVolumes(garbageThreshold string) { go func() { for { freshThreshHold := time.Now().Unix() - 3*t.pulse //3 times of sleep interval t.CollectDeadNodeAndFullVolumes(freshThreshH...
Go
package topology import ( "code.google.com/p/weed-fs/go/storage" _ "fmt" "strconv" ) type DataNode struct { NodeImpl volumes map[storage.VolumeId]storage.VolumeInfo Ip string Port int PublicUrl string LastSeen int64 // unix time in seconds Dead bool } func NewDataNode(id string) *DataNo...
Go
package topology import () func (t *Topology) ToMap() interface{} { m := make(map[string]interface{}) m["Max"] = t.GetMaxVolumeCount() m["Free"] = t.FreeSpace() var dcs []interface{} for _, c := range t.Children() { dc := c.(*DataCenter) dcs = append(dcs, dc.ToMap()) } m["DataCenters"] = dcs var layouts [...
Go
package topology import ( "code.google.com/p/weed-fs/go/sequence" "code.google.com/p/weed-fs/go/storage" "errors" "io/ioutil" "log" "math/rand" ) type Topology struct { NodeImpl //transient vid~servers mapping for each replication type replicaType2VolumeLayout []*VolumeLayout pulse int64 volumeSizeLimit...
Go
package topology import ( "code.google.com/p/weed-fs/go/storage" "log" "math/rand" ) type NodeList struct { nodes map[NodeId]Node except map[string]Node } func NewNodeList(nodes map[NodeId]Node, except map[string]Node) *NodeList { m := make(map[NodeId]Node, len(nodes)-len(except)) for _, n := range nodes { ...
Go
package topology import () type DataCenter struct { NodeImpl } func NewDataCenter(id string) *DataCenter { dc := &DataCenter{} dc.id = NodeId(id) dc.nodeType = "DataCenter" dc.children = make(map[NodeId]Node) dc.NodeImpl.value = dc return dc } func (dc *DataCenter) GetOrCreateRack(rackName string) *Rack { f...
Go
package topology import () type VolumeLocationList struct { list []*DataNode } func NewVolumeLocationList() *VolumeLocationList { return &VolumeLocationList{} } func (dnll *VolumeLocationList) Head() *DataNode { return dnll.list[0] } func (dnll *VolumeLocationList) Length() int { return len(dnll.list) } func ...
Go
package util func BytesToUint64(b []byte) (v uint64) { length := uint(len(b)) for i := uint(0); i < length-1; i++ { v += uint64(b[i]) v <<= 8 } v += uint64(b[length-1]) return } func BytesToUint32(b []byte) (v uint32) { length := uint(len(b)) for i := uint(0); i < length-1; i++ { v += uint32(b[i]) v <<=...
Go
package util import ( "io/ioutil" "log" "net/http" "net/url" ) func Post(url string, values url.Values) ([]byte, error) { r, err := http.PostForm(url, values) if err != nil { log.Println("post to", url, err) return nil, err } defer r.Body.Close() b, err := ioutil.ReadAll(r.Body) if err != nil { log.Pr...
Go
package util import ( "strconv" ) func ParseInt(text string, defaultValue int) int { count, parseError := strconv.ParseUint(text, 10, 64) if parseError != nil { if len(text) > 0 { return 0 } return defaultValue } return int(count) }
Go
// Copyright 2011 Numerotron Inc. // Use of this source code is governed by an MIT-style license // that can be found in the LICENSE file. // // Developed at www.stathat.com by Patrick Crosby // Contact us on twitter with any questions: twitter.com/stat_hat // The jconfig package provides a simple, basic configuratio...
Go
package main import ( "code.google.com/p/weed-fs/go/replication" "code.google.com/p/weed-fs/go/storage" "code.google.com/p/weed-fs/go/topology" "encoding/json" "errors" "log" "net/http" "runtime" "strconv" "strings" "time" ) func init() { cmdMaster.Run = runMaster // break init cycle cmdMaster.IsDebug = ...
Go
package main import ( "fmt" "runtime" ) const ( VERSION = "0.35" ) var cmdVersion = &Command{ Run: runVersion, UsageLine: "version", Short: "print Weed File System version", Long: `Version prints the Weed File System version`, } func runVersion(cmd *Command, args []string) bool { if len(args)...
Go
package main import ( "flag" "fmt" "os" "strings" ) type Command struct { // Run runs the command. // The args are the arguments after the command name. Run func(cmd *Command, args []string) bool // UsageLine is the one-line usage message. // The first word in the line is taken to be the command name. Usag...
Go
package main import ( "code.google.com/p/weed-fs/go/operation" "code.google.com/p/weed-fs/go/util" "encoding/json" "errors" "fmt" "net/url" "os" "path" "path/filepath" "strconv" ) var ( uploadReplication *string uploadDir *string include *string ) func init() { cmdUpload.Run = runUplo...
Go
package main import ( "code.google.com/p/weed-fs/go/operation" "code.google.com/p/weed-fs/go/replication" "code.google.com/p/weed-fs/go/storage" "log" "math/rand" "mime" "net/http" "os" "path/filepath" "runtime" "strconv" "strings" "time" ) func init() { cmdVolume.Run = runVolume // break init cycle cm...
Go
package main import ( "encoding/json" "flag" "fmt" "io" "log" "math/rand" "net/http" "os" "strings" "sync" "text/template" "time" "unicode" "unicode/utf8" ) var IsDebug *bool var server *string var commands = []*Command{ cmdFix, cmdMaster, cmdUpload, cmdShell, cmdVersion, cmdVolume, cmdExport, }...
Go
package main import ( "code.google.com/p/weed-fs/go/storage" "log" "os" "path" "strconv" ) func init() { cmdFix.Run = runFix // break init cycle cmdFix.IsDebug = cmdFix.Flag.Bool("debug", false, "enable debug mode") } var cmdFix = &Command{ UsageLine: "fix -dir=/tmp -volumeId=234", Short: "run weed tool...
Go
package main import ( "archive/tar" "bytes" "code.google.com/p/weed-fs/go/storage" "fmt" "log" "os" "path" "strconv" "strings" "text/template" "time" ) func init() { cmdExport.Run = runExport // break init cycle cmdExport.IsDebug = cmdExport.Flag.Bool("debug", false, "enable debug mode") } const ( defa...
Go
package main import ( "bufio" "fmt" "log" "os" ) func init() { cmdShell.Run = runShell // break init cycle } var cmdShell = &Command{ UsageLine: "shell", Short: "run interactive commands, now just echo", Long: `run interactive commands. `, } var () func runShell(command *Command, args []string) bool...
Go
package storage import ( "code.google.com/p/weed-fs/go/util" "encoding/hex" "strings" ) type FileId struct { VolumeId VolumeId Key uint64 Hashcode uint32 } func NewFileId(VolumeId VolumeId, Key uint64, Hashcode uint32) *FileId { return &FileId{VolumeId: VolumeId, Key: Key, Hashcode: Hashcode} } func Pars...
Go
package storage import ( "bufio" "code.google.com/p/weed-fs/go/util" "fmt" "io" "os" ) type NeedleMapper interface { Put(key uint64, offset uint32, size uint32) (int, error) Get(key uint64) (element *NeedleValue, ok bool) Delete(key uint64) error Close() ContentSize() uint64 DeletedSize() uint64 FileCount...
Go
package storage import () type NeedleValue struct { Key Key Offset uint32 `comment:"Volume offset"` //since aligned to 8 bytes, range is 4G*8=32G Size uint32 `comment:"Size of the data portion"` } const ( batch = 100000 ) type Key uint64 type CompactSection struct { values []NeedleValue overflow map[K...
Go
package storage import ( "code.google.com/p/weed-fs/go/util" "encoding/hex" "errors" "io/ioutil" "log" "mime" "net/http" "path" "strconv" "strings" "time" ) const ( NeedleHeaderSize = 16 //should never change this NeedlePaddingSize = 8 NeedleChecksumSize = 4 ) type Needle struct { Cookie uint32 `co...
Go
package storage import () type Version uint8 const ( Version1 = Version(1) Version2 = Version(2) CurrentVersion = Version2 )
Go
package storage import ( "bytes" "errors" "fmt" "io" "log" "os" "path" "sync" ) const ( SuperBlockSize = 8 ) type SuperBlock struct { Version Version ReplicaType ReplicationType } func (s *SuperBlock) Bytes() []byte { header := make([]byte, SuperBlockSize) header[0] = byte(s.Version) header[1] = s...
Go
package storage import ( "strconv" ) type VolumeId uint32 func NewVolumeId(vid string) (VolumeId, error) { volumeId, err := strconv.ParseUint(vid, 10, 64) return VolumeId(volumeId), err } func (vid *VolumeId) String() string { return strconv.FormatUint(uint64(*vid), 10) } func (vid *VolumeId) Next() VolumeId { ...
Go
package storage import ( "code.google.com/p/weed-fs/go/util" "encoding/json" "fmt" "io/ioutil" "log" "net/url" "strconv" "strings" ) type DiskLocation struct { directory string maxVolumeCount int volumes map[VolumeId]*Volume } type Store struct { Port int Ip string Pu...
Go
package storage import ( "hash/crc32" ) var table = crc32.MakeTable(crc32.Castagnoli) type CRC uint32 func NewCRC(b []byte) CRC { return CRC(0).Update(b) } func (c CRC) Update(b []byte) CRC { return CRC(crc32.Update(uint32(c), table, b)) } func (c CRC) Value() uint32 { return uint32(c>>15|c<<17) + 0xa282ead8 ...
Go
package storage import ( "bytes" "compress/flate" "compress/gzip" "io/ioutil" "strings" ) /* * Default more not to gzip since gzip can be done on client side. */ func IsGzippable(ext, mtype string) bool { if strings.HasPrefix(mtype, "text/") { return true } switch ext { case ".zip", ".rar", ".gz", ".bz2",...
Go
package storage import ( "errors" ) type ReplicationType string const ( Copy000 = ReplicationType("000") // single copy Copy001 = ReplicationType("001") // 2 copies, both on the same racks, and same data center Copy010 = ReplicationType("010") // 2 copies, both on differen...
Go
package storage import ( "code.google.com/p/weed-fs/go/util" "errors" "fmt" "io" "log" "os" ) const ( FlagGzip = 0x01 FlagHasName = 0x02 FlagHasMime = 0x04 FlagHasLastModifiedDate = 0x08 LastModifiedBytesLength = 5 ) func (n *Needle) DiskSize() uint32 { padding := N...
Go
package storage import ( "code.google.com/p/weed-fs/go/util" "encoding/json" "errors" "fmt" "github.com/tgulacsi/go-cdb" "os" "path/filepath" ) // CDB-backed read-only needle map type cdbMap struct { c1, c2 *cdb.Cdb fn1, fn2 string mapMetric } const maxCdbRecCount = 100000000 var errReadOnly = errors.Ne...
Go
package storage import () type VolumeInfo struct { Id VolumeId Size uint64 RepType ReplicationType Version Version FileCount int DeleteCount int DeletedByteCount uint64 ReadOnly bool }
Go
// © Knug Industries 2009 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package compiler import ( "os" "fmt" "log" "exec" "strings" "regexp" "path/filepath" "utilz/walker" "utilz/stringset" "utilz/handy" "utilz/say" "utilz/gl...
Go
// © Knug Industries 2009 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package dag import ( "exec" "go/parser" "go/token" "go/ast" "os" "fmt" "time" "log" "strings" "regexp" "path/filepath" "utilz/stringset" "utilz/strin...
Go
// © Knug Industries 2009 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package main import ( "os" "fmt" "log" "strings" "runtime" "path/filepath" "utilz/walker" "cmplr/compiler" "cmplr/dag" "parse/gopt" "utilz/handy" "utilz/...
Go
// © Knug Industries 2009 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package handy import ( "os" "log" "io/ioutil" "regexp" "strings" "exec" ) // some utility functions func StdExecve(argv []string, stopOnTrouble bool) (ok bool) { var err...
Go
// © Knug Industries 2011 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package say // Perl6 inspiration here :-) import ( "fmt" "io" "os" ) // package to turn of all print statements var mute bool = false func Mute() { mute = true } func Sound() { ...
Go
// © Knug Industries 2011 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package timer import ( "time" "os" "io" "fmt" ) // a very simple timer package, perhaps to simple // nanosecond: Millisecond, Second, Minute, Hour const ( Millisecond = 1e6 Se...
Go
// © Knug Industries 2009 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package stringset import "strings" // Use the built-in hash tables to construct a set of strings. type StringSet struct { elements map[string]interface{} } func New() *StringSet { s := new...
Go
// © Knug Industries 2010 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package global // Be a man and use some globals. // This is not threadsafe, unless maps are, i.e. it's not // Since I only use the globals in a single thread, I did // not bother with the 'sync' packa...
Go
// © Knug Industries 2009 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package walker /* texas ranger */ import ( "os" "path/filepath" ) // This package does something along the lines of: find PATH -type f // Filters can be added on both directory and filenames i...
Go
// © Knug Industries 2010 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package stringbuffer // Allocate a byte buffer to build strings from a set of // smaller strings, if added content exceeds maximal buffer // size, the size of the stringbuffer doubles. type StringBuf...
Go
// © Knug Industries 2009 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package gopt /* The flag package provided in the go standard library will only allow options before regular input arguments, which is not ideal. So this is another take on the old getopt. Most notabl...
Go
// © Knug Industries 2009 all rights reserved // GNU GENERAL PUBLIC LICENSE VERSION 3.0 // Author bjarneh@ifi.uio.no package gopt type Option interface { isSet() bool reset() } type StringOption struct { // all options belonging to this StringOption options []string // multiple values are allowed...
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 websocket import ( "bufio" "crypto/tls" "io" "net" "net/url" ) // DialError is an error that occurs while dialling a websocket server. type DialE...
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 websocket // This file implements a protocol of Hixie draft version 75 and 76 // (draft 76 equals to hybi 00) import ( "bufio" "bytes" "crypto/md5"...
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 websocket // This file implements a protocol of hybi draft. // http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 import ( "bufio" "...
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 websocket import ( "bufio" "fmt" "io" "net/http" ) func newServerConn(rwc io.ReadWriteCloser, buf *bufio.ReadWriter, req *http.Request) (conn *Con...
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 websocket implements a client and server for the WebSocket protocol. // The protocol is defined at http://tools.ietf.org/html/draft-ietf-hybi-thewebs...
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 spdy import ( "encoding/binary" "io" "net/http" "strings" ) func (frame *SynStreamFrame) write(f *Framer) error { return f.writeSynStreamFrame(fr...
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 spdy implements SPDY protocol which is described in // draft-mbelshe-httpbis-spdy-00. // // http://tools.ietf.org/html/draft-mbelshe-httpbis-spdy-00 ...
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 spdy import ( "compress/zlib" "encoding/binary" "io" "net/http" "strings" ) func (frame *SynStreamFrame) read(h ControlFrameHeader, f *Framer) er...
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 proxy import ( "errors" "io" "net" "strconv" ) // SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address // with an optional ...
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 proxy import ( "net" ) type direct struct{} // Direct is a direct proxy: one that makes network connections directly. var Direct = direct{} func (d...
Go