Skip to content

Instantly share code, notes, and snippets.

https://stackoverflow.com/questions/66142960/trouble-parsing-form-data-sent-from-javascript
https://stackoverflow.com/questions/66138644/how-can-i-change-the-package-type-when-calling-a-method
https://stackoverflow.com/questions/66137884/how-can-i-unmarshal-the-following-json-into-golang-struct
https://stackoverflow.com/questions/66126877/can-i-create-a-function-that-returns-types
https://stackoverflow.com/questions/66129320/json-object-returning-wrong-number-in-struct
https://stackoverflow.com/questions/66131824/how-to-use-scanner-bufio
https://stackoverflow.com/questions/66133593/execute-binary-file-in-remote-server-with-http-request-dont-work
https://stackoverflow.com/questions/66134053/why-go-servemux-is-also-a-handler
https://stackoverflow.com/questions/66106944/how-to-import-grpc-server-proto-which-is-exist-in-diff-application-in-local-syst
https://stackoverflow.com/questions/66130399/fabriccaclientservice-js-failed-to-enroll-admin-erroro-message-calling-enr
// StackOverflow analysis using its API in Go.
//
// Eli Bendersky [https://eli.thegreenplace.net]
// This code is in the public domain.
package main
import (
"encoding/json"
"flag"
"fmt"
{
"openapi": "3.0.1",
"info": {
"title": "Sample REST server",
"description": "TODO",
"version": "1.0.0"
},
"servers": [
{
"url": "https://example.com"
#
# TODO: add license?
openapi: 3.0.1
info:
title: Sample REST server
description: TODO
version: 1.0.0
servers:
- url: https://example.com
// Demonstrates async preemption in 1.14 vs. earlier versions
package main
import (
"log"
"runtime"
"time"
)
func f1() {
Title: Simple HTTP server
URL slug: httpserver
Description: A simple HTTP server serving two different routes using the default request multiplexer.
Title: Waiting for goroutines to finish
URL slug: waitgroup
Description: A WaitGroup provides a simple way to wait for a collection of goroutines to perform a task.
package main
import (
"bufio"
"encoding/json"
"fmt"
"log"
"os"
)
@eliben
eliben / thoughts.rst
Last active October 12, 2018 04:53
Thoughts on the Go 2 Error Handling proposal

TL;DR: The proposal looks good, except the handler chaining part, which adds a lot of magical complexity to cater to rare use cases. Chaining can always be added at a later stage without breaking backwards compatibility, if its lack is deemed unbearable.

As I see it, the biggest issues in current Go usage the proposal tackles are:

  1. Repeated sequences of if err != nil {return nil, err} littering Go code
  2. Lack of proper context in propagated errors (see (1) above)

To fix these issues, I believe the proposed check keyword with a single handler per function are sufficient. Using stacks of handlers for proper cleanup is best left to defer, which is already a familiar tool. Thus, handle should only exist as a default "report more context in case of an error and return the error" mechanism. Where a single handler appears insufficient because the nature of error handling required changes throug

foo = "\\"
bar = "\n"
manyescapes = "\\\\\\\\"
manyescapes2 = "\n\\\n\\"