title: Golang Debug Function
body: <p>Coming from shell programming, where i used a lot such function:</p>
  
  <pre><code>log_action() {
  case "${1}" in
  'ERROR')
      EXIT_CODE="${3}"
      echo "[${1}] | $(date +"%T") | ${2} | Exiting (${EXIT_CODE})"
      exit ${EXIT_CODE};
  ;;
  'WARNING')
      echo "[${1}] | $(date +"%T") | ${2} | Line: (${3})"
  ;;
  'DEBUG')
      if [[ ${DEBUG} -eq "1" ]]; then {
      echo "[${1}] | $(date +"%T") | ${2} | ${3}"
      }; fi
  ;;
  *)
      echo "[${1}] | $(date +"%T") | ${2} | ${3}"
  ;;
  esac
  }
  
  
  log_action "WARNING" "Cannot Connect to MySQL Database" "${LINENO}")
  </code></pre>
  
  <p>Now, i started to learn golang and will like to convert all bash scripts to go. So, I need the same function to use in golang, i tried the following:</p>
  
  <pre><code>func logHandler(t string, e string, l string) {
      switch t {
      case "warning":
          fmt.Println("WARNING")
      case "error":
          fmt.Println("ERROR")
      case "debug":
          fmt.Println("DEBUG |", e, l)
      }
  }
  
  logHandler("debug", "Test Function", "LineNumber")
  </code></pre>
  
  <p>but i don't know how to get the current linenumber variable (LineNumber) when calling logHandler function and pass it to the function as string or as int.</p>
  
  <p>Also, is there any way to run a go script in trace mode like in bash option: set -o xtrace?</p>
  
  <p>I'm just a beginner so if i'm doing something wrong please point me to the right direction.
  Thank You.</p>