DEV Community

David Hwang
David Hwang

Posted on

5/23 TIL: Go Signals, http, & Linux file systems

--Golang--
Go flag


addr = flag.String("addr", "0.0.0.0:9090", "Default HTTP address")

Enter fullscreen mode Exit fullscreen mode
  • port 9090 will be the default value unless the user specifies the port on the command line by doing something like --addr 0.0.0.0:8080.
  • the first parameter is the name of the flag, the second parameter the default value, and the last parameter describes the default value

Package http


s := &http.Server{

Addr:           ":8080",

Handler:        myHandler,

ReadTimeout:    10 * time.Second,

WriteTimeout:   10 * time.Second,

MaxHeaderBytes: 1 << 20,

}

s.ListenAndServe()

Enter fullscreen mode Exit fullscreen mode

Go Signals


sigChan := make(chan os.Signal)

// relays incoming signals to sigChan

signal.Notify(sigChan, os.Interrupt, os.Kill)

sig := ← sigChan

log.Println("Received terminate signal, gracefully shutting down", sig)

Enter fullscreen mode Exit fullscreen mode

--Systems--
File Systems

  • Devices are represented by entries in the /dev directories
  • Each device has a corresponding device driver which implements a standard set of operations: open, read, write, close functions that were discussed in file IO topic
  • A device may have a corresponding hardware device driver that implements an API
  • A hard disk is divided into one or more partitions, each of which may contain a file system
  • A file system is an organized collection of regular files and directories
  • Linux implements file systems such as the ext2 file system
  • All the file systems in Linux are mounted under a single directory tree with a directory / at its root; a privileged process can mount and unmount a file system using mount() and unmount()
  • Information about the mounted file systems can be retrieved using statvfs()

--Discrete Math--
Modus Ponens

  • A valid argument is a list of premises from which the conclusion follows
  • Ex) if p, then q. p. Therefore, q.

Modus Tollens

  • If p, then q. ~q. Therefore, ~p.

Logical Arguments:

  • Generalization: p. Therefore, p V q. (always true)
  • Specialization: p ʌ q. Therefore, p.
  • Contradiction: ~p → c. Therefore, p.

Top comments (0)