go.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Language: Go
  3. Author: Stephan Kountso aka StepLg <steplg@gmail.com>
  4. Contributors: Evgeny Stepanischev <imbolk@gmail.com>
  5. Description: Google go language (golang). For info about language
  6. Website: http://golang.org/
  7. Category: common, system
  8. */
  9. function go(hljs) {
  10. var GO_KEYWORDS = {
  11. keyword:
  12. 'break default func interface select case map struct chan else goto package switch ' +
  13. 'const fallthrough if range type continue for import return var go defer ' +
  14. 'bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 ' +
  15. 'uint16 uint32 uint64 int uint uintptr rune',
  16. literal:
  17. 'true false iota nil',
  18. built_in:
  19. 'append cap close complex copy imag len make new panic print println real recover delete'
  20. };
  21. return {
  22. name: 'Go',
  23. aliases: ['golang'],
  24. keywords: GO_KEYWORDS,
  25. illegal: '</',
  26. contains: [
  27. hljs.C_LINE_COMMENT_MODE,
  28. hljs.C_BLOCK_COMMENT_MODE,
  29. {
  30. className: 'string',
  31. variants: [
  32. hljs.QUOTE_STRING_MODE,
  33. hljs.APOS_STRING_MODE,
  34. {begin: '`', end: '`'},
  35. ]
  36. },
  37. {
  38. className: 'number',
  39. variants: [
  40. {begin: hljs.C_NUMBER_RE + '[i]', relevance: 1},
  41. hljs.C_NUMBER_MODE
  42. ]
  43. },
  44. {
  45. begin: /:=/ // relevance booster
  46. },
  47. {
  48. className: 'function',
  49. beginKeywords: 'func', end: '\\s*(\\{|$)', excludeEnd: true,
  50. contains: [
  51. hljs.TITLE_MODE,
  52. {
  53. className: 'params',
  54. begin: /\(/, end: /\)/,
  55. keywords: GO_KEYWORDS,
  56. illegal: /["']/
  57. }
  58. ]
  59. }
  60. ]
  61. };
  62. }
  63. module.exports = go;