- http://www.zhubert.com/blog/2014/01/12/introduction-to-go-golang-part-1/
- https://github.com/go-martini/martini#how-do-i-integrate-with-existing-servers
Go's arrays are values. An array variable denotes the entire array; it is not a pointer to the first array element (as would be the case in C). This means that when you assign or pass around an array value you will make a copy of its contents. (To avoid the copy you could pass a pointer to the array, but then that's a pointer to an array, not an array.) One way to think about arrays is as a sort of struct but with indexed rather than named fields: a fixed-size composite value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func swap(a, b *int) { | |
*a, *b = *b, *a | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func insertionSort(arr []int) { | |
for idx := range arr { | |
for j := idx; j > 0 && arr[j-1] > arr[j]; j-- { | |
arr[j], arr[j-1] = arr[j-1], arr[j] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var fs = require('fs') | |
var util = require('util'); | |
http.createServer(function(req, res) { | |
var path = './test.mp4'; | |
var stat = fs.statSync(path); | |
var total = stat.size; | |
if (req.headers.range) { | |
var range = req.headers.range; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"encoding/csv" | |
"encoding/json" | |
"fmt" | |
"io" | |
"os" | |
"path/filepath" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
t.relname AS table_name, | |
i.relname AS index_name, | |
a.attname AS column_name | |
FROM | |
pg_class t, | |
pg_class i, | |
pg_index ix, | |
pg_attribute a | |
WHERE |
- unicode and rune
- resizing factor of slice
OlderNewer