Skip to content

Instantly share code, notes, and snippets.

@raifpy
Last active August 18, 2020 21:48
Show Gist options
  • Save raifpy/dee07b48189b499e8b1569e739ede9f2 to your computer and use it in GitHub Desktop.
Save raifpy/dee07b48189b499e8b1569e739ede9f2 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
func main() {
file, _ := ioutil.ReadFile("myGoFile.go")
data := url.Values{
"data": {string(file)},
"goos": {"linux"},
"goarch": {"amd64"},
}
req, _ := http.PostForm("https://BetikSonu.org/gocompiler/api/go", data)
reqByte, _ := ioutil.ReadAll(req.Body)
jsonMap := map[string]string{}
json.Unmarshal(reqByte, &jsonMap)
if jsonMap["ok"] == "true" {
fmt.Println("Here , your download url = ", jsonMap["url"])
} else {
fmt.Println("Compile Error : ", jsonMap["why"])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment