feat: more work for dreadl0ck

This commit is contained in:
Jan Halfar 2022-01-19 14:51:38 +01:00
parent 9375533f1c
commit 99736c216c
6 changed files with 23 additions and 10 deletions

View File

@ -0,0 +1,9 @@
---
slug: debugging-go-map-races-in-k8s
authors: [ philipp ]
tags: [ go, debugging, backend ]
---
# debugging Go map races in k8s

View File

@ -3,3 +3,8 @@ jan:
title: foomo maintainer
url: https://github.com/janhalfar
image_url: https://github.com/janhalfar.png
philipp:
name: Philipp Mieden
title: MSc
url: https://github.com/dreadl0ck
image_url: https://github.com/dreadl0ck.png

View File

@ -0,0 +1 @@
# map races

View File

@ -0,0 +1,2 @@
# panic and recover

View File

@ -21,8 +21,6 @@ import { IsItCool } from "./IsItCool";
import Highlight, { defaultProps } from "prism-react-renderer";
import Link from "@docusaurus/Link";
//src={"https://play.golang.org/p/" + props.id}
export const GoPlayground = (props: { id: string; proportion: number }) => {
const [interactive, setInteractive] = useState(false);
const [source, setSource] = useState("");
@ -32,16 +30,12 @@ export const GoPlayground = (props: { id: string; proportion: number }) => {
fetch("http://localhost:8080/?id=" + props.id, {
mode: "cors",
})
.then((res) =>
res
.json()
.then((data) => setSource(data.code))
.catch((e) => setSource("parse json"))
)
.then((res) => res.text().then((newSource) => setSource(newSource)))
.catch((e) => setSource("can not load source yet"));
}
}, [source]);
const href = "https://goplay.tools/snippet/" + props.id;
return (
<>
<div style={{ paddingBottom: "1rem", width: "100%" }}>

View File

@ -39,13 +39,15 @@ func serve(w http.ResponseWriter, r *http.Request) {
http.Error(w, "no id get param given", http.StatusBadRequest)
return
}
resp, err := http.Get("https://goplay.tools/api/snippet/" + id)
//resp, err := http.Get("https://goplay.tools/api/snippet/" + id)
resp, err := http.Get("https://go.dev/_/share?id=" + id)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Type", "text/plain")
io.Copy(w, resp.Body)
resp.Body.Close()
}