-
Notifications
You must be signed in to change notification settings - Fork 3
/
go.yml
55 lines (50 loc) · 1.35 KB
/
go.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
source: clear
features:
- go
nginx:
root: public_html/public
passenger:
enabled: "on"
app_start_command: env PORT=$PORT ./main
commands:
- filename: main.go
content: |
package main
import (
"fmt"
"net/http"
"os"
"runtime"
"strings"
)
const html_text = `
<!DOCTYPE html>
<html>
<head>
<title>Go App</title>
<link rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css">
</head>
<body class="p-5 text-center">
<p><img src="//images.unsplash.com/photo-1465153690352-10c1b29577f8?fit=crop&w=200&h=200"
class="img-fluid rounded-circle"></p>
<h1 class="mb-3">Hello, world!</h1>
<p>Serving from Go version %s</p>
<p class="text-muted">DOM Cloud</p>
</body>
</html>
`
func home(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/html")
version := strings.Replace(runtime.Version(), "go", "", 1)
fmt.Fprintf(w, html_text, version)
}
func main() {
http.HandleFunc("/", home)
port := os.Getenv("PORT")
if port == "" {
fmt.Print("PORT environment variable not set")
os.Exit(1)
}
http.ListenAndServe("127.0.0.1:"+port, nil)
}
- go build main.go