Notice: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/anima/includes/loop.php on line 296

Youtube 影片

Emacs Go Mode

  • Go mode
    • 程式美化 Integrate with gofmt
      • goimports 取代 gofmt
    • 函數定義 Integrate with godoc
    • Integrate with godef, jump-to definition
    • Integrate with guru, jump-to caller, jump-to-callee…
    • 語法檢查 flycheck: golint
    • 程式補全 Code completion: company with gocode
    • 函數定義 Eldoc
      • go-eldoc with gocode


# for go setup
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
  • 建立目錄(workspace)
    • bin
    • src
        • yourgithubname

go 安裝

$go get
$go get
$go get
$go get
$go get
$go get
$go get

Emacs 安裝

(use-package go-mode
  :ensure t
  :mode (("\\.go\\'" . go-mode))
  :hook ((before-save . gofmt-before-save))
  (setq gofmt-command "goimports")
  (use-package company-go
    :ensure t
    (add-hook 'go-mode-hook (lambda()
                              (add-to-list (make-local-variable 'company-backends)
                                           '(company-go company-files company-yasnippet company-capf company-dabbrev)))))
  (use-package go-eldoc
    :ensure t
    :hook (go-mode . go-eldoc-setup)
  (use-package go-guru
    :ensure t
    (add-hook 'go-mode-hook #'go-guru-hl-identifier-mode)

讓 company-go 認得自己的 package

$gocode set autobuild true


package myutil

// Sum : sum of tow int
func Sum(num1, num2 int) int {
	return num1 + num2

// Multiply : two int multiplication
func Multiply(num1, num2 int) int {
	return num1 * num2

package main

import (


func main() {
	fmt.Println("Hello World")
	fmt.Printf("%d\n", myutil.Sum(1, 32))
	fmt.Printf("%d\n", myutil.Multiply(3, 6))


發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *