Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/blixt/go-pher

The PHP of Go.
https://github.com/blixt/go-pher

Last synced: about 1 month ago
JSON representation

The PHP of Go.

Awesome Lists containing this project

README

        

Pher /fə(ɹ)/
=============

Disclaimer: Most of this code was written while inebriated.

This program basically takes an input `.gopher` file (HTML mixed
with Go code in ` … ?>` statements) and outputs a Go program.

Set up
------

To set it up, just install this package:

```bash
go get github.com/blixt/go-pher
```

Example
-------

To run the example:

```bash
# Convert the .gopher file to a .go file
go run main.go -i example.gopher > example.go
# Build the .go file into a cgi-bin directory
mkdir cgi-bin
go build -o cgi-bin/example example.go
# Start up a CGI server (Python makes it easy)
python -m CGIHTTPServer
# Open the page!
open http://localhost:8000/cgi-bin/example?name=world
```

See below for the resulting contents of each file.

### example.gopher

```html

Test

func greet(name string) string{
return "what up, " + name
}
?>

= greet(pher.Get("name")) ?>

```

### example.go

```go
package main
import (
"fmt"
"github.com/blixt/go-pher/pher"
)
func greet(name string) string{
return "what up, " + name
}
func main() {
fmt.Print("Content-Type: text/html\r\n\r\n")
fmt.Print("\n\n\n\tTest\n\n\n")
fmt.Print("\t

")
fmt.Print(greet(pher.Get("name")))
fmt.Print("

\n\n\n")
}
```

### Output HTML

```html

Test

what up, world

```