I want to change the color which in package import go defer in go-mode ,need a regex..these code only change the pacakge word color

    (defface my-font-lock-gokeyword-face
    `((t (:foreground "#ab4642"))) ;; change to desired color
    "Face for go keyword.")

    (font-lock-add-keywords 'go-mode
    ;; change to desired operator regex
    '(("package"  0 'my-font-lock-gokeyword-face)))

enter image description here


If you change "package" to "^package.*" I think it will match every line that starts with package to the end of the line. I don't know enough about go to know if that is always the right thing to do here.

  • thanks for your reply ,i update the comment. you can see this pic ,i think its better. – xiaodong huan Oct 11 at 13:19
  • I don't get what you want. You just want the package word in another color than it already is? – John Kitchin Oct 11 at 18:19

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.