You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/10/02 20:42:13 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5095: Update Go version to 1.15.2

ocket8888 commented on a change in pull request #5095:
URL: https://github.com/apache/trafficcontrol/pull/5095#discussion_r499040058



##########
File path: docs/source/_ext/atc.py
##########
@@ -46,6 +46,29 @@ def run(self):
 			impl_node.append(nodes.paragraph('', '', *(n + m)))
 		return [impl_node]
 
+# -- Go Version role --------------------------------------------------
+# Returns the value of the Go version stored in GO_VERSION to minor version
+# precision.
+import os
+import re
+
+from docutils.nodes import strong
+from docutils.parsers.rst.states import Inliner
+from typing import Tuple, List
+
+def atc_go_version(unused_typ: str,
+               unused_rawtext: str,
+               unused_text: str,
+               unused_lineno: int,
+               unused_inliner: Inliner,
+               options=None,
+               content=None) -> Tuple[List[strong], list]:
+	go_version_file = os.path.join(os.path.dirname(__file__), '../../../GO_VERSION')
+	go_version = open(file=go_version_file).read()

Review comment:
       Looks like this file is never closed. I'd recommend doing a context-managed read like:
   ```python
   with open(go_version_file) as f:
       go_version = f.read()
       # ...
   ```
   So that the file is always closed and fds don't leak




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org