Flag | Description |
---|---|
-H, --header 'name: value' |
Send request headers |
-d, --data |
Send request data |
-X, --request |
The request method. -X POST is implied if -d is used. |
-b, --cookie 'SOME-COOKIE=val1;OTHER-COOKIE=val2' |
Send request cookies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple Go implementation of AES-GCM-256 encryption/decryption, with explanations | |
// https://play.golang.org/p/sQABEg5fR1T | |
package main | |
import ( | |
"crypto/aes" | |
"crypto/cipher" | |
"crypto/rand" | |
"fmt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go1.16+'s signal.NotifyContext to concisely handle graceful shutdowns on OS interrupts. | |
// Simple example from original submitter: https://henvic.dev/posts/signal-notify-context/ | |
func main() { | |
// Pass a context with a timeout to tell a blocking function that it | |
// should abandon its work after the timeout elapses. | |
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) | |
defer stop() | |
select { // blocks until |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simplest mutex example | |
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"net" | |
) | |
// Test with TCP clients: | |
// $ echo "heyo" | nc localhost 9000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
inputDate := "2023-03-10" | |
inputTime := "00:00:00" |