go.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. const 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. {
  35. begin: '`',
  36. end: '`'
  37. }
  38. ]
  39. },
  40. {
  41. className: 'number',
  42. variants: [
  43. {
  44. begin: hljs.C_NUMBER_RE + '[i]',
  45. relevance: 1
  46. },
  47. hljs.C_NUMBER_MODE
  48. ]
  49. },
  50. {
  51. begin: /:=/ // relevance booster
  52. },
  53. {
  54. className: 'function',
  55. beginKeywords: 'func',
  56. end: '\\s*(\\{|$)',
  57. excludeEnd: true,
  58. contains: [
  59. hljs.TITLE_MODE,
  60. {
  61. className: 'params',
  62. begin: /\(/,
  63. end: /\)/,
  64. keywords: GO_KEYWORDS,
  65. illegal: /["']/
  66. }
  67. ]
  68. }
  69. ]
  70. };
  71. }
  72. module.exports = go;