This is pretty specific to my setup but the idea can be adapted to work with pretty much anything.
Go has a flag package which makes parsing command line arguments really easy.
package main| express = require 'express' | |
| httpProxy = require 'http-proxy' | |
| sysPath = require 'path' | |
| config = require('./config').config | |
| startExpress = (port, base, path, callback) -> | |
| server = express() | |
| server.use (request, response, next) -> | |
| response.header 'Cache-Control', 'no-cache' | |
| next() |
| exports.config = | |
| # other stuff ... | |
| server: | |
| path: 'server.coffee' | |
| port: 3333 | |
| run: yes | |
| routes: [ | |
| { host: '127.0.0.1', port: 80, re: /\/blocks/ } # apache redirect |
This is pretty specific to my setup but the idea can be adapted to work with pretty much anything.
Go has a flag package which makes parsing command line arguments really easy.
package main| #compdef godoc | |
| typeset -A opt_args | |
| local context state line | |
| local pkgdir usrpkgdir | |
| pkgdir="$GOROOT/src/pkg" | |
| usrpkgdir="$GOPATH/src" | |
| godoctmpl=~/.godoc_templates |
| package main | |
| // explicite | |
| const ( | |
| SAY_NIL = 0x00 // 0b00000000 | |
| SAY_HELLO = 0x01 // 0b00000001 | |
| SAY_FOO = 0x02 // 0b00000010 | |
| SAY_BYE = 0x04 // 0b00000100 | |
| ) |
| # show welcome message | |
| ZSH_HINTS=() | |
| ZSH_HINTS+=("CTRL + A Move to the beginning of the line") | |
| ZSH_HINTS+=("CTRL + E Move to the end of the line") | |
| ZSH_HINTS+=("CTRL + [left arrow] Move one word backward (on some systems this is ALT + B)") | |
| ZSH_HINTS+=("CTRL + [right arrow] Move one word forward (on some systems this is ALT + F)") | |
| ZSH_HINTS+=("CTRL + U (bash) Clear the characters on the line before the current cursor position") | |
| ZSH_HINTS+=("CTRL + U (zsh) If you're using the zsh, this will clear the entire line") | |
| ZSH_HINTS+=("CTRL + K Clear the characters on the line after the current cursor position") | |
| ZSH_HINTS+=("C + [backspace] Delete the word in front of the cursor") |
| # watch/recompile go | |
| function gowatch () { | |
| echo | |
| echo "Watching files in $(pwd)" | |
| echo | |
| ls | grep ".go$" | while read go_file; do | |
| echo " - $go_file" | |
| done | |
| echo | |
| while true; do |
src: http://research.swtch.com/godata
// don't do this
func foo(s *string) { fmt.Printf("The String: %s", *s) }// do this| package main | |
| import ( | |
| "unicode/utf8" | |
| ) | |
| type Item string | |
| type Stream chan Item | |
| type Acc string |
| package main | |
| import ( | |
| "errors" | |
| "log" | |
| ) | |
| type Item struct { | |
| val string | |
| err error |