cover.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <style>
  6. body {
  7. background: black;
  8. color: rgb(80, 80, 80);
  9. }
  10. body, pre, #legend span {
  11. font-family: Menlo, monospace;
  12. font-weight: bold;
  13. }
  14. #topbar {
  15. background: black;
  16. position: fixed;
  17. top: 0; left: 0; right: 0;
  18. height: 42px;
  19. border-bottom: 1px solid rgb(80, 80, 80);
  20. }
  21. #content {
  22. margin-top: 50px;
  23. }
  24. #nav, #legend {
  25. float: left;
  26. margin-left: 10px;
  27. }
  28. #legend {
  29. margin-top: 12px;
  30. }
  31. #nav {
  32. margin-top: 10px;
  33. }
  34. #legend span {
  35. margin: 0 5px;
  36. }
  37. .cov0 { color: rgb(192, 0, 0) }
  38. .cov1 { color: rgb(128, 128, 128) }
  39. .cov2 { color: rgb(116, 140, 131) }
  40. .cov3 { color: rgb(104, 152, 134) }
  41. .cov4 { color: rgb(92, 164, 137) }
  42. .cov5 { color: rgb(80, 176, 140) }
  43. .cov6 { color: rgb(68, 188, 143) }
  44. .cov7 { color: rgb(56, 200, 146) }
  45. .cov8 { color: rgb(44, 212, 149) }
  46. .cov9 { color: rgb(32, 224, 152) }
  47. .cov10 { color: rgb(20, 236, 155) }
  48. </style>
  49. </head>
  50. <body>
  51. <div id="topbar">
  52. <div id="nav">
  53. <select id="files">
  54. <option value="file0">coursera\testing\main.go (85.7%)</option>
  55. </select>
  56. </div>
  57. <div id="legend">
  58. <span>not tracked</span>
  59. <span class="cov0">not covered</span>
  60. <span class="cov8">covered</span>
  61. </div>
  62. </div>
  63. <div id="content">
  64. <pre class="file" id="file0" style="display: none">package main
  65. import (
  66. "encoding/json"
  67. "fmt"
  68. )
  69. type User struct {
  70. ID int
  71. }
  72. var data = map[string][]byte{
  73. "ok": []byte(`{"ID": 27}`),
  74. "fail": []byte(`{"ID": 27`),
  75. }
  76. func GetUser(key string) (*User, error) <span class="cov8" title="1">{
  77. if jsonStr, ok := data[key]; ok </span><span class="cov8" title="1">{
  78. user := &amp;User{}
  79. err := json.Unmarshal(jsonStr, user)
  80. if err != nil </span><span class="cov0" title="0">{
  81. return nil, fmt.Errorf("Cant decode json")
  82. }</span>
  83. <span class="cov8" title="1">return user, nil</span>
  84. }
  85. <span class="cov8" title="1">return nil, fmt.Errorf("User doesnt exist")</span>
  86. }
  87. </pre>
  88. </div>
  89. </body>
  90. <script>
  91. (function() {
  92. var files = document.getElementById('files');
  93. var visible;
  94. files.addEventListener('change', onChange, false);
  95. function select(part) {
  96. if (visible)
  97. visible.style.display = 'none';
  98. visible = document.getElementById(part);
  99. if (!visible)
  100. return;
  101. files.value = part;
  102. visible.style.display = 'block';
  103. location.hash = part;
  104. }
  105. function onChange() {
  106. select(files.value);
  107. window.scrollTo(0, 0);
  108. }
  109. if (location.hash != "") {
  110. select(location.hash.substr(1));
  111. }
  112. if (!visible) {
  113. select("file0");
  114. }
  115. })();
  116. </script>
  117. </html>