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" | |
func main() { | |
a := []byte{'A', 'M', 'N', 'J', 'E', 'E', 'T'} | |
b := s(a) | |
b[0], b[1] = b[1], b[0] | |
fmt.Println(string(a)) |
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" | |
"sync" | |
"time" | |
) | |
func main() { | |
var mu sync.Mutex |
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
// Slice rules in go programming language | |
starting cap growth factor | |
256 2.0 | |
512 1.63 | |
1024 1.44 | |
2048 1.35 | |
4096 1.30 | |
package 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
1. Query to your local database to check that cloudtrail data is present in the local database. | |
IF yes | |
// It means you have stored some data from cloudtrail before. | |
// And now you are going to do request to cloudtrail for new trail events. | |
// Note - At a time of the first request you don't have a token (i.e. next-token) | |
GOTO Step 3 | |
ELSE |
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" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"strings" |
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 ( | |
"bytes" | |
"encoding/json" | |
"errors" | |
"fmt" | |
"log" | |
) |
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
func addConcurrent(numbers []int) int { | |
var v int64 | |
goroutines := runtime.NumCPU() | |
totalNumbers := len(numbers) | |
lastGoroutine := goroutines - 1 | |
stride := totalNumbers / goroutines | |
var wg sync.WaitGroup | |
wg.Add(goroutines) |
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
linters-settings: | |
govet: | |
check-shadowing: true | |
settings: | |
printf: | |
funcs: | |
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof | |
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf | |
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf | |
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf |
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" | |
"reflect" | |
) | |
func main() { | |
source := map[string]any{ | |
"A": 23, |
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
data, _ := json.Marshal(context.WithValue(context.Background(), "a", "b")) | |
fmt.Println(string(data)) |
NewerOlder