├── .godir ├── .gitignore ├── Procfile ├── examples ├── https-servers │ ├── .gitignore │ ├── https-servers.sh │ └── https-servers.go ├── recursion │ ├── recursion.sh │ └── recursion.go ├── short-declarations │ ├── short-declarations.sh │ └── short-declarations.go ├── channel-directions │ ├── channel-directions.sh │ └── channel-directions.go ├── variables │ ├── variables.sh │ └── variables.go ├── channel-buffering │ ├── channel-buffering.sh │ └── channel-buffering.go ├── switch │ ├── switch.sh │ └── switch.go ├── constants │ ├── constants.sh │ └── constants.go ├── range │ ├── range.sh │ └── range.go ├── structs │ ├── structs.sh │ └── structs.go ├── values │ ├── values.sh │ └── values.go ├── closures │ ├── closures.sh │ └── closures.go ├── graceful-shutdown │ └── graceful-shutdown.sh ├── canonical-hosts │ ├── canonical-hosts.sh │ └── canonical-hosts.go ├── defer │ ├── defer.sh │ └── defer.go ├── request-routing │ ├── request-routing.sh │ └── request-routing.go ├── collection-functions │ └── collection-functions.sh ├── non-blocking-channel-operations │ ├── non-blocking-channel-operations.sh │ └── non-blocking-channel-operations.go ├── redis │ └── redis.sh ├── responses │ ├── responses.sh │ └── responses.go ├── functions │ ├── functions.sh │ └── functions.go ├── static-content │ ├── static-content.sh │ └── static-content.go ├── methods │ ├── methods.sh │ └── methods.go ├── for │ ├── for.sh │ └── for.go ├── sorting │ ├── sorting.sh │ └── sorting.go ├── multiple-return-values │ ├── multiple-return-values.sh │ └── multiple-return-values.go ├── timers │ ├── timers.sh │ └── timers.go ├── number-parsing │ ├── number-parsing.sh │ └── number-parsing.go ├── atomic-counters │ ├── atomic-counters.sh │ └── atomic-counters.go ├── range-over-channels │ ├── range-over-channels.sh │ └── range-over-channels.go ├── variadic-functions │ ├── variadic-functions.sh │ └── variadic-functions.go ├── hello-world │ ├── hello-world.go │ └── hello-world.sh ├── maps │ ├── maps.sh │ └── maps.go ├── if-else │ ├── if-else.sh │ └── if-else.go ├── pointers │ ├── pointers.sh │ └── pointers.go ├── channel-synchronization │ ├── channel-synchronization.sh │ └── channel-synchronization.go ├── middleware │ ├── middleware.sh │ └── middleware.go ├── reading-files │ └── reading-files.sh ├── tickers │ ├── tickers.sh │ └── tickers.go ├── url-parsing │ └── url-parsing.sh ├── interfaces │ ├── interfaces.sh │ └── interfaces.go ├── epoch │ ├── epoch.sh │ └── epoch.go ├── line-filters │ └── line-filters.sh ├── select │ ├── select.sh │ └── select.go ├── random-numbers │ ├── random-numbers.sh │ └── random-numbers.go ├── closing-channels │ ├── closing-channels.sh │ └── closing-channels.go ├── errors │ └── errors.sh ├── signals │ ├── signals.sh │ └── signals.go ├── hello-web │ └── hello-web.go ├── mutexes │ └── mutexes.sh ├── postgres │ └── postgres.sh ├── string-functions │ ├── string-functions.sh │ └── string-functions.go ├── arrays │ ├── arrays.sh │ └── arrays.go ├── base64-encoding │ ├── base64-encoding.sh │ └── base64-encoding.go ├── exit │ ├── exit.sh │ └── exit.go ├── http-client │ └── http-client.go ├── time-formatting-parsing │ └── time-formatting-parsing.sh ├── command-line-arguments │ ├── command-line-arguments.sh │ └── command-line-arguments.go ├── regular-expressions │ └── regular-expressions.sh ├── channels │ ├── channels.sh │ └── channels.go ├── string-formatting │ └── string-formatting.sh ├── writing-files │ ├── writing-files.sh │ └── writing-files.go ├── sorting-by-functions │ ├── sorting-by-functions.sh │ └── sorting-by-functions.go ├── spawning-processes │ └── spawning-processes.sh ├── timeouts │ ├── timeouts.sh │ └── timeouts.go ├── panic │ ├── panic.sh │ └── panic.go ├── execing-processes │ ├── execing-processes.sh │ └── execing-processes.go ├── goroutines │ ├── goroutines.sh │ └── goroutines.go ├── time │ └── time.sh ├── https-client │ └── https-client.go ├── environment-variables │ ├── environment-variables.sh │ └── environment-variables.go ├── json │ └── json.sh ├── sha1-hashes │ ├── sha1-hashes.sh │ └── sha1-hashes.go ├── worker-pools │ ├── worker-pools.sh │ └── worker-pools.go ├── stateful-goroutines │ └── stateful-goroutines.sh ├── slices │ └── slices.sh ├── streaming-http-servers │ └── streaming-http-servers.go ├── rate-limiting │ └── rate-limiting.sh ├── request-logging │ └── request-logging.go └── basic-authentication │ └── basic-authentication.go ├── .env ├── vendor └── pygments │ ├── tests │ ├── examplefiles │ │ ├── function.mu │ │ ├── html+php_faulty.php │ │ ├── py3_test.txt │ │ ├── antlr_throws │ │ ├── matlab_noreturn │ │ ├── ragel-cpp_snippet │ │ ├── stripheredoc.sh │ │ ├── escape_semicolon.clj │ │ ├── example.rpf │ │ ├── foo.sce │ │ ├── webkit-transition.css │ │ ├── badcase.java │ │ ├── import.hs │ │ ├── example.cpp │ │ ├── example.pas │ │ ├── as3_test3.as │ │ ├── example.xhtml │ │ ├── example.xtend │ │ ├── AlternatingGroup.mu │ │ ├── unicode.applescript │ │ ├── test.ini │ │ ├── minimal.ns2 │ │ ├── irb_heredoc │ │ ├── ints.php │ │ ├── hello.sp │ │ ├── unicodedoc.py │ │ ├── glsl.frag │ │ ├── pytb_test2.pytb │ │ ├── erl_session │ │ ├── java.properties │ │ ├── test.scaml │ │ ├── example.gst │ │ ├── pycon_test.pycon │ │ ├── ruby_func_def.rb │ │ ├── numbers.c │ │ ├── test.ssp │ │ ├── while.pov │ │ ├── sphere.pov │ │ ├── glsl.vert │ │ ├── cheetah_example.html │ │ ├── flipflop.sv │ │ ├── pppoe.applescript │ │ ├── regex.js │ │ ├── example.cls │ │ ├── Errors.scala │ │ ├── example.sh-session │ │ ├── qsort.prolog │ │ ├── example.snobol │ │ ├── sibling.prolog │ │ ├── matlabsession_sample.txt │ │ ├── objc_example.m │ │ ├── genshitext_example.genshitext │ │ ├── example.tea │ │ ├── intro.ik │ │ ├── objc_example2.m │ │ ├── lighttpd_config.conf │ │ ├── linecontinuation.py │ │ ├── multiline_regexes.rb │ │ ├── http_request_example │ │ ├── string_delimiters.d │ │ ├── matlab_sample │ │ ├── test.dart │ │ ├── nasm_objexe.asm │ │ ├── test.gdc │ │ ├── aspx-cs_example │ │ ├── example.p │ │ ├── test.jsp │ │ ├── sqlite3.sqlite3-console │ │ ├── example2.aspx │ │ ├── addressbook.proto │ │ ├── example.weechatlog │ │ ├── condensed_ruby.rb │ │ ├── test.xsl │ │ ├── demo.cfm │ │ ├── dwarf.cw │ │ ├── test.cu │ │ ├── test.bas │ │ ├── truncated.pytb │ │ ├── jbst_example1.jbst │ │ ├── scilab.sci │ │ ├── example.ceylon │ │ ├── postgresql_test.txt │ │ ├── database.pytb │ │ ├── test.evoque │ │ ├── r-console-transcript.Rout │ │ ├── squid.conf │ │ ├── example.moo │ │ ├── livescript-demo.ls │ │ ├── test.rhtml │ │ ├── example.kt │ │ ├── test.css │ │ ├── test.flx │ │ ├── batchfile.bat │ │ ├── classes.dylan │ │ ├── evil_regex.js │ │ ├── example.msc │ │ ├── test.boo │ │ ├── example.ns2 │ │ ├── perl_misc │ │ ├── example.rkt │ │ ├── jbst_example2.jbst │ │ ├── example.jag │ │ ├── as3_test2.as │ │ └── test.maql │ ├── support.py │ ├── dtds │ │ ├── HTML4.soc │ │ └── HTML4-f.dtd │ ├── test_clexer.py │ ├── test_using_api.py │ ├── run.py │ ├── test_regexlexer.py │ ├── test_token.py │ └── test_latex_formatter.py │ ├── docs │ └── src │ │ ├── authors.txt │ │ ├── changelog.txt │ │ ├── rstdirective.txt │ │ ├── integrate.txt │ │ ├── filters.txt │ │ ├── moinmoin.txt │ │ └── index.txt │ ├── setup.cfg │ ├── pygmentize │ ├── MANIFEST.in │ ├── TODO │ ├── pygments │ └── styles │ │ ├── rrt.py │ │ ├── vs.py │ │ ├── fruity.py │ │ └── bw.py │ ├── scripts │ ├── detect_missing_analyse_text.py │ └── get_vimkw.py │ ├── external │ └── pygments.bashcomp │ └── LICENSE ├── tools ├── measure ├── generate ├── build ├── gofmt ├── build-loop └── measure.go ├── public ├── favicon.ico └── 404.html ├── templates ├── favicon.ico └── 404.html └── examples.txt /.godir: -------------------------------------------------------------------------------- 1 | gobyexample 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .anvil 2 | *.pyc 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: gobyexample 2 | -------------------------------------------------------------------------------- /examples/https-servers/.gitignore: -------------------------------------------------------------------------------- 1 | server.* 2 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | CANONICAL_HOST=127.0.0.1 2 | FORCE_HTTPS=0 3 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/function.mu: -------------------------------------------------------------------------------- 1 | a::b () 2 | -------------------------------------------------------------------------------- /examples/recursion/recursion.sh: -------------------------------------------------------------------------------- 1 | $ go run recursion.go 2 | 5040 3 | -------------------------------------------------------------------------------- /tools/measure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exec go run tools/measure.go 4 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/html+php_faulty.php: -------------------------------------------------------------------------------- 1 | apple 5 | b -> banana 6 | 0 103 7 | 1 111 8 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/badcase.java: -------------------------------------------------------------------------------- 1 | // this used to take ages 2 | void foo() throws xxxxxxxxxxxxxxxxxxxxxx{ } 3 | -------------------------------------------------------------------------------- /examples/structs/structs.sh: -------------------------------------------------------------------------------- 1 | $ go run structs.go 2 | {Bob 20} 3 | {Alice 30} 4 | {Fred 0} 5 | &{Ann 40} 6 | Sean 7 | 50 8 | 51 9 | -------------------------------------------------------------------------------- /examples/values/values.sh: -------------------------------------------------------------------------------- 1 | $ go run values.go 2 | golang 3 | 1+1 = 2 4 | 7.0/3.0 = 2.3333333333333335 5 | false 6 | true 7 | false 8 | -------------------------------------------------------------------------------- /vendor/pygments/setup.cfg: -------------------------------------------------------------------------------- 1 | [egg_info] 2 | tag_build = dev 3 | tag_date = true 4 | 5 | [aliases] 6 | release = egg_info -RDb '' 7 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/import.hs: -------------------------------------------------------------------------------- 1 | import "mtl" Control.Monad.Trans 2 | 3 | main :: IO () 4 | main = putStrLn "hello world" 5 | -------------------------------------------------------------------------------- /tools/gofmt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | ls tools/*.go examples/*/*.go | xargs gofmt -tabs=false -tabwidth=4 -w=true 7 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buger/gobyexample/master/vendor/pygments/tests/examplefiles/example.cpp -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buger/gobyexample/master/vendor/pygments/tests/examplefiles/example.pas -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/as3_test3.as: -------------------------------------------------------------------------------- 1 | protected function remote(method : String, ...args : Array) : Boolean { 2 | return true; 3 | } 4 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.xhtml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buger/gobyexample/master/vendor/pygments/tests/examplefiles/example.xhtml -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.xtend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buger/gobyexample/master/vendor/pygments/tests/examplefiles/example.xtend -------------------------------------------------------------------------------- /examples/closures/closures.sh: -------------------------------------------------------------------------------- 1 | $ go run closures.go 2 | 1 3 | 2 4 | 3 5 | 1 6 | 7 | # The last feature of functions we'll look at for now is 8 | # recursion. 9 | -------------------------------------------------------------------------------- /examples/graceful-shutdown/graceful-shutdown.sh: -------------------------------------------------------------------------------- 1 | $ go build graceful-shutdown.go 2 | $ ./graceful-shutdown 3 | 4 | $ curl -i http://127.0.0.1:5000/ 5 | 6 | ^C 7 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/AlternatingGroup.mu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buger/gobyexample/master/vendor/pygments/tests/examplefiles/AlternatingGroup.mu -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/unicode.applescript: -------------------------------------------------------------------------------- 1 | set jp to "日本語" 2 | 3 | set ru to "Русский" 4 | 5 | jp & " and " & ru -- returns "日本語 and Русский" 6 | -------------------------------------------------------------------------------- /examples/canonical-hosts/canonical-hosts.sh: -------------------------------------------------------------------------------- 1 | $ go run canonical-hosts.go 2 | 3 | $ curl -i -L http://127.0.0.1:5000/go 4 | $ curl -i -L http://127.0.0.1:5000/go 5 | -------------------------------------------------------------------------------- /examples/defer/defer.sh: -------------------------------------------------------------------------------- 1 | # Running the program confirms that the file is closed 2 | # after being written. 3 | $ go run defer.go 4 | creating 5 | writing 6 | closing 7 | -------------------------------------------------------------------------------- /examples/request-routing/request-routing.sh: -------------------------------------------------------------------------------- 1 | $ go get github.com/bmizerany/pat 2 | $ go run request-routing.go 3 | 4 | $ curl -i http://127.0.0.1:5000/hello/gopher 5 | -------------------------------------------------------------------------------- /examples/collection-functions/collection-functions.sh: -------------------------------------------------------------------------------- 1 | $ go run collection-functions.go 2 | 2 3 | false 4 | true 5 | false 6 | [peach apple pear] 7 | [PEACH APPLE PEAR PLUM] 8 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.ini: -------------------------------------------------------------------------------- 1 | [section] 2 | 3 | foo = bar 4 | continued = foo 5 | baz 6 | conttwo = 7 | foo 8 | ; comment 9 | # comment 10 | 11 | -------------------------------------------------------------------------------- /examples/non-blocking-channel-operations/non-blocking-channel-operations.sh: -------------------------------------------------------------------------------- 1 | $ go run non-blocking-channel-operations.go 2 | no message received 3 | no message sent 4 | no activity 5 | -------------------------------------------------------------------------------- /examples/redis/redis.sh: -------------------------------------------------------------------------------- 1 | # Start a Redis server. 2 | $ redis-server 3 | 4 | # In another terminal, run the redis client: 5 | $ go get github.com/fzzbt/radix/redis 6 | $ go run redis.go 7 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/minimal.ns2: -------------------------------------------------------------------------------- 1 | class A = ( | a = self m. | ) ( 2 | m = (^a isNil ifTrue: [0] ifFalse: [1]) 3 | ) 4 | class B = C ( | b0 = 0. b1 = b0 + 1. | ) () 5 | -------------------------------------------------------------------------------- /examples/responses/responses.sh: -------------------------------------------------------------------------------- 1 | $ go run xx-http-server-status-code.go 2 | 3 | $ curl -i http://127.0.0.1:5000/ | grep HTTP 4 | 5 | $ curl -i http://127.0.0.1:5000/protected | grep HTTP 6 | -------------------------------------------------------------------------------- /examples/functions/functions.sh: -------------------------------------------------------------------------------- 1 | $ go run functions.go 2 | 1+2 = 3 3 | 4 | # There are several other features to Go functions. One is 5 | # multiple return values, which we'll look at next. 6 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/irb_heredoc: -------------------------------------------------------------------------------- 1 | irb(main):001:0> puts < nil 8 | irb(main):005:0> 9 | -------------------------------------------------------------------------------- /vendor/pygments/pygmentize: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys, pygments.cmdline 4 | try: 5 | sys.exit(pygments.cmdline.main(sys.argv)) 6 | except KeyboardInterrupt: 7 | sys.exit(1) 8 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/ints.php: -------------------------------------------------------------------------------- 1 | 6 | 11 | -------------------------------------------------------------------------------- /examples/static-content/static-content.sh: -------------------------------------------------------------------------------- 1 | $ go run static-content.go 2 | 3 | $ curl http://127.0.0.1:5000/ 4 | $ curl http://127.0.0.1:5000/http-server-static.go 5 | $ curl http://127.0.0.1:5000/missing 6 | -------------------------------------------------------------------------------- /examples/methods/methods.sh: -------------------------------------------------------------------------------- 1 | $ go run methods.go 2 | area: 50 3 | perim: 30 4 | area: 50 5 | perim: 30 6 | 7 | # Next we'll look at Go's mechanism for grouping and 8 | # naming related sets of methods: interfaces. 9 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/hello.sp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Single line comment 4 | /* Multi line 5 | comment */ 6 | 7 | public OnPluginStart() { 8 | PrintToServer("Hello."); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/pygments/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include pygmentize 2 | include external/* 3 | include Makefile CHANGES LICENSE AUTHORS TODO ez_setup.py 4 | recursive-include tests * 5 | recursive-include docs * 6 | recursive-include scripts * 7 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/unicodedoc.py: -------------------------------------------------------------------------------- 1 | def foo(): 2 | ur"""unicode-raw""" 3 | 4 | def bar(): 5 | u"""unicode""" 6 | 7 | def baz(): 8 | r'raw' 9 | 10 | def zap(): 11 | """docstring""" 12 | -------------------------------------------------------------------------------- /examples/for/for.sh: -------------------------------------------------------------------------------- 1 | $ go run for.go 2 | 1 3 | 2 4 | 3 5 | 7 6 | 8 7 | 9 8 | loop 9 | 10 | # We'll see some other `for` forms later when we look at 11 | # `range` statements, channels, and other data 12 | # structures. 13 | -------------------------------------------------------------------------------- /examples/sorting/sorting.sh: -------------------------------------------------------------------------------- 1 | # Running our program prints the sorted string and int 2 | # slices and `true` as the result of our `AreSorted` test. 3 | $ go run sorting.go 4 | Strings: [a b c] 5 | Ints: [2 4 7] 6 | Sorted: true 7 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/glsl.frag: -------------------------------------------------------------------------------- 1 | /* Fragment shader */ 2 | void main() 3 | { 4 | gl_FragColor[0] = gl_FragCoord[0] / 400.0; 5 | gl_FragColor[1] = gl_FragCoord[1] / 400.0; 6 | gl_FragColor[2] = 1.0; 7 | } 8 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/pytb_test2.pytb: -------------------------------------------------------------------------------- 1 | File "temp.py", line 1 2 | SyntaxError: Non-ASCII character '\xc3' in file temp.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details 3 | -------------------------------------------------------------------------------- /examples/multiple-return-values/multiple-return-values.sh: -------------------------------------------------------------------------------- 1 | $ go run multiple-return-values.go 2 | 3 3 | 7 4 | 7 5 | 6 | # Accepting a variable number of arguments is another nice 7 | # feature of Go functions; we'll look at this next. 8 | -------------------------------------------------------------------------------- /examples/short-declarations/short-declarations.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | // `x := val` is shorthand for `var x type = val`. 7 | x := "Hello var" 8 | fmt.Println(x) 9 | } 10 | -------------------------------------------------------------------------------- /examples/timers/timers.sh: -------------------------------------------------------------------------------- 1 | // The first timer will expire ~2s after we start the 2 | // program, but the second should be stopped before it has 3 | // a chance to expire. 4 | $ go run timers.go 5 | Timer 1 expired 6 | Timer 2 stopped 7 | -------------------------------------------------------------------------------- /examples/number-parsing/number-parsing.sh: -------------------------------------------------------------------------------- 1 | $ go run number-parsing.go 2 | 1.234 3 | 123 4 | 456 5 | 789 6 | 135 7 | strconv.ParseInt: parsing "wat": invalid syntax 8 | 9 | # Next we'll look at another common parsing task: URLs. 10 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/erl_session: -------------------------------------------------------------------------------- 1 | 1> io:format("Hello\n"). 2 | Hello 3 | ok 4 | 2> fun(X) -> X + 1 end. 5 | #Fun 6 | 3> 123 + 234. 7 | 357 8 | 4> X = Y. 9 | * 1: variable 'Y' is unbound 10 | 5> 11 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/java.properties: -------------------------------------------------------------------------------- 1 | foo = bar 2 | foo: bar 3 | foo.oof: \ 4 | bar=baz; \ 5 | asdf 6 | 7 | // comment 8 | # comment 9 | ; comment 10 | 11 | x:a\ 12 | b 13 | x: a \ 14 | b 15 | 16 | x = \ 17 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.scaml: -------------------------------------------------------------------------------- 1 | -@ import val city:String = "Tampa" 2 | - val name:String = "Hiram" 3 | %html 4 | %body 5 | %p Hello #{name} from #{city} 6 | %ul 7 | - for ( i <- 1 to 10 ) 8 | %li Item #{i} -------------------------------------------------------------------------------- /examples/atomic-counters/atomic-counters.sh: -------------------------------------------------------------------------------- 1 | # Running the program shows that we executed about 2 | # 40,000 operations. 3 | $ go run atomic-counters.go 4 | ops: 40200 5 | 6 | # Next we'll look at mutexes, another tool for managing 7 | # state. 8 | -------------------------------------------------------------------------------- /examples/range-over-channels/range-over-channels.sh: -------------------------------------------------------------------------------- 1 | $ go run range-over-channels.go 2 | one 3 | two 4 | 5 | # This example also showed that it's possible to close 6 | # a non-empty channel but still have the remaining 7 | # values be received. 8 | -------------------------------------------------------------------------------- /examples/variadic-functions/variadic-functions.sh: -------------------------------------------------------------------------------- 1 | $ go run variadic-functions.go 2 | [1 2] 3 3 | [1 2 3] 6 4 | [1 2 3 4] 10 5 | 6 | # Another key aspect of functions in Go is their ability 7 | # to form closures, which we'll look at next. 8 | -------------------------------------------------------------------------------- /examples/hello-world/hello-world.go: -------------------------------------------------------------------------------- 1 | // Our first program will print the classic "hello world"` 2 | // message. Here's the full source code. 3 | package main 4 | 5 | import "fmt" 6 | 7 | func main() { 8 | fmt.Println("hello world") 9 | } 10 | -------------------------------------------------------------------------------- /examples/maps/maps.sh: -------------------------------------------------------------------------------- 1 | # Note that maps appear in the form `map[k:v k:v]` when 2 | # printed with `fmt.Println`. 3 | $ go run maps.go 4 | map: map[k1:7 k2:13] 5 | v1: 7 6 | len: 2 7 | map: map[k1:7] 8 | prs: false 9 | map: map[foo:1 bar:2] 10 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.gst: -------------------------------------------------------------------------------- 1 | <%!-- defined in example/PersonCSVTemplate.gst --%> 2 | 3 | <%@ params( users : Collection ) %> 4 | 5 | <% for( user in users ) { %> 6 | 7 | ${user.LastName}, ${user.FirstName}, ${user.Department} <% } %> -------------------------------------------------------------------------------- /examples/if-else/if-else.sh: -------------------------------------------------------------------------------- 1 | $ go run if-else.go 2 | 7 is odd 3 | 8 is divisible by 4 4 | 9 has 1 digit 5 | 6 | # There is no [ternary if](http://en.wikipedia.org/wiki/%3F:) 7 | # in Go, so you'll need to use a full `if` statement even 8 | # for basic conditions. 9 | -------------------------------------------------------------------------------- /examples/pointers/pointers.sh: -------------------------------------------------------------------------------- 1 | # `zeroval` doesn't change the `i` in `main`, but 2 | # `zeroptr` does because it has a reference to 3 | # the memory address for that variable. 4 | $ go run pointers.go 5 | initial: 1 6 | zeroval: 1 7 | zeroptr: 0 8 | pointer: 0x42131100 9 | -------------------------------------------------------------------------------- /examples/channel-synchronization/channel-synchronization.sh: -------------------------------------------------------------------------------- 1 | $ go run channel-synchronization.go 2 | working...done 3 | 4 | # If you removed the `<- done` line from this program, the 5 | # program would exit before the `worker` even 6 | # started. 7 | -------------------------------------------------------------------------------- /examples/middleware/middleware.sh: -------------------------------------------------------------------------------- 1 | $ go run middleware.go 2 | 3 | $ curl -i http://127.0.0.1:5000/ 4 | HTTP/1.1 200 OK 5 | Content-Type: text/plain 6 | Date: Tue, 02 Oct 2012 00:37:18 GMT 7 | Transfer-Encoding: chunked 8 | X-Wrapped: true 9 | 10 | Hello wrapped world 11 | -------------------------------------------------------------------------------- /examples/reading-files/reading-files.sh: -------------------------------------------------------------------------------- 1 | $ echo "hello" > /tmp/dat 2 | $ echo "go" >> /tmp/dat 3 | $ go run reading-files.go 4 | hello 5 | go 6 | 5 bytes: hello 7 | 2 bytes @ 6: go 8 | 2 bytes @ 6: go 9 | 5 bytes: hello 10 | 11 | # Next we'll look at writing files. 12 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/pycon_test.pycon: -------------------------------------------------------------------------------- 1 | >>> : 2 | File "", line 1 3 | : 4 | ^ 5 | SyntaxError: invalid syntax 6 | >>> 7 | KeyboardInterrupt 8 | >>> 9 | 10 | >>> 1/0 11 | Traceback (most recent call last): 12 | ... 13 | ZeroDivisionError 14 | 15 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/ruby_func_def.rb: -------------------------------------------------------------------------------- 1 | class (get_foo("blub"))::Foo 2 | def (foo("bar") + bar("baz")).something argh, aaahaa 3 | 42 4 | end 5 | end 6 | 7 | class get_the_fuck("out")::Of::My 8 | def parser_definition 9 | ruby! 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/numbers.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Some Number Test 3 | */ 4 | 5 | int i = 24241424; 6 | float f1 = 342423423.24234; 7 | float f2 = 25235235.; 8 | float f3 = .234234; 9 | float f4 = 234243e+34343; 10 | float f5 = 24234e-234; 11 | int o = 0234; 12 | int h = 0x2342; 13 | -------------------------------------------------------------------------------- /examples/tickers/tickers.sh: -------------------------------------------------------------------------------- 1 | # When we run this program the ticker should tick 3 times 2 | # before we stop it. 3 | $ go run tickers.go 4 | Tick at 2012-09-23 11:29:56.487625 -0700 PDT 5 | Tick at 2012-09-23 11:29:56.988063 -0700 PDT 6 | Tick at 2012-09-23 11:29:57.488076 -0700 PDT 7 | Ticker stopped 8 | -------------------------------------------------------------------------------- /examples/url-parsing/url-parsing.sh: -------------------------------------------------------------------------------- 1 | # Running our URL parsing program shows all the different 2 | # pieces that we extracted. 3 | $ go run url-parsing.go 4 | postgres 5 | user:pass 6 | user 7 | pass 8 | host.com:5432 9 | host.com 10 | 5432 11 | /path 12 | f 13 | k=v 14 | map[k:[v]] 15 | v 16 | -------------------------------------------------------------------------------- /examples/interfaces/interfaces.sh: -------------------------------------------------------------------------------- 1 | $ go run interfaces.go 2 | {3 4} 3 | 12 4 | 14 5 | {5} 6 | 78.53981633974483 7 | 31.41592653589793 8 | 9 | # To learn more about Go's interfaces, check out this 10 | # [great blog post](http://jordanorelli.tumblr.com/post/32665860244/how-to-use-interfaces-in-go). 11 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.ssp: -------------------------------------------------------------------------------- 1 | <%@ val someName: String = "someDefaultValue" %> 2 | <% import com.acme.MySnippets._ %> 3 | 4 | 5 |

Hello ${someName}%

6 | 7 |
    8 | <%= for (person <- people) { %> 9 |
  • ${person.name}
  • 10 | <% } %> 11 |
12 | 13 | -------------------------------------------------------------------------------- /examples/static-content/static-content.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | 5 | func main() { 6 | handler := http.FileServer(http.Dir("./")) 7 | http.ListenAndServe(":5000", handler) 8 | } 9 | 10 | // todo: index pages 11 | // todo: disable listing 12 | // todo: custom 404 handling 13 | -------------------------------------------------------------------------------- /examples/epoch/epoch.sh: -------------------------------------------------------------------------------- 1 | $ go run epoch.go 2 | 2012-10-31 16:13:58.292387 +0000 UTC 3 | 1351700038 4 | 1351700038292 5 | 1351700038292387000 6 | 2012-10-31 16:13:58 +0000 UTC 7 | 2012-10-31 16:13:58.292387 +0000 UTC 8 | 9 | # Next we'll look at another time-related task: time 10 | # parsing and formatting. 11 | -------------------------------------------------------------------------------- /examples/line-filters/line-filters.sh: -------------------------------------------------------------------------------- 1 | # To try out our line filter, first make a file with a few 2 | # lowercase lines. 3 | $ echo 'hello' > /tmp/lines 4 | $ echo 'filter' >> /tmp/lines 5 | 6 | # Then use the line filter to get uppercase lines. 7 | $ cat /tmp/lines | go run line-filters.go 8 | HELLO 9 | FILTER 10 | -------------------------------------------------------------------------------- /examples/select/select.sh: -------------------------------------------------------------------------------- 1 | # We receive the values `"one"` and then `"two"` as 2 | # expected. 3 | $ time go run select.go 4 | received one 5 | received two 6 | 7 | # Note that the total execution time is only ~2 seconds 8 | # since both the 1 and 2 second `Sleeps` execute 9 | # concurrently. 10 | real 0m2.245s 11 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/while.pov: -------------------------------------------------------------------------------- 1 | #declare Index1 = 0; 2 | #while(Index1 <= 9) 3 | 4 | #declare Index2 = 0; 5 | #while(Index2 <= 19) 6 | 7 | sphere { , .5 } 8 | 9 | #declare Index2 = Index2 + 1; 10 | #end 11 | 12 | #declare Index1 = Index1 + 1; 13 | #end 14 | -------------------------------------------------------------------------------- /examples/random-numbers/random-numbers.sh: -------------------------------------------------------------------------------- 1 | $ go run random-numbers.go 2 | 81,87 3 | 0.6645600532184904 4 | 7.123187485356329,8.434115364335547 5 | 5,87 6 | 5,87 7 | 8 | 9 | # See the [`math/rand`](http://golang.org/pkg/math/rand/) 10 | # package docs for references on other random quantities 11 | # that Go can provide. 12 | -------------------------------------------------------------------------------- /examples/closing-channels/closing-channels.sh: -------------------------------------------------------------------------------- 1 | $ go run closing-channels.go 2 | sent job 1 3 | received job 1 4 | sent job 2 5 | received job 2 6 | sent job 3 7 | received job 3 8 | sent all jobs 9 | received all jobs 10 | 11 | # The idea of closed channels leads naturally to our next 12 | # example: `range` over channels. 13 | -------------------------------------------------------------------------------- /examples/errors/errors.sh: -------------------------------------------------------------------------------- 1 | $ go run errors.go 2 | f1 worked: 10 3 | f1 failed: can't work with 42 4 | f2 worked: 10 5 | f2 failed: 42 - can't work with it 6 | 42 7 | can't work with it 8 | 9 | # See this [great post](http://blog.golang.org/2011/07/error-handling-and-go.html) 10 | # on the Go blog for more on error handling. 11 | -------------------------------------------------------------------------------- /examples/signals/signals.sh: -------------------------------------------------------------------------------- 1 | # When we run this program it will block waiting for a 2 | # signal. By typing `ctrl-C` (which the 3 | # terminal shows as `^C`) we can send a `SIGINT` signal, 4 | # causing the program to print `interrupt` and then exit. 5 | $ go run signals.go 6 | awaiting signal 7 | ^C 8 | interrupt 9 | exiting 10 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/sphere.pov: -------------------------------------------------------------------------------- 1 | #include "colors.inc" 2 | 3 | background { color Cyan } 4 | 5 | camera { 6 | location <0, 2, -3> 7 | look_at <0, 1, 2> 8 | } 9 | 10 | sphere { 11 | <0, 1, 2>, 2 12 | texture { 13 | pigment { color Yellow } 14 | } 15 | } 16 | 17 | light_source { <2, 4, -3> color White} 18 | 19 | -------------------------------------------------------------------------------- /examples/hello-web/hello-web.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | 5 | func hello(res http.ResponseWriter, req *http.Request) { 6 | res.Header().Set("Content-Type", "text/plain") 7 | res.Write([]byte("Hello web\n")) 8 | } 9 | 10 | func main() { 11 | http.HandleFunc("/", hello) 12 | http.ListenAndServe(":5000", nil) 13 | } 14 | -------------------------------------------------------------------------------- /examples/mutexes/mutexes.sh: -------------------------------------------------------------------------------- 1 | # Running the program shows that we executed about 2 | # 3,500,000 operations against our `mutex`-synchronized 3 | # `state`. 4 | $ go run mutexes.go 5 | ops: 3598302 6 | state: map[1:38 4:98 2:23 3:85 0:44] 7 | 8 | # Next we'll look at implementing this same state 9 | # management task using only goroutines and channels. 10 | -------------------------------------------------------------------------------- /examples/postgres/postgres.sh: -------------------------------------------------------------------------------- 1 | # First, be sure that you've installed Postgres 2 | # and have a server running locally at port 5432. 3 | 4 | # Then create an example database. 5 | $ createdb gobyexample 6 | 7 | # Now install the dependencies for the postgres 8 | # example and try running it. 9 | $ go get github.com/bmizerany/pq 10 | $ go run postgres.go 11 | -------------------------------------------------------------------------------- /examples/string-functions/string-functions.sh: -------------------------------------------------------------------------------- 1 | $ go run string-functions.go 2 | Contains: true 3 | Count: 2 4 | HasPrefix: true 5 | HasSuffix: true 6 | Index: 1 7 | Join: a-b 8 | Repeat: aaaaa 9 | Replace: f00 10 | Replace: f0o 11 | Split: [a b c d e] 12 | toLower: test 13 | ToUpper: TEST 14 | 15 | Len: 5 16 | Char: 101 17 | -------------------------------------------------------------------------------- /examples/arrays/arrays.sh: -------------------------------------------------------------------------------- 1 | # Note that arrays appear in the form `[v1 v2 v3 ...]` 2 | # when printed with `fmt.Println`. 3 | $ go run arrays.go 4 | emp: [0 0 0 0 0] 5 | set: [0 0 0 0 100] 6 | get: 100 7 | len: 5 8 | dcl: [1 2 3 4 5] 9 | 2d: [[0 1 2] [1 2 3]] 10 | 11 | # You'll see _slices_ much more often than arrays in 12 | # typical Go. We'll look at slices next. 13 | -------------------------------------------------------------------------------- /examples/base64-encoding/base64-encoding.sh: -------------------------------------------------------------------------------- 1 | # The string encodes to slightly different values with the 2 | # standard and URL base64 encoders (trailing `+` vs `-`) 3 | # but they both decode to the original string as desired. 4 | $ go run base64-encoding.go 5 | YWJjMTIzIT8kKiYoKSctPUB+ 6 | abc123!?$*&()'-=@~ 7 | 8 | YWJjMTIzIT8kKiYoKSctPUB- 9 | abc123!?$*&()'-=@~ 10 | -------------------------------------------------------------------------------- /examples/exit/exit.sh: -------------------------------------------------------------------------------- 1 | # If you run `exit.go` using `go run`, the exit 2 | # will be picked up by `go` and printed. 3 | $ go run exit.go 4 | exit status 3 5 | 6 | # By building and executing a binary you can see 7 | # the status in the terminal. 8 | $ go build exit.go 9 | $ ./exit 10 | $ echo $? 11 | 3 12 | 13 | # Note that the `!` from our program never got printed. 14 | -------------------------------------------------------------------------------- /examples/http-client/http-client.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | import "io/ioutil" 5 | import "fmt" 6 | 7 | func main() { 8 | resp, err := http.Get("http://127.0.0.1:5000/") 9 | if err != nil { 10 | panic(err) 11 | } 12 | defer resp.Body.Close() 13 | body, err := ioutil.ReadAll(resp.Body) 14 | fmt.Print(string(body)) 15 | } 16 | -------------------------------------------------------------------------------- /examples/time-formatting-parsing/time-formatting-parsing.sh: -------------------------------------------------------------------------------- 1 | $ go run time-formatting-parsing.go 2 | 2012-11-02T09:35:03-07:00 3 | 9:35AM 4 | Fri Nov 2 09:35:03 2012 5 | 2012-11-02T09:35:03.982519-07:00 6 | 2012-11-02T09:35:03-00:00 7 | 0001-01-01 00:00:00 +0000 UTC 8 | 0000-01-01 20:41:00 +0000 UTC 9 | parsing time "8:41PM" as "Mon Jan _2 15:04:05 2006": ... 10 | 9:35AM 11 | -------------------------------------------------------------------------------- /tools/build-loop: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TRAPPING=0 4 | trap "{ echo finishing; TRAPPING=1; }" SIGINT 5 | 6 | while : 7 | do 8 | tools/build 9 | RET=$? 10 | if [ $RET -eq 0 ]; then 11 | echo "success" 12 | else 13 | echo "error: $RET" 14 | fi 15 | if [ $TRAPPING -eq 0 ]; then 16 | sleep 1 17 | else 18 | echo "done" 19 | exit 0 20 | fi 21 | done 22 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/glsl.vert: -------------------------------------------------------------------------------- 1 | /* Vertex shader */ 2 | uniform float waveTime; 3 | uniform float waveWidth; 4 | uniform float waveHeight; 5 | 6 | void main(void) 7 | { 8 | vec4 v = vec4(gl_Vertex); 9 | 10 | v.z = sin(waveWidth * v.x + waveTime) * cos(waveWidth * v.y + waveTime) * waveHeight; 11 | 12 | gl_Position = gl_ModelViewProjectionMatrix * v; 13 | } 14 | -------------------------------------------------------------------------------- /examples/command-line-arguments/command-line-arguments.sh: -------------------------------------------------------------------------------- 1 | # To experiment with command-line arguments it's best to 2 | # build a binary with `go build` first. 3 | $ go build command-line-arguments.go 4 | $ ./command-line-arguments a b c d 5 | [./command-line-arguments a b c d] 6 | [a b c d] 7 | c 8 | 9 | # Next we'll look at more advanced command-line processing 10 | # with flags. 11 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/cheetah_example.html: -------------------------------------------------------------------------------- 1 | 2 | $title 3 | 4 | 5 | #for $client in $clients 6 | 7 | 8 | 9 | 10 | #end for 11 |
$client.surname, $client.firstname$client.email
12 | 13 | 14 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/flipflop.sv: -------------------------------------------------------------------------------- 1 | module toplevel(clock,reset); 2 | input clock; 3 | input reset; 4 | 5 | reg flop1; 6 | reg flop2; 7 | 8 | always @ (posedge reset or posedge clock) 9 | if (reset) 10 | begin 11 | flop1 <= 0; 12 | flop2 <= 1; 13 | end 14 | else 15 | begin 16 | flop1 <= flop2; 17 | flop2 <= flop1; 18 | end 19 | endmodule 20 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/pppoe.applescript: -------------------------------------------------------------------------------- 1 | tell application "System Events" 2 | tell network preferences 3 | tell current location 4 | set aPPPoEService to a reference to (first service whose kind is 10) 5 | if exists aPPPoEService then 6 | connect aPPPoEService 7 | end if 8 | end tell 9 | end tell 10 | end tell 11 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/regex.js: -------------------------------------------------------------------------------- 1 | // regex 2 | 3 | blah(/abc/); 4 | x = /abc/; 5 | x = /abc/.match; 6 | 7 | // math 8 | 9 | blah(1/2); //comment 10 | x = 1 / 2 / 3; 11 | x = 1/1/.1; 12 | 13 | // broken 14 | 15 | x=/1/; 16 | x=1/a/g; 17 | x=a/a/g; 18 | 19 | // real-world 20 | 21 | var x = 1/(1+Math.sqrt(sum)); // convert to number between 1-0 22 | return Math.round((num / den) * 100)/100; 23 | -------------------------------------------------------------------------------- /vendor/pygments/tests/support.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | """ 3 | Support for Pygments tests 4 | """ 5 | 6 | import os 7 | 8 | 9 | def location(mod_name): 10 | """ 11 | Return the file and directory that the code for *mod_name* is in. 12 | """ 13 | source = mod_name.endswith("pyc") and mod_name[:-1] or mod_name 14 | source = os.path.abspath(source) 15 | return source, os.path.dirname(source) 16 | -------------------------------------------------------------------------------- /examples/regular-expressions/regular-expressions.sh: -------------------------------------------------------------------------------- 1 | $ go run regular-expressions.go 2 | true 3 | true 4 | peach 5 | [0 5] 6 | [peach ea] 7 | [0 5 1 3] 8 | [peach punch pinch] 9 | [[0 5 1 3] [6 11 7 9] [12 17 13 15]] 10 | [peach punch] 11 | true 12 | p([a-z]+)ch 13 | a 14 | a PEACH 15 | 16 | # For a complete reference on Go regular expressions check 17 | # the [`regexp`](http://golang.org/pkg/regexp/) package docs. 18 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.cls: -------------------------------------------------------------------------------- 1 | USING Progress.Lang.*. 2 | 3 | CLASS Test INHERITS Progress.Sucks: 4 | 5 | DEFINE PRIVATE VARIABLE cTest AS CHAR NO-UNDO. 6 | 7 | CONSTRUCTOR PUBLIC Test(): 8 | SUPER(). 9 | MESSAGE "Why are you punishing yourself by coding in this language?". 10 | END CONSTRUCTOR. 11 | 12 | METHOD PUBLIC LOGICAL Blowup(INPUT iTime AS INT): 13 | END. 14 | 15 | END CLASS. 16 | -------------------------------------------------------------------------------- /examples/channels/channels.sh: -------------------------------------------------------------------------------- 1 | # When we run the program the `"ping"` message is 2 | # succesfully passed from one goroutine to another via our 3 | # channel. 4 | $ go run channels.go 5 | ping 6 | 7 | # By default sends and receives block until both the 8 | # sender and receiver are ready. This property allowed 9 | # us to wait at the end of our program for the `"ping"` 10 | # message without having to use any other synchronization. 11 | -------------------------------------------------------------------------------- /examples/string-formatting/string-formatting.sh: -------------------------------------------------------------------------------- 1 | $ go run string-formatting.go 2 | {1 2} 3 | {x:1 y:2} 4 | main.point{x:1, y:2} 5 | main.point 6 | true 7 | 123 8 | 1110 9 | ! 10 | 1c8 11 | 78.900000 12 | 1.234000e+08 13 | 1.234000E+08 14 | "string" 15 | "\"string\"" 16 | 6865782074686973 17 | 0x42135100 18 | | 12| 345| 19 | | 1.20| 3.45| 20 | |1.20 |3.45 | 21 | | foo| b| 22 | |foo |b | 23 | a string 24 | an error 25 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/Errors.scala: -------------------------------------------------------------------------------- 1 | /* This file /* which is totally legal scala */ will not be highlighted 2 | correcty by pygments */ 3 | 4 | object ⌘ { 5 | val `interface` = """ 6 | A 7 | "Multiline" 8 | String 9 | """ 10 | 11 | val foo_+ = "foo plus" 12 | val foo_⌬⌬ = "double benzene" 13 | 14 | def main(argv: Array[String]) { 15 | println(⌘.interface + " " + foo_+ + " " + foo_⌬⌬ ) 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /examples/writing-files/writing-files.sh: -------------------------------------------------------------------------------- 1 | # Try running the file-writing code. 2 | $ go run writing-files.go 3 | wrote 5 bytes 4 | wrote 7 bytes 5 | wrote 9 bytes 6 | 7 | # Then check the contents of the written files. 8 | $ cat /tmp/dat1 9 | hello 10 | go 11 | $ cat /tmp/dat2 12 | some 13 | writes 14 | buffered 15 | 16 | # Next we'll look at applying some of the file I/O ideas 17 | # we've just seen to the `stdin` and `stdout` streams. 18 | -------------------------------------------------------------------------------- /examples/https-servers/https-servers.sh: -------------------------------------------------------------------------------- 1 | $ cd /tmp 2 | $ rm -f server.* 3 | $ openssl genrsa -des3 -out server.orig.key 2048 4 | $ openssl rsa -in server.orig.key -out server.key 5 | $ openssl req -new -key server.key -out server.csr 6 | $ openssl x509 -req -days 365 -in server.csr \ 7 | -signkey server.key -out server.crt 8 | 9 | $ go run https-servers.go 10 | 11 | $ curl https://127.0.0.1:5000/ 12 | $ curl --insecure https://127.0.0.1:5000/ 13 | -------------------------------------------------------------------------------- /examples/sorting-by-functions/sorting-by-functions.sh: -------------------------------------------------------------------------------- 1 | # Running our program shows a list sorted by string 2 | # length, as desired. 3 | $ go run sorting-by-functions.go 4 | [kiwi peach banana] 5 | 6 | # By following this same pattern of creating a custom 7 | # type, implementing the three `Interface` methods on that 8 | # type, and then calling sort.Sort on a collection of that 9 | # custom type, we can sort Go slices by arbitrary 10 | # functions. 11 | -------------------------------------------------------------------------------- /examples/spawning-processes/spawning-processes.sh: -------------------------------------------------------------------------------- 1 | # The spawned programs return output that is the same 2 | # as if we had run them directly from the command-line. 3 | $ go run spawning-processes.go 4 | > date 5 | Wed Oct 10 09:53:11 PDT 2012 6 | 7 | > grep hello 8 | hello grep 9 | 10 | > ls -a -l -h 11 | drwxr-xr-x 4 mark 136B Oct 3 16:29 . 12 | drwxr-xr-x 91 mark 3.0K Oct 3 12:50 .. 13 | -rw-r--r-- 1 mark 1.3K Oct 3 16:28 spawning-processes.go 14 | -------------------------------------------------------------------------------- /vendor/pygments/tests/dtds/HTML4.soc: -------------------------------------------------------------------------------- 1 | OVERRIDE YES 2 | SGMLDECL HTML4.dcl 3 | DOCTYPE HTML HTML4.dtd 4 | PUBLIC "-//W3C//DTD HTML 4.0//EN" HTML4-s.dtd 5 | PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" HTML4.dtd 6 | PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" HTML4-f.dtd 7 | PUBLIC "-//W3C//ENTITIES Latin1//EN//HTML" HTMLlat1.ent 8 | PUBLIC "-//W3C//ENTITIES Special//EN//HTML" HTMLspec.ent 9 | PUBLIC "-//W3C//ENTITIES Symbols//EN//HTML" HTMLsym.ent 10 | -------------------------------------------------------------------------------- /examples/timeouts/timeouts.sh: -------------------------------------------------------------------------------- 1 | # Running this program shows the first operation timing 2 | # out and the second succeeding. 3 | $ go run timeouts.go 4 | timeout 1 5 | result 2 6 | 7 | # Using this `select` timeout pattern requires 8 | # communicating results over channels. This is a good 9 | # idea in general because other important Go features are 10 | # based on channels and `select`. We'll look at two 11 | # examples of this next: timers and tickers. 12 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.sh-session: -------------------------------------------------------------------------------- 1 | user@host:~/path$ ls -a 2 | . .. a b c 3 | user@host:~/path$ diff -u a b 4 | --- a 2008-07-26 17:10:07.000000000 -0700 5 | +++ b 2008-07-26 17:10:10.000000000 -0700 6 | @@ -1,3 +1,3 @@ 7 | a 8 | -b 9 | +x 10 | c 11 | user@host:~/path$ echo \ 12 | > a 13 | a 14 | user@host:~/path$ su 15 | root@host:~# 16 | sh-3.1$ # on hardy 17 | sh$ # on etch 18 | (virtualenv-name)user@host:~$ ls -a 19 | 20 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/qsort.prolog: -------------------------------------------------------------------------------- 1 | partition([], _, [], []). 2 | partition([X|Xs], Pivot, Smalls, Bigs) :- 3 | ( X @< Pivot -> 4 | Smalls = [X|Rest], 5 | partition(Xs, Pivot, Rest, Bigs) 6 | ; Bigs = [X|Rest], 7 | partition(Xs, Pivot, Smalls, Rest) 8 | ). 9 | 10 | quicksort([]) --> []. 11 | quicksort([X|Xs]) --> 12 | { partition(Xs, X, Smaller, Bigger) }, 13 | quicksort(Smaller), [X], quicksort(Bigger). 14 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.snobol: -------------------------------------------------------------------------------- 1 | -SOME RANDOM DIRECTIVE WOULD GO HERE 2 | * 3 | * SNOBOL4 example file for lexer 4 | * 5 | SOME.THING_OR_OTHER32 = 1 + 1.0 - 1E3 * 1E-3 ** 2.718284590E0 6 | + :F(END)S(IN_LOOP) 7 | PATTERN = LEN(3) ("GAR" | "BAR") 8 | IN_LOOP THING = INPUT :F(END) 9 | THING LEN(3) ("GAR" | "BAR") :S(OK) 10 | OUTPUT = THING " : Failure!" :(IN_LOOP) 11 | OK OUTPUT = THING ' : "Success"!' :(IN_LOOP) 12 | END 13 | FOOBAR 14 | FOOGAR 15 | THiNIg 16 | -------------------------------------------------------------------------------- /examples/https-servers/https-servers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | 5 | func handler(res http.ResponseWriter, req *http.Request) { 6 | res.Header().Set("Content-Type", "text/plain") 7 | res.Write([]byte("Hello from HTTPS\n")) 8 | } 9 | 10 | func main() { 11 | http.HandleFunc("/", handler) 12 | err := http.ListenAndServeTLS(":5000", 13 | "/tmp/server.crt", "/tmp/server.key", nil) 14 | if err != nil { 15 | panic(err) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/panic/panic.sh: -------------------------------------------------------------------------------- 1 | # Running this program will cause it to panic, print 2 | # an error message and goroutine traces, and exit with 3 | # a non-zero status. 4 | $ go run panic.go 5 | panic: a problem 6 | 7 | goroutine 1 [running]: 8 | main.main() 9 | /.../panic.go:12 +0x47 10 | ... 11 | exit status 2 12 | 13 | # Note that unlike some languages which use exceptions 14 | # for handling of many errors, in Go it is idiomatic 15 | # to use error-indicating return values wherever possible. 16 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/sibling.prolog: -------------------------------------------------------------------------------- 1 | /* Comments /* can nest */ 2 | still a comment 3 | */ 4 | 5 | :- module(maplist, maplist/3) 6 | 7 | assert(world:done). % asserts 8 | 9 | sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y). 10 | 11 | parent_child(X, Y) :- father_child(X, Y). 12 | parent_child(X, Y) :- mother_child(X, Y). 13 | 14 | mother_child(trude, sally). 15 | 16 | father_child(tom, sally). 17 | father_child(tom, erica). 18 | father_child(mike, tom). 19 | 20 | -------------------------------------------------------------------------------- /examples/request-routing/request-routing.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/bmizerany/pat" 4 | import "net/http" 5 | import "fmt" 6 | 7 | func hello(w http.ResponseWriter, req *http.Request) { 8 | fmt.Fprintln(w, "hello "+req.URL.Query().Get(":name")) 9 | } 10 | 11 | func main() { 12 | p := pat.New() 13 | p.Get("/hello/:name", http.HandlerFunc(hello)) 14 | http.ListenAndServe(":5000", p) 15 | } 16 | 17 | // todo: consider gorilla-web 18 | // todo: defaults 19 | // todo: fallthroughs 20 | -------------------------------------------------------------------------------- /examples/responses/responses.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | import "fmt" 5 | 6 | func hello(res http.ResponseWriter, req *http.Request) { 7 | res.Header().Set("Content-Type", "text/plain") 8 | if req.URL.Path == "/protected" { 9 | res.WriteHeader(401) 10 | fmt.Fprintln(res, "Not allowed") 11 | } else { 12 | fmt.Fprintln(res, "Hello") 13 | } 14 | } 15 | 16 | func main() { 17 | http.HandleFunc("/", hello) 18 | http.ListenAndServe(":5000", nil) 19 | } 20 | -------------------------------------------------------------------------------- /examples/execing-processes/execing-processes.sh: -------------------------------------------------------------------------------- 1 | # When we run our program it is replaced by `ls`. 2 | $ go run execing-processes.go 3 | total 16 4 | drwxr-xr-x 4 mark 136B Oct 3 16:29 . 5 | drwxr-xr-x 91 mark 3.0K Oct 3 12:50 .. 6 | -rw-r--r-- 1 mark 1.3K Oct 3 16:28 execing-processes.go 7 | 8 | # Note that Go does not offer a classic Unix `fork` 9 | # function. Usually this isn't an issue though, since 10 | # starting goroutines, spawning processes, and exec'ing 11 | # processes covers most use cases for `fork`. 12 | -------------------------------------------------------------------------------- /examples/recursion/recursion.go: -------------------------------------------------------------------------------- 1 | // Go supports 2 | // recursive functions. 3 | // Here's a classic factorial example. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | // This `fact` function calls itself until it reaches the 10 | // base case of `fact(0)`. 11 | func fact(n int) int { 12 | if n == 0 { 13 | return 1 14 | } 15 | return n * fact(n-1) 16 | } 17 | 18 | func main() { 19 | fmt.Println(fact(7)) 20 | } 21 | -------------------------------------------------------------------------------- /examples/goroutines/goroutines.sh: -------------------------------------------------------------------------------- 1 | # When we run this program, we see the output of the 2 | # blocking call first, then the interleaved output of the 3 | # two gouroutines. This interleaving reflects the 4 | # goroutines being run concurrently by the Go runtime. 5 | $ go run goroutines.go 6 | direct : 0 7 | direct : 1 8 | direct : 2 9 | goroutine : 0 10 | going 11 | goroutine : 1 12 | goroutine : 2 13 | 14 | done 15 | 16 | # Next we'll look at a complement to goroutines in 17 | # concurrent Go programs: channels. 18 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/matlabsession_sample.txt: -------------------------------------------------------------------------------- 1 | >> 2 | >> 3 | >> a = 'okay' 4 | 5 | a = 6 | 7 | okay 8 | 9 | >> x = rand(3) % a matrix 10 | 11 | x = 12 | 13 | 0.8147 0.9134 0.2785 14 | 0.9058 0.6324 0.5469 15 | 0.1270 0.0975 0.9575 16 | 17 | >> 1/0 18 | 19 | ans = 20 | 21 | Inf 22 | 23 | >> foo 24 | ??? Undefined function or variable 'foo'. 25 | 26 | >> 27 | >> 28 | >> {cos(2*pi), 'testing'} 29 | 30 | ans = 31 | 32 | [1] 'testing' 33 | 34 | >> 35 | >> 36 | >> 37 | 38 | -------------------------------------------------------------------------------- /examples/hello-world/hello-world.sh: -------------------------------------------------------------------------------- 1 | # To run the program, put the code in `hello-world.go` and 2 | # use `go run`. 3 | $ go run hello-world.go 4 | hello world 5 | 6 | # Sometimes we'll want to build our programs into 7 | # binaries. We can do this using `go build`. 8 | $ go build hello-world.go 9 | $ ls 10 | hello-world hello-world.go 11 | 12 | # We can then execute the built binary directly. 13 | $ ./hello-world 14 | hello world 15 | 16 | # Now that we can run and build basic Go programs, let's 17 | # learn more about the language. 18 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/objc_example.m: -------------------------------------------------------------------------------- 1 | #import "Somefile.h" 2 | 3 | @implementation ABC 4 | 5 | - (id)a:(B)b { 6 | return 1; 7 | } 8 | 9 | @end 10 | 11 | @implementation ABC 12 | 13 | - (void)xyz; 14 | 15 | @end 16 | 17 | NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys: 18 | @"quattuor", @"four", @"quinque", @"five", @"sex", @"six", nil]; 19 | 20 | 21 | NSString *key; 22 | for (key in dictionary) { 23 | NSLog(@"English: %@, Latin: %@", key, [dictionary valueForKey:key]); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /vendor/pygments/TODO: -------------------------------------------------------------------------------- 1 | Todo 2 | ==== 3 | 4 | - suggested new lexers 5 | * IPython sessions 6 | 7 | - lexers that need work: 8 | * review perl lexer (numerous bugs, but so far no one had complaints ;) 9 | * readd property support for C# lexer? that is, find a regex that doesn't 10 | backtrack to death... 11 | * add support for function name highlighting to C++ lexer 12 | 13 | - allow "overlay" token types to highlight specials: nth line, a word etc. 14 | 15 | - pygmentize option presets, more sophisticated method to output styles? 16 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/genshitext_example.genshitext: -------------------------------------------------------------------------------- 1 | ## a comment 2 | 3 | \## not a comment 4 | 5 | #if foo 6 | ${bar} 7 | #endif 8 | 9 | The answer is: 10 | #choose 11 | #when 0 == 1 12 | 0 13 | #end 14 | #when 1 == 1 15 | 1 16 | #end 17 | #otherwise 18 | 2 19 | #end 20 | #end -- comment about choose 21 | 22 | #for item in items 23 | * ${item} 24 | #end 25 | 26 | #def greeting(name) 27 | Hello, ${name}! 28 | #end 29 | ${greeting('world')} 30 | 31 | #with y=7; z=x+10 32 | $x $y $z 33 | #end 34 | -------------------------------------------------------------------------------- /examples/time/time.sh: -------------------------------------------------------------------------------- 1 | $ go run time.go 2 | 2012-10-31 15:50:13.793654 +0000 UTC 3 | 2009-11-17 20:34:58.651387237 +0000 UTC 4 | 2009 5 | November 6 | 17 7 | 20 8 | 34 9 | 58 10 | 651387237 11 | UTC 12 | Tuesday 13 | true 14 | false 15 | false 16 | 25891h15m15.142266763s 17 | 25891.25420618521 18 | 1.5534752523711128e+06 19 | 9.320851514226677e+07 20 | 93208515142266763 21 | 2012-10-31 15:50:13.793654 +0000 UTC 22 | 2006-12-05 01:19:43.509120474 +0000 UTC 23 | 24 | # Next we'll look at the related idea of time relative to 25 | # the Unix epoch. 26 | -------------------------------------------------------------------------------- /examples/https-client/https-client.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | import "crypto/tls" 5 | import "io/ioutil" 6 | import "fmt" 7 | 8 | func main() { 9 | conf := &tls.Config{InsecureSkipVerify: true} 10 | trans := &http.Transport{TLSClientConfig: conf} 11 | client := &http.Client{Transport: trans} 12 | resp, err := client.Get("https://127.0.0.1:5000/") 13 | if err != nil { 14 | panic(err) 15 | } 16 | defer resp.Body.Close() 17 | body, _ := ioutil.ReadAll(resp.Body) 18 | fmt.Print(string(body)) 19 | } 20 | -------------------------------------------------------------------------------- /examples/environment-variables/environment-variables.sh: -------------------------------------------------------------------------------- 1 | # Running the program shows that we pick up the value 2 | # value for `FOO` that we set in the program, but that 3 | # `BAR` is empty. 4 | $ go run environment-variables.go 5 | FOO: 1 6 | BAR: 7 | 8 | # The list of keys in the environment will depend on your 9 | # particular machine. 10 | TERM_PROGRAM 11 | PATH 12 | SHELL 13 | ... 14 | 15 | # If we set `BAR` in the environment first, the running 16 | # program picks that value up. 17 | $ BAR=2 go run environment-variables.go 18 | FOO: 1 19 | BAR: 2 20 | ... 21 | -------------------------------------------------------------------------------- /examples/json/json.sh: -------------------------------------------------------------------------------- 1 | $ go run json.go 2 | true 3 | 1 4 | 2.34 5 | "gopher" 6 | ["apple","peach","pear"] 7 | {"apple":5,"lettuce":7} 8 | {"Page":1,"Fruits":["apple","peach","pear"]} 9 | {"page":1,"fruits":["apple","peach","pear"]} 10 | map[num:6 strs:[a b]] 11 | 6 12 | a 13 | &{1 [apple peach]} 14 | apple 15 | {"apple":5,"lettuce":7} 16 | 17 | 18 | # We've covered the basic of JSON in Go here, but check 19 | # out the [JSON and Go](http://blog.golang.org/2011/01/json-and-go.html) 20 | # blog post and [JSON package docs](http://golang.org/pkg/encoding/json/) 21 | # for more. 22 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.tea: -------------------------------------------------------------------------------- 1 | <% template example() {...} 2 | a = 123 3 | b = "test"; 4 | c = 4.5 5 | d = call other() 6 | f = other2() 7 | 8 | define g as String 9 | 10 | h = true 11 | i = false 12 | j = null 13 | %> 14 | 15 | 16 | Example<title> 17 | <body> 18 | <a href="http://example.com">Test link</a> 19 | <% // Second block 20 | if(a == 123 and b == "test") { 21 | 'yes' 22 | } else { 23 | 'no' 24 | } 25 | 26 | foreach(i in 1..10) { 27 | i & "," 28 | } 29 | 30 | foreach(i in #(1,2,3) reverse { 31 | i & ";" 32 | } 33 | 34 | %> -------------------------------------------------------------------------------- /examples/sha1-hashes/sha1-hashes.sh: -------------------------------------------------------------------------------- 1 | # Running the program computes the hash and prints it in 2 | # a human-readable hex format. 3 | $ go run sha1-hashes.go 4 | sha1 this string 5 | cf23df2207d99a74fbe169e3eba035e633b65d94 6 | 7 | 8 | # You can compute other hashes using a similar pattern to 9 | # the one shown above. For example, to compute MD5 hashes 10 | # import `crypto/md5` and use `md5.New()`. 11 | 12 | # Note that if you need cryptographically secure hashes, 13 | # you should carefully research 14 | # [hash strength](http://en.wikipedia.org/wiki/Cryptographic_hash_function)! 15 | -------------------------------------------------------------------------------- /examples/worker-pools/worker-pools.sh: -------------------------------------------------------------------------------- 1 | # Our running program shows the 9 jobs being executed by 2 | # various workers. The program only takes about 3 seconds 3 | # despite doing about 9 seconds of total work because 4 | # there are 3 workers operating concurrently. 5 | $ time go run worker-pools.go 6 | worker 1 processing job 1 7 | worker 2 processing job 2 8 | worker 3 processing job 3 9 | worker 1 processing job 4 10 | worker 2 processing job 5 11 | worker 3 processing job 6 12 | worker 1 processing job 7 13 | worker 2 processing job 8 14 | worker 3 processing job 9 15 | 16 | real 0m3.149s 17 | -------------------------------------------------------------------------------- /examples/exit/exit.go: -------------------------------------------------------------------------------- 1 | // Use `os.Exit` to immediately exit with a given 2 | // status. 3 | 4 | package main 5 | 6 | import "fmt" 7 | import "os" 8 | 9 | func main() { 10 | 11 | // `defer`s will _not_ be run when using `os.Exit`, so 12 | // this `fmt.Println` will never be called. 13 | defer fmt.Println("!") 14 | 15 | // Exit with status 3. 16 | os.Exit(3) 17 | } 18 | 19 | // Note that unlike e.g. C, Go does not use an integer 20 | // return value from `main` to indicate exit status. If 21 | // you'd like to exit with a non-zero status you should 22 | // use `os.Exit`. 23 | -------------------------------------------------------------------------------- /examples/values/values.go: -------------------------------------------------------------------------------- 1 | // Go has various value types including strings, 2 | // integers, floats, booleans, etc. Here are a few 3 | // basic examples. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | func main() { 10 | 11 | // Strings, which can be added together with `+`. 12 | fmt.Println("go" + "lang") 13 | 14 | // Integers and floats. 15 | fmt.Println("1+1 =", 1+1) 16 | fmt.Println("7.0/3.0 =", 7.0/3.0) 17 | 18 | // Booleans, with boolean operators as you'd expect. 19 | fmt.Println(true && false) 20 | fmt.Println(true || false) 21 | fmt.Println(!true) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/intro.ik: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ioke 2 | 3 | Ioke = LanguageExperiment with( 4 | goal: :expressiveness, 5 | data: as(code), 6 | code: as(data), 7 | features: [ 8 | :dynamic, 9 | :object_oriented, 10 | :prototype_based, 11 | :homoiconic, 12 | :macros 13 | ], 14 | runtimes:(JVM, CLR), 15 | inspirations: set(Io, Smalltalk, Ruby, Lisp) 16 | ) 17 | 18 | hello = method("Every example needs a hello world!", 19 | name, 20 | "hello, #{name}!" println) 21 | 22 | Ioke inspirations select( 23 | features include?(:object_oriented) 24 | ) each(x, hello(x name)) 25 | -------------------------------------------------------------------------------- /examples/middleware/middleware.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | import "fmt" 5 | 6 | func hello(w http.ResponseWriter, r *http.Request) { 7 | w.Header().Set("Content-Type", "text/plain") 8 | fmt.Fprintln(w, "Hello wrapped world") 9 | } 10 | 11 | func wrapMiddleware(f http.HandlerFunc) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | w.Header().Set("X-Wrapped", "true") 14 | f(w, r) 15 | } 16 | } 17 | 18 | func main() { 19 | handler := wrapMiddleware(hello) 20 | http.HandleFunc("/", handler) 21 | http.ListenAndServe(":5000", nil) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/objc_example2.m: -------------------------------------------------------------------------------- 1 | // MyClass.h 2 | @interface MyClass : NSObject 3 | { 4 | NSString *value; 5 | NSTextField *textField; 6 | @private 7 | NSDate *lastModifiedDate; 8 | } 9 | @property(copy, readwrite) NSString *value; 10 | @property(retain) IBOutlet NSTextField *textField; 11 | @end 12 | 13 | // MyClass.m 14 | // Class extension to declare private property 15 | @interface MyClass () 16 | @property(retain) NSDate *lastModifiedDate; 17 | @end 18 | 19 | @implementation MyClass 20 | @synthesize value; 21 | @synthesize textField; 22 | @synthesize lastModifiedDate; 23 | // implementation continues 24 | @end 25 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/lighttpd_config.conf: -------------------------------------------------------------------------------- 1 | fastcgi.server = ( ".php" => (( 2 | "bin-path" => "/path/to/php-cgi", 3 | "socket" => "/tmp/php.socket", 4 | "max-procs" => 2, 5 | "bin-environment" => ( 6 | "PHP_FCGI_CHILDREN" => "16", 7 | "PHP_FCGI_MAX_REQUESTS" => "10000" 8 | ), 9 | "bin-copy-environment" => ( 10 | "PATH", "SHELL", "USER" 11 | ), 12 | "broken-scriptfilename" => "enable" 13 | ))) 14 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/linecontinuation.py: -------------------------------------------------------------------------------- 1 | apple.filter(x, y) 2 | apple.\ 3 | filter(x, y) 4 | 5 | 1 \ 6 | . \ 7 | __str__ 8 | 9 | from os import path 10 | from \ 11 | os \ 12 | import \ 13 | path 14 | 15 | import os.path as something 16 | 17 | import \ 18 | os.path \ 19 | as \ 20 | something 21 | 22 | class \ 23 | Spam: 24 | pass 25 | 26 | class Spam: pass 27 | 28 | class Spam(object): 29 | pass 30 | 31 | class \ 32 | Spam \ 33 | ( 34 | object 35 | ) \ 36 | : 37 | pass 38 | 39 | 40 | def \ 41 | spam \ 42 | ( \ 43 | ) \ 44 | : \ 45 | pass 46 | 47 | 48 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/multiline_regexes.rb: -------------------------------------------------------------------------------- 1 | / 2 | this is a 3 | multiline 4 | regex 5 | / 6 | 7 | this /is a 8 | multiline regex too/ 9 | 10 | foo = /is also 11 | one/ 12 | 13 | also /4 14 | is one/ 15 | 16 | this(/ 17 | too 18 | /) 19 | 20 | # this not 21 | 2 /4 22 | asfsadf/ 23 | 24 | # this is also not one 25 | 0x4d /25 26 | foo/ 27 | 28 | 42 and /this 29 | is also a multiline 30 | regex/ 31 | 32 | 33 | # And here some special string cases 34 | foo = % blah # comment here to ensure whitespace 35 | foo(% blah ) 36 | foo << % blah # stupid but has to work 37 | foo = % blah + % blub # wicked 38 | foo = %q wicked # works too 39 | -------------------------------------------------------------------------------- /examples/stateful-goroutines/stateful-goroutines.sh: -------------------------------------------------------------------------------- 1 | # Running our program shows that the goroutine-based 2 | # state management example achieves about 800,000 3 | # operations per second. 4 | $ go run stateful-goroutines.go 5 | ops: 807434 6 | 7 | # For this particular case the goroutine-based approach 8 | # was a bit more involved than the mutex-based one. It 9 | # might be useful in certain cases though, for example 10 | # where you have other channels involved or when managing 11 | # multiple such mutexes would be error-prone. You should 12 | # use whichever approach feels most natural, especially 13 | # with respect to understanding the correctness of your 14 | # program. 15 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/http_request_example: -------------------------------------------------------------------------------- 1 | POST /demo/submit/ HTTP/1.1 2 | Host: pygments.org 3 | Connection: keep-alivk 4 | Cache-Control: max-age=0 5 | Origin: http://pygments.org 6 | User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) 7 | AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7 8 | Content-Type: application/x-www-form-urlencoded 9 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 10 | Referer: http://pygments.org/ 11 | Accept-Encoding: gzip,deflate,sdch 12 | Accept-Language: en-US,en;q=0.8 13 | Accept-Charset: windows-949,utf-8;q=0.7,*;q=0.3 14 | 15 | name=test&lang=text&code=asdf&user= 16 | -------------------------------------------------------------------------------- /examples/slices/slices.sh: -------------------------------------------------------------------------------- 1 | # Note that while slices are different types than arrays, 2 | # they are rendered similarly by `fmt.Println`. 3 | $ go run slices.go 4 | emp: [ ] 5 | set: [a b c] 6 | get: c 7 | len: 3 8 | apd: [a b c d e f] 9 | cpy: [a b c d e f] 10 | sl1: [c d e] 11 | sl2: [a b c d e] 12 | sl3: [c d e f] 13 | dcl: [g h i] 14 | 2d: [[0] [1 2] [2 3 4]] 15 | 16 | # Check out this [great blog post](http://blog.golang.org/2011/01/go-slices-usage-and-internals.html) 17 | # by the Go team for more details on the design and 18 | # implementation of slices in Go. 19 | 20 | # Now that we've seen arrays and slices we'll look at 21 | # Go's other key builtin data structure: maps. 22 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/string_delimiters.d: -------------------------------------------------------------------------------- 1 | import std.stdio; 2 | 3 | void main() { 4 | // Nesting delimited strings 5 | auto a = q"{foo " {bar} baz}"; 6 | auto b = q"[foo [bar] " baz]"; 7 | auto c = q"(foo " (bar) baz)"; 8 | auto d = q"<foo <bar> " baz>"; 9 | // Non-nesting delimited strings 10 | auto e = q"/foo " bar/"; 11 | auto f = q"-Another " string-"; 12 | // "heredoc" strings 13 | auto g = q"FOO 14 | This is a string! 15 | FOO"; 16 | // Token strings (only the q{} should be highlighted as a string) 17 | auto h = q{ 18 | int i; 19 | void foo() { writefln("Hello, world!"); } 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /examples/functions/functions.go: -------------------------------------------------------------------------------- 1 | // _Functions_ are central in Go. We'll learn about 2 | // functions with a few different examples. 3 | 4 | package main 5 | 6 | import "fmt" 7 | 8 | // Here's a function that takes two `int`s and returns 9 | // their sum as an `int`. 10 | func plus(a int, b int) int { 11 | 12 | // Go requires explicit returns, i.e. it won't 13 | // automatically return the value of the last 14 | // expression. 15 | return a + b 16 | } 17 | 18 | func main() { 19 | 20 | // Call a function just as you'd expect, with 21 | // `name(args)`. 22 | res := plus(1, 2) 23 | fmt.Println("1+2 =", res) 24 | } 25 | 26 | // todo: coalesced parameter types 27 | -------------------------------------------------------------------------------- /examples/for/for.go: -------------------------------------------------------------------------------- 1 | // `for` is Go's only looping construct. Here are 2 | // three basic types of `for` loops. 3 | 4 | package main 5 | 6 | import "fmt" 7 | 8 | func main() { 9 | 10 | // The most basic type, with a single condition. 11 | i := 1 12 | for i <= 3 { 13 | fmt.Println(i) 14 | i = i + 1 15 | } 16 | 17 | // A classic initial/condition/after `for` loop. 18 | for j := 7; j <= 9; j++ { 19 | fmt.Println(j) 20 | } 21 | 22 | // `for` without a condition will loop repeatedly 23 | // until you `break` out of the loop or `return` from 24 | // the enclosing function. 25 | for { 26 | fmt.Println("loop") 27 | break 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/matlab_sample: -------------------------------------------------------------------------------- 1 | function zz=sample(aa) 2 | %%%%%%%%%%%%%%%%%% 3 | % some comments 4 | %%%%%%%%%%%%%%%%%% 5 | 6 | x = 'a string'; % some 'ticks' in a comment 7 | y = 'a string with ''interal'' quotes'; 8 | 9 | for i=1:20 10 | disp(i); 11 | end 12 | 13 | a = rand(30); 14 | b = rand(30); 15 | 16 | c = a .* b ./ a \ ... comment at end of line and continuation 17 | (b .* a + b - a); 18 | 19 | c = a' * b'; % note: these ticks are for transpose, not quotes. 20 | 21 | disp('a comment symbol, %, in a string'); 22 | 23 | !echo abc % this isn't a comment - it's passed to system command 24 | 25 | function y=myfunc(x) 26 | y = exp(x); 27 | 28 | {% 29 | a block comment 30 | %} 31 | -------------------------------------------------------------------------------- /examples/streaming-http-servers/streaming-http-servers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "time" 7 | ) 8 | 9 | func stream(resp http.ResponseWriter, req *http.Request) { 10 | respf, ok := resp.(http.Flusher) 11 | if !ok { 12 | panic("not flushable") 13 | } 14 | fmt.Println("stream") 15 | resp.WriteHeader(200) 16 | for i := 0; i < 10; i++ { 17 | n, err := resp.Write([]byte("tick\n")) 18 | respf.Flush() 19 | fmt.Println("tick", n, err) 20 | time.Sleep(time.Second * 1) 21 | } 22 | } 23 | 24 | func main() { 25 | http.HandleFunc("/", stream) 26 | fmt.Println("serve") 27 | http.ListenAndServe(":5000", nil) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.dart: -------------------------------------------------------------------------------- 1 | // Greeter example from 2 | // <http://www.dartlang.org/docs/getting-started/interface.html> 3 | class Greeter implements Comparable { 4 | String prefix = 'Hello,'; 5 | Greeter() {} 6 | Greeter.withPrefix(this.prefix); 7 | greet(String name) => print('$prefix $name'); 8 | 9 | int compareTo(Greeter other) => prefix.compareTo(other.prefix); 10 | } 11 | 12 | void main() { 13 | Greeter greeter = new Greeter(); 14 | Greeter greeter2 = new Greeter.withPrefix('Hi,'); 15 | 16 | num result = greeter2.compareTo(greeter); 17 | if (result == 0) { 18 | greeter2.greet('you are the same.'); 19 | } else { 20 | greeter2.greet('you are different.'); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/nasm_objexe.asm: -------------------------------------------------------------------------------- 1 | ; Demonstration of how to write an entire .EXE format program as a .OBJ 2 | ; file to be linked. Tested with the VAL free linker. 3 | ; To build: 4 | ; nasm -fobj objexe.asm 5 | ; val objexe.obj,objexe.exe; 6 | ; To test: 7 | ; objexe 8 | ; (should print `hello, world') 9 | 10 | segment code 11 | 12 | ..start: mov ax,data 13 | mov ds,ax 14 | mov ax,stack 15 | mov ss,ax 16 | mov sp,stacktop 17 | 18 | mov dx,hello 19 | mov ah,9 20 | int 0x21 21 | 22 | mov ax,0x4c00 23 | int 0x21 24 | 25 | segment data 26 | hello: db 'hello, world', 13, 10, '$' 27 | 28 | segment stack stack 29 | resb 64 30 | stacktop: 31 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.gdc: -------------------------------------------------------------------------------- 1 | # Execute the date dimension MAQL script 2 | ExecuteMaql(maqlFile="examples/quotes/quote_date.maql"); 3 | 4 | # load the stock quotes data file 5 | # the data file config has been generated 6 | LoadCsv(csvDataFile="examples/quotes/quotes.csv", 7 | header="true", 8 | configFile="examples/quotes/quotes.config.xml"); 9 | 10 | # transfer the stock quotes data 11 | TransferLastSnapshot(); 12 | 13 | LoadGoogleAnalytics(configFile="examples/ga/ga.config.xml",username="example@gmail.com",password="******",profileId="ga:7468896",dimensions="ga:date|ga:browser|ga:browserVersion|ga:country|ga:isMobile",metrics="ga:bounces|ga:newVisits|ga:pageViews|ga:visits",startDate="2008-01-01",endDate="2010-06-15"); 14 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/aspx-cs_example: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" %> 2 | 3 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 4 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 5 | 6 | <script runat="server"> 7 | 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | Label1.Text = DateTime.Now.ToLongDateString(); 11 | } 12 | 13 | </script> 14 | 15 | <html xmlns="http://www.w3.org/1999/xhtml"> 16 | <head runat="server"> 17 | <title>Sample page 18 | 19 | 20 |
21 |
22 | The current time is: 23 |
24 |
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.p: -------------------------------------------------------------------------------- 1 | {include.i} 2 | {nested.i {include.i}} 3 | 4 | &SCOPED-DEFINE MY_NAME "Abe" 5 | 6 | DEF VAR i AS INT NO-UNDO. 7 | i = 0xABE + 1337 / (1 * 1.00) 8 | 9 | def var clowercasetest as char no-undo. 10 | DEF VAR vardashtest AS DATETIME-TZ NO-UNDO. 11 | 12 | DEFINE TEMP-TABLE ttNames NO-UNDO 13 | FIELD cName AS CHAR 14 | INDEX IXPK_ttNames IS PRIMARY UNIQUE cName. 15 | 16 | /* One-line comment */ 17 | /* Two-line 18 | Comment */ 19 | /* 20 | Nested 21 | /* 22 | Multiline 23 | /* 24 | Comment 25 | */ 26 | */ 27 | */ 28 | 29 | CREATE ttNames. 30 | ASSIGN ttNames.cName = {&MY_NAME}. 31 | 32 | FOR EACH ttNames: 33 | MESSAGE "Hello, " + ttNames.cName + '!' VIEW-AS ALERT-BOX. 34 | END. 35 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.jsp: -------------------------------------------------------------------------------- 1 | 2 | <%= var x = 1; 3 | %> 4 | <%! int i = 0; %> 5 | <%! int a, b, c; %> 6 | <%! Circle a = new Circle(2.0); %> 7 | 8 | <% 9 | String name = null; 10 | if (request.getParameter("name") == null) { 11 | %> 12 | <%@ include file="error.html" %> 13 | <% 14 | } else { 15 | foo.setName(request.getParameter("name")); 16 | if (foo.getName().equalsIgnoreCase("integra")) 17 | name = "acura"; 18 | if (name.equalsIgnoreCase( "acura" )) { 19 | %> 20 | 21 | 22 |

23 | Calendar of 24 |

25 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/sqlite3.sqlite3-console: -------------------------------------------------------------------------------- 1 | SQLite version 3.4.2 2 | Enter ".help" for instructions 3 | sqlite> .schema 4 | CREATE TABLE paste (paste_id integer, code text, parsed_code text, pub_date 5 | varchar(24), language varchar(64), parent_id integer, url varchar(128)); 6 | CREATE TABLE vars (key varchar(24), value varchar(128)); 7 | sqlite> a ' 8 | ...> ' 9 | ...> ; 10 | SQL error: near "a": syntax error 11 | sqlite> %; 12 | SQL error: near "%": syntax error 13 | sqlite> select count(language), language from paste group by language order 14 | ...> by count(language) desc; 15 | 144|python 16 | 76|text 17 | 22|pycon 18 | 9|ruby 19 | 7|c 20 | 7|js 21 | 6|html+django 22 | 4|html 23 | 4|tex 24 | 2|html+php 25 | 1|cpp 26 | 1|scheme 27 | sqlite> 28 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example2.aspx: -------------------------------------------------------------------------------- 1 | <%@ Register TagPrefix="Acme" TagName="Message" Src="userctrl2_vb.ascx" %> 2 | 3 | 4 | 5 | 13 | 14 | 15 | 16 |

A Simple User Control w/ Properties

17 | 18 |
19 | 20 | 21 | 22 |

23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/addressbook.proto: -------------------------------------------------------------------------------- 1 | // See README.txt for information and build instructions. 2 | 3 | package tutorial; 4 | 5 | option java_package = "com.example.tutorial"; 6 | option java_outer_classname = "AddressBookProtos"; 7 | 8 | message Person { 9 | required string name = 1; 10 | required int32 id = 2; // Unique ID number for this person. 11 | optional string email = 3; 12 | 13 | enum PhoneType { 14 | MOBILE = 0; 15 | HOME = 1; 16 | WORK = 2; 17 | } 18 | 19 | message PhoneNumber { 20 | required string number = 1; 21 | optional PhoneType type = 2 [default = HOME]; 22 | } 23 | 24 | repeated PhoneNumber phone = 4; 25 | } 26 | 27 | // Our address book file is just one of these. 28 | message AddressBook { 29 | repeated Person person = 1; 30 | } 31 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.weechatlog: -------------------------------------------------------------------------------- 1 | **** Beginning of log 2007 Sep 01 00:23:55 **** 2 | 2007 Sep 01 00:23:55 --> weechat_user (weechat@localhost.) ist in den Channel &bitlbee gekommen 3 | 2007 Sep 01 00:23:55 -=- Modus &bitlbee [+t] durch localhost. 4 | 2007 Sep 01 00:23:55 -@- Nicks &bitlbee: [@root @weechat_user] 5 | 2007 Sep 01 00:23:55 -=- Channel &bitlbee: 2 Nicks (2 Operatoren, 0 Halb-Operator, 0 Gevoiceter, 0 normal) 6 | 2007 Sep 01 00:23:55 -=- Das Topic von &bitlbee lautet: "Welcome to the control channel. Type help for help information." 7 | 2007 Sep 01 00:23:55 Welcome to the BitlBee gateway! 8 | 2007 Sep 01 00:23:55 9 | 2007 Sep 01 00:23:55 If you've never used BitlBee before, please do read the help information using the help command. Lots of FAQ's are answered there. -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/condensed_ruby.rb: -------------------------------------------------------------------------------- 1 | # Server: ruby p2p.rb password server server-uri merge-servers 2 | # Sample: ruby p2p.rb foobar server druby://localhost:1337 druby://foo.bar:1337 3 | # Client: ruby p2p.rb password client server-uri download-pattern 4 | # Sample: ruby p2p.rb foobar client druby://localhost:1337 *.rb 5 | require'drb';F,D,C,P,M,U,*O=File,Class,Dir,*ARGV;def s(p)F.split(p[/[^|].*/])[-1 6 | ]end;def c(u);DRbObject.new((),u)end;def x(u)[P,u].hash;end;M=="client"&&c(U).f( 7 | x(U)).each{|n|p,c=x(n),c(n);(c.f(p,O[0],0).map{|f|s f}-D["*"]).each{|f|F.open(f, 8 | "w"){|o|o< 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/sorting/sorting.go: -------------------------------------------------------------------------------- 1 | // Go's `sort` package implements sorting for builtins 2 | // and user-defined types. We'll look at sorting for 3 | // builtins first. 4 | 5 | package main 6 | 7 | import "fmt" 8 | import "sort" 9 | 10 | func main() { 11 | 12 | // Sort methods are specific to the builtin type; 13 | // here's an example for strings. Note that sorting is 14 | // in-place, so it changes the given slice and doesn't 15 | // return a new one. 16 | strs := []string{"c", "a", "b"} 17 | sort.Strings(strs) 18 | fmt.Println("Strings:", strs) 19 | 20 | // An example of sorting `int`s. 21 | ints := []int{7, 2, 4} 22 | sort.Ints(ints) 23 | fmt.Println("Ints: ", ints) 24 | 25 | // We can also use `sort` to check if a slice is 26 | // already in sorted order. 27 | s := sort.IntsAreSorted(ints) 28 | fmt.Println("Sorted: ", s) 29 | } 30 | -------------------------------------------------------------------------------- /examples/command-line-arguments/command-line-arguments.go: -------------------------------------------------------------------------------- 1 | // [_Command-line arguments_](http://en.wikipedia.org/wiki/Command-line_interface#Arguments) 2 | // are a common way to parameterize execution of programs. 3 | // For example, `go run hello.go` uses `run` and 4 | // `hello.go` arguments to the `go` program. 5 | 6 | package main 7 | 8 | import "os" 9 | import "fmt" 10 | 11 | func main() { 12 | 13 | // `os.Args` provides access to raw command-line 14 | // arguments. Note that the first value in this slice 15 | // is the path to the program, and `os.Args[1:]` 16 | // holds the arguments to the program. 17 | argsWithProg := os.Args 18 | argsWithoutProg := os.Args[1:] 19 | 20 | // You can get individual args with normal indexing. 21 | arg := os.Args[3] 22 | 23 | fmt.Println(argsWithProg) 24 | fmt.Println(argsWithoutProg) 25 | fmt.Println(arg) 26 | } 27 | -------------------------------------------------------------------------------- /examples/channel-buffering/channel-buffering.go: -------------------------------------------------------------------------------- 1 | // By default channels are _unbuffered_, meaning that they 2 | // will only accept sends (`chan <-`) if there is a 3 | // corresponding receive (`<- chan`) ready to receive the 4 | // sent value. _Buffered channels_ accept a limited 5 | // number of values without a corresponding receiver for 6 | // those values. 7 | 8 | package main 9 | 10 | import "fmt" 11 | 12 | func main() { 13 | 14 | // Here we `make` a channel of strings buffering up to 15 | // 2 values. 16 | messages := make(chan string, 2) 17 | 18 | // Because this channel is buffered, we can send these 19 | // values into the channel without a corresponding 20 | // concurrent receive. 21 | messages <- "buffered" 22 | messages <- "channel" 23 | 24 | // Later we can receive these two values as usual. 25 | fmt.Println(<-messages) 26 | fmt.Println(<-messages) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/demo.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Date Functions 6 | 7 | 8 | 9 | 10 | #RightNow#
11 | #DateFormat(RightNow)#
12 | #DateFormat(RightNow,"mm/dd/yy")#
13 | #TimeFormat(RightNow)#
14 | #TimeFormat(RightNow,"hh:mm tt")#
15 | #IsDate(RightNow)#
16 | #IsDate("January 31, 2007")#
17 | #IsDate("foo")#
18 | #DaysInMonth(RightNow)# 19 |
20 | 21 | #x# 22 | #y# 23 | #z# 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/dwarf.cw: -------------------------------------------------------------------------------- 1 | ;redcode 2 | ;name Dwarf 3 | ;author A. K. Dewdney 4 | ;version 94.1 5 | ;date April 29, 1993 6 | ;strategy Bombs every fourth instruction. 7 | ORG start ; Indicates the instruction with 8 | ; the label "start" should be the 9 | ; first to execute. 10 | step EQU 4 ; Replaces all occurrences of "step" 11 | ; with the character "4". 12 | target DAT.F #0, #0 ; Pointer to target instruction. 13 | start ADD.AB #step, target ; Increments pointer by step. 14 | MOV.AB #0, @target ; Bombs target instruction. 15 | JMP.A start ; Same as JMP.A -2. Loops back to 16 | ; the instruction labelled "start". 17 | END 18 | -------------------------------------------------------------------------------- /examples/channel-directions/channel-directions.go: -------------------------------------------------------------------------------- 1 | // When using channels as function parameters, you can 2 | // specify if a channel is meant to only send or receive 3 | // values. This specificity increases the type-safety of 4 | // the program. 5 | 6 | package main 7 | 8 | import "fmt" 9 | 10 | // This `ping` function only accepts a channel for sending 11 | // values. It would be a compile-time error to try to 12 | // receive on this channel. 13 | func ping(pings chan<- string, msg string) { 14 | pings <- msg 15 | } 16 | 17 | // The `pong` function accepts one channel for receives 18 | // (`pings`) and a second for sends (`pongs`). 19 | func pong(pings <-chan string, pongs chan<- string) { 20 | msg := <-pings 21 | pongs <- msg 22 | } 23 | 24 | func main() { 25 | pings := make(chan string, 1) 26 | pongs := make(chan string, 1) 27 | ping(pings, "passed message") 28 | pong(pings, pongs) 29 | fmt.Println(<-pongs) 30 | } 31 | -------------------------------------------------------------------------------- /examples/channel-synchronization/channel-synchronization.go: -------------------------------------------------------------------------------- 1 | // We can use channels to synchronize execution 2 | // across goroutines. Here's an example of using a 3 | // blocking receive to wait for a goroutine to finish. 4 | 5 | package main 6 | 7 | import "fmt" 8 | import "time" 9 | 10 | // This is the function we'll run in a goroutine. The 11 | // `done` channel will be used to notify another 12 | // goroutine that this function's work is done. 13 | func worker(done chan bool) { 14 | fmt.Print("working...") 15 | time.Sleep(time.Second) 16 | fmt.Println("done") 17 | 18 | // Send a value to notify that we're done. 19 | done <- true 20 | } 21 | 22 | func main() { 23 | 24 | // Start a worker goroutine, giving it the channel to 25 | // notify on. 26 | done := make(chan bool, 1) 27 | go worker(done) 28 | 29 | // Block until we receive a notification from the 30 | // worker on the channel. 31 | <-done 32 | } 33 | -------------------------------------------------------------------------------- /examples/variadic-functions/variadic-functions.go: -------------------------------------------------------------------------------- 1 | // [_Variadic functions_](http://en.wikipedia.org/wiki/Variadic_function) 2 | // can be called with any number of trailing arguments. 3 | // For example, `fmt.Println` is a common variadic 4 | // function. 5 | 6 | package main 7 | 8 | import "fmt" 9 | 10 | // Here's a function that will take an arbitrary number 11 | // of `ints` as arguments. 12 | func sum(nums ...int) { 13 | fmt.Print(nums, " ") 14 | total := 0 15 | for _, num := range nums { 16 | total += num 17 | } 18 | fmt.Println(total) 19 | } 20 | 21 | func main() { 22 | 23 | // Variadic functions can be called in the usual way 24 | // with individual arguments. 25 | sum(1, 2) 26 | sum(1, 2, 3) 27 | 28 | // If you already have multiple args in a slice, 29 | // apply them to a variadic function using 30 | // `func(slice...)` like this. 31 | nums := []int{1, 2, 3, 4} 32 | sum(nums...) 33 | } 34 | -------------------------------------------------------------------------------- /examples/constants/constants.go: -------------------------------------------------------------------------------- 1 | // Go supports _constants_ of character, string, boolean, 2 | // and numeric values. 3 | 4 | package main 5 | 6 | import "fmt" 7 | import "math" 8 | 9 | // `const` declares a constant value. 10 | const s string = "constant" 11 | 12 | func main() { 13 | fmt.Println(s) 14 | 15 | // A `const` statement can appear anywhere a `var` 16 | // statement can. 17 | const n = 500000000 18 | 19 | // Constant expressions perform arithmetic with 20 | // arbitrary precision. 21 | const d = 3e20 / n 22 | fmt.Println(d) 23 | 24 | // A numeric constant has no type until it's given 25 | // one, such as by an explicit cast. 26 | fmt.Println(int64(d)) 27 | 28 | // A number can be given a type by using it in a 29 | // context that requires one, such as a variable 30 | // assignment or function call. For example, here 31 | // `math.Sin` expects a `float64`. 32 | fmt.Println(math.Sin(n)) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // __device__ function 4 | __device__ void func() 5 | { 6 | short* array0 = (short*)array; 7 | float* array1 = (float*)&array0[127]; 8 | } 9 | 10 | /* __global__ function */ 11 | __global__ static void reduction(const float* __restrict__ input, float *output, clock_t *timer) 12 | { 13 | // __shared__ float shared[2 * blockDim.x]; 14 | extern __shared__ float shared[]; 15 | 16 | const int tid = threadIdx.x; 17 | const int bid = blockIdx.x; 18 | 19 | if (threadIdx.x == 0) { 20 | __threadfence(); 21 | } 22 | 23 | // Perform reduction to find minimum. 24 | for (int d = blockDim.x; d > 0; d /= 2) 25 | { 26 | __syncthreads(); 27 | } 28 | } 29 | 30 | int main(int argc, char **argv) 31 | { 32 | dim3 dimBlock(8, 8, 1); 33 | 34 | timedReduction<<>>(dinput, doutput, dtimer); 35 | cudaDeviceReset(); 36 | } 37 | -------------------------------------------------------------------------------- /examples/if-else/if-else.go: -------------------------------------------------------------------------------- 1 | // Branching with `if` and `else` in Go is 2 | // straight-forward. 3 | 4 | package main 5 | 6 | import "fmt" 7 | 8 | func main() { 9 | 10 | // Here's a basic example. 11 | if 7%2 == 0 { 12 | fmt.Println("7 is even") 13 | } else { 14 | fmt.Println("7 is odd") 15 | } 16 | 17 | // You can have an `if` statement without an else. 18 | if 8%4 == 0 { 19 | fmt.Println("8 is divisible by 4") 20 | } 21 | 22 | // A statement can precede conditionals; any variables 23 | // declared in this statement are available in all 24 | // branches. 25 | if num := 9; num < 0 { 26 | fmt.Println(num, "is negative") 27 | } else if num < 10 { 28 | fmt.Println(num, "has 1 digit") 29 | } else { 30 | fmt.Println(num, "has multiple digits") 31 | } 32 | } 33 | 34 | // Note that you don't need parentheses around conditions 35 | // in Go, but that the brackets are required. 36 | -------------------------------------------------------------------------------- /examples/channels/channels.go: -------------------------------------------------------------------------------- 1 | // _Channels_ are the pipes that connect concurrent 2 | // goroutines. You can send values into channels from one 3 | // goroutine and receive those values into another 4 | // goroutine. Channels are a powerful primitive that 5 | // underly much of Go's functionality. 6 | 7 | package main 8 | 9 | import "fmt" 10 | 11 | func main() { 12 | 13 | // Create a new channel with `make(chan val-type)`. 14 | // Channels are typed by the values they convey. 15 | messages := make(chan string) 16 | 17 | // _Send_ a value into a channel using the `channel <-` 18 | // syntax. Here we send `"ping"` to the `messages` 19 | // channel we made above, from a new goroutine. 20 | go func() { messages <- "ping" }() 21 | 22 | // The `<-channel` syntax _receives_ a value from the 23 | // channel. Here we'll receive the `"ping"` message 24 | // we sent above and print it out. 25 | msg := <-messages 26 | fmt.Println(msg) 27 | } 28 | -------------------------------------------------------------------------------- /examples/variables/variables.go: -------------------------------------------------------------------------------- 1 | // In Go, _variables_ are explicitly declared and used by 2 | // the compiler to e.g. check type-correctness of function 3 | // calls. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | func main() { 10 | 11 | // `var` declares 1 or more variables. 12 | var a string = "initial" 13 | fmt.Println(a) 14 | 15 | // You can declare multiple variables at once. 16 | var b, c int = 1, 2 17 | fmt.Println(b, c) 18 | 19 | // Go will infer the type of initialized variables. 20 | var d = true 21 | fmt.Println(d) 22 | 23 | // Variables declared without a corresponding 24 | // initialization are _zero-valued_. For example, the 25 | // zero value for an `int` is `0`. 26 | var e int 27 | fmt.Println(e) 28 | 29 | // The `:=` syntax is shorthand for declaring and 30 | // initializing a variable, e.g. for 31 | // `var f string = "short"` in this case. 32 | f := "short" 33 | fmt.Println(f) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/pygments/docs/src/rstdirective.txt: -------------------------------------------------------------------------------- 1 | .. -*- mode: rst -*- 2 | 3 | ================================ 4 | Using Pygments in ReST documents 5 | ================================ 6 | 7 | Many Python people use `ReST`_ for documentation their sourcecode, programs, 8 | scripts et cetera. This also means that documentation often includes sourcecode 9 | samples or snippets. 10 | 11 | You can easily enable Pygments support for your ReST texts using a custom 12 | directive -- this is also how this documentation displays source code. 13 | 14 | From Pygments 0.9, the directive is shipped in the distribution as 15 | `external/rst-directive.py`. You can copy and adapt this code to your liking. 16 | 17 | .. removed -- too confusing 18 | *Loosely related note:* The ReST lexer now recognizes ``.. sourcecode::`` and 19 | ``.. code::`` directives and highlights the contents in the specified language 20 | if the `handlecodeblocks` option is true. 21 | 22 | .. _ReST: http://docutils.sf.net/rst.html 23 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.bas: -------------------------------------------------------------------------------- 1 | Public Class Form1 2 | Inherits System.Windows.Forms.Form 3 | 4 | Private t As New System.Timers.Timer(2000) 5 | 6 | Private Sub Form1_Load(ByVal sender As Object, _ 7 | ByVal e As System.EventArgs) Handles MyBase.Load 8 | 9 | AddHandler t.Elapsed, AddressOf TimerFired 10 | End Sub 11 | 12 | Private Sub btnStart_Click(ByVal sender As System.Object, _ 13 | ByVal e As System.EventArgs) Handles btnStart.Click 14 | 15 | t.Enabled = True 16 | End Sub 17 | 18 | Private Sub btnStop_Click(ByVal sender As System.Object, _ 19 | ByVal e As System.EventArgs) Handles btnStop.Click 20 | 21 | t.Enabled = False 22 | End Sub 23 | 24 | Public Sub TimerFired(ByVal sender As Object, _ 25 | ByVal e As System.Timers.ElapsedEventArgs) 26 | 27 | Label1.Text = "Signal Time = " & e.SignalTime.ToString 28 | End Sub 29 | End Class 30 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/truncated.pytb: -------------------------------------------------------------------------------- 1 | File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 314, in dispatch_request 2 | dispatcher.dispatch(req) 3 | File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 186, in dispatch 4 | req.session = Session(self.env, req) 5 | File "/usr/lib/python2.3/site-packages/trac/web/session.py", line 52, in __init__ 6 | self.promote_session(sid) 7 | File "/usr/lib/python2.3/site-packages/trac/web/session.py", line 125, in promote_session 8 | "AND authenticated=0", (sid,)) 9 | File "/usr/lib/python2.3/site-packages/trac/db/util.py", line 47, in execute 10 | return self.cursor.execute(sql_escape_percent(sql), args) 11 | File "/usr/lib/python2.3/site-packages/trac/db/sqlite_backend.py", line 44, in execute 12 | args or []) 13 | File "/usr/lib/python2.3/site-packages/trac/db/sqlite_backend.py", line 36, in _rollback_on_error 14 | return function(self, *args, **kwargs) 15 | OperationalError: database is locked 16 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/jbst_example1.jbst: -------------------------------------------------------------------------------- 1 | <%@ Control Name="MyApp.MyJbstControl" Language="JavaScript" %> 2 | 3 | 11 | 12 | <%! 13 | /* initialization code block, executed only once as control is loaded */ 14 | /* alternate syntax to script block above */ 15 | this.myInitTime = this.generateValue(); 16 | %> 17 | 18 | <% 19 | /* data binding code block, executed each time as control is data bound */ 20 | this.myBindTime = this.generateValue(); 21 | %> 22 | 23 | <%-- JBST Comment --%> 24 | <%= this.myBindTime /* data binding expression */ %> 25 | <%= this.myInitTime /* data binding expression */ %> 26 | 27 | 28 | <%$ Resources: localizationKey %><%-- JBST globalization--%> -------------------------------------------------------------------------------- /vendor/pygments/pygments/styles/rrt.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.rrt 4 | ~~~~~~~~~~~~~~~~~~~ 5 | 6 | pygments "rrt" theme, based on Zap and Emacs defaults. 7 | 8 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Comment, Name, Keyword, String 14 | 15 | 16 | class RrtStyle(Style): 17 | """ 18 | Minimalistic "rrt" theme, based on Zap and Emacs defaults. 19 | """ 20 | 21 | background_color = '#000000' 22 | highlight_color = '#0000ff' 23 | 24 | styles = { 25 | Comment: '#00ff00', 26 | Name.Function: '#ffff00', 27 | Name.Variable: '#eedd82', 28 | Name.Constant: '#7fffd4', 29 | Keyword: '#ff0000', 30 | Comment.Preproc: '#e5e5e5', 31 | String: '#87ceeb', 32 | Keyword.Type: '#ee82ee', 33 | } 34 | -------------------------------------------------------------------------------- /vendor/pygments/scripts/detect_missing_analyse_text.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from pygments.lexers import get_all_lexers, find_lexer_class 4 | from pygments.lexer import Lexer 5 | 6 | def main(): 7 | uses = {} 8 | 9 | for name, aliases, filenames, mimetypes in get_all_lexers(): 10 | cls = find_lexer_class(name) 11 | for f in filenames: 12 | if f not in uses: 13 | uses[f] = [] 14 | uses[f].append(cls) 15 | 16 | ret = 0 17 | for k, v in uses.iteritems(): 18 | if len(v) > 1: 19 | #print "Multiple for", k, v 20 | for i in v: 21 | if i.analyse_text is None: 22 | print i, "has a None analyse_text" 23 | ret |= 1 24 | elif Lexer.analyse_text.__doc__ == i.analyse_text.__doc__: 25 | print i, "needs analyse_text, multiple lexers for", k 26 | ret |= 2 27 | return ret 28 | 29 | if __name__ == '__main__': 30 | sys.exit(main()) 31 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/scilab.sci: -------------------------------------------------------------------------------- 1 | // Scilab ( http://www.scilab.org/ ) 2 | // Copyright (C) INRIA - Serge STEER 3 | // 4 | 5 | function I=sub2ind(dims,varargin) 6 | //sub2ind is used to determine the equivalent single index 7 | //corresponding to a given set of subscript values. 8 | 9 | //I = sub2ind(dims,i1,i2,..) returns the linear index equivalent to the 10 | //row, column, ... subscripts in the arrays i1,i2,.. for an matrix of 11 | //size dims. 12 | 13 | //I = sub2ind(dims,Mi) returns the linear index 14 | //equivalent to the n subscripts in the columns of the matrix Mi for a matrix 15 | //of size dims. 16 | 17 | d=[1;cumprod(matrix(dims(1:$-1),-1,1))] 18 | for i=1:size(varargin) 19 | if varargin(i)==[] then I=[],return,end 20 | end 21 | 22 | if size(varargin)==1 then //subindices are the columns of the argument 23 | I=(varargin(1)-1)*d+1 24 | else //subindices are given as separated arguments 25 | I=1 26 | for i=1:size(varargin) 27 | I=I+(varargin(i)-1)*d(i) 28 | end 29 | end 30 | endfunction 31 | -------------------------------------------------------------------------------- /vendor/pygments/tests/test_clexer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Basic CLexer Test 4 | ~~~~~~~~~~~~~~~~~ 5 | 6 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 7 | :license: BSD, see LICENSE for details. 8 | """ 9 | 10 | import unittest 11 | import os 12 | 13 | from pygments.token import Text, Number 14 | from pygments.lexers import CLexer 15 | 16 | 17 | class CLexerTest(unittest.TestCase): 18 | 19 | def setUp(self): 20 | self.lexer = CLexer() 21 | 22 | def testNumbers(self): 23 | code = '42 23.42 23. .42 023 0xdeadbeef 23e+42 42e-23' 24 | wanted = [] 25 | for item in zip([Number.Integer, Number.Float, Number.Float, 26 | Number.Float, Number.Oct, Number.Hex, 27 | Number.Float, Number.Float], code.split()): 28 | wanted.append(item) 29 | wanted.append((Text, ' ')) 30 | wanted = [(Text, '')] + wanted[:-1] + [(Text, '\n')] 31 | self.assertEqual(list(self.lexer.get_tokens(code)), wanted) 32 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.ceylon: -------------------------------------------------------------------------------- 1 | doc "A top-level function, 2 | with multi-line documentation." 3 | void topLevel(String? a, Integer b=5, String... seqs) { 4 | function nested(String s) { 5 | print(s[1..2]); 6 | return true; 7 | } 8 | for (s in seqs.filter((String x) x.size > 2)) { 9 | nested(s); 10 | } 11 | value uppers = seqs.sequence[].uppercased; 12 | String|Nothing z = a; 13 | Sequence ints = { 1, 2, 3, 4, 5 }; 14 | } 15 | 16 | shared class Example(name, element) satisfies Comparable> 17 | given Element satisfies Comparable { 18 | shared String name; 19 | shared Element element; 20 | 21 | shared actual Comparison compare(Example other) { 22 | return element <=> other.element; 23 | } 24 | 25 | shared actual String string { 26 | return "Example with " + element.string; 27 | } 28 | } 29 | 30 | Example instance = Example { 31 | name = "Named args call"; 32 | element = 5; 33 | }; 34 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/postgresql_test.txt: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION something() RETURNS int4 AS 2 | $x$ 3 | BEGIN 4 | RETURN 42; 5 | END 6 | $x$ 7 | LANGUAGE 'plpgsql'; 8 | 9 | CREATE FUNCTION pymax (a integer, b integer) 10 | RETURNS integer 11 | AS $$ 12 | if a > b: 13 | return a 14 | return b 15 | $$ language plpythonu; 16 | 17 | CREATE FUNCTION nested_lexers (a integer, b integer) 18 | $function$ 19 | BEGIN 20 | SELECT ($1 ~ $q$[\t\r\n\v\\]$q$); 21 | END; 22 | $function$ 23 | LANGUAGE sql; 24 | 25 | CREATE OR REPLACE FUNCTION measurement_insert_trigger() 26 | RETURNS TRIGGER AS $$ 27 | BEGIN 28 | <> 29 | INSERT INTO measurement_y2008m01 VALUES (NEW.*); 30 | RETURN NULL; 31 | END; 32 | $$ 33 | LANGUAGE plpgsql; 34 | 35 | -- As returned by pg_dump 36 | CREATE FUNCTION test_function() RETURNS integer 37 | LANGUAGE plpgsql STABLE STRICT 38 | AS $$ 39 | begin 40 | return 42; 41 | end 42 | $$; 43 | 44 | -- Unicode names and strings 45 | SELECT U&'\0441\043B\043E\043D' 46 | FROM U&"\0441\043B\043E\043D"; 47 | 48 | -------------------------------------------------------------------------------- /examples/tickers/tickers.go: -------------------------------------------------------------------------------- 1 | // [Timers](timers) are for when you want to do 2 | // something once in the future - _tickers_ are for when 3 | // you want to do something repeatedly at regular 4 | // intervals. Here's an example of a ticker that ticks 5 | // periodically until we stop it. 6 | 7 | package main 8 | 9 | import "time" 10 | import "fmt" 11 | 12 | func main() { 13 | 14 | // Tickers use a similar mechanism to timers: a 15 | // channel that is sent values. Here we'll use the 16 | // `range` builtin on the channel to iterate over 17 | // the values as they arrive every 500ms. 18 | ticker := time.NewTicker(time.Millisecond * 500) 19 | go func() { 20 | for t := range ticker.C { 21 | fmt.Println("Tick at", t) 22 | } 23 | }() 24 | 25 | // Tickers can be stopped like timers. Once a ticker 26 | // is stopped it won't receive any more values on its 27 | // channel. We'll stop ours after 1500ms. 28 | time.Sleep(time.Millisecond * 1500) 29 | ticker.Stop() 30 | fmt.Println("Ticker stopped") 31 | } 32 | -------------------------------------------------------------------------------- /examples/epoch/epoch.go: -------------------------------------------------------------------------------- 1 | // A common requirement in programs is getting the number 2 | // of seconds, milliseconds, or nanoseconds since the 3 | // [Unix epoch](http://en.wikipedia.org/wiki/Unix_time). 4 | // Here's how to do it in Go. 5 | 6 | package main 7 | 8 | import "fmt" 9 | import "time" 10 | 11 | func main() { 12 | 13 | // Use `time.Now` with `Unix` or `UnixNano` to get 14 | // elapsed time since the Unix epoch in seconds or 15 | // nanoseconds, respectively. 16 | now := time.Now() 17 | secs := now.Unix() 18 | nanos := now.UnixNano() 19 | fmt.Println(now) 20 | 21 | // Note that there is no `UnixMillis`, so to get the 22 | // milliseconds since epoch you'll need to manually 23 | // dive from nanoseconds. 24 | millis := nanos / 1000000 25 | fmt.Println(secs) 26 | fmt.Println(millis) 27 | fmt.Println(nanos) 28 | 29 | // You can also convert integer seconds or nanoseconds 30 | // since the epoch into the corresponding `time`. 31 | fmt.Println(time.Unix(secs, 0)) 32 | fmt.Println(time.Unix(0, nanos)) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/database.pytb: -------------------------------------------------------------------------------- 1 | Text before 2 | 3 | Traceback (most recent call last): 4 | File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 314, in dispatch_request 5 | dispatcher.dispatch(req) 6 | File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 186, in dispatch 7 | req.session = Session(self.env, req) 8 | File "/usr/lib/python2.3/site-packages/trac/web/session.py", line 52, in __init__ 9 | self.promote_session(sid) 10 | File "/usr/lib/python2.3/site-packages/trac/web/session.py", line 125, in promote_session 11 | "AND authenticated=0", (sid,)) 12 | File "/usr/lib/python2.3/site-packages/trac/db/util.py", line 47, in execute 13 | return self.cursor.execute(sql_escape_percent(sql), args) 14 | File "/usr/lib/python2.3/site-packages/trac/db/sqlite_backend.py", line 44, in execute 15 | args or []) 16 | File "/usr/lib/python2.3/site-packages/trac/db/sqlite_backend.py", line 36, in _rollback_on_error 17 | return function(self, *args, **kwargs) 18 | OperationalError: database is locked 19 | 20 | Text after 21 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.evoque: -------------------------------------------------------------------------------- 1 | $overlay{name=site_base} 2 | 3 | $begin{table_row} 4 | $for{ col in row } 5 | ${col}\ 6 | $else 7 | empty row 8 | $rof 9 | $end{table_row} 10 | 11 | 12 | $for{ i, row in enumerate(rows) } 13 | #[ "odd" rows get a special style ]# 14 | $evoque{#table_row} 15 | $evoque{ 16 | #table_row 17 | } 18 | $evoque{'#table_row'} 19 | $evoque{ '#table_row', collection=None, quoting="str"} 20 | $evoque{name="#table_row"} 21 | $evoque{name=var_table_row} 22 | $evoque{%#table_row%} 23 | $evoque{% #table_row %} 24 | 25 | $rof 26 |
27 | 28 | $evoque{disclaimer, collection="legals"} 29 | $evoque{ disclaimer , collection="legals", abc=123} 30 | $evoque{% disclaimer, collection="legals"%} 31 | 32 | $test{% site_base="site.html", 33 | rows=[("a", "b", 3.0, {"one":1}, "", "i", "j")] %} 34 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/r-console-transcript.Rout: -------------------------------------------------------------------------------- 1 | 2 | R version 2.9.2 (2009-08-24) 3 | Copyright (C) 2009 The R Foundation for Statistical Computing 4 | ISBN 3-900051-07-0 5 | 6 | R is free software and comes with ABSOLUTELY NO WARRANTY. 7 | You are welcome to redistribute it under certain conditions. 8 | Type 'license()' or 'licence()' for distribution details. 9 | 10 | Natural language support but running in an English locale 11 | 12 | R is a collaborative project with many contributors. 13 | Type 'contributors()' for more information and 14 | 'citation()' on how to cite R or R packages in publications. 15 | 16 | Type 'demo()' for some demos, 'help()' for on-line help, or 17 | 'help.start()' for an HTML browser interface to help. 18 | Type 'q()' to quit R. 19 | 20 | [R.app GUI 1.29 (5464) i386-apple-darwin8.11.1] 21 | 22 | > x <- function {} 23 | Error: syntax error 24 | > x <- function() {} 25 | > x <- function() { 26 | + cat("hello") 27 | + cat("world") 28 | + } 29 | > x 30 | function() { 31 | cat("hello") 32 | cat("world") 33 | } 34 | > x() 35 | helloworld 36 | > 2 + 2 37 | [1] 4 38 | > -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/squid.conf: -------------------------------------------------------------------------------- 1 | # Some multiline comments 2 | 3 | acl manager proto cache_object 4 | acl localhost src 127.0.0.1/32 ::1 5 | acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1 6 | acl SSL_ports port 443 7 | acl Safe_ports port 80 # http 8 | acl Safe_ports port 21 # ftp 9 | acl Safe_ports port 443 # https 10 | acl Safe_ports port 70 # gopher 11 | acl Safe_ports port 210 # wais 12 | acl Safe_ports port 1025-65535 # unregistered ports 13 | acl Safe_ports port 280 # http-mgmt 14 | acl Safe_ports port 488 # gss-http 15 | acl Safe_ports port 591 # filemaker 16 | acl Safe_ports port 777 # multiling http 17 | acl CONNECT method CONNECT 18 | http_access allow manager localhost 19 | http_access deny manager 20 | http_access deny !Safe_ports 21 | http_access deny CONNECT !SSL_ports 22 | http_access allow localhost 23 | http_access deny all 24 | http_port 3128 25 | hierarchy_stoplist cgi-bin ? 26 | coredump_dir /var/spool/squid3 27 | refresh_pattern ^ftp: 1440 20% 10080 28 | refresh_pattern ^gopher: 1440 0% 1440 29 | refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 30 | refresh_pattern . 0 20% 4320 31 | -------------------------------------------------------------------------------- /examples/goroutines/goroutines.go: -------------------------------------------------------------------------------- 1 | // A _goroutine_ is a lightweight thread of execution. 2 | 3 | package main 4 | 5 | import "fmt" 6 | 7 | func f(from string) { 8 | for i := 0; i < 3; i++ { 9 | fmt.Println(from, ":", i) 10 | } 11 | } 12 | 13 | func main() { 14 | 15 | // Suppose we have a function call `f(s)`. Here's how 16 | // we'd call that in the usual way, running it 17 | // synchronously. 18 | f("direct") 19 | 20 | // To invoke this function in a goroutine, use 21 | // `go f(s)`. This new goroutine will execute 22 | // concurrently with the calling one. 23 | go f("goroutine") 24 | 25 | // You can also start a goroutine for an anonymous 26 | // function call. 27 | go func(msg string) { 28 | fmt.Println(msg) 29 | }("going") 30 | 31 | // Our two goroutines are running asynchronously in 32 | // separate goroutines now, so execution falls through 33 | // to here. This `Scanln` code requires we press a key 34 | // before the program exits. 35 | var input string 36 | fmt.Scanln(&input) 37 | fmt.Println("done") 38 | } 39 | -------------------------------------------------------------------------------- /examples/methods/methods.go: -------------------------------------------------------------------------------- 1 | // Go supports _methods_ defined on struct types. 2 | 3 | package main 4 | 5 | import "fmt" 6 | 7 | type rect struct { 8 | width, height int 9 | } 10 | 11 | // This `area` method has a _receiver type_ of `*rect`. 12 | func (r *rect) area() int { 13 | return r.width * r.height 14 | } 15 | 16 | // Methods can be defined for either pointer or value 17 | // receiver types. Here's an example of a value receiver. 18 | func (r rect) perim() int { 19 | return 2*r.width + 2*r.height 20 | } 21 | 22 | func main() { 23 | r := rect{width: 10, height: 5} 24 | 25 | // Here we call the 2 methods defined for our struct. 26 | fmt.Println("area: ", r.area()) 27 | fmt.Println("perim:", r.perim()) 28 | 29 | // Go automatically handles conversion between values 30 | // and pointers for method calls. You may want to use 31 | // a pointer receiver type to avoid copying on method 32 | // calls or to allow the method to mutate the 33 | // receiving struct. 34 | rp := &r 35 | fmt.Println("area: ", rp.area()) 36 | fmt.Println("perim:", rp.perim()) 37 | } 38 | -------------------------------------------------------------------------------- /examples/canonical-hosts/canonical-hosts.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | import "strings" 5 | import "fmt" 6 | 7 | type handler http.HandlerFunc 8 | 9 | func hello(w http.ResponseWriter, r *http.Request) { 10 | w.Header().Set("Content-Type", "text/plain") 11 | fmt.Fprintln(w, "Hello canonical world") 12 | } 13 | 14 | func wrapCanonicalHost(f handler, chost string) handler { 15 | return func(w http.ResponseWriter, r *http.Request) { 16 | hostPort := strings.Split(r.Host, ":") 17 | host := hostPort[0] 18 | if host != chost { 19 | fmt.Println("redirect to", chost) 20 | hostPort[0] = chost 21 | url := "http://" + 22 | strings.Join(hostPort, ":") + 23 | r.URL.String() 24 | http.Redirect(w, r, url, 301) 25 | return 26 | } 27 | f(w, r) 28 | } 29 | } 30 | 31 | func main() { 32 | handler := wrapCanonicalHost(hello, "localhost") 33 | http.HandleFunc("/", handler) 34 | http.ListenAndServe(":5000", nil) 35 | } 36 | 37 | // todo: comment about https canonicalization 38 | -------------------------------------------------------------------------------- /examples/select/select.go: -------------------------------------------------------------------------------- 1 | // Go's _select_ lets you wait on multiple channel 2 | // operations. Combining goroutines and channels with 3 | // select is powerful feature of Go. 4 | 5 | package main 6 | 7 | import "time" 8 | import "fmt" 9 | 10 | func main() { 11 | 12 | // For our example we'll select across two channels. 13 | c1 := make(chan string) 14 | c2 := make(chan string) 15 | 16 | // Each channel will receive a value after some amount 17 | // of time, to simulate e.g. blocking RPC operations 18 | // executing in concurrent goroutines. 19 | go func() { 20 | time.Sleep(time.Second * 1) 21 | c1 <- "one" 22 | }() 23 | go func() { 24 | time.Sleep(time.Second * 2) 25 | c2 <- "two" 26 | }() 27 | 28 | // We'll use `select` to await both of these values 29 | // simultaneously, printing each one as it arrives. 30 | for i := 0; i < 2; i++ { 31 | select { 32 | case msg1 := <-c1: 33 | fmt.Println("received", msg1) 34 | case msg2 := <-c2: 35 | fmt.Println("received", msg2) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.moo: -------------------------------------------------------------------------------- 1 | if (this.running) 2 | player:tell("[Train] Error: already a jump in progress"); 3 | return; 4 | endif 5 | this.running = 1; 6 | this.aborted = 0; 7 | this:announce_all("[Train] departure in 20 seconds"); 8 | dest = this.targets[random(length(this.targets))]; 9 | this:announce_all("[Train] Next stop is '", dest:title(), "'"); 10 | this:announce_all("You hear the engines starting up"); 11 | this.location:announce("The MOOTrain starts up his engines"); 12 | suspend(20); 13 | if (this.aborted) 14 | this.running = 0; 15 | this.aborted = 0; 16 | return; 17 | endif 18 | this:announce_all("[Train] Departure!"); 19 | this.location:announce_all("The MOOTrain leaves into the 42th dimension!"); 20 | this:announce_all("Outside you see the lights of the 42th dimension"); 21 | this:moveto(dest); 22 | suspend(4); 23 | this:announce_all("The glowing gets less, until you can see the clear shape of the room, the MOOTrain has landed in"); 24 | this.location:announce_all("The MOOTrain arrives out of the 42th dimension!"); 25 | this:announce_all("[Train] arrived in '", dest:title(), "'"); 26 | this.running = 0; -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/livescript-demo.ls: -------------------------------------------------------------------------------- 1 | a = -> [1 to 50] 2 | const b = --> [2 til 5] 3 | var c = ~~> 10_000_000km * 500ms - 16~ff / 32~lol 4 | e = (a) -> (b) ~> (c) --> (d, e) ~~> <[list of words]> 5 | dashes-identifiers = -> 6 | a - a b -- c 1-1 1- -1 a- a a -a 7 | underscores_i$d = -> 8 | /regexp1/ 9 | //regexp2//g 10 | 'strings' and "strings" and \strings 11 | 12 | [2 til 10] 13 | |> map (* 2) 14 | |> filter (> 5) 15 | |> fold (+) 16 | 17 | obj = 18 | prop1: 1 19 | prop2: 2 20 | 21 | class Class extends Anc-est-or 22 | (args) -> 23 | <- # Comment 24 | <~ /* Comment */ 25 | void undefined yes no on off 26 | a.void b.undefined c.off d.if f.no g.not 27 | avoid bundefined coff dif fno gnot 28 | "inter #{2 + 2} #variable" 29 | '''HELLO 'world' ''' 30 | 31 | copy = (from, to, callback) --> 32 | error, data <- read file 33 | return callback error if error? 34 | error <~ write file, data 35 | return callback error if error? 36 | callback() 37 | 38 | take(n, [x, ...xs]:list) = 39 | | n <= 0 => [] 40 | | empty list => [] 41 | | otherwise => [x] +++ take n - 1, xs 42 | -------------------------------------------------------------------------------- /examples/request-logging/request-logging.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | import "time" 5 | import "fmt" 6 | 7 | func runLogging(logs chan string) { 8 | for log := range logs { 9 | fmt.Println(log) 10 | } 11 | } 12 | 13 | func wrapLogging(f http.HandlerFunc) http.HandlerFunc { 14 | logs := make(chan string, 10000) 15 | go runLogging(logs) 16 | return func(w http.ResponseWriter, r *http.Request) { 17 | start := time.Now() 18 | f(w, r) 19 | method := r.Method 20 | path := r.URL.Path 21 | elapsed := float64(time.Since(start)) / 1000000.0 22 | logs <- fmt.Sprintf( 23 | "method=%s path=%s elapsed=%f", 24 | method, path, elapsed) 25 | } 26 | } 27 | 28 | func hello(w http.ResponseWriter, r *http.Request) { 29 | w.Header().Set("Content-Type", "text/plain") 30 | time.Sleep(time.Millisecond * 50) 31 | fmt.Fprintln(w, "Hello logged world") 32 | } 33 | 34 | func main() { 35 | handler := wrapLogging(hello) 36 | http.HandleFunc("/", handler) 37 | http.ListenAndServe(":5000", nil) 38 | } 39 | 40 | // todo: logging status code? 41 | -------------------------------------------------------------------------------- /examples/structs/structs.go: -------------------------------------------------------------------------------- 1 | // Go's _structs_ are typed collections of fields. 2 | // They're useful for grouping data together to form 3 | // records. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | // This `person` struct type has `name` and `age` fields. 10 | type person struct { 11 | name string 12 | age int 13 | } 14 | 15 | func main() { 16 | 17 | // This syntax creates a new struct. 18 | fmt.Println(person{"Bob", 20}) 19 | 20 | // You can name the fields when initializing a struct. 21 | fmt.Println(person{name: "Alice", age: 30}) 22 | 23 | // Omitted fields will be zero-valued. 24 | fmt.Println(person{name: "Fred"}) 25 | 26 | // An `&` prefix yields a pointer to the struct. 27 | fmt.Println(&person{name: "Ann", age: 40}) 28 | 29 | // Access struct fields with a dot. 30 | s := person{name: "Sean", age: 50} 31 | fmt.Println(s.name) 32 | 33 | // You can also use dots with struct pointers - the 34 | // pointers are automatically dereferenced. 35 | sp := &s 36 | fmt.Println(sp.age) 37 | 38 | // Structs are mutable. 39 | sp.age = 51 40 | fmt.Println(sp.age) 41 | } 42 | -------------------------------------------------------------------------------- /tools/measure.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | "regexp" 9 | "strings" 10 | ) 11 | 12 | func check(err error) { 13 | if err != nil { 14 | panic(err) 15 | } 16 | } 17 | 18 | func readLines(path string) []string { 19 | srcBytes, err := ioutil.ReadFile(path) 20 | check(err) 21 | return strings.Split(string(srcBytes), "\n") 22 | } 23 | 24 | var commentPat = regexp.MustCompile("\\s*\\/\\/") 25 | 26 | func main() { 27 | sourcePaths, err := filepath.Glob("./examples/*/*") 28 | check(err) 29 | foundLongFile := false 30 | for _, sourcePath := range sourcePaths { 31 | foundLongLine := false 32 | lines := readLines(sourcePath) 33 | for i, line := range lines { 34 | if !foundLongLine && !commentPat.MatchString(line) && (len(line) > 58) { 35 | fmt.Printf("measure: %s:%d\n", sourcePath, i+1) 36 | foundLongLine = true 37 | foundLongFile = true 38 | } 39 | } 40 | } 41 | if foundLongFile { 42 | os.Exit(1) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.rhtml: -------------------------------------------------------------------------------- 1 | 2 | <% rows.each do |row| %> 3 | 4 | 5 | 6 | 7 | <% end %> 8 |
<%= item.title %><%= item.description %>
9 | 10 | 11 |

Pages

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | <% if @homepage -%> 23 | <%= render_node @homepage -%> 24 | <% else -%> 25 | 26 | 27 | 28 | <% end -%> 29 | 30 |
PageStatusModify
No Pages
31 | 36 |
37 |

38 | <% unless @homepage -%> 39 | <%= link_to image_tag('new-homepage', :alt => 'New Homepage'), homepage_new_url %> 40 | <% end -%> 41 | <%= image_submit_tag 'clear-page-cache' %> 42 |

43 |
44 | -------------------------------------------------------------------------------- /examples/environment-variables/environment-variables.go: -------------------------------------------------------------------------------- 1 | // [Environment variables](http://en.wikipedia.org/wiki/Environment_variable) 2 | // are a universal mechanism for [conveying configuration 3 | // information to Unix programs](http://www.12factor.net/config). 4 | // Let's look at how to set, get, and list environment variables. 5 | 6 | package main 7 | 8 | import "os" 9 | import "strings" 10 | import "fmt" 11 | 12 | func main() { 13 | 14 | // To set a key/value pair, use `os.Setenv`. To get a 15 | // value for a key, use `os.Getenv`. This will return 16 | // an empty string if the key isn't present in the 17 | // environment. 18 | os.Setenv("FOO", "1") 19 | fmt.Println("FOO:", os.Getenv("FOO")) 20 | fmt.Println("BAR:", os.Getenv("BAR")) 21 | 22 | // Use `os.Environ` to list all key/value pairs in the 23 | // environment. This returns a slice of strings in the 24 | // form `KEY=value`. You can `strings.Split` them to 25 | // get the key and value. Here we print all the keys. 26 | fmt.Println() 27 | for _, e := range os.Environ() { 28 | pair := strings.Split(e, "=") 29 | fmt.Println(pair[0]) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/pygments/tests/dtds/HTML4-f.dtd: -------------------------------------------------------------------------------- 1 | 20 | 25 | 26 | 27 | ... 28 | 29 | 30 | ... 31 | 32 | 33 | --> 34 | 35 | 36 | 37 | %HTML4.dtd; -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.kt: -------------------------------------------------------------------------------- 1 | package addressbook 2 | 3 | class Contact( 4 | val name : String, 5 | val emails : List, 6 | val addresses : List, 7 | val phonenums : List 8 | ) 9 | 10 | class EmailAddress( 11 | val user : String, 12 | val host : String 13 | ) 14 | 15 | class PostalAddress( 16 | val streetAddress : String, 17 | val city : String, 18 | val zip : String, 19 | val state : USState?, 20 | val country : Country 21 | ) { 22 | assert {(state == null) xor (country == Countries["US"]) } 23 | } 24 | 25 | class PhoneNumber( 26 | val country : Country, 27 | val areaCode : Int, 28 | val number : Long 29 | ) 30 | 31 | object Countries { 32 | fun get(id : CountryID) : Country = countryTable[id] 33 | 34 | private var table : Map? = null 35 | private val countryTable : Map 36 | get() { 37 | if (table == null) { 38 | table = HashMap() 39 | for (line in TextFile("countries.txt").lines(stripWhiteSpace = true)) { 40 | table[line] = Country(line) 41 | } 42 | } 43 | return table 44 | } 45 | } 46 | 47 | class Country(val name : String) -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 12pt; 3 | background: #fff url(temp.png) top left no-repeat; 4 | } 5 | 6 | * html body { 7 | font-size: 14pt; 8 | } 9 | 10 | #nav .new { 11 | display: block; 12 | -webkit-border-radius: 5px; 13 | -moz-border-radius: 5px; 14 | -ms-border-radius: 5px; 15 | -o-border-radius: 5px; 16 | border-radius: 5px; 17 | } 18 | 19 | ul#nav li.new { 20 | font-weight: bold; 21 | } 22 | 23 | :link { 24 | color: #f00; 25 | } 26 | 27 | :link:hover { 28 | color: #0f0; 29 | } 30 | 31 | @media screen { 32 | body { 33 | background: #ccc; 34 | } 35 | } 36 | 37 | @namespace "http://www.w3.org/1999/xhtml"; 38 | 39 | @import url("mystyle.css"); 40 | 41 | @charset "ISO-8859-1"; 42 | 43 | @font-face { font-family: "Example Font"; src: url("http://www.example.com/fonts/example"); } 44 | 45 | @media screen { body { font-size: 16px } } @media print { body { font-size: 12pt } } 46 | 47 | 48 | @page { body { margin: 1in 1.5in; } } 49 | 50 | @page linke-seite:left { body { margin:20mm; margin-right:25mm; } } 51 | 52 | @-moz-document url-prefix(http://pygments.org) { a {font-style: normal !important;} } 53 | 54 | 55 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.flx: -------------------------------------------------------------------------------- 1 | type tiny = "%i8"; 2 | type int = "%i32"; 3 | typedef bool = 2; 4 | fun add : int*int -> int = "%add"; 5 | fun sub : int*int -> int = "%sub"; 6 | fun eq : int*int -> bool = "%eq"; 7 | fun lnot : bool -> bool = "%lnot"; 8 | proc exit : int = "exit"; 9 | 10 | // comment 1 11 | /* 12 | /* 13 | foo bar 14 | */ 15 | asdas 16 | */ 17 | 18 | noinline fun foo (x:int) = { 19 | val y = 6; 20 | return x + y; 21 | } 22 | 23 | noinline proc fake_exit (x:int) { 24 | exit x; 25 | return; 26 | } 27 | 28 | noinline fun bar (x:int) = { 29 | var y = 10; 30 | noinline proc baz () { 31 | y = 20; 32 | return; 33 | } 34 | baz (); 35 | return x + y; 36 | } 37 | 38 | noinline fun x (a:int, b:int, c:tiny) = { 39 | val x1 = a; 40 | val x2 = b; 41 | val x3 = c; 42 | noinline fun y (d:int, e:int, f:tiny) = { 43 | val y1 = x1; 44 | val y2 = x2; 45 | val y3 = f; 46 | noinline fun z (g:int, h:int, i:tiny) = { 47 | val z1 = x1; 48 | val z2 = x2; 49 | val z3 = i; 50 | return z1; 51 | } 52 | return z (y1,y2,y3); 53 | } 54 | return y (x1,x2,x3); 55 | } 56 | 57 | fake_exit $ (foo 2) + (bar 3) + (x (1,2,3t)); 58 | -------------------------------------------------------------------------------- /examples/switch/switch.go: -------------------------------------------------------------------------------- 1 | // _Switch statements_ express conditionals across many 2 | // branches. 3 | 4 | package main 5 | 6 | import "fmt" 7 | import "time" 8 | 9 | func main() { 10 | 11 | // Here's a basic `switch`. 12 | i := 2 13 | fmt.Print("write ", i, " as ") 14 | switch i { 15 | case 1: 16 | fmt.Println("one") 17 | case 2: 18 | fmt.Println("two") 19 | case 3: 20 | fmt.Println("three") 21 | } 22 | 23 | // You can use commas to separate multiple expressions 24 | // in the same `case` statement. We use the optional 25 | // `default` case in this example as well. 26 | switch time.Now().Weekday() { 27 | case time.Saturday, time.Sunday: 28 | fmt.Println("it's the weekend") 29 | default: 30 | fmt.Println("it's a weekday") 31 | } 32 | 33 | // `switch` without an expression is an alternate way 34 | // to express if/else logic. Here we also show how the 35 | // `case` expressions can be non-constants. 36 | t := time.Now() 37 | switch { 38 | case t.Hour() < 12: 39 | fmt.Println("it's before noon") 40 | default: 41 | fmt.Println("it's after noon") 42 | } 43 | } 44 | 45 | // todo: type switches 46 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/batchfile.bat: -------------------------------------------------------------------------------- 1 | rem this is a demo file. 2 | @rem 3 | @echo off 4 | 5 | call c:\temp.bat somearg 6 | call :lab somearg 7 | rem This next one is wrong in the vim lexer! 8 | call c:temp.bat 9 | 10 | echo "Hi!" 11 | echo hi 12 | echo on 13 | echo off 14 | echo. 15 | @echo off 16 | if exist *.log echo The log file has arrived. 17 | rem These are all escapes, also done incorrectly by the vim lexer 18 | echo ^^ ^> ^< ^| 19 | 20 | x=beginning 21 | setlocal 22 | x = new text 23 | endlocal 24 | 25 | echo testrem x 26 | echo test rem x 27 | 28 | for %%var in (*.jpg) do echo %%var 29 | for /D %%var in (a b c) do echo %%var 30 | for /R C:\temp %%var in (*.jpg) do iexplore.exe %%var 31 | rem Vim has this one wrong too. 32 | for /L %%var in (10,-1,1) do echo %%var 33 | for /F %%var in ("hi!") do echo %%var 34 | for /F "eol=c,skip=1,usebackq" %%var in (`command`) do echo %%var %~l %~fl %~dl %~pl %~nl %~xl %~sl %~al %~tl %~zl %~$PATH:l %~dpl %~dp$PATH:l %~ftzal 35 | 36 | echo some file ?! > somefile.txt 37 | 38 | set PATH=%PATH%;c:\windows 39 | 40 | goto answer%errorlevel% 41 | :answer0 42 | echo Hi it's zero 43 | :answer1 44 | echo New 45 | 46 | if exist a del a 47 | else echo A is missing! 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/number-parsing/number-parsing.go: -------------------------------------------------------------------------------- 1 | // Parsing numbers from strings is a basic but common task 2 | // in many programs; here's how to do it in Go. 3 | 4 | package main 5 | 6 | // The built-in package `strconv` provides the number 7 | // parsing. 8 | import "strconv" 9 | import "fmt" 10 | 11 | func main() { 12 | 13 | // With `ParseFloat`, this `64` tells how many bits of 14 | // precision to parse. 15 | f, _ := strconv.ParseFloat("1.234", 64) 16 | fmt.Println(f) 17 | 18 | // For `ParseInt`, the `0` means infer the base from 19 | // the string. `64` requires that the result fit in 64 20 | // bits. 21 | i, _ := strconv.ParseInt("123", 0, 64) 22 | fmt.Println(i) 23 | 24 | // `ParseInt` will recognize hex-formatted numbers. 25 | d, _ := strconv.ParseInt("0x1c8", 0, 64) 26 | fmt.Println(d) 27 | 28 | // A `ParseUint` is also available. 29 | u, _ := strconv.ParseUint("789", 0, 64) 30 | fmt.Println(u) 31 | 32 | // `Atoi` is a convenience function for basic base-10 33 | // `int` parsing. 34 | k, _ := strconv.Atoi("135") 35 | fmt.Println(k) 36 | 37 | // Parse functions return an error on bad input. 38 | _, e := strconv.Atoi("wat") 39 | fmt.Println(e) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/pygments/external/pygments.bashcomp: -------------------------------------------------------------------------------- 1 | #!bash 2 | # 3 | # Bash completion support for Pygments (the 'pygmentize' command). 4 | # 5 | 6 | _pygmentize() 7 | { 8 | local cur prev 9 | 10 | COMPREPLY=() 11 | cur=`_get_cword` 12 | prev=${COMP_WORDS[COMP_CWORD-1]} 13 | 14 | case "$prev" in 15 | -f) 16 | FORMATTERS=`pygmentize -L formatters | grep '* ' | cut -c3- | sed -e 's/,//g' -e 's/:$//'` 17 | COMPREPLY=( $( compgen -W '$FORMATTERS' -- "$cur" ) ) 18 | return 0 19 | ;; 20 | -l) 21 | LEXERS=`pygmentize -L lexers | grep '* ' | cut -c3- | sed -e 's/,//g' -e 's/:$//'` 22 | COMPREPLY=( $( compgen -W '$LEXERS' -- "$cur" ) ) 23 | return 0 24 | ;; 25 | -S) 26 | STYLES=`pygmentize -L styles | grep '* ' | cut -c3- | sed s/:$//` 27 | COMPREPLY=( $( compgen -W '$STYLES' -- "$cur" ) ) 28 | return 0 29 | ;; 30 | esac 31 | 32 | if [[ "$cur" == -* ]]; then 33 | COMPREPLY=( $( compgen -W '-f -l -S -L -g -O -P -F \ 34 | -N -H -h -V -o' -- "$cur" ) ) 35 | return 0 36 | fi 37 | } 38 | complete -F _pygmentize -o default pygmentize 39 | -------------------------------------------------------------------------------- /examples/defer/defer.go: -------------------------------------------------------------------------------- 1 | // _Defer_ is used to ensure that a function call is 2 | // performed later in a program's execution, usually for 3 | // purposes of cleanup. `defer` is often used where e.g. 4 | // `ensure` and `finally` would be used in other languages. 5 | 6 | package main 7 | 8 | import "fmt" 9 | import "os" 10 | 11 | // Suppose we wanted to create a file, write to it, 12 | // and then close when we're done. Here's how we could 13 | // do that with `defer`. 14 | func main() { 15 | 16 | // Immediately after getting a file object with 17 | // `createFile`, we defer the closing of that file 18 | // with `closeFile`. This will be executed at the end 19 | // of the enclosing function (`main`), after 20 | // `writeFile` has finished. 21 | f := createFile("/tmp/defer.txt") 22 | defer closeFile(f) 23 | writeFile(f) 24 | } 25 | 26 | func createFile(p string) *os.File { 27 | fmt.Println("creating") 28 | f, err := os.Create(p) 29 | if err != nil { 30 | panic(err) 31 | } 32 | return f 33 | } 34 | 35 | func writeFile(f *os.File) { 36 | fmt.Println("writing") 37 | fmt.Fprintln(f, "data") 38 | 39 | } 40 | 41 | func closeFile(f *os.File) { 42 | fmt.Println("closing") 43 | f.Close() 44 | } 45 | -------------------------------------------------------------------------------- /vendor/pygments/pygments/styles/vs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.vs 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Simple style with MS Visual Studio colors. 7 | 8 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Operator, Generic 15 | 16 | 17 | class VisualStudioStyle(Style): 18 | 19 | background_color = "#ffffff" 20 | default_style = "" 21 | 22 | styles = { 23 | Comment: "#008000", 24 | Comment.Preproc: "#0000ff", 25 | Keyword: "#0000ff", 26 | Operator.Word: "#0000ff", 27 | Keyword.Type: "#2b91af", 28 | Name.Class: "#2b91af", 29 | String: "#a31515", 30 | 31 | Generic.Heading: "bold", 32 | Generic.Subheading: "bold", 33 | Generic.Emph: "italic", 34 | Generic.Strong: "bold", 35 | Generic.Prompt: "bold", 36 | 37 | Error: "border:#FF0000" 38 | } 39 | -------------------------------------------------------------------------------- /vendor/pygments/tests/test_using_api.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Pygments tests for using() 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 7 | :license: BSD, see LICENSE for details. 8 | """ 9 | 10 | import unittest 11 | 12 | from pygments.lexer import using, bygroups, this, RegexLexer 13 | from pygments.token import String, Text, Keyword 14 | 15 | class TestLexer(RegexLexer): 16 | tokens = { 17 | 'root': [ 18 | (r'#.*', 19 | using(this, state='invalid')), 20 | (r'(")(.+?)(")', 21 | bygroups(String, using(this, state='string'), String)), 22 | (r'[^"]+', Text), 23 | ], 24 | 'string': [ 25 | (r'.+', Keyword), 26 | ], 27 | } 28 | 29 | 30 | class UsingStateTest(unittest.TestCase): 31 | def test_basic(self): 32 | expected = [(Text, 'a'), (String, '"'), (Keyword, 'bcd'), 33 | (String, '"'), (Text, 'e\n')] 34 | t = list(TestLexer().get_tokens('a"bcd"e')) 35 | self.assertEqual(t, expected) 36 | 37 | def test_error(self): 38 | def gen(): 39 | return list(TestLexer().get_tokens('#a')) 40 | self.assertRaises(KeyError, gen) 41 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/classes.dylan: -------------------------------------------------------------------------------- 1 | define class () 2 | slot serial-number :: = unique-serial-number(); 3 | slot model-name :: , 4 | required-init-keyword: model:; 5 | slot has-sunroof? :: , 6 | init-keyword: sunroof?:, 7 | init-value: #f; 8 | end class ; 9 | 10 | define constant $empty-string = ""; 11 | define constant $escaped-backslash = '\\'; 12 | define constant $escaped-single-quote = '\''; 13 | 14 | define variable *unique-serial-number* = 0; 15 | 16 | define function unique-serial-number() => (usn :: ) 17 | let serial = *unique-serial-number*; 18 | *unique-serial-number* := *unique-serial-number* + 1; 19 | serial; 20 | end function; 21 | 22 | define constant $blue-car = make(, model: "Viper"); 23 | define constant $black-car = make(, model: "Town Car", sunroof?: #t); 24 | define constant $red-car = make(, model: "F40", sunroof?: #f); 25 | 26 | define method foo() => _ :: 27 | #t 28 | end method; 29 | 30 | define method foo() => _ :: ; 31 | #t 32 | end method; 33 | 34 | define method \+() 35 | end; 36 | 37 | define constant $symbol = #"hello"; 38 | define variable *vector* = #[3.5, 5] 39 | define constant $list = #(1, 2); 40 | define constant $pair = #(1 . "foo") 41 | -------------------------------------------------------------------------------- /examples/arrays/arrays.go: -------------------------------------------------------------------------------- 1 | // In Go, an _array_ is a numbered sequence of elements of a 2 | // specific length. 3 | 4 | package main 5 | 6 | import "fmt" 7 | 8 | func main() { 9 | 10 | // Here we create an array `a` that will hold exactly 11 | // 5 `int`s. The type of elements and length are both 12 | // part of the array's type. By default an array is 13 | // zero-valued, which for `int`s means `0`s. 14 | var a [5]int 15 | fmt.Println("emp:", a) 16 | 17 | // We can set a value at an index using the 18 | // `array[index] = value` syntax, and get a value with 19 | // `array[index]`. 20 | a[4] = 100 21 | fmt.Println("set:", a) 22 | fmt.Println("get:", a[4]) 23 | 24 | // The builtin `len` returns the length of an array. 25 | fmt.Println("len:", len(a)) 26 | 27 | // Use this syntax to declare and initialize an array 28 | // in one line. 29 | b := [5]int{1, 2, 3, 4, 5} 30 | fmt.Println("dcl:", b) 31 | 32 | // Array types are one-dimensional, but you can 33 | // compose types to build multi-dimensional data 34 | // structures. 35 | var twoD [2][3]int 36 | for i := 0; i < 2; i++ { 37 | for j := 0; j < 3; j++ { 38 | twoD[i][j] = i + j 39 | } 40 | } 41 | fmt.Println("2d: ", twoD) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/evil_regex.js: -------------------------------------------------------------------------------- 1 | /regexp/.test(foo) || x = [/regexp/,/regexp/, /regexp/, // comment 2 | // comment 3 | /regexp/]; 4 | if (/regexp/.test(string)) 5 | {/regexp/.test(string);}; 6 | x =/regexp/; 7 | x = /regexp/; 8 | if (0/regexp/.exec(string)) 9 | x = { u:/regexp/, v: /regexp/ }; 10 | foo();/regexp/.test(string); /regexp/.test(string); 11 | if (!/regexp/) foobar(); 12 | x = u %/regexp/.exec(string) */regexp/.exec(string) / /regexp/.exec(string); 13 | x = u?/regexp/.exec(string) : v +/regexp/.exec(string) -/regexp/.exec(string); 14 | a = u^/regexp/.exec(string) &/regexp/.exec(string) |/regexp/.exec(string) +~/regexp/.exec(string); 15 | x = /regexp/ /* a comment */ ; 16 | x = /[reg/exp]/; 17 | x = 4/2/i; 18 | x = (a == b) ?/* this is a comment */ c : d; 19 | /// a comment // 20 | a = /regex//2/1; //syntactically correct, returns NaN 21 | 22 | 23 | 24 | 25 | /* original examples */ 26 | 27 | // regex 28 | 29 | blah(/abc/); 30 | x = /abc/; 31 | x = /abc/.match; 32 | 33 | // math 34 | 35 | blah(1/2); //comment 36 | x = 1 / 2 / 3; 37 | x = 1/1/.1; 38 | 39 | // broken 40 | 41 | x=/1/; 42 | x=1/a/g; 43 | x=a/a/g; 44 | 45 | // real-world 46 | 47 | var x = 1/(1+Math.sqrt(sum)); // convert to number between 1-0 48 | return Math.round((num / den) * 100)/100; 49 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.msc: -------------------------------------------------------------------------------- 1 | msc { 2 | hscale=5; 3 | 4 | //test comment 5 | 6 | a,b,c,d; 7 | 8 | /* another 9 | comment 10 | goes here */ /* too */ // now 11 | 12 | ... [label="test1", id="1"]; 13 | --- [label="test2", id="2"]; 14 | ||| [label="test3", id="2"]; 15 | a ABOX b; 16 | a--b [label="test4", id="2"]; 17 | a == b [label="test5", id="2"]; 18 | a .. b [label="test6", id="2"]; 19 | a::b [label="test7", id="2"]; 20 | a<<=>> b [label="test8", id="2"], 21 | b <->c [label="test9", id="2"], 22 | b RBOX c; 23 | a BOX d; 24 | a<=> b [label="test10", id="2"]; 25 | a <<>> b [label="test11", id="2"]; 26 | a<:>b [label="test12", id="2"]; 27 | a->b [label="test13", id="2"]; 28 | a =>> b [label="test14", id="2"], 29 | b >> c [label="test15", id="2"], 30 | a=> b [label="test16", id="2"]; 31 | a :>b [label="test17", id="2"]; 32 | a-x b [label="test18", id="2"]; 33 | a -Xb [label="test19", id="2"]; 34 | a<- b [label="test20", id="2"]; 35 | a <<=b [label="test21", id="2"]; 36 | a<< b [label="test22", id="2"]; 37 | a <= b [label="test23", id="2"]; 38 | a<: b [label="test24", id="2"]; 39 | a -xb [label="test25", id="2"]; 40 | a-X b [ label="test26",id="2" ]; 41 | a->* [label="test27" , id="2"]; 42 | *<-b [label="test28",id="28"]; 43 | } 44 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.boo: -------------------------------------------------------------------------------- 1 | import System 2 | import Boo.Lang.Interpreter from Boo.Lang.Interpreter 3 | 4 | class ObjectInterpreter(AbstractInterpreter): 5 | 6 | _context as object 7 | 8 | [getter(Value)] 9 | _value as object 10 | 11 | def constructor(context): 12 | _context = context 13 | self.RememberLastValue = true 14 | 15 | override def Lookup(name as string): 16 | property = _context.GetType().GetProperty(name) 17 | return property.PropertyType if property is not null 18 | 19 | override def GetValue(name as string): 20 | return _context.GetType().GetProperty(name).GetValue( 21 | _context, null) 22 | 23 | override def SetLastValue(value): 24 | _value = value 25 | 26 | override def SetValue(name as string, value): 27 | raise InvalidOperationException() 28 | 29 | override def Declare(name as string, type as Type): 30 | raise InvalidOperationException() 31 | 32 | class Person: 33 | [property(FirstName)] 34 | _fname as string = "" 35 | 36 | p = Person(FirstName: "Homer") 37 | i = ObjectInterpreter(p) 38 | i.Eval('"Hello, ${FirstName.ToUpper()}!"') 39 | print i.Value 40 | -------------------------------------------------------------------------------- /examples/base64-encoding/base64-encoding.go: -------------------------------------------------------------------------------- 1 | // Go provides built-in support for [base64 2 | // encoding/decoding](http://en.wikipedia.org/wiki/Base64). 3 | 4 | package main 5 | 6 | // This syntax imports the `encoding/base64` package with 7 | // the `b64` name instead of the default `base64`. It'll 8 | // save us some space below. 9 | import b64 "encoding/base64" 10 | import "fmt" 11 | 12 | func main() { 13 | 14 | // Here's the `string` we'll encode/decode. 15 | data := "abc123!?$*&()'-=@~" 16 | 17 | // Go supports both standard and URL-compatible 18 | // base64. Here's how to encode using the standard 19 | // encoder. The encoder requires a `[]byte` so we 20 | // cast our `string` to that type. 21 | sEnc := b64.StdEncoding.EncodeToString([]byte(data)) 22 | fmt.Println(sEnc) 23 | 24 | // Decoding may return an error, which you can check 25 | // if you don't already know the input to be 26 | // well-formed. 27 | sDec, _ := b64.StdEncoding.DecodeString(sEnc) 28 | fmt.Println(string(sDec)) 29 | fmt.Println() 30 | 31 | // This encodes/decodes using a URL-compatible base64 32 | // format. 33 | uEnc := b64.URLEncoding.EncodeToString([]byte(data)) 34 | fmt.Println(uEnc) 35 | uDec, _ := b64.URLEncoding.DecodeString(uEnc) 36 | fmt.Println(string(uDec)) 37 | } 38 | -------------------------------------------------------------------------------- /examples/timers/timers.go: -------------------------------------------------------------------------------- 1 | // We often want to execute Go code at some point in the 2 | // future, or repeatedly at some interval. Go's built-in 3 | // _timer_ and _ticker_ features make both of these tasks 4 | // easy. We'll look first at timers and then 5 | // at [tickers](tickers). 6 | 7 | package main 8 | 9 | import "time" 10 | import "fmt" 11 | 12 | func main() { 13 | 14 | // Timers represent a single event in the future. You 15 | // tell the timer how long you want to wait, and it 16 | // provides a channel that will be notified at that 17 | // time. This timer will wait 2 seconds. 18 | timer1 := time.NewTimer(time.Second * 2) 19 | 20 | // The `<-timer1.C` blocks on the timer's channel `C` 21 | // until it sends a value indicating that the timer 22 | // expired. 23 | <-timer1.C 24 | fmt.Println("Timer 1 expired") 25 | 26 | // If you just wanted to wait, you could have used 27 | // `time.Sleep`. One reason a timer may be useful is 28 | // that you can cancel the timer before it expires. 29 | // Here's an example of that. 30 | timer2 := time.NewTimer(time.Second) 31 | go func() { 32 | <-timer2.C 33 | fmt.Println("Timer 2 expired") 34 | }() 35 | stop2 := timer2.Stop() 36 | if stop2 { 37 | fmt.Println("Timer 2 stopped") 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/closures/closures.go: -------------------------------------------------------------------------------- 1 | // Go supports [_anonymous functions_](http://en.wikipedia.org/wiki/Anonymous_function), 2 | // which can form closures. 3 | // Anonymous functions are useful when you want to define 4 | // a function inline without having to name it. 5 | 6 | package main 7 | 8 | import "fmt" 9 | 10 | // This function `intSeq` returns another function, which 11 | // we define anonymously in the body of `intSeq`. The 12 | // returned function _closes over_ the variable `i` to 13 | // form a closure. 14 | func intSeq() func() int { 15 | i := 0 16 | return func() int { 17 | i += 1 18 | return i 19 | } 20 | } 21 | 22 | func main() { 23 | 24 | // We call `intSeq`, assigning the result (a function) 25 | // to `nextInt`. This function value captures its 26 | // own `i` value, which will be updated each time 27 | // we call `nextInt`. 28 | nextInt := intSeq() 29 | 30 | // See the effect of the closure by calling `nextInt` 31 | // a few times. 32 | fmt.Println(nextInt()) 33 | fmt.Println(nextInt()) 34 | fmt.Println(nextInt()) 35 | 36 | // To confirm that the state is unique to that 37 | // particular function, create and test a new one. 38 | newInts := intSeq() 39 | fmt.Println(newInts()) 40 | } 41 | -------------------------------------------------------------------------------- /examples/sha1-hashes/sha1-hashes.go: -------------------------------------------------------------------------------- 1 | // [_SHA1 hashes_](http://en.wikipedia.org/wiki/SHA-1) are 2 | // frequently used to compute short identities for binary 3 | // or text blobs. For example, the [git revision control 4 | // system](http://git-scm.com/) uses SHA1s extensively to 5 | // identify versioned files and directories. Here's how to 6 | // compute SHA1 hashes in Go. 7 | 8 | package main 9 | 10 | // Go implements several hash functions in various 11 | // `crypto/*` packages. 12 | import "crypto/sha1" 13 | import "fmt" 14 | 15 | func main() { 16 | s := "sha1 this string" 17 | 18 | // The pattern for generating a hash is `sha1.New()`, 19 | // `sha1.Write(bytes)`, then `sha1.Sum([]byte{})`. 20 | // Here we start with a new hash. 21 | h := sha1.New() 22 | 23 | // `Write` expects bytes. If you have a string `s`, 24 | // use `[]byte(s)` to coerce it to bytes. 25 | h.Write([]byte(s)) 26 | 27 | // This gets the finalized hash result as a byte 28 | // slice. The argument to `Sum` can be used to append 29 | // to an existing byte slice: it usually isn't needed. 30 | bs := h.Sum(nil) 31 | 32 | // SHA1 values are often printed in hex, for example 33 | // in git commits. Use the `%x` format verb to convert 34 | // a hash results to a hex string. 35 | fmt.Println(s) 36 | fmt.Printf("%x\n", bs) 37 | } 38 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Go by Example: Not Found 6 | 7 | 8 | 20 | 21 |
22 |

Go by Example

23 |

Sorry, we couldn't find that! Check out the home page?

24 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /templates/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Go by Example: Not Found 6 | 7 | 8 | 20 | 21 |
22 |

Go by Example

23 |

Sorry, we couldn't find that! Check out the home page?

24 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/range/range.go: -------------------------------------------------------------------------------- 1 | // _range_ iterates over of elements in a variety of 2 | // data structures. Let's see how to use `range` with some 3 | // of the data structures we've already learned. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | func main() { 10 | 11 | // Here we use `range` to sum the numbers in a slice. 12 | // Arrays work like this too. 13 | nums := []int{2, 3, 4} 14 | sum := 0 15 | for _, num := range nums { 16 | sum += num 17 | } 18 | fmt.Println("sum:", sum) 19 | 20 | // `range` on arrays and slices provides both the 21 | // index and value for each entry. Above we didn't 22 | // need the index, so we ignored it with the 23 | // _blank identifier_ `_`. Sometimes we actually want 24 | // the indexes though. 25 | for i, num := range nums { 26 | if num == 3 { 27 | fmt.Println("index:", i) 28 | } 29 | } 30 | 31 | // `range` on map iterates over key/value pairs. 32 | kvs := map[string]string{"a": "apple", "b": "banana"} 33 | for k, v := range kvs { 34 | fmt.Printf("%s -> %s\n", k, v) 35 | } 36 | 37 | // `range` on strings iterates over Unicode code 38 | // points. The first value is the starting byte index 39 | // of the `rune` and the second the `rune` itself. 40 | for i, c := range "go" { 41 | fmt.Println(i, c) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/pointers/pointers.go: -------------------------------------------------------------------------------- 1 | // Go supports pointers, 2 | // allowing you to pass references to values and records 3 | // within your program. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | // We'll show how pointers work in contrast to values with 10 | // 2 functions: `zeroval` and `zeroptr`. `zeroval` has an 11 | // `int` parameter, so arguments will be passed to it by 12 | // value. `zeroval` will get a copy of `ival` distinct 13 | // from the one in the calling function. 14 | func zeroval(ival int) { 15 | ival = 0 16 | } 17 | 18 | // `zeroptr` in contrast has an `*int` parameter, meaning 19 | // that it takes an `int` pointer. The `*iptr` code in the 20 | // function body then _dereferences_ the pointer from its 21 | // memory address to the current value at that address. 22 | // Assigning a value to a dereferenced pointer changes the 23 | // value at the referenced address. 24 | func zeroptr(iptr *int) { 25 | *iptr = 0 26 | } 27 | 28 | func main() { 29 | i := 1 30 | fmt.Println("initial:", i) 31 | 32 | zeroval(i) 33 | fmt.Println("zeroval:", i) 34 | 35 | // The `&i` syntax gives the memory address of `i`, 36 | // i.e. a pointer to `i`. 37 | zeroptr(&i) 38 | fmt.Println("zeroptr:", i) 39 | 40 | // Pointers can be printed too. 41 | fmt.Println("pointer:", &i) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/pygments/docs/src/integrate.txt: -------------------------------------------------------------------------------- 1 | .. -*- mode: rst -*- 2 | 3 | =================================== 4 | Using Pygments in various scenarios 5 | =================================== 6 | 7 | PyGtk 8 | ----- 9 | 10 | Armin has written a piece of sample code that shows how to create a Gtk 11 | `TextBuffer` object containing Pygments-highlighted text. 12 | 13 | See the article here: http://lucumr.pocoo.org/cogitations/2007/05/30/pygments-gtk-rendering/ 14 | 15 | Wordpress 16 | --------- 17 | 18 | He also has a snippet that shows how to use Pygments in WordPress: 19 | 20 | http://lucumr.pocoo.org/cogitations/2007/05/30/pygments-in-wordpress/ 21 | 22 | Markdown 23 | -------- 24 | 25 | Since Pygments 0.9, the distribution ships Markdown_ preprocessor sample code 26 | that uses Pygments to render source code in `external/markdown-processor.py`. 27 | You can copy and adapt it to your liking. 28 | 29 | .. _Markdown: http://www.freewisdom.org/projects/python-markdown/ 30 | 31 | TextMate 32 | -------- 33 | 34 | Antonio Cangiano has created a Pygments bundle for TextMate that allows to 35 | colorize code via a simple menu option. It can be found here_. 36 | 37 | .. _here: http://antoniocangiano.com/2008/10/28/pygments-textmate-bundle/ 38 | 39 | Bash completion 40 | --------------- 41 | 42 | The source distribution contains a file ``external/pygments.bashcomp`` that 43 | sets up completion for the ``pygmentize`` command in bash. 44 | -------------------------------------------------------------------------------- /vendor/pygments/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2012 by the respective authors (see AUTHORS file). 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/pygments/docs/src/filters.txt: -------------------------------------------------------------------------------- 1 | .. -*- mode: rst -*- 2 | 3 | ======= 4 | Filters 5 | ======= 6 | 7 | *New in Pygments 0.7.* 8 | 9 | You can filter token streams coming from lexers to improve or annotate the 10 | output. For example, you can highlight special words in comments, convert 11 | keywords to upper or lowercase to enforce a style guide etc. 12 | 13 | To apply a filter, you can use the `add_filter()` method of a lexer: 14 | 15 | .. sourcecode:: pycon 16 | 17 | >>> from pygments.lexers import PythonLexer 18 | >>> l = PythonLexer() 19 | >>> # add a filter given by a string and options 20 | >>> l.add_filter('codetagify', case='lower') 21 | >>> l.filters 22 | [] 23 | >>> from pygments.filters import KeywordCaseFilter 24 | >>> # or give an instance 25 | >>> l.add_filter(KeywordCaseFilter(case='lower')) 26 | 27 | The `add_filter()` method takes keyword arguments which are forwarded to 28 | the constructor of the filter. 29 | 30 | To get a list of all registered filters by name, you can use the 31 | `get_all_filters()` function from the `pygments.filters` module that returns an 32 | iterable for all known filters. 33 | 34 | If you want to write your own filter, have a look at `Write your own filter`_. 35 | 36 | .. _Write your own filter: filterdevelopment.txt 37 | 38 | 39 | Builtin Filters 40 | =============== 41 | 42 | [builtin_filter_docs] 43 | -------------------------------------------------------------------------------- /examples/random-numbers/random-numbers.go: -------------------------------------------------------------------------------- 1 | // Go's `math/rand` package provides 2 | // [pseudorandom number](http://en.wikipedia.org/wiki/Pseudorandom_number_generator) 3 | // generation. 4 | 5 | package main 6 | 7 | import "fmt" 8 | import "math/rand" 9 | 10 | func main() { 11 | 12 | // For example, `rand.Intn` returns a random `int` n, 13 | // `0 <= n < 100`. 14 | fmt.Print(rand.Intn(100), ",") 15 | fmt.Print(rand.Intn(100)) 16 | fmt.Println() 17 | 18 | // `rand.Float64` returns a `float64` `f`, 19 | // `0.0 <= f < 1.0`. 20 | fmt.Println(rand.Float64()) 21 | 22 | // This can be used to generate random floats in 23 | // other ranges, for example `5.0 <= f' < 10.0`. 24 | fmt.Print((rand.Float64()*5)+5, ",") 25 | fmt.Print((rand.Float64() * 5) + 5) 26 | fmt.Println() 27 | 28 | // To make the pseudorandom generator deterministic, 29 | // give it a well-known seed. 30 | s1 := rand.NewSource(42) 31 | r1 := rand.New(s1) 32 | 33 | // Call the resulting `rand.Source` just like the 34 | // functions on the `rand` package. 35 | fmt.Print(r1.Intn(100), ",") 36 | fmt.Print(r1.Intn(100)) 37 | fmt.Println() 38 | 39 | // If you seed a source with the same number, it 40 | // produces the same sequence of random numbers. 41 | s2 := rand.NewSource(42) 42 | r2 := rand.New(s2) 43 | fmt.Print(r2.Intn(100), ",") 44 | fmt.Print(r2.Intn(100)) 45 | fmt.Println() 46 | } 47 | -------------------------------------------------------------------------------- /vendor/pygments/tests/run.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Pygments unit tests 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Usage:: 7 | 8 | python run.py [testfile ...] 9 | 10 | 11 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 12 | :license: BSD, see LICENSE for details. 13 | """ 14 | 15 | import sys, os 16 | 17 | if sys.version_info >= (3,): 18 | # copy test suite over to "build/lib" and convert it 19 | print ('Copying and converting sources to build/lib/test...') 20 | from distutils.util import copydir_run_2to3 21 | testroot = os.path.dirname(__file__) 22 | newroot = os.path.join(testroot, '..', 'build/lib/test') 23 | copydir_run_2to3(testroot, newroot) 24 | # make nose believe that we run from the converted dir 25 | os.chdir(newroot) 26 | else: 27 | # only find tests in this directory 28 | os.chdir(os.path.dirname(__file__)) 29 | 30 | 31 | try: 32 | import nose 33 | except ImportError: 34 | print ('nose is required to run the Pygments test suite') 35 | sys.exit(1) 36 | 37 | try: 38 | # make sure the current source is first on sys.path 39 | sys.path.insert(0, '..') 40 | import pygments 41 | except ImportError: 42 | print ('Cannot find Pygments to test: %s' % sys.exc_info()[1]) 43 | sys.exit(1) 44 | else: 45 | print ('Pygments %s test suite running (Python %s)...' % 46 | (pygments.__version__, sys.version.split()[0])) 47 | 48 | nose.main() 49 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.ns2: -------------------------------------------------------------------------------- 1 | Newsqueak2 2 | 'Langexplr 3 | ' 4 | 5 | class ShapesExperiment usingLib: platform = ( 6 | "A small experiment for using Hopscotch shape classes ." 7 | | 8 | CanvasDependent = platform CanvasDependent. 9 | Presenter = platform HPresenter. 10 | Subject = platform Subject. 11 | EllipseShape = platform EllipseShape. 12 | Color = platform Color. 13 | | 14 | ) 15 | ( 16 | 17 | class ShapesExperimentSubject = Subject( 18 | "Subject for shapes experiment" 19 | | 20 | 21 | | 22 | ) 23 | ('as yet unclassified' 24 | createPresenter = ( 25 | ^ShapesExperimentPresenter new subject: self. 26 | ) 27 | 28 | ) 29 | 30 | class ShapesExperimentPresenter = Presenter ( 31 | "A presenter for a small experiment of using shape classes" 32 | | 33 | | 34 | ) 35 | ('as yet unclassified' 36 | controlPoint = ( 37 | ^ControlPoint new. 38 | ) 39 | 40 | definition = ( 41 | ^ column: { 42 | canvas: { 43 | at: 10 @ 10 display: controlPoint. 44 | at: 15 @ 10 display: controlPoint. 45 | } 46 | } 47 | ) 48 | 49 | ) 50 | 51 | class ControlPoint = CanvasDependent( 52 | "A class that represents a small point in the screen" 53 | | 54 | | 55 | ) 56 | ('as yet unclassified' 57 | addVisualsTo: container = ( 58 | container add: visual. 59 | updateLayout. 60 | ) 61 | 62 | createVisual = ( 63 | | s | 64 | s:: EllipseShape new size: 5@5 . 65 | s color: Color red. 66 | ^ s 67 | ) 68 | 69 | )) 70 | -------------------------------------------------------------------------------- /vendor/pygments/tests/test_regexlexer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Pygments regex lexer tests 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 7 | :license: BSD, see LICENSE for details. 8 | """ 9 | 10 | import unittest 11 | 12 | from pygments.token import Text 13 | from pygments.lexer import RegexLexer 14 | from pygments.lexer import bygroups 15 | 16 | 17 | class TestLexer(RegexLexer): 18 | """Test tuple state transitions including #pop.""" 19 | tokens = { 20 | 'root': [ 21 | ('a', Text.Root, 'rag'), 22 | ('e', Text.Root), 23 | ], 24 | 'beer': [ 25 | ('d', Text.Beer, ('#pop', '#pop')), 26 | ], 27 | 'rag': [ 28 | ('b', Text.Rag, '#push'), 29 | ('c', Text.Rag, ('#pop', 'beer')), 30 | ], 31 | } 32 | 33 | 34 | class TupleTransTest(unittest.TestCase): 35 | def test(self): 36 | lx = TestLexer() 37 | toks = list(lx.get_tokens_unprocessed('abcde')) 38 | self.assertEqual(toks, 39 | [(0, Text.Root, 'a'), (1, Text.Rag, 'b'), (2, Text.Rag, 'c'), 40 | (3, Text.Beer, 'd'), (4, Text.Root, 'e')]) 41 | 42 | def test_multiline(self): 43 | lx = TestLexer() 44 | toks = list(lx.get_tokens_unprocessed('a\ne')) 45 | self.assertEqual(toks, 46 | [(0, Text.Root, 'a'), (1, Text, u'\n'), 47 | (2, Text.Root, 'e')]) 48 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/perl_misc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # from http://gist.github.com/485595 4 | use strict; 5 | use warnings; 6 | use Time::HiRes 'usleep'; 7 | 8 | for (1..5) { 9 | open my $in, '<', '/proc/sys/kernel/random/entropy_avail' or die; 10 | print <$in>; 11 | close $in; 12 | usleep 100_000; 13 | } 14 | 15 | # other miscellaneous tests of numbers separated by _ 16 | #usleep 100_000; 17 | 100_000_000; 18 | my $nichts = 0.005_006; 19 | print "$nichts\n"; 20 | my $nichts2 = 0.005_006_007; 21 | print 900_800_700.005_006_007, $/; 22 | 23 | # numbers from `man 1 perlnumber` 24 | my $n; 25 | $n = 1234; # decimal integer 26 | $n = 0b1110011; # binary integer 27 | $n = 01234; # octal integer 28 | $n = 0x1234; # hexadecimal integer 29 | $n = 12.34e-56; # exponential notation 30 | $n = "-12.34e56"; # number specified as a string 31 | $n = "1234"; # number specified as a string 32 | 33 | # other numbers 34 | for ( 35 | -9876, 36 | +8765, 37 | -9876.02, 38 | -9876.02e+10, 39 | +765_432e30, 40 | 2002., 41 | .2002, 42 | ) { 43 | print $_, "\n"; 44 | } 45 | 46 | # operators on numbers 47 | for ( 48 | $n + 300, 49 | $n - 300, 50 | $n / 300 + 10, 51 | $n * 250 / 2.0, 52 | $n == 100, 53 | $n != 100, 54 | $n > 100, 55 | $n >= 100, 56 | $n < 100, 57 | $n <= 100, 58 | $n % 2, 59 | abs $n, 60 | ) { 61 | print $_, "\n"; 62 | } 63 | -------------------------------------------------------------------------------- /examples/worker-pools/worker-pools.go: -------------------------------------------------------------------------------- 1 | // In this example we'll look at how to implement 2 | // a _worker pool_ using goroutines and channels. 3 | 4 | package main 5 | 6 | import "fmt" 7 | import "time" 8 | 9 | // Here's the worker, of which we'll run several 10 | // concurrent instances. These workers will receive 11 | // work on the `jobs` channel and send the corresponding 12 | // results on `results`. We'll sleep a second per job to 13 | // simulate an expensive task. 14 | func worker(id int, jobs <-chan int, results chan<- int) { 15 | for j := range jobs { 16 | fmt.Println("worker", id, "processing job", j) 17 | time.Sleep(time.Second) 18 | results <- j * 2 19 | } 20 | } 21 | 22 | func main() { 23 | 24 | // In order to use our pool of workers we need to send 25 | // them work and collect their results. We make 2 26 | // channels for this. 27 | jobs := make(chan int, 100) 28 | results := make(chan int, 100) 29 | 30 | // This starts up 3 workers, initially blocked 31 | // because there are no jobs yet. 32 | for w := 1; w <= 3; w++ { 33 | go worker(w, jobs, results) 34 | } 35 | 36 | // Here we send 9 `jobs` and then `close` that 37 | // channel to indicate that's all the work we have. 38 | for j := 1; j <= 9; j++ { 39 | jobs <- j 40 | } 41 | close(jobs) 42 | 43 | // Finally we collect all the results of the work. 44 | for a := 1; a <= 9; a++ { 45 | <-results 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/pygments/pygments/styles/fruity.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.fruity 4 | ~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | pygments version of my "fruity" vim theme. 7 | 8 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Token, Comment, Name, Keyword, \ 14 | Generic, Number, String, Whitespace 15 | 16 | class FruityStyle(Style): 17 | """ 18 | Pygments version of the "native" vim theme. 19 | """ 20 | 21 | background_color = '#111111' 22 | highlight_color = '#333333' 23 | 24 | styles = { 25 | Whitespace: '#888888', 26 | Token: '#ffffff', 27 | Generic.Output: '#444444 bg:#222222', 28 | Keyword: '#fb660a bold', 29 | Keyword.Pseudo: 'nobold', 30 | Number: '#0086f7 bold', 31 | Name.Tag: '#fb660a bold', 32 | Name.Variable: '#fb660a', 33 | Comment: '#008800 bg:#0f140f italic', 34 | Name.Attribute: '#ff0086 bold', 35 | String: '#0086d2', 36 | Name.Function: '#ff0086 bold', 37 | Generic.Heading: '#ffffff bold', 38 | Keyword.Type: '#cdcaa9 bold', 39 | Generic.Subheading: '#ffffff bold', 40 | Name.Constant: '#0086d2', 41 | Comment.Preproc: '#ff0007 bold' 42 | } 43 | -------------------------------------------------------------------------------- /examples.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | Values 3 | Variables 4 | Constants 5 | For 6 | If/Else 7 | Switch 8 | Arrays 9 | Slices 10 | Maps 11 | Range 12 | Functions 13 | Multiple Return Values 14 | Variadic Functions 15 | Closures 16 | Recursion 17 | Pointers 18 | Structs 19 | Methods 20 | Interfaces 21 | Errors 22 | Goroutines 23 | Channels 24 | Channel Buffering 25 | Channel Synchronization 26 | Channel Directions 27 | Select 28 | Timeouts 29 | Non-Blocking Channel Operations 30 | Closing Channels 31 | Range over Channels 32 | Timers 33 | Tickers 34 | Worker Pools 35 | Rate Limiting 36 | Atomic Counters 37 | Mutexes 38 | Stateful Goroutines 39 | Sorting 40 | Sorting by Functions 41 | Panic 42 | Defer 43 | Collection Functions 44 | String Functions 45 | String Formatting 46 | Regular Expressions 47 | JSON 48 | Time 49 | Epoch 50 | Time Formatting / Parsing 51 | Random Numbers 52 | Number Parsing 53 | URL Parsing 54 | SHA1 Hashes 55 | Base64 Encoding 56 | Reading Files 57 | Writing Files 58 | Line Filters 59 | Command-Line Arguments 60 | Command-Line Flags 61 | Environment Variables 62 | Spawning Processes 63 | Exec'ing Processes 64 | Signals 65 | Exit 66 | # HTTP Client 67 | # HTTPS Client 68 | # Redis 69 | # Postgres 70 | # Hello Web 71 | # Responses 72 | # Request Routing 73 | # Request Logging 74 | # Static Content 75 | # Basic Authentication 76 | # Canonical Hosts 77 | # Middleware 78 | # Graceful Shutdown 79 | # HTTPS Servers 80 | # Testing 81 | # CPU Profiling 82 | # Memory Profiling 83 | # Factoring Packages 84 | # Shipping Libraries 85 | # Shipping Commands 86 | -------------------------------------------------------------------------------- /examples/non-blocking-channel-operations/non-blocking-channel-operations.go: -------------------------------------------------------------------------------- 1 | // Basic sends and receives on channels are blocking. 2 | // However, we can use `select` with a `default` clause to 3 | // implement _non-blocking_ sends, receives, and even 4 | // non-blocking multi-way `select`s. 5 | 6 | package main 7 | 8 | import "fmt" 9 | 10 | func main() { 11 | messages := make(chan string) 12 | signals := make(chan bool) 13 | 14 | // Here's a non-blocking receive. If a value is 15 | // available on `messages` then `select` will take 16 | // the `<-messages` `case` with that value. If not 17 | // it will immediately take the `default` case. 18 | select { 19 | case msg := <-messages: 20 | fmt.Println("received message", msg) 21 | default: 22 | fmt.Println("no message received") 23 | } 24 | 25 | // A non-blocking send works similarly. 26 | msg := "hi" 27 | select { 28 | case messages <- msg: 29 | fmt.Println("sent message", msg) 30 | default: 31 | fmt.Println("no message sent") 32 | } 33 | 34 | // We can use multiple `case`s above the `default` 35 | // clause to implement a multi-way non-blocking 36 | // select. Here we attempt non-blocking receives 37 | // on both `messages` and `signals`. 38 | select { 39 | case msg := <-messages: 40 | fmt.Println("received message", msg) 41 | case sig := <-signals: 42 | fmt.Println("received signal", sig) 43 | default: 44 | fmt.Println("no activity") 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/sorting-by-functions/sorting-by-functions.go: -------------------------------------------------------------------------------- 1 | // Sometimes we'll want to sort a collection by something 2 | // other than its natural order. For example, suppose we 3 | // wanted to sort strings by their length instead of 4 | // alphabetically. Here's an example of custom sorts sorts 5 | // in Go. 6 | 7 | package main 8 | 9 | import "sort" 10 | import "fmt" 11 | 12 | // In order to sort by a custom function in Go, we need a 13 | // corresponding type. Here we've created a `ByLength` 14 | // type that is just an alias for the builtin `[]string` 15 | // type. 16 | type ByLength []string 17 | 18 | // We implement `sort.Interface` - `Len`, `Less`, and 19 | // `Swap` - on our type so we can use the `sort` package's 20 | // generic `Sort` function. `Len` and `Swap` 21 | // will usually be similar across types and `Less` will 22 | // hold the actual custom sorting logic. In our case we 23 | // want to sort in order of increasing string length, so 24 | // we use `len(s[i])` and `len(s[j])` here. 25 | func (s ByLength) Len() int { 26 | return len(s) 27 | } 28 | func (s ByLength) Swap(i, j int) { 29 | s[i], s[j] = s[j], s[i] 30 | } 31 | func (s ByLength) Less(i, j int) bool { 32 | return len(s[i]) < len(s[j]) 33 | } 34 | 35 | // With all of this in place, we can now implement our 36 | // custom sort by casting the original `fruits` slice to 37 | // `ByLength`, and then use `sort.Sort` on that typed 38 | // slice. 39 | func main() { 40 | fruits := []string{"peach", "banana", "kiwi"} 41 | sort.Sort(ByLength(fruits)) 42 | fmt.Println(fruits) 43 | } 44 | -------------------------------------------------------------------------------- /examples/maps/maps.go: -------------------------------------------------------------------------------- 1 | // _Maps_ are Go's built-in [associative data type](http://en.wikipedia.org/wiki/Associative_array) 2 | // (sometimes called _hashes_ or _dicts_ in other languages). 3 | 4 | package main 5 | 6 | import "fmt" 7 | 8 | func main() { 9 | 10 | // To create an empty map, use the builtin `make`: 11 | // `make(map[key-type]val-type)`. 12 | m := make(map[string]int) 13 | 14 | // Set key/value pairs using typical `name[key] = val` 15 | // syntax. 16 | m["k1"] = 7 17 | m["k2"] = 13 18 | 19 | // Printing a map with e.g. `Println` will show all of 20 | // its key/value pairs. 21 | fmt.Println("map:", m) 22 | 23 | // Get a value for a key with `name[key]`. 24 | v1 := m["k1"] 25 | fmt.Println("v1: ", v1) 26 | 27 | // The builtin `len` returns the number of key/value 28 | // pairs when called on a map. 29 | fmt.Println("len:", len(m)) 30 | 31 | // The builtin `delete` removes key/value pairs from 32 | // a map. 33 | delete(m, "k2") 34 | fmt.Println("map:", m) 35 | 36 | // The optional second return value when getting a 37 | // value from a map indicates if the key was present 38 | // in the map. This can be used to disambiguate 39 | // between missing keys and keys with zero values 40 | // like `0` or `""`. 41 | _, prs := m["k2"] 42 | fmt.Println("prs:", prs) 43 | 44 | // You can also declare and initialize a new map in 45 | // the same line with this syntax. 46 | n := map[string]int{"foo": 1, "bar": 2} 47 | fmt.Println("map:", n) 48 | } 49 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Single-line comment style. 4 | 5 | ;; Single-line comment style. 6 | 7 | #| Multi-line comment style ... on one line |# 8 | 9 | #| 10 | Multi-line comment style ... 11 | ... on multiple lines 12 | |# 13 | 14 | (define (a-function x #:keyword [y 0]) 15 | (define foo0 'symbol) ; () 16 | [define foo1 'symbol] ; [] 17 | {define foo2 'symbol} ; {} 18 | (and (append (car '(1 2 3)))) 19 | (regexp-match? #rx"foobar" "foobar") 20 | (regexp-match? #px"foobar" "foobar") 21 | (define a 1)) 22 | (let ([b "foo"]) 23 | (displayln b)) 24 | (for/list ([x (in-list (list 1 2 (list 3 4)))]) 25 | (cond 26 | [(pair? x) (car x)] 27 | [else x]))) 28 | 29 | ;; Literal number examples 30 | (values 31 | ;; #b 32 | #b1.1 33 | #b-1.1 34 | #b1e1 35 | #b0/1 36 | #b1/1 37 | #b1e-1 38 | #b101 39 | 40 | ;; #d 41 | #d-1.23 42 | #d1.123 43 | #d1e3 44 | #d1e-22 45 | #d1/2 46 | #d-1/2 47 | #d1 48 | #d-1 49 | 50 | ;; No # reader prefix -- same as #d 51 | -1.23 52 | 1.123 53 | 1e3 54 | 1e-22 55 | 1/2 56 | -1/2 57 | 1 58 | -1 59 | 60 | ;; #e 61 | #e-1.23 62 | #e1.123 63 | #e1e3 64 | #e1e-22 65 | #e1 66 | #e-1 67 | #e1/2 68 | #e-1/2 69 | 70 | ;; #i always float 71 | #i-1.23 72 | #i1.123 73 | #i1e3 74 | #i1e-22 75 | #i1/2 76 | #i-1/2 77 | #i1 78 | #i-1 79 | 80 | ;; #o 81 | #o777.777 82 | #o-777.777 83 | #o777e777 84 | #o777e-777 85 | #o3/7 86 | #o-3/7 87 | #o777 88 | #o-777 89 | 90 | ;; #x 91 | #x-f.f 92 | #xf.f 93 | #x-f 94 | #xf 95 | ) 96 | -------------------------------------------------------------------------------- /vendor/pygments/pygments/styles/bw.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | pygments.styles.bw 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Simple black/white only style. 7 | 8 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 9 | :license: BSD, see LICENSE for details. 10 | """ 11 | 12 | from pygments.style import Style 13 | from pygments.token import Keyword, Name, Comment, String, Error, \ 14 | Operator, Generic 15 | 16 | 17 | class BlackWhiteStyle(Style): 18 | 19 | background_color = "#ffffff" 20 | default_style = "" 21 | 22 | styles = { 23 | Comment: "italic", 24 | Comment.Preproc: "noitalic", 25 | 26 | Keyword: "bold", 27 | Keyword.Pseudo: "nobold", 28 | Keyword.Type: "nobold", 29 | 30 | Operator.Word: "bold", 31 | 32 | Name.Class: "bold", 33 | Name.Namespace: "bold", 34 | Name.Exception: "bold", 35 | Name.Entity: "bold", 36 | Name.Tag: "bold", 37 | 38 | String: "italic", 39 | String.Interpol: "bold", 40 | String.Escape: "bold", 41 | 42 | Generic.Heading: "bold", 43 | Generic.Subheading: "bold", 44 | Generic.Emph: "italic", 45 | Generic.Strong: "bold", 46 | Generic.Prompt: "bold", 47 | 48 | Error: "border:#FF0000" 49 | } 50 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/jbst_example2.jbst: -------------------------------------------------------------------------------- 1 | <%@ Control Name="Foo.MyZebraList" Language="JavaScript" %> 2 | 3 | 30 | 31 |
32 |

<%= this.data.title %> as of <%= this.formatTime(this.data.timestamp) %>!

33 |

<%= this.data.description %>

34 |
    35 | 36 | 37 | 38 | 39 |
  • 40 | <%= this.data.label %> (<%= this.index+1 %> of <%= this.count %>) 41 |
  • 42 |
    43 | 44 |
45 |
-------------------------------------------------------------------------------- /examples/signals/signals.go: -------------------------------------------------------------------------------- 1 | // Sometines we'd like our Go programs to intelligently 2 | // handle [Unix signals](http://en.wikipedia.org/wiki/Unix_signal). 3 | // For example, we might want a server to gracefully 4 | // shutdown when it receives a `SIGTERM`, or a command-line 5 | // tool to stop processing input if it receives a `SIGINT`. 6 | // Here's how to handle signals in Go with channels. 7 | 8 | package main 9 | 10 | import "fmt" 11 | import "os" 12 | import "os/signal" 13 | import "syscall" 14 | 15 | func main() { 16 | 17 | // Go signal notification works by sending `os.Signal` 18 | // values on a channel. We'll create a channel to 19 | // receive these notifications (we'll also make one to 20 | // notify us when the program can exit.) 21 | sigs := make(chan os.Signal, 1) 22 | done := make(chan bool, 1) 23 | 24 | // `signal.Notify` registers the given channel to 25 | // receive notifications of the specified signals. 26 | signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) 27 | 28 | // This goroutine executes a blocking receive for 29 | // signals. When it gets one it'll print it out 30 | // and then notify the program that it can finish. 31 | go func() { 32 | sig := <-sigs 33 | fmt.Println() 34 | fmt.Println(sig) 35 | done <- true 36 | }() 37 | 38 | // The program will wait here until it gets the 39 | // expected signal (as indicated by the goroutine 40 | // above sending a value on `done`) and then exit. 41 | fmt.Println("awaiting signal") 42 | <-done 43 | fmt.Println("exiting") 44 | } 45 | -------------------------------------------------------------------------------- /examples/timeouts/timeouts.go: -------------------------------------------------------------------------------- 1 | // _Timeouts_ are important for programs that connect to 2 | // external resources or that otherwise need to bound 3 | // execution time. Implementing timeouts in Go is easy and 4 | // elegant thanks to channels and `select`. 5 | 6 | package main 7 | 8 | import "time" 9 | import "fmt" 10 | 11 | func main() { 12 | 13 | // For our example, suppose we're executing an external 14 | // call that returns its result on a channel `c1` 15 | // after 2s. 16 | c1 := make(chan string, 1) 17 | go func() { 18 | time.Sleep(time.Second * 2) 19 | c1 <- "result 1" 20 | }() 21 | 22 | // Here's the `select` implementing a timeout. 23 | // `res := <-c1` awaits the result and `<-Time.After` 24 | // awaits a value to be sent after the timeout of 25 | // 1s. Since `select` proceeds with the first 26 | // receive that's ready, we'll take the timeout case 27 | // if the operation takes more than the allowed 1s. 28 | select { 29 | case res := <-c1: 30 | fmt.Println(res) 31 | case <-time.After(time.Second * 1): 32 | fmt.Println("timeout 1") 33 | } 34 | 35 | // If we allow a longer timeout of 3s, then the receive 36 | // from `c2` will succeed and we'll print the result. 37 | c2 := make(chan string, 1) 38 | go func() { 39 | time.Sleep(time.Second * 2) 40 | c2 <- "result 2" 41 | }() 42 | select { 43 | case res := <-c2: 44 | fmt.Println(res) 45 | case <-time.After(time.Second * 3): 46 | fmt.Println("timeout 2") 47 | } 48 | } 49 | 50 | // todo: cancellation? 51 | -------------------------------------------------------------------------------- /examples/writing-files/writing-files.go: -------------------------------------------------------------------------------- 1 | // Writing files in Go follows similar patterns to the 2 | // ones we saw earlier for reading. 3 | 4 | package main 5 | 6 | import ( 7 | "bufio" 8 | "fmt" 9 | "io/ioutil" 10 | "os" 11 | ) 12 | 13 | func check(e error) { 14 | if e != nil { 15 | panic(e) 16 | } 17 | } 18 | 19 | func main() { 20 | 21 | // To start, here's how to dump a string (or just 22 | // bytes) into a file. 23 | d1 := []byte("hello\ngo\n") 24 | err := ioutil.WriteFile("/tmp/dat1", d1, 0644) 25 | check(err) 26 | 27 | // For more granular writes, open a file for writing. 28 | f, err := os.Create("/tmp/dat2") 29 | check(err) 30 | 31 | // It's idiomatic to defer a `Close` immediately 32 | // after opening a file. 33 | defer f.Close() 34 | 35 | // You can `Write` byte slices as you'd expect. 36 | d2 := []byte{115, 111, 109, 101, 10} 37 | n2, err := f.Write(d2) 38 | check(err) 39 | fmt.Printf("wrote %d bytes\n", n2) 40 | 41 | // A `WriteString` is also available. 42 | n3, err := f.WriteString("writes\n") 43 | fmt.Printf("wrote %d bytes\n", n3) 44 | 45 | // Issue a `Sync` to flush writes to stable storage. 46 | f.Sync() 47 | 48 | // `bufio` provides buffered writers in addition 49 | // to the buffered readers we saw earlier. 50 | w := bufio.NewWriter(f) 51 | n4, err := w.WriteString("buffered\n") 52 | fmt.Printf("wrote %d bytes\n", n4) 53 | 54 | // Use `Flush` to ensure all buffered operations have 55 | // been applied to the underlying writer. 56 | w.Flush() 57 | 58 | } 59 | -------------------------------------------------------------------------------- /vendor/pygments/tests/test_token.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Test suite for the token module 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 7 | :license: BSD, see LICENSE for details. 8 | """ 9 | 10 | import unittest 11 | 12 | from pygments import token 13 | 14 | 15 | class TokenTest(unittest.TestCase): 16 | 17 | def test_tokentype(self): 18 | e = self.assertEqual 19 | 20 | t = token.String 21 | 22 | e(t.split(), [token.Token, token.Literal, token.String]) 23 | 24 | e(t.__class__, token._TokenType) 25 | 26 | def test_functions(self): 27 | self.assertTrue(token.is_token_subtype(token.String, token.String)) 28 | self.assertTrue(token.is_token_subtype(token.String, token.Literal)) 29 | self.assertFalse(token.is_token_subtype(token.Literal, token.String)) 30 | 31 | self.assertTrue(token.string_to_tokentype(token.String) is token.String) 32 | self.assertTrue(token.string_to_tokentype('') is token.Token) 33 | self.assertTrue(token.string_to_tokentype('String') is token.String) 34 | 35 | def test_sanity_check(self): 36 | stp = token.STANDARD_TYPES.copy() 37 | stp[token.Token] = '---' # Token and Text do conflict, that is okay 38 | t = {} 39 | for k, v in stp.iteritems(): 40 | t.setdefault(v, []).append(k) 41 | if len(t) == len(stp): 42 | return # Okay 43 | 44 | for k, v in t.iteritems(): 45 | if len(v) > 1: 46 | self.fail("%r has more than one key: %r" % (k, v)) 47 | -------------------------------------------------------------------------------- /examples/basic-authentication/basic-authentication.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/base64" 5 | "fmt" 6 | "net/http" 7 | "strings" 8 | ) 9 | 10 | type Auth func(string, string) bool 11 | type handler http.HandlerFunc 12 | 13 | func testAuth(r *http.Request, auth Auth) bool { 14 | header := r.Header.Get("Authorization") 15 | s := strings.SplitN(header, " ", 2) 16 | if len(s) != 2 || s[0] != "Basic" { 17 | return false 18 | } 19 | b, err := base64.StdEncoding.DecodeString(s[1]) 20 | if err != nil { 21 | return false 22 | } 23 | pair := strings.SplitN(string(b), ":", 2) 24 | if len(pair) != 2 { 25 | return false 26 | } 27 | return auth(pair[0], pair[1]) 28 | } 29 | 30 | func requireAuth(w http.ResponseWriter, r *http.Request) { 31 | w.Header().Set("WWW-Authenticate", 32 | "Basic realm=\"private\"") 33 | w.WriteHeader(401) 34 | w.Write([]byte("401 Unauthorized\n")) 35 | } 36 | 37 | func wrapAuth(h handler, a Auth) handler { 38 | return func(w http.ResponseWriter, r *http.Request) { 39 | if testAuth(r, a) { 40 | h(w, r) 41 | } else { 42 | requireAuth(w, r) 43 | } 44 | } 45 | } 46 | 47 | func hello(w http.ResponseWriter, r *http.Request) { 48 | fmt.Fprintln(w, "Hello secret world!") 49 | } 50 | 51 | func main() { 52 | checkPassword := func(_, password string) bool { 53 | return password == "supersecret" 54 | } 55 | handler1 := http.HanderFunc(hello) 56 | handler2 := wrapAuth(handler1, checkPassword) 57 | http.ListenAndServe(":5000", handler2) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/pygments/docs/src/moinmoin.txt: -------------------------------------------------------------------------------- 1 | .. -*- mode: rst -*- 2 | 3 | ============================ 4 | Using Pygments with MoinMoin 5 | ============================ 6 | 7 | From Pygments 0.7, the source distribution ships a `Moin`_ parser plugin that 8 | can be used to get Pygments highlighting in Moin wiki pages. 9 | 10 | To use it, copy the file `external/moin-parser.py` from the Pygments 11 | distribution to the `data/plugin/parser` subdirectory of your Moin instance. 12 | Edit the options at the top of the file (currently ``ATTACHMENTS`` and 13 | ``INLINESTYLES``) and rename the file to the name that the parser directive 14 | should have. For example, if you name the file ``code.py``, you can get a 15 | highlighted Python code sample with this Wiki markup:: 16 | 17 | {{{ 18 | #!code python 19 | [...] 20 | }}} 21 | 22 | where ``python`` is the Pygments name of the lexer to use. 23 | 24 | Additionally, if you set the ``ATTACHMENTS`` option to True, Pygments will also 25 | be called for all attachments for whose filenames there is no other parser 26 | registered. 27 | 28 | You are responsible for including CSS rules that will map the Pygments CSS 29 | classes to colors. You can output a stylesheet file with `pygmentize`, put it 30 | into the `htdocs` directory of your Moin instance and then include it in the 31 | `stylesheets` configuration option in the Moin config, e.g.:: 32 | 33 | stylesheets = [('screen', '/htdocs/pygments.css')] 34 | 35 | If you do not want to do that and are willing to accept larger HTML output, you 36 | can set the ``INLINESTYLES`` option to True. 37 | 38 | 39 | .. _Moin: http://moinmoin.wikiwikiweb.de/ 40 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/example.jag: -------------------------------------------------------------------------------- 1 | # lsat.jags example from classic-bugs examples in JAGS 2 | # See http://sourceforge.net/projects/mcmc-jags/files/Examples/2.x/ 3 | var 4 | response[R,T], m[R], culm[R], alpha[T], a[T], theta[N], r[N,T], 5 | p[N,T], beta, theta.new, p.theta[T], p.item[R,T], P.theta[R]; 6 | data { 7 | for (j in 1:culm[1]) { 8 | r[j, ] <- response[1, ]; 9 | } 10 | for (i in 2:R) { 11 | for (j in (culm[i - 1] + 1):culm[i]) { 12 | r[j, ] <- response[i, ]; 13 | } 14 | } 15 | } 16 | model { 17 | # 2-parameter Rasch model 18 | for (j in 1:N) { 19 | for (k in 1:T) { 20 | probit(p[j,k]) <- delta[k]*theta[j] - eta[k]; 21 | r[j,k] ~ dbern(p[j,k]); 22 | } 23 | theta[j] ~ dnorm(0,1); 24 | } 25 | 26 | # Priors 27 | for (k in 1:T) { 28 | eta[k] ~ dnorm(0,0.0001); 29 | e[k] <- eta[k] - mean(eta[]); # sum-to-zero constraint 30 | 31 | delta[k] ~ dnorm(0,1) T(0,); # constrain variance to 1, slope +ve 32 | d[k] <- delta[k]/pow(prod(delta), 1/T); # PRODUCT_k (d_k) = 1 33 | 34 | g[k] <- e[k]/d[k]; # equivalent to B&A's threshold parameters 35 | } 36 | 37 | # Compute probability of response pattern i, for later use in computing G^2 38 | theta.new ~ dnorm(0,1); # ability parameter for random student 39 | for(k in 1:T) { 40 | probit(p.theta[k]) <- delta[k]*theta.new - eta[k]; 41 | for(i in 1:R) { 42 | p.item[i,k] <- p.theta[k]^response[i,k] * (1-p.theta[k])^(1-response[i,k]); 43 | } 44 | } 45 | for(i in 1:R) { 46 | P.theta[i] <- prod(p.item[i,]) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/pygments/scripts/get_vimkw.py: -------------------------------------------------------------------------------- 1 | import re 2 | from pprint import pprint 3 | 4 | r_line = re.compile(r"^(syn keyword vimCommand contained|syn keyword vimOption " 5 | r"contained|syn keyword vimAutoEvent contained)\s+(.*)") 6 | r_item = re.compile(r"(\w+)(?:\[(\w+)\])?") 7 | 8 | def getkw(input, output): 9 | out = file(output, 'w') 10 | 11 | output_info = {'command': [], 'option': [], 'auto': []} 12 | for line in file(input): 13 | m = r_line.match(line) 14 | if m: 15 | # Decide which output gets mapped to d 16 | if 'vimCommand' in m.group(1): 17 | d = output_info['command'] 18 | elif 'AutoEvent' in m.group(1): 19 | d = output_info['auto'] 20 | else: 21 | d = output_info['option'] 22 | 23 | # Extract all the shortened versions 24 | for i in r_item.finditer(m.group(2)): 25 | d.append('(%r,%r)' % 26 | (i.group(1), "%s%s" % (i.group(1), i.group(2) or ''))) 27 | 28 | output_info['option'].append("('nnoremap','nnoremap')") 29 | output_info['option'].append("('inoremap','inoremap')") 30 | output_info['option'].append("('vnoremap','vnoremap')") 31 | 32 | for a, b in output_info.items(): 33 | b.sort() 34 | print >>out, '%s=[%s]' % (a, ','.join(b)) 35 | 36 | def is_keyword(w, keywords): 37 | for i in range(len(w), 0, -1): 38 | if w[:i] in keywords: 39 | return signals[w[:i]][:len(w)] == w 40 | return False 41 | 42 | if __name__ == "__main__": 43 | getkw("/usr/share/vim/vim73/syntax/vim.vim", "temp.py") 44 | -------------------------------------------------------------------------------- /vendor/pygments/docs/src/index.txt: -------------------------------------------------------------------------------- 1 | .. -*- mode: rst -*- 2 | 3 | ======== 4 | Overview 5 | ======== 6 | 7 | Welcome to the Pygments documentation. 8 | 9 | - Starting with Pygments 10 | 11 | - `Installation `_ 12 | 13 | - `Introduction and Quickstart `_ 14 | 15 | - `Command line interface `_ 16 | 17 | - Builtin components 18 | 19 | - `Lexers `_ 20 | 21 | - `Formatters `_ 22 | 23 | - `Filters `_ 24 | 25 | - `Styles `_ 26 | 27 | - Reference 28 | 29 | - `Unicode and encodings `_ 30 | 31 | - `Builtin tokens `_ 32 | 33 | - `API documentation `_ 34 | 35 | - Hacking for Pygments 36 | 37 | - `Write your own lexer `_ 38 | 39 | - `Write your own formatter `_ 40 | 41 | - `Write your own filter `_ 42 | 43 | - `Register plugins `_ 44 | 45 | - Hints and Tricks 46 | 47 | - `Using Pygments in ReST documents `_ 48 | 49 | - `Using Pygments with MoinMoin `_ 50 | 51 | - `Using Pygments in other contexts `_ 52 | 53 | - About Pygments 54 | 55 | - `Changelog `_ 56 | 57 | - `Authors `_ 58 | 59 | 60 | -------------- 61 | 62 | If you find bugs or have suggestions for the documentation, please 63 | look `here`_ for info on how to contact the team. 64 | 65 | You can download an offline version of this documentation from the 66 | `download page`_. 67 | 68 | .. _here: http://pygments.org/contribute/ 69 | .. _download page: http://pygments.org/download/ 70 | -------------------------------------------------------------------------------- /examples/string-functions/string-functions.go: -------------------------------------------------------------------------------- 1 | // The standard library's `strings` package provides many 2 | // useful string-related functions. Here are some examples 3 | // to give you a sense of the package. 4 | 5 | package main 6 | 7 | import s "strings" 8 | import "fmt" 9 | 10 | // We alias `fmt.Println` to a shorter name as we'll use 11 | // it a lot below. 12 | var p = fmt.Println 13 | 14 | func main() { 15 | 16 | // Here's a sample of the functions available in 17 | // `strings`. Note that these are all functions from 18 | // package, not methods on the string object itself. 19 | // This means that we need pass the string in question 20 | // as the first argument to the function. 21 | p("Contains: ", s.Contains("test", "es")) 22 | p("Count: ", s.Count("test", "t")) 23 | p("HasPrefix: ", s.HasPrefix("test", "te")) 24 | p("HasSuffix: ", s.HasSuffix("test", "st")) 25 | p("Index: ", s.Index("test", "e")) 26 | p("Join: ", s.Join([]string{"a", "b"}, "-")) 27 | p("Repeat: ", s.Repeat("a", 5)) 28 | p("Replace: ", s.Replace("foo", "o", "0", -1)) 29 | p("Replace: ", s.Replace("foo", "o", "0", 1)) 30 | p("Split: ", s.Split("a-b-c-d-e", "-")) 31 | p("ToLower: ", s.ToLower("TEST")) 32 | p("ToUpper: ", s.ToUpper("test")) 33 | p() 34 | 35 | // You can find more functions in the [`strings`](http://golang.org/pkg/strings/) 36 | // package docs. 37 | 38 | // Not part of `strings` but worth mentioning here are 39 | // the mechanisms for getting the length of a string 40 | // and getting a character by index. 41 | p("Len: ", len("hello")) 42 | p("Char:", "hello"[1]) 43 | } 44 | -------------------------------------------------------------------------------- /examples/closing-channels/closing-channels.go: -------------------------------------------------------------------------------- 1 | // _Closing_ a channel indicates that no more values 2 | // will be sent on it. This can be useful to communicate 3 | // completion to the channel's receivers. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | // In this example we'll use a `jobs` channel to 10 | // communicate work to be done from the `main()` goroutine 11 | // to a worker goroutine. When we have no more jobs for 12 | // the worker we'll `close` the `jobs` channel. 13 | func main() { 14 | jobs := make(chan int, 5) 15 | done := make(chan bool) 16 | 17 | // Here's the worker goroutine. It repeatedly receives 18 | // from `jobs` with `j, more := <-jobs`. In this 19 | // special 2-value form of receive, the `more` value 20 | // will be `false` if `jobs` has been `close`d and all 21 | // values in the channel have already been received. 22 | // We use this to notify on `done` when we've worked 23 | // all our jobs. 24 | go func() { 25 | for { 26 | j, more := <-jobs 27 | if more { 28 | fmt.Println("received job", j) 29 | } else { 30 | fmt.Println("received all jobs") 31 | done <- true 32 | return 33 | } 34 | } 35 | }() 36 | 37 | // This sends 3 jobs to the worker over the `jobs` 38 | // channel, then closes it. 39 | for j := 1; j <= 3; j++ { 40 | jobs <- j 41 | fmt.Println("sent job", j) 42 | } 43 | close(jobs) 44 | fmt.Println("sent all jobs") 45 | 46 | // We await the worker using the 47 | // [synchronization](channel-synchronization) approach 48 | // we saw earlier. 49 | <-done 50 | } 51 | -------------------------------------------------------------------------------- /examples/atomic-counters/atomic-counters.go: -------------------------------------------------------------------------------- 1 | // The primary mechanism for managing state in Go is 2 | // communication over channels. We saw this for example 3 | // with [worker pools](worker-pool). There are a few other 4 | // options for managing state though. Here we'll 5 | // look at using the `sync/atomic` package for _atomic 6 | // counters_ accessed by multiple goroutines. 7 | 8 | package main 9 | 10 | import "fmt" 11 | import "time" 12 | import "sync/atomic" 13 | 14 | func main() { 15 | 16 | // We'll use an unsigned integer to represent our 17 | // (always-positive) counter. 18 | var ops uint64 = 0 19 | 20 | // To simulate concurrent updates, we'll start 50 21 | // goroutines that each increment the counter about 22 | // once a millisecond. 23 | for i := 0; i < 50; i++ { 24 | go func() { 25 | for { 26 | time.Sleep(time.Millisecond) 27 | 28 | // To atomically increment the counter we 29 | // use `AddUint64`, giving it the memory 30 | // address of our `ops` counter with the 31 | // `&` syntax. 32 | atomic.AddUint64(&ops, 1) 33 | } 34 | }() 35 | } 36 | 37 | // Wait a second to allow some ops to accumulate. 38 | time.Sleep(time.Second) 39 | 40 | // In order to safely use the counter while it's still 41 | // being updated by other goroutines, we extract a 42 | // copy of the current value into `opsFinal` via 43 | // `LoadUint64`. As above we need to give this 44 | // function the memory address `&ops` from which to 45 | // fetch the value. 46 | opsFinal := atomic.LoadUint64(&ops) 47 | fmt.Println("ops:", opsFinal) 48 | } 49 | -------------------------------------------------------------------------------- /examples/execing-processes/execing-processes.go: -------------------------------------------------------------------------------- 1 | // In the previous example we looked at 2 | // [spawning external processes](spawning-processes). We 3 | // do this when we need an external process accessible to 4 | // a running Go process. Sometimes we just want to 5 | // completely replace the current Go process with another 6 | // (perhaps non-Go) one. To do this we'll use Go's 7 | // implementation of the classic 8 | // exec 9 | // function. 10 | 11 | package main 12 | 13 | import "syscall" 14 | import "os" 15 | import "os/exec" 16 | 17 | func main() { 18 | 19 | // For our example we'll exec `ls`. Go requires an 20 | // absolute path to the binary we want to execute, so 21 | // we'll use `exec.LookPath` to find it (probably 22 | // `/bin/ls`). 23 | binary, lookErr := exec.LookPath("ls") 24 | if lookErr != nil { 25 | panic(lookErr) 26 | } 27 | 28 | // `Exec` requires arguments in slice form (as 29 | // apposed to one big string). We'll give `ls` a few 30 | // common arguments. 31 | args := []string{"-a", "-l", "-h"} 32 | 33 | // `Exec` also needs a set of [environment variables](environment-variables) 34 | // to use. Here we just provide our current 35 | // environment. 36 | env := os.Environ() 37 | 38 | // Here's the actual `os.Exec` call. If this call is 39 | // successful, the execution of our process will end 40 | // here and be replaced by the `/bin/ls -a -l -h` 41 | // process. If there is an error we'll get a return 42 | // value. 43 | execErr := syscall.Exec(binary, args, env) 44 | if execErr != nil { 45 | panic(execErr) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/as3_test2.as: -------------------------------------------------------------------------------- 1 | package ru.dfls.events { 2 | import flash.events.Event; 3 | import flash.events.ErrorEvent; 4 | 5 | /** 6 | * This event is usually dispatched if some error was thrown from an asynchronous code, i.e. there 7 | * is no relevant user stack part to process the error. There is only one type of such event: 8 | * ErrorEvent.ERROR which is same as flash.events.ErrorEvent.ERROR. 9 | * The only difference between flash.events.ErrorEvent and 10 | * ru.dfls.events.ErrorEvent is the capability of the latter to store the underlying cause 11 | * (the Error). 12 | * 13 | * @see flash.events.ErrorEvent 14 | * @see Error 15 | * @author dragonfly 16 | */ 17 | public class ErrorEvent extends flash.events.ErrorEvent { 18 | 19 | public static var ERROR : String = flash.events.ErrorEvent.ERROR; 20 | 21 | private var _error : Error; 22 | 23 | public function ErrorEvent(type : String, bubbles : Boolean = false, cancelable : Boolean = false, 24 | text : String = "", error : Error = null) { 25 | super(type, bubbles, cancelable, text); 26 | _error = error; 27 | } 28 | 29 | public function get error() : Error { 30 | return _error; 31 | } 32 | 33 | public function set error(value : Error) : void { 34 | _error = value; 35 | } 36 | 37 | public override function toString() : String { 38 | return formatToString("ErrorEvent", "type", "bubbles", "cancelable", "eventPhase", "text", "error"); 39 | } 40 | 41 | public override function clone() : Event { 42 | return new ru.dfls.events.ErrorEvent(type, bubbles, cancelable, text, error); 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/interfaces/interfaces.go: -------------------------------------------------------------------------------- 1 | // _Interfaces_ are named collections of method 2 | // signatures. 3 | 4 | package main 5 | 6 | import "fmt" 7 | import "math" 8 | 9 | // Here's a basic interface for geometric shapes. 10 | type geometry interface { 11 | area() float64 12 | perim() float64 13 | } 14 | 15 | // For our example we'll implement this interface on 16 | // `square` and `circle` types. 17 | type square struct { 18 | width, height float64 19 | } 20 | type circle struct { 21 | radius float64 22 | } 23 | 24 | // To implement an interface in Go, we just need to 25 | // implement all the methods in the interface. Here we 26 | // implement `geometry` on `square`s. 27 | func (s square) area() float64 { 28 | return s.width * s.height 29 | } 30 | func (s square) perim() float64 { 31 | return 2*s.width + 2*s.height 32 | } 33 | 34 | // The implementation for `circle`s. 35 | func (c circle) area() float64 { 36 | return math.Pi * c.radius * c.radius 37 | } 38 | func (c circle) perim() float64 { 39 | return 2 * math.Pi * c.radius 40 | } 41 | 42 | // If a variable has an interface type, then we can call 43 | // methods that are in the named interface. Here's a 44 | // generic `measure` function taking advantage of this 45 | // to work on any `geometry`. 46 | func measure(g geometry) { 47 | fmt.Println(g) 48 | fmt.Println(g.area()) 49 | fmt.Println(g.perim()) 50 | } 51 | 52 | func main() { 53 | s := square{width: 3, height: 4} 54 | c := circle{radius: 5} 55 | 56 | // The `circle` and `square` struct types both 57 | // implement the `geometry` interface so we can use 58 | // instances of 59 | // these structs as arguments to `measure. 60 | measure(s) 61 | measure(c) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/pygments/tests/examplefiles/test.maql: -------------------------------------------------------------------------------- 1 | # MAQL script 2 | CREATE DATASET {dataset.quotes} VISUAL(TITLE "St\\tock Qu\totes Data"); 3 | 4 | # A comment 5 | CREATE DATASET {dataset.quotes} VISUAL(TITLE "Stock Qu\"otes Data"); 6 | 7 | CREATE DATASET {dataset.quotes} VISUAL(TITLE "Stock Quotes Data"); 8 | 9 | ALTER DATASET {dataset.quotes} ADD {attribute.sector}; 10 | 11 | ALTER DATASET {dataset.quotes} DROP {attribute.symbol}; 12 | 13 | ALTER DATASET {dataset.quotes} VISUAL(TITLE "Internal Quotes Data"); 14 | 15 | CREATE ATTRIBUTE {attr.quotes.symbol} 16 | VISUAL(TITLE "Symbol", FOLDER {folder.quotes.attr}) 17 | AS {d_quotes_symbol.nm_symbol}; 18 | 19 | ALTER ATTRIBUTE {attr.quotes.symbol} 20 | ADD LABELS {attr.quotes.company} VISUAL(TITLE "Company") 21 | AS {d_quotes_symbol.nm_company}; 22 | 23 | CREATE FACT {fact.quotes.open_price} 24 | VISUAL( TITLE "Open Price", FOLDER {folder.quotes.fact}) AS {f_quotes.f_open_price}; 25 | 26 | ALTER FACT {fact.quotes.open_price} ADD {f_quotes2.f_open_price}; 27 | 28 | CREATE FOLDER {folder.quotes.attr} 29 | VISUAL ( TITLE "Stock Quotes Data", 30 | DESCRIPTION "Stock quotes data obtained from John Doe etc." ) 31 | TYPE ATTRIBUTE; 32 | 33 | ALTER DATATYPE {d_quotes_symbol.nm_symbol} VARCHAR(4), 34 | {d_quotes_symbol.nm_symbol} VARCHAR(80), 35 | {f_quotes.f_open_price} DECIMAL(10,2); 36 | 37 | INCLUDE TEMPLATE "URN:GOODDATA:DATE" MODIFY (IDENTIFIER "my-date", TITLE "quote") 38 | 39 | ALTER ATTRIBUTE {attr.quotes.symbol} ADD KEYS {d_quotes_symbol.nm_symbol} PRIMARY; 40 | 41 | ALTER ATTRIBUTE {attr.quotes.symbol} DROP KEYS {d_quotes_symbol.nm_symbol}; 42 | 43 | ALTER FACT {fact.quotes.open_price} ADD {f_quotes2.f_open_price}; 44 | 45 | # Another comment 46 | -------------------------------------------------------------------------------- /vendor/pygments/tests/test_latex_formatter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Pygments LaTeX formatter tests 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 7 | :license: BSD, see LICENSE for details. 8 | """ 9 | 10 | import os 11 | import unittest 12 | import tempfile 13 | 14 | from pygments.formatters import LatexFormatter 15 | from pygments.lexers import PythonLexer 16 | 17 | import support 18 | 19 | TESTFILE, TESTDIR = support.location(__file__) 20 | 21 | 22 | class LatexFormatterTest(unittest.TestCase): 23 | 24 | def test_valid_output(self): 25 | fp = open(TESTFILE) 26 | try: 27 | tokensource = list(PythonLexer().get_tokens(fp.read())) 28 | finally: 29 | fp.close() 30 | fmt = LatexFormatter(full=True, encoding='latin1') 31 | 32 | handle, pathname = tempfile.mkstemp('.tex') 33 | # place all output files in /tmp too 34 | old_wd = os.getcwd() 35 | os.chdir(os.path.dirname(pathname)) 36 | tfile = os.fdopen(handle, 'wb') 37 | fmt.format(tokensource, tfile) 38 | tfile.close() 39 | try: 40 | import subprocess 41 | po = subprocess.Popen(['latex', '-interaction=nonstopmode', 42 | pathname], stdout=subprocess.PIPE) 43 | ret = po.wait() 44 | output = po.stdout.read() 45 | po.stdout.close() 46 | except OSError: 47 | # latex not available 48 | pass 49 | else: 50 | if ret: 51 | print output 52 | self.assertFalse(ret, 'latex run reported errors') 53 | 54 | os.unlink(pathname) 55 | os.chdir(old_wd) 56 | --------------------------------------------------------------------------------