A very simple example of using a map of channels for pub/sub in go.
To run it go here http://play.golang.org/p/eXwppMgHR3
import ( | |
"runtime" | |
"time" | |
) | |
... | |
go func() { | |
for { | |
var m runtime.MemStats |
package qsort | |
import "math/rand" | |
func QuickSort(slice []int) []int { | |
length := len(slice) | |
if length <= 1 { | |
sliceCopy := make([]int, length) | |
copy(sliceCopy, slice) |
package main | |
import ( | |
"log" | |
"myserver" | |
"net/http" | |
) | |
const addr = "localhost:12345" |
A very simple example of using a map of channels for pub/sub in go.
To run it go here http://play.golang.org/p/eXwppMgHR3
Would it be possible to include an iCal file attachment to the Access-A-Ride advance notification emails with a 30 minute window from the specified pickup time (that is the window in which Access-A-Ride drivers need to arrive)?
For example: if my Access-A-Ride is supposed to pick me up at 10:34 am from 1000 Broadway Ave and then again at 8:00 pm from 900 Jay St., include a calendar event (a .ics file) that would look similar to the following, attached to the advance trip notification:
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
SUMMARY:Access-A-Ride Pickup
Twelve Go Best Practices
Francesc Campoy Flores Gopher at Google @francesc http://campoy.cat/+
package main | |
import ( | |
"bufio" | |
"compress/gzip" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"log" | |
"net/http" |
There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.
So, these are the different settings we are going to compare:
#!/bin/sh | |
parse_yaml() { | |
local prefix=$2 | |
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') | |
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ | |
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | | |
awk -F$fs '{ | |
indent = length($1)/2; | |
vname[indent] = $2; | |
for (i in vname) {if (i > indent) {delete vname[i]}} |
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) { | |
// path/to/whatever does not exist | |
} | |
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) { | |
// path/to/whatever exists | |
} |