|
| 1 | + |
| 2 | +<!DOCTYPE html> |
| 3 | +<html> |
| 4 | + <head> |
| 5 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 | + <title>secretenv: Go Coverage Report</title> |
| 7 | + <style> |
| 8 | + body { |
| 9 | + background: black; |
| 10 | + color: rgb(80, 80, 80); |
| 11 | + } |
| 12 | + body, pre, #legend span { |
| 13 | + font-family: Menlo, monospace; |
| 14 | + font-weight: bold; |
| 15 | + } |
| 16 | + #topbar { |
| 17 | + background: black; |
| 18 | + position: fixed; |
| 19 | + top: 0; left: 0; right: 0; |
| 20 | + height: 42px; |
| 21 | + border-bottom: 1px solid rgb(80, 80, 80); |
| 22 | + } |
| 23 | + #content { |
| 24 | + margin-top: 50px; |
| 25 | + } |
| 26 | + #nav, #legend { |
| 27 | + float: left; |
| 28 | + margin-left: 10px; |
| 29 | + } |
| 30 | + #legend { |
| 31 | + margin-top: 12px; |
| 32 | + } |
| 33 | + #nav { |
| 34 | + margin-top: 10px; |
| 35 | + } |
| 36 | + #legend span { |
| 37 | + margin: 0 5px; |
| 38 | + } |
| 39 | + .cov0 { color: rgb(192, 0, 0) } |
| 40 | +.cov1 { color: rgb(128, 128, 128) } |
| 41 | +.cov2 { color: rgb(116, 140, 131) } |
| 42 | +.cov3 { color: rgb(104, 152, 134) } |
| 43 | +.cov4 { color: rgb(92, 164, 137) } |
| 44 | +.cov5 { color: rgb(80, 176, 140) } |
| 45 | +.cov6 { color: rgb(68, 188, 143) } |
| 46 | +.cov7 { color: rgb(56, 200, 146) } |
| 47 | +.cov8 { color: rgb(44, 212, 149) } |
| 48 | +.cov9 { color: rgb(32, 224, 152) } |
| 49 | +.cov10 { color: rgb(20, 236, 155) } |
| 50 | + |
| 51 | + </style> |
| 52 | + </head> |
| 53 | + <body> |
| 54 | + <div id="topbar"> |
| 55 | + <div id="nav"> |
| 56 | + <select id="files"> |
| 57 | + |
| 58 | + <option value="file0">github.com/ndthuan/secretenv/secretenv.go (100.0%)</option> |
| 59 | + |
| 60 | + </select> |
| 61 | + </div> |
| 62 | + <div id="legend"> |
| 63 | + <span>not tracked</span> |
| 64 | + |
| 65 | + <span class="cov0">not covered</span> |
| 66 | + <span class="cov8">covered</span> |
| 67 | + |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + <div id="content"> |
| 71 | + |
| 72 | + <pre class="file" id="file0" style="display: none">package secretenv |
| 73 | + |
| 74 | +import ( |
| 75 | + "io" |
| 76 | + "os" |
| 77 | + "strings" |
| 78 | +) |
| 79 | + |
| 80 | +// Get first checks if the key suffixed with "_FILE" exists. |
| 81 | +// If it does, it reads the content of the file and returns it. |
| 82 | +// Otherwise, it returns the environment value of the key. |
| 83 | +func Get(key string) string <span class="cov8" title="1">{ |
| 84 | + if key == "" </span><span class="cov8" title="1">{ |
| 85 | + return "" |
| 86 | + }</span> |
| 87 | + |
| 88 | + <span class="cov8" title="1">fileKey := key + "_FILE" |
| 89 | + |
| 90 | + if value, ok := os.LookupEnv(fileKey); ok </span><span class="cov8" title="1">{ |
| 91 | + file, err := os.Open(value) |
| 92 | + if err == nil </span><span class="cov8" title="1">{ |
| 93 | + defer file.Close() |
| 94 | + |
| 95 | + data, err := io.ReadAll(file) |
| 96 | + if err == nil </span><span class="cov8" title="1">{ |
| 97 | + return strings.TrimSpace(string(data)) |
| 98 | + }</span> |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + <span class="cov8" title="1">return os.Getenv(key)</span> |
| 103 | +} |
| 104 | +</pre> |
| 105 | + |
| 106 | + </div> |
| 107 | + </body> |
| 108 | + <script> |
| 109 | + (function() { |
| 110 | + var files = document.getElementById('files'); |
| 111 | + var visible; |
| 112 | + files.addEventListener('change', onChange, false); |
| 113 | + function select(part) { |
| 114 | + if (visible) |
| 115 | + visible.style.display = 'none'; |
| 116 | + visible = document.getElementById(part); |
| 117 | + if (!visible) |
| 118 | + return; |
| 119 | + files.value = part; |
| 120 | + visible.style.display = 'block'; |
| 121 | + location.hash = part; |
| 122 | + } |
| 123 | + function onChange() { |
| 124 | + select(files.value); |
| 125 | + window.scrollTo(0, 0); |
| 126 | + } |
| 127 | + if (location.hash != "") { |
| 128 | + select(location.hash.substr(1)); |
| 129 | + } |
| 130 | + if (!visible) { |
| 131 | + select("file0"); |
| 132 | + } |
| 133 | + })(); |
| 134 | + </script> |
| 135 | +</html> |
0 commit comments