Here is the entire application. Below that is a step by step guide.
package main
import (
"bytes"
"io/ioutil"
package main | |
//Messing with Negroni subroutes. | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"os" |
package main | |
import ( | |
"fmt" | |
"time" | |
"golang.org/x/net/context" | |
) | |
func main() { |
package main | |
import ( | |
"bytes" | |
"io/ioutil" | |
"log" | |
"os" | |
) | |
//Open a file, read the bytes, check if the bytes have a sequence of bytes, then replace those bytes with other ones |
#!/bin/bash | |
# Install and extract go | |
sudo wget -P /home/ec2-user/ https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz | |
cd /home/ec2-user/ | |
tar -xzf go1.7.4.linux-amd64.tar.gz | |
# Set up env. variables | |
export GOROOT=/home/ec2-user/go | |
export PATH=$PATH:$GOROOT/bin |
Pipelines in Go are really neat. They're composable functions that allow you to chain concurrent events together, safely.
If you have the need to call API after API after API, witl the same data, maybe pipelines could help. Imagine you have the following:
func create(item Object) Object {
// do things, call APIs
return item
}
definition( | |
name: "Smarter Nightlight", | |
author: "Nathan Hyland", | |
description: "Turns on lights when it's dark and motion is detected and lights are not already on. Turns lights off when it becomes light or some time after motion ceases.", | |
category: "Convenience", | |
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet-luminance.png", | |
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet-luminance@2x.png" | |
) | |
preferences { |