code: func getPasswd(prompt string, masked bool, r FdReader, w io.Writer) ([]byte, error) {
  	var err error
  	var pass, bs, mask []byte
  	if masked {
  		bs = []byte("\b \b")
  		mask = []byte("*")
  	}
  
  	if isTerminal(r.Fd()) {
  		if oldState, err := makeRaw(r.Fd()); err != nil {
  			return pass, err
  		} else {
  			defer func() {
  				restore(r.Fd(), oldState)
  				fmt.Fprintln(w)
  			}()
  		}
  	}
  
  	if prompt != "" {
  		fmt.Fprint(w, prompt)
  	}
  
  	// Track total bytes read, not just bytes in the password.  This ensures any
  	// errors that might flood the console with nil or -1 bytes infinitely are
  	// capped.
  	var counter int
  	for counter = 0; counter <= maxLength; counter++ {
  		if v, e := getch(r); e != nil {
  			err = e
  			break
  		} else if v == 127 || v == 8 {
  			if l := len(pass); l > 0 {
  				pass = pass[:l-1]
  				fmt.Fprint(w, string(bs))
  			}
  		} else if v == 13 || v == 10 {
  			break
  		} else if v == 3 {
  			err = ErrInterrupted
  			break
  		} else if v != 0 {
  			pass = append(pass, v)
  			fmt.Fprint(w, string(mask))
  		}
  	}
  
  	if counter > maxLength {
  		err = ErrMaxLengthExceeded
  	}
  
  	return pass, err
  }
docs: // getPasswd returns the input read from terminal.
  // If prompt is not empty, it will be output as a prompt to the user
  // If masked is true, typing will be matched by asterisks on the screen.
  // Otherwise, typing will echo nothing.