code stringlengths 10 1.34M | language stringclasses 1
value |
|---|---|
// 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 pointer
// This file defines the internal (context-sensitive) call graph.
import (
"fmt"
"go/token"
"code.google.com/p/go.tools/go/ssa"
)
type cg... | 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 pointer implements Andersen's analysis, an inclusion-based
pointer analysis algorithm first described in (Andersen, 1994).
The implementation is si... | 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 gccgoimporter
import (
"bufio"
"os"
"os/exec"
"path/filepath"
"strings"
"code.google.com/p/go.tools/go/types"
)
// Information about a specific... | 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 gccgoimporter implements Import for gccgo-generated object files.
package gccgoimporter
import (
"debug/elf"
"fmt"
"io"
"os"
"path/filepath"
"... | 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 gccgoimporter
import (
"bytes"
"errors"
"fmt"
"go/token"
"io"
"strconv"
"strings"
"text/scanner"
"code.google.com/p/go.tools/go/exact"
"code... | Go |
package eg
import (
"fmt"
"go/ast"
"go/token"
"log"
"os"
"reflect"
"code.google.com/p/go.tools/go/exact"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/types"
)
// matchExpr reports whether pattern x matches y.
//
// If tr.allowWildcards, Idents in x that refer to parameters are
// tr... | Go |
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 dumpwave
import (
"fmt"
"os"
"log"
"time"
)
////////////////////////////////////////////////////////
//variaveis para criação do arquivo value dump chanel
var inicio time.Time
var f *os.File
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
... | Go |
package deadlock
import "fmt"
func mux(
decodeMux chan DEMU,
aluMux chan ALMU,
muxRegister chan MURE) {
for{
demu :=<- decodeMux
fmt.Println("[MUX] DEMU <-- DECODE")
almu :=<-aluMux
fmt.Println("[MUX] ALMU <-- ALU")
if almu.CANCELLED == false{
switch demu.MUX_UNIT{
case ALU:
switch de... | Go |
package deadlock
import (
"fmt"
"dumpwave"
)
type DECO struct{
CP0_COMMAND, CP0_BDS uint32
}
type DERE struct{
RF_COMMAND, RS, RT, RD uint32 // Em caso de instruções do tipo Load/Store/Branch RS=BASE RD=OFFSET
}
type DEDM struct{
DMUX_COMMAND, DMUX_UNIT uint32
}
type DEMU struct{
MUX_COMMAND, MUX_UNIT uin... | Go |
package deadlock
const(
//COP0
EX_ADES = 4; //Erro de endereço de Store Exception
EX_NO = 0;
//OpCodes
SPECIAL = 0; //tipo de instruções especiais
ADD = 32;
AND = 36;
SUB = 34;
J = 2;
BEQ = 4;
LW = 35;
SW = 43;
//Register
RRS_RRT_WRD = 1;
RRS_WRT = 2;
RRS_RRT= 3;
WAIT_EXCEPTION;
ALU;
//Decode... | Go |
package deadlock
import "fmt"
func cop0(
exception chan int32,
decodeCop0 chan DECO) {
for{
code :=<- decodeCop0
fmt.Println("[COP0] ?")
fmt.Println("[COP0] Exception: ",<-exception)
fmt.Println("[COP0] DECO: ",code.CP0_COMMAND," ", code.CP0_BDS)
}
} | Go |
package deadlock
import "fmt"
import "dumpwave"
func alu(
decodeAlu chan DEAL,
dmuxAlu chan DMAL,
aluMux chan ALMU,
exception chan int32,
ls_addr chan uint32,
ls_rw chan bool,
ls_data_in chan int32,
ls_data_out chan int32,
aluPc chan uint32){
var addr_offset uint32
for{
select{
c... | Go |
package deadlock
const (
MEM_SIZE=4096
)
func RAM (
address chan uint32,
read_write chan bool,
data_in chan int32,
data_out chan int32 ) {
var (
data [MEM_SIZE]int32
v_addr uint32
write bool
)
for {
v_addr = <-address;
write = <-read_write;
if (write) {
data [v_addr%MEM_SIZE] = <-da... | Go |
package deadlock
import "fmt"
import "dumpwave"
func decode(
instruction chan uint32,
//pc_command chan int32,
decodeAlu chan DEAL,
decodeCop0 chan DECO,
decodeRegister chan DERE,
decodeDmux chan DEDM,
decodeMux chan DEMU,
decodePC chan DEPC) {
var (
OpCode uint32
rd uint32
rt uint32
... | Go |
package deadlock
import "fmt"
import "dumpwave"
const (
BYTE_0 = iota;
BYTE_1;
BYTE_2;
BYTE_3;
BYTE_01;
BYTE_23;
BYTE_012;
BYTE_123;
BYTE_ALL;
)
func Memory (
load chan int32,
pc_addr chan uint32,
instruction chan uint32,
ls_addr chan uint32,
ls_rw chan bool,
ls_data_in chan int32... | Go |
package deadlock
import "fmt"
import "dumpwave"
func pc(
//pc_command chan int32,
instruction_address chan uint32,
decodePC chan DEPC,
aluPc chan uint32) {
// var(
// vPC,
// vCoreInstAddr,
// vDecodeInstAddr,
// vMemInstAddr int32
// )
var vPC uint32
fmt.Println("[PC ] Starting Program Counte... | Go |
package deadlock
import "fmt"
import "dumpwave"
func register(
decodeRegister chan DERE,
muxRegister chan MURE,
registerDmux chan REDM) {
var (
i int32
register [32] int32
)
for i=0; i<32; i++ {
register[i] = i
}
//register[0] = 2147483648
//register[1] = 2147483648
register[0] = 5
register[8] = ... | Go |
package deadlock
import "fmt"
import "dumpwave"
func dmux(
decodeDmux chan DEDM,
registerDmux chan REDM,
dmuxAlu chan DMAL) {
for{
dedm :=<- decodeDmux
fmt.Println("[DMUX] Recebeu a instrucao")
switch dedm.DMUX_UNIT{
case ALU:
switch dedm.DMUX_COMMAND{
case RRS_RRT_WRD:
fmt.Println(... | Go |
package ygo
import "fmt"
func mux(
decodeMux chan DEMU,
aluMux chan ALMU,
muxRegister chan MURE) {
for{
demu :=<- decodeMux
fmt.Println("[MUX] DEMU <-- DECODE")
almu :=<- aluMux
fmt.Println("[MUX] ALMU <-- ALU")
if almu.CANCELLED == false{
switch demu.MUX_UNIT{
case ALU:
switch demu.M... | Go |
/****************************************************************************************
* Title: Yam
*****************************************************************************************
* File:
* Authors: Joao Leonardo Fragoso, Roger da Silva Pereira, Robim Araujo Pacheco
* Company: UERGS - Unidade Guaiba
* Cre... | Go |
// Arquivo para constantes ygo
package ygo
const(
//COP0
EX_ADES = 4; //Erro de endereço de Store Exception
EX_INTERRUPTION = 0;
//OpCodes
SPECIAL = 0; //tipo de instruções especiais
ADD = 32;
AND = 36;
SUB = 34;
ADDI = 8;
J = 2;
BEQ = 4;
LW = 35;
SW = 43;
//Register
RRS_RRT_WRD = 1;
RRS_WRT = 2;... | Go |
package ygo
import "fmt"
func cop0(
cop0Decode chan uint32,
aluCop0_exception chan int32,
decodeCop0 chan DECO,
pcCop0 chan uint32,
cop0Pc chan uint32) {
var (
epc uint32
v_exception int32
//error_pc uint32
)
// R/W bit 2 (Error Level)
status_ERL := 01
... | Go |
package ygo
import (
"fmt"
"dumpwave"
)
func alu(
decodeAlu chan DEAL,
dmuxAlu chan DMAL,
aluMux chan ALMU,
aluCop0_exception chan int32,
ls_addr chan uint32,
ls_rw chan bool,
ls_data_in chan int32,
ls_data_out chan int32,
al... | Go |
package ygo
const (
MEM_SIZE=4096
)
func RAM (
address chan uint32,
read_write chan bool,
data_in chan int32,
data_out chan int32 ) {
var (
data [MEM_SIZE]int32
v_addr uint32
write bool
)
for {
v_addr = <-address;
write = <-read_write;
if (write) {
data [v_addr%MEM_SIZE] = <-data_in... | Go |
package ygo
import (
"fmt"
"dumpwave"
)
func decode(
instruction chan uint32,
cop0Decode chan uint32,
decodeAlu chan DEAL,
decodeCop0 chan DECO,
decodeRegister chan DERE,
decodeDmux chan DEDM,
decodeMux chan DEMU,
decodePC chan DEPC,
aluDecode... | Go |
package ygo
import ( "fmt"
"dumpwave"
)
const (
BYTE_0 = iota;
BYTE_1;
BYTE_2;
BYTE_3;
BYTE_01;
BYTE_23;
BYTE_012;
BYTE_123;
BYTE_ALL;
)
func Memory (
load chan int32,
pc_addr chan uint32,
instruction chan uint32,
ls_addr chan uint32,
ls_rw chan bool,
ls_data_in chan int32,
ls... | Go |
package ygo
import ( "fmt"
"dumpwave"
)
func pc(
//pc_command chan int32,
instruction_address chan uint32,
decodePC chan DEPC,
aluPc chan uint32,
pcCop0 chan uint32,
cop0Pc chan uint32) {
// var(
// vPC,
// vCoreInstAddr,
// vDecodeInst... | Go |
package ygo
import (
"fmt"
)
func register(
decodeRegister chan DERE,
muxRegister chan MURE,
registerDmux chan REDM) {
var (
i int32
register [32] int32
)
for i=0; i<32; i++ {
register[i] = i
}
//register[0] = 2147483648
//register[1] = 2147483648
//register[0] = 5
register[8] = 12
register[... | Go |
package ygo
import ( "fmt"
"dumpwave"
)
func dmux(
decodeDmux chan DEDM,
registerDmux chan REDM,
dmuxAlu chan DMAL) {
for{
dedm :=<- decodeDmux
switch dedm.DMUX_UNIT{
case ALU:
switch dedm.DMUX_COMMAND{
case RRS_RRT_WRD:
fmt.Println("[DMUX] DEDM <-- DECODE (unit: ALU, cmd: RRS_RRT_WR... | Go |
package minimips
import (
"fmt"
"dumpwave"
"os"
// "time"
// "log"
)
type DEEX struct {
op,function,offset uint
rs,rt int
}
type EXDM struct {
addr int
read_write uint
}
const (
datainiciatial = "$timescale 1ns $end\n"+
"$scope module yam $end\n"+
"$var wire 1 decodeExecuteRA 01#D... | Go |
package minimips
import (
"fmt"
"dumpwave"
// "testbanch"
// "os"
// "log"
)
func imem(
instructions chan []uint32,
imem_address chan uint,
imem_data chan uint){
// memory := (testbanch.Instrutions())
memory :=<- instructions
fmt.Println(memory)
// memory := [] uint {
// 0x8c220000, //L: lw r2,0... | Go |
package minimips
import (
"fmt"
"dumpwave"
)
func decode(
decode_instr chan uint,
decodeExecute chan DEEX,
execute_rd chan int,
dmem_datain chan int,
dmem_dataout chan int,
end chan int) {
var register = [] int {
0x0000000,
0x0000000,
0x0000000,
0x0000000,
0x0000000,
0x0000000,
... | Go |
package minimips
import (
"fmt"
"dumpwave"
)
func fetch(
branch_decision chan uint,
decode_instr chan uint,
imem_address chan uint,
imem_data chan uint) {
var instr uint
var PC, branch_d, branch_offset uint = 0, 0, 0
for {
fmt.Println("[fetch] PC --> IMEM:",PC)
dumpwave.Wave(1,"imem_addressRA")
dum... | Go |
package minimips
import (
"fmt"
"dumpwave"
// "time"
)
func execute(
decodeExecute chan DEEX,
execute_rd chan int,
executeDmem chan EXDM,
branch_decision chan uint) {
addr_offset:=uint(0)
for{
deex :=<- decodeExecute
fmt.Printf("[execute] DEEX <-- DECODE: (op: 0x%x | function: 0x%x | rs: 0x%x | rt: 0x%x... | Go |
package minimips
import (
"fmt"
"dumpwave"
)
func dmem(
executeDmemo chan EXDM,
data_in chan int,
data_out chan int) {
/*var dmem = [] int {
0x00000000,
0x11111111,
0x22222222,
0x33333333,
0x44444444,
0x55555555,
0x66666666,
0x77777777}*/
var dmem = [] int {
0x00000000,
0x00000000... | Go |
package main
import (
// "fmt"
"os"
"log"
"io"
"minimips"
)
func Instructions ()([]uint32){
instr := make([]uint32,100)
data := make([]byte, 4)
count := 4;
var err error;
file, err := os.Open("spim.dump")
if err != nil {
log.Fatal(err)
}
for i:=0;count!=0;i++ {
count, err = file.Read(data)
if err ... | Go |
// teste do yam com a instrução AND
package main
import (
"ygo"
"fmt"
)
func main() {
load := make(chan int32)
instruction_address := make(chan uint32)
instruction := make(chan uint32)
end := make(chan uint32)
ls_addr := make(chan uint32)
ls_rw := make(chan bool)
ls_data_in := make(chan int32)
ls_data... | Go |
// teste do yam com a instrução SUB
package main
import (
"ygo"
"fmt"
)
func main() {
load := make(chan int32)
instruction_address := make(chan uint32)
instruction := make(chan uint32)
end := make(chan uint32)
ls_addr := make(chan uint32)
ls_rw := make(chan bool)
ls_data_in := make(chan int32)
ls_data... | Go |
// teste do yam com a instrução BEQ
package main
import (
"ygo"
"fmt"
)
func main() {
load := make(chan int32)
instruction_address := make(chan uint32)
instruction := make(chan uint32)
end := make(chan int32)
ls_addr := make(chan uint32)
ls_rw := make(chan bool)
ls_data_in := make(chan int32)
ls_data_o... | Go |
// teste do yam com a instrução LW
package main
import (
"ygo"
"fmt"
)
func main() {
load := make(chan int32)
instruction_address := make(chan uint32)
instruction := make(chan uint32)//, 2)
end := make(chan uint32)
ls_addr := make(chan uint32)
ls_rw := make(chan bool)
ls_data_in := make(chan int32)
ls... | Go |
/****************************************************************************************
* Title: TESTE YAM-MEMORY
*****************************************************************************************
* File: tb_add2.go
* Authors: Joao Leonardo Fragoso, Luciana Mendes, Gisell Moura
* Company: UERGS - Unidade Guaib... | Go |
// teste do yam com a instrução ADD
package main
import (
"ygo"
"fmt"
)
func main() {
load := make(chan int32)
instruction_address := make(chan uint32)
instruction := make(chan uint32)
end := make(chan int32)
ls_addr := make(chan uint32)
ls_rw := make(chan bool)
ls_data_in := make(chan int32)
ls_data_o... | Go |
// teste do yam com a instrução LW
package main
import (
"ygo"
"fmt"
)
func main() {
load := make(chan int32)
instruction_address := make(chan uint32)
instruction := make(chan uint32)//, 2)
end := make(chan uint32)
ls_addr := make(chan uint32)
ls_rw := make(chan bool)
ls_data_in := make(chan int32)
ls_... | Go |
package main
import (
ygo
)
func main(){
/* var unit_mux = make (chan int)
var cmd_mux = make (chan int)
var exec_to_reg = make (chan int)
var cancelled_in = make (chan bool)
var mdu_to_reg = make (chan int)
var pc_address = make (chan int)
var cp0_to_reg = make (chan int)
var cp0_canc... | Go |
package main
import (
"os"
"io"
"bufio"
"bytes"
"fmt"
"strconv"
"ygo"
)
//import "memory"
func readLines(path string) (lines []string, err error) {
var (
file *os.File
part []byte
prefix bool
)
if file, err = os.Open(path); err != nil {
return
... | Go |
/*
This is a little test app that demonstrates how goweb
is to be used in a real application.
INSTALL GOWEB
=============
You may need to install 'goweb' in order to import it here.
To do this navigate to the 'goweb/goweb' directory in a terminal
and type:
gomake install
This should put a copy of gowe... | Go |
package goweb
import (
"regexp"
"strings"
)
/*
Route
*/
// Represents a single route mapping
type Route struct {
pattern string
parameterKeys ParameterKeyMap
extension string
Path string
Controller Controller
MatcherFuncs []RouteMatcherFunc
}
func (r *Route) String() string {
return... | Go |
package goweb
/*
Constants
*/
// Regex placeholder pattern
var ROUTE_REGEX_PLACEHOLDER string = "(.*)"
// HTTP Methods
const GET_HTTP_METHOD string = "GET"
const POST_HTTP_METHOD string = "POST"
const PUT_HTTP_METHOD string = "PUT"
const DELETE_HTTP_METHOD string = "DELETE"
/*
Error messages
*/
const ERR_STANDARD... | Go |
package goweb
// Handler method to read an item by the specified ID
type RestReader interface {
Read(id string, c *Context)
}
// Handler method to read many items
type RestManyReader interface {
ReadMany(c *Context)
}
// Handler method to update a single item specified by the ID
type RestUpdater interface {
Updat... | Go |
package goweb
/*
RouteManager
*/
// Manages routes and matching
type RouteManager struct {
routes []*Route
}
// Creates a route that maps the specified path to the specified controller
// along with any optional RouteMatcherFunc modifiers
func (manager *RouteManager) Map(path string, controller Controller, matcher... | Go |
package goweb
// Represents the return value for RouteMatcher functions
type RouteMatcherFuncValue int
// Functions used to decide whether a route matches a request or not
type RouteMatcherFunc func(c *Context) RouteMatcherFuncValue
// Indicates that the RouteMatcherFunc doesn't care whether the
// route is a Match ... | Go |
package goweb
import (
"http"
"strings"
)
// Constant string for HTML format
const HTML_FORMAT string = "HTML"
// Constant string for XML format
const XML_FORMAT string = "XML"
// Constant string for JSON format
const JSON_FORMAT string = "JSON"
// The fallback format if one cannot be determined by the request
c... | Go |
package goweb
// Holds parameter keys and actual values
type ParameterValueMap map[string]string
| Go |
package goweb
import (
"fmt"
"json"
"io/ioutil"
"os"
"xml"
"strings"
)
// types that impliment RequestDecoder can unmarshal
// the request body into an apropriate type/struct
type RequestDecoder interface {
Unmarshal(cx *Context, v interface{}) os.Error
}
// a JSON decoder for request body (just a wrapper to ... | Go |
package goweb
import "http"
// The standard API response object
type standardResponse struct {
// The context of the request that initiated this response
C string
// The HTTP Status code of this response
S int
// The data (if any) for this response
D interface{}
// A list of any errors that occurred while ... | Go |
package goweb
import (
"runtime/debug"
"log"
"strings"
"fmt"
"http"
)
// Wraps a controllerFunc to catch any panics, log them and
// respond with an appropriate error
func safeControllerFunc(controllerFunc func(*Context)) func(*Context) {
return func(cx *Context) {
defer func() {
if err := recover(); err !... | Go |
package goweb
import "strings"
/*
Path parsing
*/
// Tests whether a path segment is dynamic or not
func isDynamicSegment(segment string) bool {
return strings.HasPrefix(segment, "{") && strings.HasSuffix(segment, "}")
}
func isExtensionSegment(segment string) bool {
return strings.HasPrefix(segment, ".")
}
// ... | Go |
package goweb
import (
"http"
"os"
"strings"
)
// Object holding details about the request and responses
type Context struct {
// The underlying http.Request for this context
Request *http.Request
// The underlying http.ResponseWriter for this context
ResponseWriter http.ResponseWriter
// A ParameterValueM... | Go |
package goweb
// Interface for controller types that handle requests
type Controller interface {
// When implemented, handles the request
HandleRequest(c *Context)
}
// The ControllerFunc type is an adapter to allow the use of
// ordinary functions as goweb handlers. If f is a function
// with the appropriate sig... | Go |
package goweb
import (
"http"
"os"
"strings"
)
// A handler type to handle actual http requests using the
// DefaultRouteManager to route requests to the right places
type HttpHandler struct{}
// Serves the HTTP request and writes the response to the specified writer
func (handler *HttpHandler) ServeHTTP(response... | Go |
package goweb
import (
"os"
"json"
)
// Interface describing an object responsible for
// handling transformed/formatted response data
type Formatter interface {
// method to transform response
Format(context *Context, input interface{}) ([]uint8, os.Error)
// method that decides if this formatter will be used
... | Go |
package goweb
import (
"os"
"reflect"
"strconv"
"url"
"fmt"
)
// Fill a struct `v` from the values in `form`
func UnmarshalForm(form url.Values, v interface{}) os.Error {
// check v is valid
rv := reflect.ValueOf(v).Elem()
// dereference pointer
if rv.Kind() == reflect.Ptr {
rv = rv.Elem()
}
// get type
... | Go |
package goweb
// Holds parameter keys and their respective positions in the path
type ParameterKeyMap map[string]int
| Go |
package goweb
import (
"regexp"
"strings"
)
/*
Route
*/
// Represents a single route mapping
type Route struct {
pattern string
parameterKeys ParameterKeyMap
extension string
Path string
Controller Controller
MatcherFuncs []RouteMatcherFunc
}
func (r *Route) String() string {
return... | Go |
package goweb
/*
Constants
*/
// Regex placeholder pattern
var ROUTE_REGEX_PLACEHOLDER string = "(.*)"
// HTTP Methods
const GET_HTTP_METHOD string = "GET"
const POST_HTTP_METHOD string = "POST"
const PUT_HTTP_METHOD string = "PUT"
const DELETE_HTTP_METHOD string = "DELETE"
/*
Error messages
*/
const ERR_STANDARD... | Go |
package goweb
// Handler method to read an item by the specified ID
type RestReader interface {
Read(id string, c *Context)
}
// Handler method to read many items
type RestManyReader interface {
ReadMany(c *Context)
}
// Handler method to update a single item specified by the ID
type RestUpdater interface {
Updat... | Go |
package goweb
/*
RouteManager
*/
// Manages routes and matching
type RouteManager struct {
routes []*Route
}
// Creates a route that maps the specified path to the specified controller
// along with any optional RouteMatcherFunc modifiers
func (manager *RouteManager) Map(path string, controller Controller, matcher... | Go |
package goweb
// Represents the return value for RouteMatcher functions
type RouteMatcherFuncValue int
// Functions used to decide whether a route matches a request or not
type RouteMatcherFunc func(c *Context) RouteMatcherFuncValue
// Indicates that the RouteMatcherFunc doesn't care whether the
// route is a Match ... | Go |
package goweb
import (
"http"
"strings"
)
// Constant string for HTML format
const HTML_FORMAT string = "HTML"
// Constant string for XML format
const XML_FORMAT string = "XML"
// Constant string for JSON format
const JSON_FORMAT string = "JSON"
// The fallback format if one cannot be determined by the request
c... | Go |
package goweb
// Holds parameter keys and actual values
type ParameterValueMap map[string]string
| Go |
package goweb
import (
"fmt"
"json"
"io/ioutil"
"os"
"xml"
"strings"
)
// types that impliment RequestDecoder can unmarshal
// the request body into an apropriate type/struct
type RequestDecoder interface {
Unmarshal(cx *Context, v interface{}) os.Error
}
// a JSON decoder for request body (just a wrapper to ... | Go |
package goweb
import "http"
// The standard API response object
type standardResponse struct {
// The context of the request that initiated this response
C string
// The HTTP Status code of this response
S int
// The data (if any) for this response
D interface{}
// A list of any errors that occurred while ... | Go |
package goweb
import (
"runtime/debug"
"log"
"strings"
"fmt"
"http"
)
// Wraps a controllerFunc to catch any panics, log them and
// respond with an appropriate error
func safeControllerFunc(controllerFunc func(*Context)) func(*Context) {
return func(cx *Context) {
defer func() {
if err := recover(); err !... | Go |
package goweb
import "strings"
/*
Path parsing
*/
// Tests whether a path segment is dynamic or not
func isDynamicSegment(segment string) bool {
return strings.HasPrefix(segment, "{") && strings.HasSuffix(segment, "}")
}
func isExtensionSegment(segment string) bool {
return strings.HasPrefix(segment, ".")
}
// ... | Go |
package goweb
import (
"http"
"os"
"strings"
)
// Object holding details about the request and responses
type Context struct {
// The underlying http.Request for this context
Request *http.Request
// The underlying http.ResponseWriter for this context
ResponseWriter http.ResponseWriter
// A ParameterValueM... | Go |
package goweb
// Interface for controller types that handle requests
type Controller interface {
// When implemented, handles the request
HandleRequest(c *Context)
}
// The ControllerFunc type is an adapter to allow the use of
// ordinary functions as goweb handlers. If f is a function
// with the appropriate sig... | Go |
package goweb
import (
"http"
"os"
"strings"
)
// A handler type to handle actual http requests using the
// DefaultRouteManager to route requests to the right places
type HttpHandler struct{}
// Serves the HTTP request and writes the response to the specified writer
func (handler *HttpHandler) ServeHTTP(response... | Go |
package goweb
import (
"os"
"json"
)
// Interface describing an object responsible for
// handling transformed/formatted response data
type Formatter interface {
// method to transform response
Format(context *Context, input interface{}) ([]uint8, os.Error)
// method that decides if this formatter will be used
... | Go |
package goweb
import (
"os"
"reflect"
"strconv"
"url"
"fmt"
)
// Fill a struct `v` from the values in `form`
func UnmarshalForm(form url.Values, v interface{}) os.Error {
// check v is valid
rv := reflect.ValueOf(v).Elem()
// dereference pointer
if rv.Kind() == reflect.Ptr {
rv = rv.Elem()
}
// get type
... | Go |
package goweb
// Holds parameter keys and their respective positions in the path
type ParameterKeyMap map[string]int
| Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
/*
Copyright 2012, Google Inc.
All rights reserved.
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 disc... | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.