Design patterns with Go
Course Materials
- Handouts / Worksheets
- Slides
- Code Examples
- Videos
resource "aws_lambda_function" "check" { | |
filename = "./check.zip" | |
function_name = "check" | |
role = "arn:aws:iam::424242:role/something" | |
handler = "main" | |
runtime = "go1.x" | |
source_code_hash = "${base64sha256(file("./check.zip"))}" | |
} | |
resource "aws_cloudwatch_event_rule" "every_twelve_hours" { |
package singleton | |
import ( | |
"sync" | |
) | |
type singleton struct { | |
} | |
var instance *singleton |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
type Fetcher interface { | |
Fetch(url string) (body string, urls []string, err error) |
package main | |
import ( | |
"golang.org/x/tour/tree" | |
"fmt" | |
) | |
func _walk(t *tree.Tree, ch chan int) { | |
if t == nil { | |
return |
<?php | |
function getPeriod(int $int, int $n): int { | |
$m = '1'; | |
$m .= str_repeat(0, $n); | |
return $int * ((int) $m); | |
} | |
function getRomanNumber(int $input): string{ |
<?php | |
function cm(array $ar1, array $ar2, int $rc = 0): array | |
{ | |
$duplicatePositions = []; | |
$merged = []; | |
foreach($ar1 as $key => &$value){ | |
if($dk = array_search($value, $ar2, true)){ | |
$duplicatePositions[$dk] = $ar2[$dk]; |