go.js 1.6 KB

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