#+Begin_SRC go
package main
import ("fmt")

func main(){


(when (memq window-system '(mac ns))
  (exec-path-from-shell-copy-env "GOPATH"))

;; Define function to call when go-mode loads
(defun my-go-mode-hook ()
  (add-hook 'before-save-hook 'gofmt-before-save) ; gofmt before every save
  (setq gofmt-command "goimports")                ; gofmt uses invokes goimports
  (if (not (string-match "go" compile-command))   ; set compile command default
      (set (make-local-variable 'compile-command)
           "go build -v && go test -v && go vet"))

  ;; guru settings
  (go-guru-hl-identifier-mode)                    ; highlight identifiers

  ;; Key bindings specific to go-mode
  (local-set-key (kbd "M-.") 'godef-jump)         ; Go to definition
  (local-set-key (kbd "M-*") 'pop-tag-mark)       ; Return from whence you came
  (local-set-key (kbd "M-p") 'compile)            ; Invoke compiler
  (local-set-key (kbd "M-P") 'recompile)          ; Redo most recent compile cmd
  (local-set-key (kbd "M-]") 'next-error)         ; Go to next error (or msg)
  (local-set-key (kbd "M-[") 'previous-error)     ; Go to previous error or msg

  (auto-complete-mode 1))                         

(add-hook 'go-mode-hook 'my-go-mode-hook)

(with-eval-after-load 'go-mode
   (require 'go-autocomplete))

(require 'go-guru)
; i want use ob-go , above code just compile the code
;(require 'ob-go)
;'((go . t)))

But this is not execute how i execute this block. I'm new in Literal Programming Please help me

  • Why do you have the code to add go to languages supported by org-babel commented out? – user12563 Dec 1 '18 at 18:10
  • because i like go and project requirements in c,c++,go,lisp,clojure and ruby. Second i used go for most of problems – Ali Hassan Dec 2 '18 at 14:12
  • That code should register a function which should handle go blocks in org-mode, possibly including code block execution. That's probably your issue. – user12563 Dec 2 '18 at 17:52
  • by adding org-mode ? – Ali Hassan Dec 3 '18 at 3:18
  • The 4 last lines of your init file have code that should add go support to org-babel, but you've commented them out. – user12563 Dec 3 '18 at 7:33

You already have necessary code to enable go support for org-babel in your init file, it's just commented out. All it takes to enable it is to uncomment them.

Change the following part (which is right at the end of your init file):

; i want use ob-go , above code just compile the code
;(require 'ob-go)
;'((go . t)))

You just have to remove heading semicolons at the beginning of last 4 lines, (which is the syntax for comments) which should leave you with something looking like this:

; i want use ob-go , above code just compile the code
(require 'ob-go)
 '((go . t)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.