code
stringlengths
10
1.34M
language
stringclasses
1 value
//Copyright 2011 Siyabonga Dlamini (siyabonga.dlamini@gmail.com). All rights reserved. // //Redistribution and use in source and binary forms, with or without //modification, are permitted provided that the following conditions //are met: // // 1. Redistributions of source code must retain the above copyright /...
Go
//Copyright 2011 Siyabonga Dlamini (siyabonga.dlamini@gmail.com). All rights reserved. // //Redistribution and use in source and binary forms, with or without //modification, are permitted provided that the following conditions //are met: // // 1. Redistributions of source code must retain the above copyright // n...
Go
package main import "fmt" func main() { fmt.Println(count(10)); fmt.Printf("%d\n", sum([]int{1,2,3})); fmt.Println(sumrange([]int{3,4})); } func count(i int) int { return 10; } func sumrange(a []int) int { s := 0; for _, v := range a { s += v; } return s; } func sum(a [...
Go
package main import ( "os"; "flag"; ) var omitNewline = flag.Bool("n", false, "dont print final newline") const ( Space = " "; Newline = "\n"; ) func main() { flag.Parse(); var s string = ""; for i := 0; i < flag.NArg(); i++ { if i > 0 { s += Space } s += flag.Arg(i) } ...
Go
package main import "fmt" func main() { fmt.Printf("hello world\n") }
Go
package main import ( "appengine" "appengine/urlfetch" "bytes" "encoding/json" "errors" "fmt" "html/template" "io/ioutil" "net/http" "regexp" ) const ( EXAMPLE_URL = "https://www.googleapis.com/plus/v1/people/+DeWittClinton" API_KEY = "AIzaSyDyMJWU-cElvX5NESC8zdQ3XoURbkT4DOc" // rate limited per...
Go
// Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package regexp implements a simple regular expression library. // // The syntax of the regular expressions accepted is the same // general syntax used by Perl, Python, and other languages. // More precisely, it 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. // Package syntax parses regular expressions into syntax trees. // WORK IN PROGRESS. package syntax // Note to implementers: // In this package, re is always ...
Go
package syntax import ( "bytes" "strconv" "unicode" ) // Compiled program. // May not belong in this package, but convenient for now. // A Prog is a compiled regular expression program. type Prog struct { Inst []Inst Start int // index of start instruction NumCap int // number of InstCapture insts in re } ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package syntax // Simplify returns a regexp equivalent to re but without counted repetitions // and with various other simplifications, such as rewriting /(?:...
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 syntax import ( "os" "sort" "strings" "unicode" "utf8" ) // An Error describes a failure to parse a regular expression // and gives the offendin...
Go
package syntax import ( "os" "unicode" ) // A patchList is a list of instruction pointers that need to be filled in (patched). // Because the pointers haven't been filled in yet, we can reuse their storage // to hold the list. It's kind of sleazy, but works well in practice. // See http://swtch.com/~rsc/regexp/reg...
Go
package regexp import "appengine-go-backports/regexp/syntax" // A queue is a 'sparse array' holding pending threads of execution. // See http://research.swtch.com/2008/03/using-uninitialized-memory-for-fun-and.html type queue struct { sparse []uint32 dense []entry } // A entry is an entry on a queue. // It holds ...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package socket provides outbound network sockets. */ package socket import ( "fmt" "io" "net" "strconv" "time" "appengine" "appengine_internal" pb "...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package datastore import ( "bytes" "encoding/base64" "encoding/gob" "errors" "fmt" "strconv" "strings" "appengine" basepb "appengine_internal/base" "...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package datastore import ( "errors" "fmt" "math" "reflect" "time" "appengine" "github.com/golang/protobuf/proto" pb "appengine_internal/datastore" ) ...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package datastore import ( "encoding/base64" "errors" "fmt" "math" "reflect" "strings" "appengine" "github.com/golang/protobuf/proto" pb "appengine_i...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package datastore import ( "fmt" "reflect" "time" "appengine" pb "appengine_internal/datastore" ) var ( typeOfBlobKey = reflect.TypeOf(appengine.Blo...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package datastore import ( "errors" "appengine" "appengine_internal" "github.com/golang/protobuf/proto" pb "appengine_internal/datastore" ) func init() ...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package datastore import ( "fmt" "reflect" "strings" "sync" "unicode" ) // Entities with more than this many indexed properties will not be saved. const m...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package datastore import ( "errors" "fmt" "reflect" "appengine" "appengine_internal" "github.com/golang/protobuf/proto" pb "appengine_internal/datastor...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package datastore provides a client for App Engine's datastore service. Basic Operations Entities are the unit of storage and are associated with a key. A ...
Go
// Copyright 2014 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package search import ( "fmt" "reflect" ) // Field is a name/value pair. A search index's document can be loaded and // saved as a sequence of Fields. type F...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package search provides a client for App Engine's search service. Indexes contains documents, and a document's contents are a mapping from case- sensitive fi...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package file import ( "errors" "fmt" "io" "os" "sync" "appengine" blobpb "appengine_internal/blobstore" filepb "appengine_internal/files" "github.com/...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package file import ( "bufio" "errors" "fmt" "io" "strings" "appengine" pb "appengine_internal/files" "github.com/golang/protobuf/proto" ) const write...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package file provides a client for Google Cloud Storage. // // NOTE: The Files API was deprecated on June 11, 2013 (v1.8.1) and will // be shut down soon, at ...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package user import ( "appengine" pb "appengine_internal/user" ) // CurrentOAuth returns the user associated with the OAuth consumer making this // request....
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package user provides a client for App Engine's user authentication service. package user import ( "strings" "appengine" "appengine_internal" "github.co...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package user import ( "net/http" "appengine" ) const ( hEmail = "X-AppEngine-User-Email" hFederatedIdentity = "X-AppEngine-User-Federated-Iden...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package taskqueue provides a client for App Engine's taskqueue service. Using this service, applications may perform work outside a user's request. A Task ma...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package appengine provides basic functionality for Google App Engine. // // For more information on how to write Go apps for Google App Engine, see: // https:...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package capability exposes information about outages and scheduled downtime for specific API capabilities. Example: if !capability.Enabled(c, "datastore_v3"...
Go
// Copyright 2013 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package cloudsql exposes access to Google Cloud SQL databases. This package is intended for MySQL drivers to make App Engine-specific connections. Applicati...
Go
// Copyright 2013 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package cloudsql import ( "errors" "net" ) func connect(instance string) (net.Conn, error) { return nil, errors.New("cloudsql: not supported in dev yet") }
Go
/* Package module provides functions for interacting with modules. The appengine package contains functions that report the identity of the app, including the module name. */ package module import ( "appengine" pb "appengine_internal/modules" "github.com/golang/protobuf/proto" ) // List returns the names of modul...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package remote_api implements the /_ah/remote_api endpoint. This endpoint is used by offline tools such as the bulk loader. */ package remote_api import ( "...
Go
package remote_api // This file provides the client for connecting remotely to a user's production // application. import ( "bytes" "fmt" "io/ioutil" "log" "math/rand" "net/http" "net/url" "regexp" "strconv" "strings" "time" "appengine" "appengine_internal" pb "appengine_internal/remote_api" "github.c...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package appengine import ( "strings" "time" "appengine_internal" pb "appengine_internal/app_identity" modpb "appengine_internal/modules" ) // AppID retur...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package delay provides a way to execute code outside the scope of a user request by using the taskqueue API. To declare a function that may be executed later...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package memcache provides a client for App Engine's distributed in-memory // key-value store for small chunks of arbitrary data. // // The fundamental operati...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // This file provides error functions for common API failure modes. package appengine import ( "fmt" "appengine_internal" ) // IsOverQuota reports whether ...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package appengine import ( "fmt" "regexp" "appengine_internal" basepb "appengine_internal/base" "github.com/golang/protobuf/proto" ) // Namespace returns...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package mail provides the means of sending email from an App Engine application. Example: msg := &mail.Message{ Sender: "romeo@montague.com", To: ...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package xmpp provides the means to send and receive instant messages to and from users of XMPP-compatible services. To send a message, m := &xmpp.Message{ ...
Go
package aetest import ( "bufio" "crypto/rand" "errors" "fmt" "io" "io/ioutil" "net/http" "os" "os/exec" "path/filepath" "regexp" "time" "appengine_internal" ) // Instance represents a running instance of the development API Server. type Instance interface { // Close kills the child api_server.py proces...
Go
package aetest import ( "hash/crc32" "net/http" "strconv" "appengine/user" ) // Login causes the provided Request to act as though issued by the given user. func Login(u *user.User, req *http.Request) { req.Header.Set("X-AppEngine-User-Email", u.Email) id := u.ID if id == "" { id = strconv.Itoa(int(crc32.Ch...
Go
// Copyright 2013 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package aetest provides an appengine.Context for use in tests. An example test file: package foo_test import ( "testing" "appengine/memcache" "app...
Go
// Copyright 2013 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package appengine import ( "time" "appengine_internal" ) // IsTimeoutError reports whether err is a timeout error. func IsTimeoutError(err error) bool { if...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package log provides the means of querying an application's logs from within an App Engine application. Example: c := appengine.NewContext(r) query := &log...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package urlfetch provides an http.RoundTripper implementation // for fetching URLs via App Engine's urlfetch service. package urlfetch import ( "errors" "f...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package runtime exposes information about the resource usage of the application. It also provides a way to run code in a new background context of a module. *...
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package image provides image services. package image import ( "fmt" "net/url" "appengine" "appengine_internal" pb "appengine_internal/image" ) type Se...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package channel implements the server side of App Engine's Channel API. Create creates a new channel associated with the given clientID, which must be unique...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package blobstore provides a client for App Engine's persistent blob // storage service. // // NOTE: The Files API was deprecated on June 11, 2013 (v1.8.1) an...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package main import ( "go/ast" ) var blobstoreUploadOptionsFix = fix{ "blobstore_upload_options", "2011-09-15", blobstoreUploadOptions, "Add an options ar...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package main import ( "go/ast" ) var taskqueueFix = fix{ "taskqueue", "2011-09-15", taskqueue, `Update the names of appengine/taskqueue functions.`, } fu...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package main import ( "go/ast" ) var datastoreTransactionOptionsFix = fix{ "datastore_transaction_options", "2011-09-22", datastoreTransactionOptions, "Ad...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package main import ( "go/ast" ) var datastoreKeyFix = fix{ "datastore_key", "2011-09-15", datastoreKey, `Add an appengine.Context argument to datastore.N...
Go
// To be placed in the output Go repo at cmd/go. package main import ( "errors" "fmt" "go/build" "os" "os/exec" "os/signal" "path/filepath" "strconv" "strings" ) var cmdServe = &Command{ UsageLine: "serve [serve flags] [application_dir | package | yaml_files...]", Short: "starts a local development Ap...
Go
// To be placed in the output Go repo at cmd/go. package main import ( "path/filepath" ) var cmdDeploy = &Command{ UsageLine: "deploy [deploy flags] [ application_dir | package | yaml_files...]", Short: "deploys your application to App Engine", Long: ` Deploy uploads your application files to Google App Engi...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package appengine_internal provides support for package appengine. // // Programs should not use this package directly. Its API is not stable. // Use packages...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package appengine_internal import ( "bytes" "encoding/base64" "fmt" "io" "io/ioutil" "log" "net" "net/http" "os" "strings" "sync" "sync/atomic" "ti...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package appengine_internal // These functions are implementations of the wrapper functions // in ../appengine/identity.go. See that file for commentary. func A...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package appengine_internal import ( "log" "net/http" "strconv" "strings" "github.com/golang/protobuf/proto" pb "appengine_internal/modules" ) // These ...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package appengine_internal import ( "strings" ) func parseFullAppID(appid string) (partition, domain, displayID string) { if i := strings.Index(appid, "~"); ...
Go
package appengine_internal // This file implements hooks for applying datastore transactions. import ( "reflect" pb "appengine_internal/datastore" ) var transactionSetters = make(map[reflect.Type]reflect.Value) // RegisterTransactionSetter registers a function that sets transaction information // in a protocol b...
Go
// Copyright 2013 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* Package init provides initialization that must happen before any App Engine user code runs. It is imported in apps built by go-appengine-builder. */ package i...
Go
// Copyright 2013 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package init import "os" func init() { os.DisableWritesForAppEngine = true }
Go
// Copyright 2012 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package main import ( "strings" ) func parseToolFlags(s string) []string { // Manual split to handle backslash escaped commas. // This doesn't need to be pa...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package main import ( "bytes" "text/template" ) // MakeMain creates the synthetic main package for a Go App Engine app. func MakeMain(app *App) (string, erro...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package main import ( "bytes" "errors" "fmt" "go/ast" "go/build" "go/parser" "go/scanner" "go/token" "io/ioutil" "log" "math/rand" "os" "path/filep...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. /* go-app-builder is a program that builds Go App Engine apps. It takes a list of source file names, loads and parses them, deduces their package structure, cre...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package counter import ( "fmt" "io" "net/http" "strconv" "appengine" "appengine/memcache" ) func serveError(c appengine.Context, w http.ResponseWriter, ...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package guestbook import ( "html/template" "net/http" "time" "appengine" "appengine/datastore" "appengine/user" ) type Greeting struct { Author string...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package id import ( "fmt" "net/http" "os" "appengine" ) func init() { http.HandleFunc("/id", handleID) } func handleID(w http.ResponseWriter, r *http.Re...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package memcache implements a simple memcache-alike. package memcache import ( "io" "net/http" "strconv" "sync" "appengine" ) func init() { http.Hand...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. // Package frontend implements a frontend to the example memcache module. // TODO: Demonstrate sharding across multiple instances. package frontend import ( "f...
Go
package main // Simple tool which lists the entity kinds, and a sample for each, for an // app engine app. // // This tool can be invoked using the goapp tool bundled with the SDK. // $ goapp run demos/remote_api/datastore_info.go \ // -email admin@example.com \ // -host my-app.appspot.com \ // -password_file ~/...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package later import ( "fmt" "net/http" "appengine" "appengine/delay" ) func init() { http.HandleFunc("/", handle) } func handle(w http.ResponseWriter, ...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package transaction // This app demonstrates the datastore transaction API. // // A bank account is initialized with 4 million dollars, and 10 concurrent // wit...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package logviewer import ( "encoding/base64" "errors" "html/template" "net/http" "strconv" "strings" "appengine" "appengine/log" ) // appLevel holds d...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package mandelbrot import ( "bytes" "encoding/json" "fmt" "html/template" "image" "image/color" "image/png" "net/http" "strconv" "time" "appengine" ...
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" ) // Resize returns a scaled copy of the image slice r of m. // The returned image has width w and height h. f...
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. // On App Engine, the framework sets up main; we should be a different package. package moustachio import ( "bytes" "crypto/sha1" "fmt" "html/template" "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. package moustachio import ( "image" "image/color" "image/draw" "code.google.com/p/freetype-go/freetype/raster" ) // moustache draws a moustache of the sp...
Go
// Copyright 2011 Google Inc. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package helloworld import ( "fmt" "net/http" ) func init() { http.HandleFunc("/", handle) } func handle(w http.ResponseWriter, r *http.Request) { fmt.Fpri...
Go
/* * jQuery File Upload Plugin GAE Go Example 3.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/ima...
Go
package main type Version struct { value []int }
Go
package main import ( "fmt" ) // main entry point func main() { packages := make([]*Package, 0, 100) packageVersions := make([]*PackageVersion, 0, 100) p := new(Package) p.title = "Test package" p.name = "test" packages = append(packages, p) pv := new(PackageVersion) pv.Package = p.name ...
Go
package main // a package like "Go Lite IDE" type Package struct { name string title string } func (p Package) String() string { return p.title + " (" + p.name + ")" }
Go
package main import "fmt" type PackageVersion struct { Package string Version Version } func (p PackageVersion) String() string { return fmt.Sprintf("%v %v", p.Package, p.Version) }
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. // Compute Fibonacci numbers with two goroutines // that pass integers back and forth. No actual // concurrency, just threads and synchronization // and forei...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* A trivial example of wrapping a C library in Go. For a more complex example and explanation, see ../gmp/gmp.go. */ package stdio // TODO(rsc): Remove fflu...
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 main import "stdio" func main() { // stdio.Stdout.WriteString("hello, world\n"); stdio.Puts("hello, world") }
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. // Pass numbers along a chain of threads. package main import ( "runtime"; "stdio"; "strconv"; ) const N = 10 const R = 5 func link(left chan<- int, rig...
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. // Compute Fibonacci numbers with two goroutines // that pass integers back and forth. No actual // concurrency, just threads and synchronization // and forei...
Go
/* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form ...
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. /* An example of wrapping a C library in Go. This is the GNU multiprecision library gmp's integer type mpz_t wrapped to look like the Go package big's integer ...
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. // The expvar package provides a standardized interface to public variables, // such as operation counters in servers. It exposes these variables via // HTTP at...
Go