Skip to content

Instantly share code, notes, and snippets.

@taosx
Created March 20, 2020 11:41
Show Gist options
  • Save taosx/30dcf968c6f3bc844a311fd0587662e8 to your computer and use it in GitHub Desktop.
Save taosx/30dcf968c6f3bc844a311fd0587662e8 to your computer and use it in GitHub Desktop.

Interview Preparation

Created: Mar 19, 2020 4:37 PM Tags: Golang, Linux

When using an empty struct?

  • When you want to save some memory.
  • When implementing a data set.
  • When writing a seen hash
  • When you group methods and not care about intermediary data
  • When you need an event to signal a channel

How copy a slice, map, interface?

  • Slice using the built in copy(a,b) function
  • Assignment of a slice only copies the descriptor
  • Map by traversing it's keys
  • No build-in way to copy an interface but you can use reflection, type casting and wrapping again

Compare two structs or two interfaces

  • You can compare two structs with the equal operator while you don't have slices, maps or functions
  • You can compare two interfaces with the == operator as long as the underlying types are “simple” and identical or panic
  • reflect.DeepEqual() work on both structs and interfaces that don't contains functions

Linux Commands

awk, basename, cat, class, chmod, chown, chroot, chdir, cut, dirname, grep, gcc, gdb, false, insmod, kill, killall, mkdir, mknod, modprobe, mount, ldd, ln, lsmod, nice, ps, pwd, pushd, popd, rmmod, route, sleep, ssh, scp, seq, shift, sed, sort, strace, strings, strip, tail, tar, tr, try, true, top, traceroute, uniq, ulimit, w, whois, wget, wc, whereis, $PATH, ~user, `

  • Ce face urmatoarele comenzi in linux?

    • sleep

    • Pause execution of shell scripts or commands for a given perion of time on unix-like systems.

    • Suspends the calling shell script for a specified time.

    • Pauses the next shell command for a given time.

    • w

    • The w command provides a quick summary of every user logged into a computer, what each user is currently doing what load all activity is imposing on the computer itself.

    • The command is a combination of several other Unix programs: who, uptime and ps -a

    • chroot

    • Changes the apparent root directory for the current running process and its children.

      1. Mount root partition of the linux system that you're trying chroot
      2. Create directory where you want to mount the root partition
      3. Mount it
      4. Mount all the separate partitions of the system

      TIP: Mount filesystems before chrooting

      Command: chroot /mnt/arch /usr/bin/bash

    • pushd / popd | dir

    • The pushd command stores a directory in the directory stack

    • The popd command removes the top directory path from the same stack.

    • The dirs command is used the view the directory stack (dirs -l -v)

    • (Move into another directory while remembering the current one)

    • rmmod

    • Unloads loadable modules from running kernel with the restriction that they are not in use and that they are not a dependency of other modules

    • -r Option is used to make a recursive removal of modules

    • lsmod

    • Print a list of loadable kernel modules in terminal

    • shift

    • The shift command is used to move the command line arguments to one position left. The first argument is lost when you use the shift command.

    • strace

    • tool for debugging and troubleshooting programs. It captures and records all system calls made by a process and the signals received by the process.

    • displays the name of each system call with its arguments enclosed in a parenthesis and its return value to standard error; you can optionally redirect it to a file as well.

    • strace df -h

    • traceroute

  • traceroute, route

  • Golang pointer, receiver

  • Mutex, Semaphore

  • Concurency, Queue

  • Message Queue, NATs

  • Scheduler, Golang Scheduler

  • How kubernetes functions?

  • In what order does golang executes statements?

  • Static Linking vs Dynamic Linking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment