Consider the following example:
package main
import "fmt"
func main() {
// structs are considered a primitive type and as such are passed by value. | |
// but if you have a pointer to struct you need to be careful not to assign it to a variable thinking you're getting a copy of the 'value'. | |
// you're only getting a copy of the 'pointer'! which means the newly assigned variable will mutate the underlying struct. | |
// so to make a copy you have to dereference the struct pointer first. | |
package main | |
import "fmt" | |
type Foo struct { |
// This is a file designed to be run on go.dev/play (link below). | |
// It validates the behaviour of init() functions. | |
// i.e. init() is only called once regardless of how many times its package is imported. | |
// https://go.dev/play/p/99YpDma6mVJ | |
package main | |
import ( | |
"play.ground/bar" | |
"play.ground/foo" | |
) |
// https://play.golang.com/p/NOxcQO8U-G7 | |
// | |
// IMPORTANT: Even though you can call the pointer receiver method, you still can't access a field without triggering a runtime panic. But just being able to call the method is still useful/interesting. | |
// | |
// The explanation for this is as follows... | |
// | |
// There’s two things going on here. The first is calling a method. Go knows which method to call thanks to the name of the method and the type of the receiver. That’s all there is to knowing which method to call. | |
// e.g. The Go runtime evaluates the code `e.PointerMethod()` into something like `(*Example).PointerMethod(e)`. | |
// The trick to understand the rest is to remember that having a pointer be nil is not a reason to panic just yet. You only panic when you try to do something that needs to dereference that nil pointer. | |
// Now when the method gets called, the sugared version (e.g. `(*Example).PointerMethod(e)`) shows that the first argument is the receiver. |
#!/bin/bash | |
AWK_PATH=$(which awk) | |
CAT_PATH=$(which cat) | |
read -rp "Enter API Version (e.g. 1.0.0): " VERSION | |
read -rp "Enter API Title: " TITLE | |
read -rp "Enter API Description: " DESCRIPTION | |
read -rp "Enter Your Name (for contact info): " NAME | |
read -rp "Enter Your Email (for contact info): " EMAIL |
// WARNING: There are regexes in trufflehog that try to match the VALUE. | |
// So for example, setting `AWS_SECRET_ACCESS_KEY` by itself doesn't get identified. | |
// Only if the VALUE assigned to it matches the expected regex pattern defined in trufflehog. | |
package main | |
import ( | |
"fmt" | |
"log" | |
"runtime" |
package main | |
import ( | |
"fmt" | |
"go/ast" | |
"go/parser" | |
"go/token" | |
"log" | |
"os" | |
"path/filepath" |
// https://play.golang.com/p/iPOOcSzZCe7 | |
package main | |
import ( | |
"fmt" | |
) | |
type Foo struct { | |
Bar string |
#!/bin/bash | |
replacement_patterns() { | |
echo "Processing file: $1" | |
} | |
replacement_patterns "$@" |
The application/x-ndjson
MIME type refers to a type of data format called Newline delimited JSON (NDJSON). NDJSON is a way of storing structured data as a sequence of JSON (JavaScript Object Notation) objects, separated by newline characters.
Each line of an NDJSON file contains a complete JSON object, which means that a single NDJSON file can contain multiple JSON objects. This format is commonly used for streaming large datasets, as it allows data to be processed in a continuous and efficient manner.
The application/x-ndjson
MIME type is used to indicate that a file or data stream contains NDJSON formatted data. The x
in the MIME type indicates that it is an unregistered type, which means that it is not an official MIME type defined by the Internet Assigned Numbers Authority (IANA). However, it is widely used and supported by many applications and APIs that deal with structured data.
Here's an example of how you could use Go to send an NDJSON-formatted payload to an API:
package main