github.com/carbocation/gotogether@v0.0.0-20130502180533-aa88e503440f/doc.go (about)

     1  /* Serving resource from zip file appended to Go executable (this enables on file deploy).
     2  
     3  Making it happen:
     4  	1. Add code to serve resources (see example below)
     5  	2. Compile your executable
     6  	3. Run the `gotogether` script from https://github.com/carbocation/gotogether/src
     7  	4. Deploy
     8  
     9  Example code:
    10  
    11  	package main
    12  
    13  	import (
    14  		"fmt"
    15  		"net/http"
    16  		"os"
    17  
    18  		"github.com/carbocation/gotogether"
    19  	)
    20  
    21  	type params struct {
    22  		Number  int
    23  	}
    24  
    25  	func indexHandler(w http.ResponseWriter, req *http.Request) {
    26  		t, err := gotogether.LoadTemplates(nil, "t.html")
    27  		if err != nil {
    28  			http.NotFound(w, req)
    29  		}
    30  		if err = t.Execute(w, params{7}); err != nil {
    31  			http.NotFound(w, req)
    32  		}
    33  	}
    34  
    35  	func main() {
    36  		gotogether.Handle("/static/")
    37  		http.HandleFunc("/", indexHandler)
    38  		if err := http.ListenAndServe(":8080", nil); err != nil {
    39  			fmt.Fprintf(os.Stderr, "error: %s\n", err)
    40  			os.Exit(1)
    41  		}
    42  	}
    43  */
    44  package gotogether