I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2.2 KiB

Go

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software1

Setup

Install golang1 on your system, and configure your environment prior to loading this module.

RUN apt install -y golang

Language server

Get started by installing the gopls2 language server.

GO111MODULE=on go get golang.org/x/tools/gopls@latest

Setup the environment

Make some modifications to the environment. Set the $GOPATH variable prior to loading, allowing modification of the default value. Include the bin subdirectory of the $GOPATH in the $PATH variable, adding compiled golang applications to the system path.

(setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))

Config

Use the go-mode3 package for integration with lsp-mode, manually setting the path to gopls2 before loading.

(use-package go-mode
  :hook (go-mode . lsp)
  :custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))

Before save hooks

Apply some custom behaviour when saving golang1 buffers. Format and organize the imports before saving.

(defun dotfiles/go-hook ()
  (add-hook 'before-save-hook #'lsp-format-buffer t t)
  (add-hook 'before-save-hook #'lsp-organize-imports t t))

(add-hook 'go-mode-hook #'dotfiles/go-hook)

Babel structure templates

Configure the babel engine to support golang1 source blocks.

(add-to-list 'org-structure-template-alist '("go" . "src go"))

Footnotes