code stringlengths 10 1.34M | language stringclasses 1
value |
|---|---|
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/glog"
"code.google.com/p/weed-fs/go/util"
"errors"
"fmt"
"io"
"os"
)
const (
FlagGzip = 0x01
FlagHasName = 0x02
FlagHasMime = 0x04
FlagHasLastModifiedDate = 0x08
LastModifiedBytesLength = 5
)
func (n *Needle) Dis... | Go |
package storage
import (
"code.google.com/p/weed-fs/go/glog"
"code.google.com/p/weed-fs/go/util"
"encoding/hex"
"errors"
"strings"
)
type FileId struct {
VolumeId VolumeId
Key uint64
Hashcode uint32
}
func NewFileIdFromNeedle(VolumeId VolumeId, n *Needle) *FileId {
return &FileId{VolumeId: VolumeId, Ke... | 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 (
"code.google.com/p/weed-fs/go/glog"
"code.google.com/p/weed-fs/go/util"
"encoding/hex"
"errors"
"io/ioutil"
"mime"
"net/http"
"path"
"strconv"
"strings"
"time"
)
const (
NeedleHeaderSize = 16 //should never change this
NeedlePaddingSize = 8
NeedleChecksumSize = 4
Ma... | 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 Version uint8
const (
Version1 = Version(1)
Version2 = Version(2)
CurrentVersion = Version2
)
| Go |
package sequence
import (
"sync"
)
// just for testing
type MemorySequencer struct {
counter uint64
sequenceLock sync.Mutex
}
func NewMemorySequencer() (m *MemorySequencer) {
m = &MemorySequencer{counter: 1}
return
}
func (m *MemorySequencer) NextFileId(count int) (uint64, int) {
m.sequenceLock.Lock()
d... | Go |
package sequence
import ()
type Sequencer interface {
NextFileId(count int) (uint64, int)
SetMax(uint64)
Peek() uint64
}
| Go |
// +build linux
package stats
import (
"syscall"
)
func (mem *MemStatus) fillInStatus() {
//system memory usage
sysInfo := new(syscall.Sysinfo_t)
err := syscall.Sysinfo(sysInfo)
if err == nil {
mem.All = uint64(sysInfo.Totalram) //* uint64(syscall.Getpagesize())
mem.Free = uint64(sysInfo.Freeram) //* uint64... | Go |
package stats
import (
"time"
)
type TimedValue struct {
t time.Time
val int64
}
func NewTimedValue(t time.Time, val int64) *TimedValue {
return &TimedValue{t: t, val: val}
}
type RoundRobinCounter struct {
LastIndex int
Values []int64
Counts []int64
}
func NewRoundRobinCounter(slots int) *RoundRobi... | Go |
package stats
import (
"runtime"
)
type MemStatus struct {
Goroutines int
All uint64
Used uint64
Free uint64
Self uint64
Heap uint64
Stack uint64
}
func MemStat() MemStatus {
mem := MemStatus{}
mem.Goroutines = runtime.NumGoroutine()
memStat := new(runtime.MemStats)
ru... | Go |
// +build !windows,!openbsd,!netbsd,!plan9
package stats
import (
"syscall"
)
func (disk *DiskStatus) fillInStatus() {
fs := syscall.Statfs_t{}
err := syscall.Statfs(disk.Dir, &fs)
if err != nil {
return
}
disk.All = fs.Blocks * uint64(fs.Bsize)
disk.Free = fs.Bfree * uint64(fs.Bsize)
disk.Used = disk.All ... | Go |
// +build windows openbsd netbsd plan9
package stats
import ()
func (disk *DiskStatus) fillInStatus() {
return
}
| Go |
// +build !linux
package stats
import ()
func (mem *MemStatus) fillInStatus() {
return
}
| Go |
package stats
import ()
type DiskStatus struct {
Dir string
All uint64
Used uint64
Free uint64
}
func NewDiskStatus(path string) (disk *DiskStatus) {
disk = &DiskStatus{Dir: path}
disk.fillInStatus()
return
}
| Go |
package stats
import (
"time"
)
type ServerStats struct {
Requests *DurationCounter
Connections *DurationCounter
AssignRequests *DurationCounter
ReadRequests *DurationCounter
WriteRequests *DurationCounter
DeleteRequests *DurationCounter
BytesIn *DurationCounter
BytesOut *DurationCou... | Go |
package glog
import ()
/*
Copying the original glog because it is missing several convenient methods.
1. remove nano time in log format
*/
| Go |
// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/
//
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
/... | Go |
// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/
//
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
/... | Go |
package operation
import (
"code.google.com/p/weed-fs/go/util"
"encoding/json"
"errors"
_ "fmt"
"math/rand"
"net/url"
"strings"
)
type Location struct {
Url string `json:"url,omitempty"`
PublicUrl string `json:"publicUrl,omitempty"`
}
type LookupResult struct {
VolumeId string `json:"volumeId,omi... | Go |
package operation
import (
"code.google.com/p/weed-fs/go/util"
"encoding/json"
"errors"
"net/url"
"strings"
"sync"
)
type DeleteResult struct {
Fid string `json:"fid"`
Size int `json:"size"`
Error string `json:"error,omitempty"`
}
func DeleteFile(master string, fileId string) error {
fileUrl, err := ... | Go |
package operation
import (
"code.google.com/p/weed-fs/go/glog"
"code.google.com/p/weed-fs/go/util"
"encoding/json"
"errors"
"net/url"
"strconv"
)
type AssignResult struct {
Fid string `json:"fid,omitempty"`
Url string `json:"url,omitempty"`
PublicUrl string `json:"publicUrl,omitempty"`
Count ... | Go |
package operation
import (
"bytes"
"code.google.com/p/weed-fs/go/glog"
"io"
"mime"
"os"
"path"
"strconv"
"strings"
)
type FilePart struct {
Reader io.Reader
FileName string
FileSize int64
IsGzipped bool
MimeType string
ModTime int64 //in seconds
Replication string
Collection strin... | Go |
package operation
import (
"code.google.com/p/weed-fs/go/glog"
"code.google.com/p/weed-fs/go/util"
"encoding/json"
)
type ClusterStatusResult struct {
IsLeader bool `json:"IsLeader,omitempty"`
Leader string `json:"Leader,omitempty"`
Peers []string `json:"Peers,omitempty"`
}
func ListMasters(server s... | Go |
package operation
import (
"bytes"
"code.google.com/p/weed-fs/go/glog"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"mime"
"mime/multipart"
"net/http"
"net/textproto"
"path/filepath"
"strings"
)
type UploadResult struct {
Name string `json:"name,omitempty"`
Size uint32 `json:"size,omitempty"`
Err... | Go |
package operation
import ()
type JoinResult struct {
VolumeSizeLimit uint64 `json:"VolumeSizeLimit,omitempty"`
Error string `json:"error,omitempty"`
}
| Go |
package util
import (
"bufio"
"code.google.com/p/weed-fs/go/glog"
"errors"
"os"
)
func TestFolderWritable(folder string) (err error) {
fileInfo, err := os.Stat(folder)
if err != nil {
return err
}
if !fileInfo.IsDir() {
return errors.New("Not a valid folder!")
}
perm := fileInfo.Mode().Perm()
glog.V(0)... | 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 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 (
"bytes"
"code.google.com/p/weed-fs/go/glog"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
var (
client *http.Client
Transport *http.Transport
)
func init() {
Transport = &http.Transport{
MaxIdleConnsPerHost: 1024,
}
client = &http.Client{Transport: Transport}
}
func PostB... | Go |
package util
import (
"code.google.com/p/weed-fs/go/stats"
"net"
"time"
)
// Listener wraps a net.Listener, and gives a place to store the timeout
// parameters. On Accept, it will wrap the net.Conn with our own Conn for us.
type Listener struct {
net.Listener
ReadTimeout time.Duration
WriteTimeout time.Durati... | 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 |
package util
import ()
const (
VERSION = "0.56 beta"
)
| 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 main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
return fmt.Sprintf("Sqrt: negative number %g"... | 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 main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
f, g := 0, 1
return func... | 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 main
import (
"fmt"
"tour/tree"
)
func walkImpl(t *tree.Tree, ch chan int) {
if t.Left != nil {
walkImpl(t.Left, ch)
}
ch <- t.Value
if t.Rig... | 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 main
import (
"strings"
"tour/wc"
)
func WordCount(s string) map[string]int {
m := make(map[string]int)
for _, f := range strings.Fields(s) {
m... | 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 main
import "tour/pic"
func Pic(dx, dy int) [][]uint8 {
p := make([][]uint8, dy)
for i := range p {
p[i] = make([]uint8, dx)
}
for y, row := r... | 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 main
import (
"io"
"os"
"strings"
)
func rot13(b byte) byte {
var a, z byte
switch {
case 'a' <= b && b <= 'z':
a, z = 'a', 'z'
case 'A' <= ... | 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 main
import (
"fmt"
"math/cmplx"
)
const delta = 1e-10
func Cbrt(x complex128) complex128 {
z := x
for {
n := z - (z*z*z-x)/(3*z*z)
if cmplx... | 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 main
import (
"errors"
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetc... | 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 main
import (
"image"
"image/color"
"tour/pic"
)
type Image struct {
Height, Width int
}
func (m Image) ColorModel() color.Model {
return color... | 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 main
import (
"fmt"
"math"
)
const delta = 1e-10
func Sqrt(x float64) float64 {
z := x
for {
n := z - (z*z-x)/(2*z)
if math.Abs(n-z) < delta... | 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 wc
import "fmt"
// Test runs a test suite against f.
func Test(f func(string) map[string]int) {
ok := true
for _, c := range testCases {
got := f... | 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 goplay
import (
"bytes"
"encoding/json"
"go/ast"
"go/parser"
"go/printer"
"go/token"
"net/http"
)
func init() {
http.HandleFunc("/fmt", fmtHa... | 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 goplay
import (
"fmt"
"io"
"net/http"
"appengine"
"appengine/urlfetch"
)
const runUrl = "http://golang.org/compile?output=json"
func init() {
... | 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 tree
import (
"fmt"
"math/rand"
)
// A Tree is a binary tree with integer values.
type Tree struct {
Left *Tree
Value int
Right *Tree
}
// New... | 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 pic
import (
"bytes"
"encoding/base64"
"fmt"
"image"
"image/png"
)
func Show(f func(int, int) [][]uint8) {
const (
dx = 256
dy = 256
)
da... | 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 main
import (
"bytes"
"encoding/json"
"go/ast"
"go/parser"
"go/printer"
"go/token"
"net/http"
)
func init() {
http.HandleFunc("/fmt", fmtHand... | 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/build"
"io/ioutil"
"log"
"net"
"net/http"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strc... | 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 main
import (
"encoding/json"
"log"
"net/http"
)
func init() {
http.HandleFunc("/compile", Compile)
}
type Response struct {
Output string `jso... | Go |
package app
import (
"fmt"
"net/http"
"appengine"
"appengine/memcache"
_ "code.google.com/p/rsc/appfs/server"
_ "code.google.com/p/rsc/blog/post"
)
func init() {
http.HandleFunc("/admin/", Admin)
}
func Admin(w http.ResponseWriter, req *http.Request) {
c := appengine.NewContext(req)
switch req.FormValue("... | 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 (
"code.google.com/p/rsc/devweb/slave"
_ "code.google.com/p/rsc/blog/post"
)
func main() {
slave.Main()
}
| 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.
// Adapted from encoding/xml/read_test.go.
// Package atom defines XML data structures for an Atom feed.
package atom
import (
"encoding/xml"
"time"
)
typ... | 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 post
import (
"bytes"
"encoding/json"
"encoding/xml"
"fmt"
"html/template"
"net/http"
"os"
"path"
"runtime/debug"
"sort"
"strings"
"time"
... | Go |
package post
import (
"fmt"
"net/http"
"runtime/debug"
qrweb "code.google.com/p/rsc/qr/web"
)
func carp(f http.HandlerFunc) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
defer func() {
if err := recover(); err != nil {
w.Header().Set("Content-Type", "text/plain... | Go |
package main
import (
"io/ioutil"
"log"
"os"
"code.google.com/p/goprotobuf/proto"
"code.google.com/p/rsc/gtfs"
)
func main() {
log.SetFlags(0)
if len(os.Args) != 2 {
log.Fatal("usage: mbta file.pb")
}
pb, err := ioutil.ReadFile(os.Args[1])
if err != nil {
log.Fatal(err)
}
var feed gtfs.FeedMessage
... | 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 smugmug uses the SmugMug API to manipulate photo albums
// stored on smugmug.com.
package smugmug
import (
"bytes"
"crypto/md5"
"encoding/json"
... | 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.
// Smugup uploads a collection of photos to SmugMug.
//
// Run 'smugup -help' for details.
package main
import (
"crypto/md5"
"flag"
"fmt"
"io/ioutil"
"l... | 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.
// Copied from code.google.com/p/codesearch/regexp/copy.go.
// Copied from Go's regexp/syntax.
// Formatters edited to handle instByteRange.
package main
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.
// Copy of go/src/pkg/sort/sort.go, specialized for []int
// and to remove some array indexing.
package main
func min(a, b int) int {
if a < b {
return a
... | 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 main
import (
"flag"
"fmt"
"log"
"os"
"regexp/syntax"
"runtime/pprof"
)
var maxState = flag.Int("m", 1e5, "maximum number of states to explore"... | 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.
// Code to merge (join) multiple regexp progs into a single prog.
// New code; not copied from anywhere.
package main
import "regexp/syntax"
func joinProgs(... | 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.
// Copied from code.google.com/p/codesearch/sparse/set.go,
// tweaked for better inlinability.
package main
// For comparison: running cindex over the Linux ... | 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.
// Copy of code.google.com/p/codesearch/regexp/utf.go.
package main
import (
"regexp/syntax"
"unicode"
"unicode/utf8"
)
const (
instFail = syntax.I... | 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.
// Copied from code.google.com/p/codesearch/regexp/copy.go
// and adapted for the problem of finding a matching string, not
// testing whether a particular str... | 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 gf256 implements arithmetic over the Galois Field GF(256).
package gf256
import "strconv"
// A Field represents an instance of GF(256) defined by ... | 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.
// FUSE directory tree, for servers that wish to use it with the service loop.
package fuse
import (
"os"
pathpkg "path"
"strings"
)
// A Tree implements... | Go |
package fuse
import "time"
type attr struct {
Ino uint64
Size uint64
Blocks uint64
Atime uint64
Mtime uint64
Ctime uint64
AtimeNsec uint32
MtimeNsec uint32
CtimeNsec uint32
Mode uint32
Nlink uint32
Uid uint32
Gid uint32
Rdev uint32
// Blksize uint32... | 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.
// Adapted from Plan 9 from User Space's src/cmd/9pfuse/fuse.c,
// which carries this notice:
//
// The files in this directory are subject to the following li... | 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.
// TODO: Rewrite using package syscall not cgo
package fuse
/*
// Adapted from Plan 9 from User Space's src/cmd/9pfuse/fuse.c,
// which carries this notice:... | 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.
// Derived from FUSE's fuse_kernel.h
/*
This file defines the kernel interface of FUSE
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
T... | Go |
package fuse
import (
"time"
)
type attr struct {
Ino uint64
Size uint64
Blocks uint64
Atime uint64
Mtime uint64
Ctime uint64
Crtime_ uint64 // OS X only
AtimeNsec uint32
MtimeNsec uint32
CtimeNsec uint32
CrtimeNsec uint32 // OS X only
Mode uint32
Nlink u... | 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.
// Hellofs implements a simple "hello world" file system.
package main
import (
"log"
"os"
"code.google.com/p/rsc/fuse"
)
func main() {
c, err := fuse.M... | 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 fuse
import (
"fmt"
"net"
"os"
"os/exec"
"syscall"
)
func mount(dir string) (fusefd int, errmsg string) {
fds, err := syscall.Socketpair(syscal... | Go |
package fuse
| 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.
// FUSE service loop, for servers that wish to use it.
package fuse
import (
"runtime"
)
func stack() string {
buf := make([]byte, 1024)
return string(bu... | 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.
// FUSE service loop, for servers that wish to use it.
package fuse
import (
"fmt"
"hash/fnv"
"io"
"log"
"os"
"path"
"sync"
"syscall"
"time"
)
// 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.
/*
QR data layout
qr/
upload/
id.png
id.fix
flag/
id
*/
// TODO: Random seed taken from GET for caching, repeatability.
// TODO: Flag for abuse butto... | Go |
package web
import (
"bytes"
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"net/http"
"strconv"
"strings"
"code.google.com/p/freetype-go/freetype"
"code.google.com/p/rsc/appfs/fs"
"code.google.com/p/rsc/qr"
"code.google.com/p/rsc/qr/coding"
)
func makeImage(req *http.Request, caption, font 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 resize
import (
"image"
"image/color"
)
// average convert the sums to averages and returns the result.
func average(sum []uint64, w, h int, n uint6... | Go |
// +build ignore
package main
import "fmt"
// tables from qrencode-3.1.1/qrspec.c
var capacity = [41]struct {
width int
words int
remainder int
ec [4]int
}{
{0, 0, 0, [4]int{0, 0, 0, 0}},
{21, 26, 0, [4]int{7, 10, 13, 17}}, // 1
{25, 44, 7, [4]int{10, 16, 22, 28}},
{29, 70, 7, [4]int{15, 26, ... | 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 coding implements low-level QR coding details.
package coding
import (
"fmt"
"strconv"
"strings"
"code.google.com/p/rsc/gf256"
)
// Field is ... | 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 libqrencode wraps the C libqrencode library.
// The qr package (in this package's parent directory)
// does not use any C wrapping. This code is he... | 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 qr
// PNG writer for QR codes.
import (
"bytes"
"encoding/binary"
"hash"
"hash/crc32"
)
// PNG returns a PNG image displaying the code.
//
// PN... | 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 qr encodes QR codes.
*/
package qr
import (
"errors"
"image"
"image/color"
"code.google.com/p/rsc/qr/coding"
)
// A Level denotes a QR error ... | 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 plist implements parsing of Apple plist files.
package plist
import (
"bytes"
"fmt"
"reflect"
"strconv"
)
func next(data []byte) (skip, tag, r... | 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 proto defines the protocol between appfs client and server.
package proto
import "time"
// An Auth appears, JSON-encoded, as the X-Appfs-Auth head... | 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 fs is an indirection layer, allowing code to use a
// file system without knowing whether it is the host file system
// (running without App Engine)... | 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 fs
import (
"io/ioutil"
"net/http"
"os"
"path/filepath"
"code.google.com/p/rsc/appfs/proto"
)
type context struct{}
type cacheKey struct{}
fu... | 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 client implements a basic appfs client.
package client
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
"time"
... | 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.
// appmount mounts an appfs file system.
package main
import (
"bytes"
"encoding/gob"
"flag"
"fmt"
"log"
"os"
"os/exec"
"path"
"strings"
"syscall"
... | 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 server implements an appfs server backed by the
// App Engine datastore.
package server
import (
"bytes"
"crypto/sha1"
"encoding/base64"
"enco... | 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.
// appfile is a command-line interface to an appfs file system.
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"code.google.com/p/rsc/appfs/... | Go |
package imap
import (
"bufio"
"bytes"
"crypto/md5"
"crypto/tls"
"fmt"
"io"
"log"
"net"
"os"
"os/exec"
"strconv"
"strings"
"sync"
)
var Debug = false
const tag = "#"
// A Mode specifies the IMAP connection mode.
type Mode int
const (
Unencrypted Mode = iota // unencrypted TCP connection
StartTLS ... | Go |
package imap
// NOTE(rsc): These belong elsewhere but the existing charset
// packages seem too complicated.
var tab_iso8859_1 = [256]rune{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x... | Go |
package imap
import (
"bytes"
"fmt"
"log"
"regexp"
"sort"
"strings"
"time"
)
type Flags uint32
const (
FlagJunk Flags = 1 << iota
FlagNonJunk
FlagReplied
FlagFlagged
FlagDeleted
FlagDraft
FlagRecent
FlagSeen
FlagNoInferiors
FlagNoSelect
FlagMarked
FlagUnMarked
FlagHasChildren
FlagHasNoChildren
... | Go |
package imap
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"strings"
"time"
)
type sxKind int
const (
sxNone sxKind = iota
sxAtom
sxString
sxNumber
sxList
)
type sx struct {
kind sxKind
data []byte
number int64
sx []*sx
}
func rdsx(b *bufio.Reader) (*sx, error) {
x := &sx{kind: sxList}
for {
... | Go |
package imap
import (
"bytes"
"encoding/base64"
"strings"
"unicode"
)
func decode2047chunk(s string) (conv []byte, rest string, ok bool) {
// s is =?...
// and should be =?charset?e?text?=
j := strings.Index(s[2:], "?")
if j < 0 {
return
}
j += 2
if j+2 >= len(s) || s[j+2] != '?' {
return
}
k := stri... | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.