What happens to the size of the table after inserting a thousand rows and then deleting everything?
Golang
Why can't port 80 be occupied without permissions? What is the group of such ports called?
How does data transfer physically occur through an unbuffered channel?
What list of commands do you use daily?
Why is the copy operation needed for slices? Why can't you just assign one slice to another?
How to see what the program does when it starts? How to diagnose the cause of a crash?
At what level was idempotency implemented and what was the idempotent key?
How to run something with administrator rights in Linux?
Share interesting cases from working with PostgreSQL
Does the virtualization use the host OS kernel?
Which command shows disk space?
What is ACID and through which mechanisms is each letter implemented in PostgreSQL?
// isPalindrome checks if a string is a palindrome. // Only letters and digits are considered (alphanumeric characters), case-insensitive comparison. // O(1) in memory + O(n) in time // s := "racecar" func isPalindrome(s string) bool { }
Under what type of multitasking is livelock possible? What types of multitasking do you know?
What is the difference between 'a' - 'A' and why is it needed for case conversion?
How is a hash table (map) in Go structured? What is a collision and how is it handled? Closed vs open addressing, chaining.
What is a snapshot in the context of MVCC in PostgreSQL?
How is Mutex implemented under the hood? What is SpinLock and how does it work?
func GetUniqueUserFirstNamesByProjectID(ctx context.Context, projectID string) ([]string, error) { userFirstNames, err := GetUserFirstNamesByProjectID(ctx, projectID) if err != nil { return nil, err } var ( userFirstNamesMap map[string]bool uniqueUserFirstNames []string ) for _, userFirstName := range userFirstNames { if _, ok := userFirstNamesMap[userFirstName]; !ok { userFirstNamesMap[userFirstName] = true uniqueUserFirstNames = append(uniqueUserFirstNames, userFirstName) } } return uniqueUserFirstNames, nil } // users // id first_name project_id func GetUserFirstNamesByProjectID(ctx context.Context, projectID string) ([]string, error) { rows, err := conn.Query(context.Background(), fmt.Sprintf("SELECT first_name from users where project_id = '%s';", projectID)) if err != nil { return nil, err } var userFirstNames []string for rows.Next() { var userFirstName string if err := rows.Scan(&userFirstName); err != nil { return nil, err } userFirstNames = append(userFirstNames, userFirstName) } return userFirstNames, nil }