<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>blog</title>
		<description>in which glasnt has thoughts</description>
		<link>https://glasnt.com/blog/</link>
		<atom:link href="https://glasnt.com/blog" rel="self" type="application/rss+xml" />
		
			<item>
				<title>GoLang for Python Devs</title>
				<description>&lt;p&gt;This post is a text version of the code samples and resources from &lt;a href=&quot;https://www.youtube.com/watch?v=AVxosSFzq5s&quot;&gt;Golang for Python Devs&lt;/a&gt; by Dana Garifullina from Kiwi PyCon 2016.&lt;/p&gt;

&lt;p&gt;Some resources no longer work, so I’ve updated to the most accurate thing I can find.&lt;/p&gt;

&lt;p&gt;Some Python samples were Python 2, updated to Python 3.&lt;/p&gt;

&lt;p&gt;Most code OCR’d, may contain translation issues&lt;/p&gt;

&lt;h2 id=&quot;hello-world&quot;&gt;Hello World&lt;/h2&gt;

&lt;p&gt;Python&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Golang&lt;/p&gt;

&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello, KiwiPycon!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;lists&quot;&gt;Lists&lt;/h2&gt;

&lt;p&gt;Python&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# initialise a list
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# initialise sized List
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# add one element
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;21&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Length of list
&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 13
# List extending
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# get element by index
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 0
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Golang&lt;/p&gt;

&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// initialise a list&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// ［9, e, 9］&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// change element via index&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;125&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// SLICES - when you don&apos;t know size&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// of List&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;colours&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;red&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;blue&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// append == recreation&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;colours&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;colours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;purple&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// Length, capacity&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;colours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;colours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;dictionaries-maps&quot;&gt;Dictionaries (maps)&lt;/h2&gt;

&lt;p&gt;Python&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#initialisation of dictionary
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;py_map&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# add element
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;py_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# delete element
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;py_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# re-fill
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;py_map&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# print element
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;py_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;py_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# or just
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;py_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Golang&lt;/p&gt;

&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// initialisation&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;go_map&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;make&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;go_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;25&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;go_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

	&lt;span class=&quot;c&quot;&gt;// remove by key&lt;/span&gt;
	&lt;span class=&quot;nb&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;go_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;c&quot;&gt;// print element&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ok&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;go_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;random_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ok&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// won&apos;t be printed&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ok&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;go_map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;first_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ok&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// 25&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;while-loop&quot;&gt;While Loop&lt;/h2&gt;
&lt;p&gt;Python&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# while Loop
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Golang&lt;/p&gt;
&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// Loop from 0 until 10 is reached.&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;c&quot;&gt;// Display integer.&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;infinite-loop&quot;&gt;Infinite Loop&lt;/h2&gt;
&lt;p&gt;Python&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# no condition
&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Golang&lt;/p&gt;
&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// This Loop continues infinitely until broken.&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;c&quot;&gt;// Break if id is past a certain number.&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
		&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;range-loop&quot;&gt;Range Loop&lt;/h2&gt;

&lt;p&gt;Python&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#for Loop
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# other way
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Peter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Anders&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Bengt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;enumerate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;%d. %s&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Golang&lt;/p&gt;
&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;s&quot;&gt;&quot;Peter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s&quot;&gt;&quot;Anders&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;s&quot;&gt;&quot;Bengt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;/* This will print
	1. Peter
	2. Anders
	3. Bengt
	*/&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;range&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;names&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;%d. %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;if-statements&quot;&gt;If Statements&lt;/h2&gt;

&lt;p&gt;Python&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# if-elif-else switches
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;This is 1.0 but I will print...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;One point five&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Two point five&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Anything else&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Golang&lt;/p&gt;
&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1.0&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// Switch on a floating-point value.&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;This is 1.0, but i will print...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;fallthrough&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1.5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;One point five&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2.5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Two point five&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Anything else&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;exceptions&quot;&gt;Exceptions&lt;/h2&gt;

&lt;p&gt;Python&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# An error occurs.
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;# Except clause:
&lt;/span&gt;	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Error encountered&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;finally&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;# Finally clause:
&lt;/span&gt;	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Finally clause reached&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# another example
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;# Read int from console.
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;denominator&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;# Use int as denominator.
&lt;/span&gt;	&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;denominator&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Error&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;OK&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;error-handling&quot;&gt;Error handling&lt;/h2&gt;

&lt;p&gt;Golang&lt;/p&gt;

&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;explode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// Cause a panic.&lt;/span&gt;
	&lt;span class=&quot;nb&quot;&gt;panic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WRONG&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// Handle errors in defer func with recover.&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;defer&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;recover&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;nil&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;c&quot;&gt;// Handle our error.&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;FIX&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; ERR&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}()&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;// This causes an error.&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;explode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Open&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;filename.ext&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;nil&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Fatal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;// do something with the open *File f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;oop-in-go&quot;&gt;OOP in Go&lt;/h2&gt;

&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Attendee&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;Topic&lt;/span&gt;  &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;    &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;City&lt;/span&gt;    &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;Company&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Attendee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SayHi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hi, my name is %s and today I will talk about %s! &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Topic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Attendee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;About&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;I&apos;m from %s and currently working in %s by the way. &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;City&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Company&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;guy&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Attendee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;Topic&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Meetings with cookies: never have less then 10&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;    &lt;span class=&quot;s&quot;&gt;&quot;John Doe&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;City&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;    &lt;span class=&quot;s&quot;&gt;&quot;Doeville&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;Company&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;WeCodes Inc&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;guy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SayHi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;guy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;About&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;empty-interfaces&quot;&gt;Empty Interfaces&lt;/h2&gt;

&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
	&lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;
	&lt;span class=&quot;s&quot;&gt;&quot;strconv&quot;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// for conversions to and from string&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;  &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;   &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;phone&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;// Returns a nice string representing a Person&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;// With this method, Person implements fmt.Stringer&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&amp;lt;&amp;lt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; - &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strconv&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Itoa&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; years - @&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;phone&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&amp;gt;&amp;gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;John&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;John&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;022-4XX-66X&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;This Person is: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;concurrency&quot;&gt;Concurrency&lt;/h2&gt;

&lt;div class=&quot;language-go highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
	&lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;
	&lt;span class=&quot;s&quot;&gt;&quot;time&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;go&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sayHello&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Going to sleep....ZZzzzzzZZ&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;c&quot;&gt;//make main last a little bit more&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sleep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;6&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Second&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sayHello&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Waking up....&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sleep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Second&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello KiwiPycon!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;// Going to sleep...ZZzzzzzZZ&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;// Waking up....&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;// Hello KiwiPycon!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;channels-and-defers&quot;&gt;Channels and Defers&lt;/h2&gt;

&lt;p&gt;(complicated, see talk)&lt;/p&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;p&gt;Books:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;http://www.golang-book.com/books/intro
    &lt;ul&gt;
      &lt;li&gt;no longer works. Try https://github.com/ashleymcnamara/an-introduction-to-programming-in-go&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Introducing Go by Caleb Doxsey http://shop.oreilly.com/product/0636920046516.do&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Official docs:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A tour of Go: https://tour.golang.org/welcome/1&lt;/li&gt;
  &lt;li&gt;Effective Go: https://golang.org/doc/effective_go.html&lt;/li&gt;
  &lt;li&gt;Blog: https://blog.golang.org/&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Talks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The Evolution of Go https://youtu.be/0ReKdcpNyQg&lt;/li&gt;
  &lt;li&gt;Concurrency Is Not Parallelism https://youtu.be/cN_DpYBzKso
    &lt;ul&gt;
      &lt;li&gt;Probably https://go.dev/blog/waza-talk&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Simplicity is complicated: https://youtu.be/rFejpH_tAHM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Articles:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Traps, Gotchas, etc for New Golang Devs: http://goo.gl/ijZVrw
    &lt;ul&gt;
      &lt;li&gt;http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Five things that make Go fast: http://goo.gl/WYPJ8K
    &lt;ul&gt;
      &lt;li&gt;Probably https://dave.cheney.net/2014/06/07/five-things-that-make-go-fast&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
				<pubDate>Mon, 23 Mar 2026 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/golang-for-python-devs/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/golang-for-python-devs/</guid>
			</item>
		
			<item>
				<title>Announcement - New paper</title>
				<description>&lt;p&gt;Happy to announce that after learning my way around research papers with &lt;a href=&quot;https://whodoesthe.dev/about/&quot;&gt;ACROSS&lt;/a&gt;,
I’ve published a new paper.&lt;/p&gt;

&lt;p&gt;Sadly I don’t have a journal to contribute to (I’m still learning that part without guidance), but I’ve pushed the
PDF and raw data &lt;a href=&quot;https://github.com/glasnt/fluid-conveyance&quot;&gt;up on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This one was a long time in the making (original research was from 2019), but hopefully it’s now in a form that can be shared with the scientific community to better understand the domain of fluid conveyance.&lt;/p&gt;
</description>
				<pubDate>Tue, 01 Apr 2025 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/research-paper-announce/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/research-paper-announce/</guid>
			</item>
		
			<item>
				<title>Generative epiphany</title>
				<description>&lt;p&gt;I’ve recently been learning more about Generative AI and LLMs as part of my day job, and was having problems understanding some of the concepts. Evals, fine tuning, etc; it was all confusing to me.&lt;/p&gt;

&lt;p&gt;Until I had an epiphany, and realised that I already have a mental model for this sort thing already: &lt;strong&gt;containers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Dockerfiles that build containers are &lt;a href=&quot;https://www.youtube.com/watch?v=tGseJW_uBB8&quot;&gt;just instructions&lt;/a&gt; to build a tarball. That container image without the instructions is a black box. That black box could be an LLM Model.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Prompt engineering&lt;/em&gt; is changing the entrypoint of a LLM model.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fine Tuning&lt;/em&gt; is adding more to layers into the container, by adding to the Dockerfile, adding onto the existing base container.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Evaluation&lt;/em&gt; is comparing the outputs of two different containers with custom args, or different base images.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Retrieval Augmented Generation (RAG)&lt;/em&gt; is connecting to a database. That could be a SQLite flatfile to add into the container, or it could be a live SQL database, information that is not baked into the model/container.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Functions&lt;/em&gt; are just functions, connecting to APIs.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;HuggingFace&lt;/em&gt; is just Docker Hub, or any other hosting platform for blobs of stuff that you can call down by name.&lt;/p&gt;

&lt;p&gt;You can also skip the whole Dockerfile part and use named models from a hosting provider, sort of like using Cloud Functions or Buildpacks for named programming environments. E.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gemini-1.5.-pro&lt;/code&gt; is just contents of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.python-version&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;You will never see the contents of the Dockerfile, unless you build it yourself (and you may not need to, depending on your use case, you don’t have to start &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FROM scratch&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: this blogpost is more for me than anyone else, but please let me know if this helped map the concepts in your mind!&lt;/em&gt;&lt;/p&gt;
</description>
				<pubDate>Thu, 14 Nov 2024 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/generative-epiphany/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/generative-epiphany/</guid>
			</item>
		
			<item>
				<title>A decade of public speaking</title>
				<description>&lt;p&gt;Previous articles:
&lt;a href=&quot;https://glasnt.com/blog/2015/11/04/a-year-of-public-speaking.html&quot;&gt;2015&lt;/a&gt;,
&lt;a href=&quot;https://glasnt.com/blog/2016/10/24/another-year-of-public-speaking.html&quot;&gt;2016&lt;/a&gt;,
&lt;a href=&quot;https://glasnt.com/blog/2017/10/28/yet-another-year-of-public-speaking.html&quot;&gt;2017&lt;/a&gt;,
&lt;a href=&quot;https://glasnt.com/blog/2018/10/27/gosh-another-year-of-public-speaking.html&quot;&gt;2018&lt;/a&gt;,
&lt;a href=&quot;https://glasnt.com/blog/half-a-decade-of-public-speaking/&quot;&gt;2019&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;A decade ago today, I gave my first conference presentation.&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;Talk 95 - Where should I run my code? Dublin, Ireland, Nov 2019&lt;/p&gt;

  &lt;p&gt;~ much time passes ~&lt;/p&gt;

  &lt;p&gt;Talk 124 - Present like a pro, Wellington New Zealand, Aug 2024&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well. The last five years. What can be said that hasn’t been said many times already.&lt;/p&gt;

&lt;p&gt;I ended up working for exactly one year as a Developer Advocate before the lockdowns started. My ““Googleversary”” was the first day I would work from home. I have since moved to perma-remote (and moved cities!)&lt;/p&gt;

&lt;p&gt;Turns out when you peg your career on the ability to travel and speak, and travel stops…&lt;/p&gt;

&lt;p&gt;During the height of lockdowns, I did more podcasts than anything else, but I did do a few remote events. The lack of feedback and energy from presenting online is definitely… something. Being in UTC+10 with online events spinning up left and right (and in mostly UTC-negative timezones) didn’t help with the inclusiveness. But the joy I felt giving my first in-person talk in two years in a small meetup room where the front row was full of humans I adore and hadn’t seen in a while… that is why I do this speaking thing. The ability to help people learn technical concepts, and learn from others, in both an event structure that works well with my brain (and having months to plan the words that will come out of my mouth during my presentation), it really works for me.&lt;/p&gt;

&lt;p&gt;However, my career has pivoted again during the lockdowns. I ended up working more on that scalable advocacy thing I mentioned last time, helping to develop tutorials and written work that then resulted in moving from Developer Advocacy to Developer Programs Engineering (in not-company terms: moving from the talky talk to the codey code). Google has since consolidated both roles into a general “Developer Relations Engineer” role, so I have scope to do both talky and codey! (Obligatory “Look mum, I’m a Google Engineer!”)&lt;/p&gt;

&lt;p&gt;I haven’t stopped speaking though! I’ve definitely hit that experience level where I can genuinely give the ‘speaking about speaking’ talk (which I was presenting internally before taking it on the road), and the feedback I’ve gotten about being inspiring to the next wave of speakers has been delightful.&lt;/p&gt;

&lt;p&gt;Oh, and I’ve also presented talks at company events in Las Vegas, London, and Tokyo; given a few more keynotes, including one in two languages with live translation. I’ve spoken at more meetups, and I’ve also gotten to present in proper recording studios. But I’ve also guested on podcasts. You know, like a &lt;em&gt;proper&lt;/em&gt; thought leader.&lt;/p&gt;

&lt;p&gt;What will the next decade be like? It’s been a while since I’ve created a brand new talk, so that’s something I look forward to having the time and space to do again. Not to say that repeating talks isn’t work: the refinement and polish some of my encores have given makes them some of my proudest work. But the blank canvas is always appealing (and terrifying!).&lt;/p&gt;

&lt;p&gt;Here’s to another decade of making the words on a stage. 🎤&lt;/p&gt;
</description>
				<pubDate>Mon, 04 Nov 2024 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/a-decade-of-public-speaking/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/a-decade-of-public-speaking/</guid>
			</item>
		
			<item>
				<title>Getting GitHub Review Requests per Team</title>
				<description>&lt;p&gt;In both my day job and my community work, I use GitHub. A lot. And I’m asked to review code on GitHub. A lot. At the time of writing I have over 100 review requests on the platform.&lt;/p&gt;

&lt;p&gt;When I have things that require reviewing, I’m normally notified by email. But the email footer doesn’t tell me much about &lt;em&gt;why&lt;/em&gt; I was requested.&lt;/p&gt;

&lt;p&gt;I can also use the &lt;a href=&quot;https://github.com/pulls/review-requested&quot;&gt;Review requests&lt;/a&gt; page to view all my requests. In this view you can filter by organisation, and sort by age and such, but this still doesn’t help me identify why I was requested.&lt;/p&gt;

&lt;p&gt;There’s also the &lt;a href=&quot;https://github.com/notifications&quot;&gt;Notifications&lt;/a&gt; view, but I don’t use this very often, and I have Inbox 1000+ over there. This view does have at least a search option, but I don’t use it often.&lt;/p&gt;

&lt;p&gt;What I would like is a view of what pull requests I’ve been requested on, and why. What is directly to me? (This is most important, as it’s a specific request.) Was it to a team where I’m a maintainer? (This might be important right now, or maybe there’s other folks on the team who can address). Was it to a team that is a large one with specific rotational duties? (It might not be important right now, but might be when I’m on rotation).&lt;/p&gt;

&lt;p&gt;So I write a script using &lt;a href=&quot;https://pygithub.readthedocs.io/&quot;&gt;PyGitHub&lt;/a&gt; that goes through the following logic:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Return all pull requests from the “Review requested search”&lt;/li&gt;
  &lt;li&gt;For each of those:
    &lt;ul&gt;
      &lt;li&gt;Pull the list of Review requests&lt;/li&gt;
      &lt;li&gt;For each request:
        &lt;ul&gt;
          &lt;li&gt;Is it a user? Is it me? Log the PR as a “direct request”&lt;/li&gt;
          &lt;li&gt;Is it a team? Am I an active member? Log the PR as a request for that team.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;For all the team groupings, group each PR by repo, and output the PR by Team, Repo, PR ID, title, and a link to the request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are more options that could be added here, like “Is it for a team I’m a maintainer of? Log this separately”, or “Is this for a team I’m on rotation for? Log this higher”.&lt;/p&gt;

&lt;p&gt;My exact needs are specific, but I’ve created a general script that you can expand on. It will currently return a flat list of teams and pull request URLs, ordered by team name.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/glasnt/b7a976753a0aa629e06b88623bd83c8b.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;Running this script for my own requests, I will get all the direct requests at the top, then any team requests sorted alphabetically (because the underscore character sorts higher). With this output, I can get information to help prioritise my time.&lt;/p&gt;

&lt;p&gt;Update: While reviewing this post, I found the ability to filter pull request reviews by ones directly for you, or ones for you or a team. Read about it on &lt;a href=&quot;https://github.com/glasnt/puff/blob/latest/github/review_requested_for_me.md&quot;&gt;puff&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With thanks to Adam Ross for reviewing this post!&lt;/em&gt;&lt;/p&gt;

&lt;!--- Fix for gist styling (unsure why broke) ---&gt;
&lt;style&gt;.gist .blub-num { padding: 1px 0px !important } .gist .blob-code {padding: 1px 30px !important } &lt;/style&gt;

</description>
				<pubDate>Fri, 23 Feb 2024 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/github-requests-per-team/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/github-requests-per-team/</guid>
			</item>
		
			<item>
				<title>Auto-provisioning Artifact Registry though Cloud Run Source Deploys</title>
				<description>&lt;p&gt;One of the neat features when developing in Cloud Run was knowing you can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcr.io/yourproject&lt;/code&gt; as a place to push your Docker containers. This is a Container Registry (the CR in GCR.io), and would be available as soon as you created your project, ready for your containers.&lt;/p&gt;

&lt;p&gt;Container Registry’s implementation included the interesting detail that the container layers you pushed would end up in Cloud Storage (specifically the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;artifacts.yourproject.appspot.com/containers&lt;/code&gt; bucket.) (It’s one of those buckets that appears with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yourproject_cloudbuild&lt;/code&gt; (which is for Cloud Build. It’s usefully named.)&lt;/p&gt;

&lt;p&gt;However, as of May 2023, &lt;a href=&quot;https://cloud.google.com/artifact-registry/docs/transition/transition-from-gcr&quot;&gt;Container Registry is deprecated&lt;/a&gt;, being replaced with Artifact Registry. Once set up, a Docker registry in Artifact Registry works the same as it would as Container Registry (only now it doesn’t use Cloud Storage). You’ll get a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;REGION-docker.pkg.dev/yourproject/yourregistry&lt;/code&gt; link you can find/replace with your existing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcr.io&lt;/code&gt; URLs (or you can &lt;a href=&quot;https://cloud.google.com/artifact-registry/docs/transition/setup-gcr-repo&quot;&gt;set up domain redirection&lt;/a&gt; and not even have to do this update).&lt;/p&gt;

&lt;p&gt;A new thing that is required with Artifact Registry is that it doesn’t come as standard in your project. Artifact Registry &lt;a href=&quot;https://cloud.google.com/artifact-registry/docs/supported-formats&quot;&gt;supports more than just Docker containers&lt;/a&gt;, and you have to create your Docker registry before you can use it.&lt;/p&gt;

&lt;p&gt;A trick I often use, and would suggest using, is getting your registry automatically provisioned using &lt;a href=&quot;https://cloud.google.com/run/docs/deploying-source-code&quot;&gt;Cloud Run Source Deploys&lt;/a&gt;.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Within your application source code directory, if you run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcloud run deploy&lt;/code&gt;, you’ll be using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--source .&lt;/code&gt; deployments. This method will build your container using a Dockerfile (if it exists), or use Cloud Buildpacks (&lt;a href=&quot;https://cloud.google.com/docs/buildpacks/builders#buildergoogle-22_supported_languages&quot;&gt;for supported languages&lt;/a&gt;). Behind the scenes, the first time you run this command in your project, it will create an Artifact Registry called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cloud-run-source-deploy&lt;/code&gt; in the same region as your service.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;run deploy&lt;/code&gt; method also is a nice helper around the combination &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcloud builds submit; gcloud run deploy --image&lt;/code&gt; command, that may be familiar you.&lt;/p&gt;

&lt;p&gt;Once your service has been deployed, you can find the image that was created by interrogating the service with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcloud run services describe&lt;/code&gt;, or getting the value specifically:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gcloud run services describe yourservice \
   --region yourregion \
   --format &quot;value(spec.template.spec.containers[0].image)&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;Developer processes change over time, but as platforms evolve, the experience should improve developer quality of life. With Source Deploys’ integrated functionality in other parts of the deployment pipeline, you can spend less time deploying and more time coding. ✨&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With thanks to Jennifer Davis for reviewing this post!&lt;/em&gt;&lt;/p&gt;
</description>
				<pubDate>Thu, 15 Feb 2024 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/auto-provisioning-artifact-registry/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/auto-provisioning-artifact-registry/</guid>
			</item>
		
			<item>
				<title>Building GitHub Pages with GitHub Actions</title>
				<description>&lt;p&gt;A lot of writing on this blog stems from meta content about the blog. This is completely fine. It also helps
me pinpoint that it’s been &lt;a href=&quot;https://glasnt.com/blog/jekyll-and-rake-for-better-blogging/&quot;&gt;9 years&lt;/a&gt; since I 
first moved my content into Jekyll.&lt;/p&gt;

&lt;p&gt;I was using the integrated &lt;a href=&quot;https://pages.github.com/&quot;&gt;GitHub Pages&lt;/a&gt; functionality (a website that seems to have &lt;a href=&quot;https://web.archive.org/web/20141117080213/https://pages.github.com/&quot;&gt;not changed much&lt;/a&gt; since I first migrated to it), but one of the issues I’ve written about it before 
is that I was locked to the version of jekyll, and didn’t have much control over the processes involved.&lt;/p&gt;

&lt;p&gt;Recently I’ve been having issues where I’d have to deploy ‘noop’ changes just to force a re-build and new content to be published.&lt;/p&gt;

&lt;p&gt;But as of today, I seem to have been succesfully able to use a &lt;a href=&quot;https://github.com/orgs/community/discussions/301139&quot;&gt;new beta functionality&lt;/a&gt;, where
my action can build the site, then I let &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;actions/upload-pages-artifact&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;actions/deploy-pages&lt;/code&gt; take care of the rest.&lt;/p&gt;

&lt;p&gt;I’m using a combination of the &lt;a href=&quot;https://github.com/actions/starter-workflows/blob/a0a25cc2d4b6bd5d9870c18c04159dbe4e599e31/pages/jekyll.yml&quot;&gt;jekyll&lt;/a&gt; and &lt;a href=&quot;https://github.com/actions/starter-workflows/blob/a0a25cc2d4b6bd5d9870c18c04159dbe4e599e31/pages/jekyll-gh-pages.yml&quot;&gt;jekyll-gh-pages&lt;/a&gt; starter workflows. (These are the suggestions that show up if you go to Actions &amp;gt; New Workflow on a repo). You can see the setup I’m using in &lt;a href=&quot;https://github.com/glasnt/blog/blob/main/.github/workflows/publish.yml&quot;&gt;.github/workflows/publish.yml&lt;/a&gt; (this may be further refined).&lt;/p&gt;

&lt;p&gt;When changing from the existing method, I needed to go to Settings &amp;gt; Pages &amp;gt; Build and deployment, then change my Source from “Deploy from branch” to “GitHub Actions (beta)”, otherwise I’d get permissions errors on deployment. I also had to change the (inherited? defaulted? legacy’d?) branch protection on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;github-pages&lt;/code&gt; environment, but I’m unsure if that was a configuration I made, or one that migrated with me.&lt;/p&gt;

&lt;p&gt;In any case, I seem to have a blog that now deploys from a push to main to my website in just shy of 40 seconds, which is good enough for me!&lt;/p&gt;

&lt;p&gt;Here’s to another nine years of futzing ✨&lt;/p&gt;
</description>
				<pubDate>Tue, 12 Dec 2023 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/building-github-pages-github-actions/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/building-github-pages-github-actions/</guid>
			</item>
		
			<item>
				<title>Using Cloud Buildpacks images as Cloud Build steps</title>
				<description>&lt;p&gt;In Cloud Build, you can &lt;a href=&quot;https://cloud.google.com/build/docs/configuring-builds/create-basic-configuration&quot;&gt;create steps&lt;/a&gt;, with each step using a base image. Images can be common ones to interact with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcloud&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker&lt;/code&gt;, but you can also create your own.&lt;/p&gt;

&lt;p&gt;When building custom images in Docker, you might have your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ENTRYPOINT&lt;/code&gt; as the name of an executable, then you can send various runtime parameters to it. How the &lt;a href=&quot;https://github.com/GoogleCloudPlatform/cloud-builders/blob/master/docker/Dockerfile-versioned&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker&lt;/code&gt; Cloud Builder&lt;/a&gt; image is defined in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dockerfile&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;However, when you’re using &lt;a href=&quot;https://cloud.google.com/docs/buildpacks/overview&quot;&gt;Google Cloud buildpacks&lt;/a&gt;, you specify an optional &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Procfile&lt;/code&gt; with your application, when you need to configure an &lt;a href=&quot;https://cloud.google.com/docs/buildpacks/nodejs#application_entrypoint&quot;&gt;application entrypoint&lt;/a&gt; different to the default.&lt;/p&gt;

&lt;p&gt;Problems arise if you’re trying to define a custom entrypoint, then additionally customise the runtime parameters. The &lt;a href=&quot;https://github.com/buildpacks/spec&quot;&gt;Cloud Native Buildpacks Specification v3&lt;/a&gt; doesn’t (at the time of writing) specify how a Procfile should be processed, so the implementation is up to the provider.&lt;/p&gt;

&lt;p&gt;You can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pack inspect&lt;/code&gt; to see how an image’s processes have been parsed into a command and arguments. For instance a Procfile of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;web: python main.py&lt;/code&gt; used in a cloud buildpack may result in the following:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
Processes:
  TYPE           SHELL        COMMAND           ARGS
  web (default)  bash         python3 main.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Specifically, the entrypoint was parsed as a complex command, and not a single command with zero or more args.&lt;/p&gt;

&lt;p&gt;The complexity of &lt;a href=&quot;https://nickjanetakis.com/blog/docker-tip-63-difference-between-an-array-and-string-based-cmd&quot;&gt;exec and shell form ENTRYPOINTs in Docker&lt;/a&gt; aside, there is a simpler way to solve the issue.&lt;/p&gt;

&lt;p&gt;The way I found to reduce the complexity is to introduce an execution detail where you allow the python file to be executable, or package it, in that such a way that at the operating system level, it’s a single command to start the process.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Take the following example, where the image is build in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build.cloudbuild.yaml&lt;/code&gt; and built in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cloudbuild.yaml&lt;/code&gt;: &lt;a href=&quot;https://gist.github.com/glasnt/125c86569fe67a14e02b16c531f89a3d&quot;&gt;GitHub Gist&lt;/a&gt;&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/glasnt/125c86569fe67a14e02b16c531f89a3d.js&quot;&gt;&lt;/script&gt;

&lt;hr /&gt;

&lt;p&gt;The image is built specifically using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--workspace&lt;/code&gt; flag of &lt;strong&gt;not&lt;/strong&gt; the default workspace. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/workspace&lt;/code&gt; is used by both Buildpacks and Cloud Build, and in my investigations I found conflict here. The default volume &lt;a href=&quot;https://cloud.google.com/build/docs/configuring-builds/pass-data-between-steps&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/workspace&lt;/code&gt;&lt;/a&gt; is used by Cloud Build to pass information between steps, but also as a source of the files within your current working directly when running Cloud Build configurations. If your image also uses this as the default workspace, when using Cloud Build, the image contains none of your custom files.&lt;/p&gt;

&lt;p&gt;Additionally of note, I’m using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.py&lt;/code&gt; here. Recent changes to Cloud buildpacks means that &lt;a href=&quot;https://cloud.google.com/docs/buildpacks/python#application_entrypoint&quot;&gt;Python buildpacks now use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gunicorn main:app&lt;/code&gt; as a default&lt;/a&gt;. This functionality is similar to how App Engine works.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Other languages that have single executables may not have these issues to begin with.&lt;/p&gt;

&lt;p&gt;I’m also sure there’s cleaner patterns. but this one has worked for me.&lt;/p&gt;
</description>
				<pubDate>Tue, 21 Nov 2023 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/buildpack-images-as-cloud-build-steps/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/buildpack-images-as-cloud-build-steps/</guid>
			</item>
		
			<item>
				<title>Getting contextful `latest` images for IaC</title>
				<description>&lt;p&gt;If you’re using Infrastructure as Code for declaring your serverless applications, you may encounter issues if you’re relying on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;latest&lt;/code&gt; container tags.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;latest&lt;/code&gt; is used in Docker &lt;a href=&quot;https://cloud.ibm.com/docs/Registry?topic=Registry-troubleshoot-docker-latest&quot;&gt;when there is a lack of tag&lt;/a&gt; – if you’re not using other tags, it will typically be the most recent image to be built, as therefore “latest”.&lt;/p&gt;

&lt;p&gt;However, if you’re using tools like Terraform, you may be declaring this image without a tag, or explictly as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;latest&lt;/code&gt;. If you rebuild your image, then apply your IaC changes, your service will not refresh, enough though there’s a new image.&lt;/p&gt;

&lt;p&gt;In Terraform and other IaCs, they will confirm the configured value against your infrastructure. Even if the reference to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;latest&lt;/code&gt; image has changed, it will still see something like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcr.io/myproject/myimage:latest&lt;/code&gt; as being the current value, and this no change is required.&lt;/p&gt;

&lt;p&gt;A way to get around this is to not map the image name directly, but to map the &lt;strong&gt;image digest&lt;/strong&gt;. The digest is a &lt;a href=&quot;https://docs.digitalocean.com/glossary/digest/&quot;&gt;SHA256 hash of the docker image&lt;/a&gt;. If there are no changes in the source code between image builds, the digest will not change. If there are changes, the digest will be updated.&lt;/p&gt;

&lt;p&gt;If you link the image digest to your service, then you can allow your service to be updated only if the image has been updated. The digest won’t change even if there’s a new image built with the same SHA, thus you only update when required.&lt;/p&gt;

&lt;p&gt;Getting the digest can be complicated, but it is possible using a bit of extra logic.&lt;/p&gt;

&lt;p&gt;In Terraform, you can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker&lt;/code&gt; provider to inspect your docker registry. You can then get the digest from that, and use that in your image URL. An implementation of this can be seen in the &lt;a href=&quot;https://github.com/GoogleCloudPlatform/avocano/blob/main/docs/admin/terraform-latest.md&quot;&gt;avocano application&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In Pulumi, instead of using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;image_name&lt;/code&gt;, you can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo_digest&lt;/code&gt;, which will be the full image plus sha identifier. Changing this reference in the &lt;a href=&quot;https://github.com/pulumi/templates/blob/master/container-gcp-python/__main__.py#L76&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;container-gcp-python&lt;/code&gt;&lt;/a&gt; will make the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pulumi up&lt;/code&gt; method update the service if and only if the application code is updated.&lt;/p&gt;
</description>
				<pubDate>Tue, 15 Aug 2023 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/context-latest-images/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/context-latest-images/</guid>
			</item>
		
			<item>
				<title>Running Cloud Build with Pull Request context</title>
				<description>&lt;p&gt;When using Cloud Build &lt;a href=&quot;https://cloud.google.com/build/docs/automating-builds/create-manage-triggers&quot;&gt;pull request triggers&lt;/a&gt;, especially when the trigger is to run tests, you’ll traditionally be running your “run my unit tests please” command which will run every test across your entire repo.&lt;/p&gt;

&lt;p&gt;But in cases where that takes a long time, it might be useful to only run tests for pull requests across the code that’s been changed.&lt;/p&gt;

&lt;p&gt;You might be familiar with using a test suite that runs tests for the file you’re changing when you’re developing locally, so for sufficiently complex repos, it might be useful to replicate this in CI.&lt;/p&gt;

&lt;p&gt;When Cloud Build starts, it will fetch a &lt;a href=&quot;https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---depthltdepthgt&quot;&gt;shallow clone&lt;/a&gt; of your repo. This is greatly advantagous for complex repos with long histories, but it means that you don’t have the detail of seeing what the current diff is. (For &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git clone --depth 1&lt;/code&gt;, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git diff&lt;/code&gt; is the entire repo has been added under the most recent commit).&lt;/p&gt;

&lt;p&gt;There are ways around this, however. Cloud Build provides &lt;a href=&quot;https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values&quot;&gt;substitution variables&lt;/a&gt; for the base branch (which will return &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;latest&lt;/code&gt;, or whatever you’ve configured as your default branch), and the head branch (the branch of the pull request). Using these two values, you can ask the cloned git repo to tell you the sum total of the changes from this pull request (the same view you’d get on the “Files changed” tab in GitHub).&lt;/p&gt;

&lt;p&gt;The git commands to do this are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git fetch --unshallow&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;fetches all of the information&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git diff origin/${_BASE_BRANCH} --name-only&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;gives the names of the files that have been changed between the base branch and the (implied) current branch.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(Update 2023-10-17: A previous version of the blog psot used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;origin/${_BASE_BRANCH}..origin/${_HEAD_BRANCH}&lt;/code&gt;, which won’t work for forks. &lt;a href=&quot;https://github.com/terraform-google-modules/terraform-docs-samples/pull/514&quot;&gt;H/T to Roger&lt;/a&gt; for the fix!)&lt;/p&gt;

&lt;p&gt;From there, you can do your own logic to work out which tests need to be run.&lt;/p&gt;

&lt;p&gt;As an example, I have a repo full of folders, each of which have their own tests, and I’m using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pytest&lt;/code&gt;, which without any other arguments will run every &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test_*.py&lt;/code&gt; file, even in nested directories.&lt;/p&gt;

&lt;p&gt;However, I can parse the output from git to work out which folders have had changes, and tell &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pytest&lt;/code&gt; to only run test in the folders which have been changed. In my case, I want to run tests in the entire folder if anything within that top level folder has changed.&lt;/p&gt;

&lt;p&gt;To do this in Cloud Build, I would setup something like the following:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;retrieve delta&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;gcr.io/cloud-builders/git&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;entrypoint&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;bash&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; 
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;-c&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;|&lt;/span&gt; 
        &lt;span class=&quot;s&quot;&gt;set -e&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;git fetch --unshallow&lt;/span&gt;
        
        &lt;span class=&quot;s&quot;&gt;# get the changed files&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;git diff origin/${_BASE_BRANCH} --name-only &amp;gt; _changed_files&lt;/span&gt;
        
        &lt;span class=&quot;s&quot;&gt;# parse out the folders that have changed&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;cat _changed_files  | grep &apos;/&apos; | cut -d &apos;/&apos; -f1 | sort | uniq | tr &apos;\n&apos; &apos; &apos; &amp;gt; _changed_folders&lt;/span&gt;

        &lt;span class=&quot;s&quot;&gt;echo &quot;Change files:&quot; &amp;amp;&amp;amp; cat _changed_files&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;echo &quot;Change folders:&quot; &amp;amp;&amp;amp; cat _changed_folders&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;echo &quot;EOF&quot;&lt;/span&gt;
  
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;pytest&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;python:slim&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;|&lt;/span&gt;
      &lt;span class=&quot;s&quot;&gt;#!/bin/bash&lt;/span&gt;
      &lt;span class=&quot;s&quot;&gt;pip install -r requirements.txt -U pip&lt;/span&gt;
      &lt;span class=&quot;s&quot;&gt;pytest $(cat _changed_folders)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For example, the resulting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pytest&lt;/code&gt; command for a pull request that changes and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;db/src/mydb.py&lt;/code&gt; would be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pytest db&lt;/code&gt;, running on my database unit tests. The integration tests tests in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app/&lt;/code&gt; won’t run, which could save hours of CI time.&lt;/p&gt;

&lt;p&gt;In this example, I’m &lt;a href=&quot;https://cloud.google.com/build/docs/configuring-builds/pass-data-between-steps&quot;&gt;passing data between build steps&lt;/a&gt;, and making use of the &lt;a href=&quot;https://cloud.google.com/build/docs/cloud-builders&quot;&gt;git cloud builder&lt;/a&gt;, a container with git already installed and ready to go. I’m opting to use &lt;a href=&quot;https://cloud.google.com/build/docs/configuring-builds/run-bash-scripts#running_inline_bash_scripts_legacy&quot;&gt;legacy inline scripting&lt;/a&gt; as opposed to the &lt;a href=&quot;https://cloud.google.com/build/docs/configuring-builds/run-bash-scripts#using_substitutions_with_the_script_field&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;script&lt;/code&gt; field&lt;/a&gt;, because I have to rely on a number of environment variables. I could explicitly declare these, but the code is shorter without it. (I don’t need any variables in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pytest&lt;/code&gt; step, so I’m using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;script&lt;/code&gt; field here.)&lt;/p&gt;

&lt;p&gt;You could extend this example by checking if there are any changes that should fire &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;playwright&lt;/code&gt; tests, or indeed run all tests if the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cloudbuild.yaml&lt;/code&gt; file itself is updated.&lt;/p&gt;

&lt;p&gt;Using a setup like this will mean you are potentially (and intentionally) skipping tests in pull requests, so it should be combined with &lt;a href=&quot;https://cloud.google.com/build/docs/schedule-builds&quot;&gt;scheduled builds&lt;/a&gt; to run all the tests nightly or weekly, which can take as long as you want (as long as your tests don’t take as long as the time between tests! Having nightly tests that take more than 24 hours is a horror story for another time.)&lt;/p&gt;
</description>
				<pubDate>Wed, 02 Aug 2023 00:00:00 +0000</pubDate>
				<link>https://glasnt.com/blog/cloud-build-pull-request-context/</link>
				<guid isPermaLink="true">https://glasnt.com/blog/cloud-build-pull-request-context/</guid>
			</item>
		
	</channel>
</rss>
