When using net/http
, handling errors is kinda annoying.
http.HandleFunc("/foo", func(w http.ResponseWriter, r *http.Request) {
thing, err := storage.Get("thing")
if err != nil {
http.Error(w, err.Error(), 500)
go func() { | |
for { | |
err = rmq.Stream(cancelCtx) | |
if errors.Is(err, rabbitmq.ErrDisconnected) { | |
continue | |
} | |
break | |
} | |
}() |
I've been looking for the best Linux backup system, and also reading lots of HN comments.
Instead of putting pros and cons of every backup system I'll just list some deal-breakers which would disqualify them.
Also I would like that you, the HN community, would add more deal breakers for these or other backup systems if you know some more and at the same time, if you have data to disprove some of the deal-breakers listed here (benchmarks, info about something being true for older releases but is fixed on newer releases), please share it so that I can edit this list accordingly.
package main | |
import ( | |
"context" | |
"html" | |
"log" | |
"net/http" | |
"golang.org/x/text/language" | |
"golang.org/x/text/message" |
// Traverses an arbitrary struct and translates all stings it encounters | |
// | |
// I haven't seen an example for reflection traversing an arbitrary struct, so | |
// I want to share this with you. If you encounter any bugs or want to see | |
// another example please comment. | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2014 Heye Vöcking | |
// |
port module Api exposing (..) | |
import JsonStuff exposing (ToJson, FromJson, getEncoder, getDecoder) | |
import Http | |
helpPostJson : String -> ToJson a msg -> FromJson b msg -> a -> Http.Request b | |
helpPostJson url toJson fromJson o = | |
Http.request | |
{ method = "POST" | |
, headers = [] |
package subcommands | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"strings" | |
) | |
type Command interface { |
PATH_TO_JAR="node_modules/superstartup-closure-compiler/build" | |
JAR="${PATH_TO_JAR}/compiler.jar" | |
ELM_JS_FILE="app/scripts/elm_components/elm.js" | |
TMP_FILE=".tmp/elm.js" | |
if [ ! -f ${JAR} ]; then | |
echo "google-closure-compiler JAR not found, make sure you `npm install` the `superstartup-closure-compiler` package" | |
else | |
java -jar ${JAR} --compilation_level=ADVANCED_OPTIMIZATIONS --js="${ELM_JS_FILE}" --js_output_file="${TMP_FILE}" --language_in=ECMASCRIPT5 | |
mv ${TMP_FILE} ${ELM_JS_FILE} |
#!/bin/bash | |
# This scripts scans the elasticsearch source code for all the registered REST endpoints | |
# It will put the formatted output in $DEFINITIONOUTPUTFILE | |
# [MethodName] [HttpVerb] [Route] | |
ESFOLDER="../elasticsearch" | |
DEFINITIONOUTPUTFILE="src/Generated/rest-actions.txt" | |
# Find all the lines that registerHandlers |