Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/blixt/go-pher
- Owner: blixt
- Created: 2013-10-25T01:04:33.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-21T16:32:31.000Z (over 10 years ago)
- Last Synced: 2024-04-21T10:12:33.699Z (7 months ago)
- Language: Go
- Size: 172 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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")
\n\n\n")
fmt.Print(greet(pher.Get("name")))
fmt.Print("
}
```### Output HTML
```html
Test
what up, world
```