No Description

Sebastian P Sobolewski 3df3079594 Update 'README.md' 1 year ago
README.md 3df3079594 Update 'README.md' 1 year ago

README.md

Go Lang Tips and Tricks

External Resources

Go Modules

https://encore.dev/guide/go.mod

Templates

Using Maps

.meta = map[string]string{ "sidebar": "glance" }

// compare a value at key
{{ if eq (index .Meta "sidebar") "glance" }}

// enumerate map 
{{ range .Meta }}


// value assignment
{{ $selected := index .Meta "sidebar" }}


// setting option values
{{ $selected := index .Meta "sidebar" }}

<select value="{{ $selected }}">
   {{ range .Options }}
       {{ if eq . $selected }}
        <option selected>{{ . }}</option>
       {{ else }}
        <option>{{ . }}</option>
       {{ end }}
    {{ end }}
</select>

Working Group

 ssh-keygen -t ecdsa -f ecdsa -b 256 -m pem

func LoadKey(path string) error {
	raw, err := os.ReadFile(path)
	if err != nil {
		return err
	}

	for {
		block, rest := pem.Decode(raw)
		if block == nil {
			break
		}
		if block.Type == "CERTIFICATE" {
			dst := make([]byte, base64.StdEncoding.EncodedLen(len(block.Bytes)))
			base64.StdEncoding.Encode(dst, block.Bytes)

			fmt.Printf("C: %s\n", string(dst))
		} else {
			dst := make([]byte, base64.StdEncoding.EncodedLen(len(block.Bytes)))
			base64.StdEncoding.Encode(dst, block.Bytes)
			fmt.Printf("K: %s\n", string(dst))
			fmt.Printf("K: %s\n", string(dst))
		}
		raw = rest
	}

	return nil
}