<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Tymoteusz Blazejczyk</title>
    <description>The latest articles on Forem by Tymoteusz Blazejczyk (@tymonx).</description>
    <link>https://forem.com/tymonx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F355561%2F5a049241-492d-4b80-b157-a259723eaab6.png</url>
      <title>Forem: Tymoteusz Blazejczyk</title>
      <link>https://forem.com/tymonx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tymonx"/>
    <language>en</language>
    <item>
      <title>Go Error</title>
      <dc:creator>Tymoteusz Blazejczyk</dc:creator>
      <pubDate>Tue, 20 Oct 2020 18:48:54 +0000</pubDate>
      <link>https://forem.com/tymonx/go-error-3k2m</link>
      <guid>https://forem.com/tymonx/go-error-3k2m</guid>
      <description>&lt;p&gt;Tired of using boring #Go &lt;code&gt;errors.New&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;Try the latest &lt;a href="https://gitlab.com/tymonx/go-error"&gt;Go Error&lt;/a&gt; package today. It implements replacement fields surrounded by curly braces &lt;code&gt;{}&lt;/code&gt; format strings similar to Python string format.&lt;/p&gt;

&lt;p&gt;Features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implements &lt;strong&gt;replacement fields&lt;/strong&gt; surrounded by curly braces &lt;code&gt;{}&lt;/code&gt; format strings&lt;/li&gt;
&lt;li&gt;Format string by providing arguments without using placeholders or format verbs &lt;code&gt;%&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format string using automatic placeholder &lt;code&gt;{p}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format string using positional placeholders &lt;code&gt;{pN}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format string using named placeholders &lt;code&gt;{name}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format string using object placeholders &lt;code&gt;{.Field}&lt;/code&gt;, &lt;code&gt;{p.Field}&lt;/code&gt; and &lt;code&gt;{pN.Field}&lt;/code&gt; where &lt;code&gt;Field&lt;/code&gt; is an exported &lt;code&gt;struct&lt;/code&gt; field or method&lt;/li&gt;
&lt;li&gt;Set custom format error message string. Default is &lt;code&gt;{.BaseFile}:{.Line}:{.BaseFunction}(): {.Message}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Error message contains file path, line number, function name from where was called&lt;/li&gt;
&lt;li&gt;Compatible with the standard &lt;code&gt;errors&lt;/code&gt; package with &lt;code&gt;As&lt;/code&gt;, &lt;code&gt;Is&lt;/code&gt; and &lt;code&gt;Unwrap&lt;/code&gt; functions&lt;/li&gt;
&lt;li&gt;It uses the &lt;a href="https://gitlab.com/tymonx/go-formatter"&gt;Go Formatter&lt;/a&gt; library&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Go Formatter</title>
      <dc:creator>Tymoteusz Blazejczyk</dc:creator>
      <pubDate>Tue, 20 Oct 2020 10:53:14 +0000</pubDate>
      <link>https://forem.com/tymonx/go-formatter-3l6</link>
      <guid>https://forem.com/tymonx/go-formatter-3l6</guid>
      <description>&lt;p&gt;Tired of using boring #Go &lt;code&gt;fmt&lt;/code&gt; package?&lt;/p&gt;

&lt;p&gt;Try the latest &lt;a href="https://gitlab.com/tymonx/go-formatter"&gt;Go Formatter&lt;/a&gt; package today. It implements &lt;strong&gt;replacement fields&lt;/strong&gt; surrounded by curly braces &lt;code&gt;{}&lt;/code&gt; format strings similar to Python string format.&lt;/p&gt;

&lt;p&gt;Features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implements &lt;strong&gt;replacement fields&lt;/strong&gt; surrounded by curly braces &lt;code&gt;{}&lt;/code&gt; format strings&lt;/li&gt;
&lt;li&gt;Format string by providing arguments without using placeholders or format verbs &lt;code&gt;%&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format string using automatic placeholder &lt;code&gt;{p}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format string using positional placeholders &lt;code&gt;{pN}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format string using named placeholders &lt;code&gt;{name}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format string using object placeholders &lt;code&gt;{.Field}&lt;/code&gt;, &lt;code&gt;{p.Field}&lt;/code&gt; and &lt;code&gt;{pN.Field}&lt;/code&gt; where &lt;code&gt;Field&lt;/code&gt; is an exported &lt;code&gt;struct&lt;/code&gt; field or method&lt;/li&gt;
&lt;li&gt;Use custom placeholder string. Default is &lt;code&gt;p&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use custom replacement delimiters. Default are &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use custom replacement functions with transformation using pipeline &lt;code&gt;|&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Under the hood it uses the standard &lt;a href="https://golang.org/pkg/text/template/"&gt;text/template&lt;/a&gt; package&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Feedback about the go-mock script that create mocks for all automatically and recursively detected Go interfaces</title>
      <dc:creator>Tymoteusz Blazejczyk</dc:creator>
      <pubDate>Sat, 23 May 2020 11:13:44 +0000</pubDate>
      <link>https://forem.com/tymonx/feedback-about-the-go-mock-script-that-create-mocks-for-all-automatically-and-recursively-detected-go-interfaces-2n7k</link>
      <guid>https://forem.com/tymonx/feedback-about-the-go-mock-script-that-create-mocks-for-all-automatically-and-recursively-detected-go-interfaces-2n7k</guid>
      <description>&lt;p&gt;Recently I have working on a project that allow to work on Go projects out-of-box using a Docker image.&lt;/p&gt;

&lt;p&gt;It contains preinstalled tools for developing, mocking, formatting, linting, building, testing and documenting Go projects.&lt;/p&gt;

&lt;p&gt;For mocking Go interfaces, I'm using the standard and classic &lt;code&gt;mockgen&lt;/code&gt; tool in reflect mode. One of annoying thing about that tool is command line invocations.&lt;/p&gt;

&lt;p&gt;I have scripted that to automatically and recursively detect all Go interfaces. It excludes &lt;code&gt;_test.go&lt;/code&gt; files, &lt;code&gt;mocks&lt;/code&gt; directories and the &lt;code&gt;package main&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Go module detection is based on the &lt;code&gt;go env GOMOD&lt;/code&gt; command invocation. All &lt;code&gt;mocks&lt;/code&gt; are generated under the mocks directory for given Go package.&lt;/p&gt;

&lt;p&gt;For me it works well. But I may have miss something. And because of that, I want to ask you for a small feedback. In advance, I appreciate it for any comments :)&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;go-mock&lt;/code&gt; script that covers this topic: &lt;a href="https://gitlab.com/tymonx/docker-go/-/blob/master/scripts/go-mock"&gt;https://gitlab.com/tymonx/docker-go/-/blob/master/scripts/go-mock&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Project site: &lt;a href="https://gitlab.com/tymonx/docker-go"&gt;https://gitlab.com/tymonx/docker-go&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also hope, that it may be useful for someone ;)&lt;/p&gt;

</description>
      <category>go</category>
      <category>discuss</category>
      <category>docker</category>
      <category>help</category>
    </item>
    <item>
      <title>A Docker image with preinstalled tools for developing, formatting, linting,
building, testing and documenting Go projects</title>
      <dc:creator>Tymoteusz Blazejczyk</dc:creator>
      <pubDate>Thu, 21 May 2020 09:44:48 +0000</pubDate>
      <link>https://forem.com/tymonx/a-docker-image-with-preinstalled-tools-for-developing-formatting-linting-building-testing-and-documenting-go-projects-4o49</link>
      <guid>https://forem.com/tymonx/a-docker-image-with-preinstalled-tools-for-developing-formatting-linting-building-testing-and-documenting-go-projects-4o49</guid>
      <description>&lt;h1&gt;
  
  
  Docker Go
&lt;/h1&gt;

&lt;p&gt;A Docker image with preinstalled tools for developing, formatting, linting,&lt;br&gt;
building, testing and documenting Go projects.&lt;/p&gt;

&lt;p&gt;Project site: &lt;a href="https://gitlab.com/tymonx/docker-go"&gt;https://gitlab.com/tymonx/docker-go&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For GitLab CI: &lt;a href="https://gitlab.com/tymonx/gitlab-ci"&gt;https://gitlab.com/tymonx/gitlab-ci&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  Pre-installed required tools for developing, formatting, linting, building, testing and documenting Go projects&lt;/li&gt;
&lt;li&gt;  Pre-installed the &lt;code&gt;mockgen&lt;/code&gt; tool for generating mocks for testing&lt;/li&gt;
&lt;li&gt;  Formatting and validating Go source files imports with the &lt;code&gt;goimports&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;  Formatting and validating Go source files format with the &lt;code&gt;gofmt&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;  Validating Go source files errors with the &lt;code&gt;errcheck&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;  Linting Go source files with the &lt;code&gt;revive&lt;/code&gt;, the &lt;code&gt;golangci-lint&lt;/code&gt; and the &lt;code&gt;golint&lt;/code&gt; tools&lt;/li&gt;
&lt;li&gt;  Building Go source files&lt;/li&gt;
&lt;li&gt;  Testing Go project&lt;/li&gt;
&lt;li&gt;  Generating Go coverage result, text and HTML reports&lt;/li&gt;
&lt;li&gt;  Generating JUnit test XML report for GitLab Merge Requests&lt;/li&gt;
&lt;li&gt;  Generating Cobertura coverage XML report for GitLab Merge Requests&lt;/li&gt;
&lt;li&gt;  Validating Go coverage value threshold with colorization&lt;/li&gt;
&lt;li&gt;  Colorizing Go imports and format validation with the &lt;code&gt;colordiff&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;  Colorizing Go tests with the &lt;code&gt;richgo&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;  Colorizing Go coverage results and format nicely with the &lt;code&gt;column&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;  Generating static HTML coverage report with the &lt;code&gt;go tool cover&lt;/code&gt; tool&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Download the &lt;code&gt;docker-run.sh&lt;/code&gt; helper script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget -O docker-run.sh https://gitlab.com/tymonx/docker-go/-/raw/master/docker-run.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Make it executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod a+x ./docker-run.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Run the &lt;code&gt;docker-run.sh&lt;/code&gt; script without any arguments to work in Docker container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./docker-run.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Or pass arguments to the &lt;code&gt;docker-run.sh&lt;/code&gt; script to execute commands inside Docker container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./docker-run.sh go build ./...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Use the &lt;code&gt;go-format&lt;/code&gt; command to automatically reformat Go source files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./docker-run.sh go-format
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Use the &lt;code&gt;go-lint&lt;/code&gt; command to run various Go linters on Go source files with enabled colorization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./docker-run.sh go-lint
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Use the &lt;code&gt;go-build&lt;/code&gt; command to build Go source files. Equivalent to the &lt;code&gt;go build ./...&lt;/code&gt; execution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./docker-run.sh go-build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Use the &lt;code&gt;go-test&lt;/code&gt; command to run tests and validate coverage result with enabled colorization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./docker-run.sh go-test
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All commands accept standard Go paths as additional arguments like &lt;code&gt;./&lt;/code&gt;, &lt;code&gt;./...&lt;/code&gt;, &lt;code&gt;&amp;lt;package-name&amp;gt;&lt;/code&gt; and so on.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>go</category>
      <category>productivity</category>
      <category>devops</category>
    </item>
    <item>
      <title>Handy Gitlab CI YAML job templates for Go projects</title>
      <dc:creator>Tymoteusz Blazejczyk</dc:creator>
      <pubDate>Thu, 14 May 2020 08:50:56 +0000</pubDate>
      <link>https://forem.com/tymonx/handy-gitlab-ci-yaml-job-templates-for-go-projects-15c7</link>
      <guid>https://forem.com/tymonx/handy-gitlab-ci-yaml-job-templates-for-go-projects-15c7</guid>
      <description>&lt;p&gt;Various useful and handy GitLab CI YAML templates for typical GitLab CI tasks.&lt;/p&gt;

&lt;p&gt;Project site: &lt;a href="https://gitlab.com/tymonx/gitlab-ci"&gt;https://gitlab.com/tymonx/gitlab-ci&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  General Features
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Supporting validating, building, testing and auto-documenting projects out-of-box&lt;/li&gt;
&lt;li&gt;Automating various and mostly typical GitLab CI tasks&lt;/li&gt;
&lt;li&gt;Extending GitLab CI like with parallel download with caching support&lt;/li&gt;
&lt;li&gt;Easy to use with the GitLab CI &lt;code&gt;include&lt;/code&gt; keyword in your &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; files&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Go Features
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Automatically installing required Go tools for validating, testing and documenting project&lt;/li&gt;
&lt;li&gt;Validating Go source files imports with the &lt;code&gt;goimports&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;Validating Go source files errors with the &lt;code&gt;errcheck&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;Validating Go source files format with the &lt;code&gt;gofmt&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;Linting Go source files with the &lt;code&gt;revive&lt;/code&gt;, the &lt;code&gt;golangci-lint&lt;/code&gt; and the &lt;code&gt;golint&lt;/code&gt; tools&lt;/li&gt;
&lt;li&gt;Building Go source files&lt;/li&gt;
&lt;li&gt;Testing Go project&lt;/li&gt;
&lt;li&gt;Generating Go coverage result, text and HTML reports&lt;/li&gt;
&lt;li&gt;Generating JUnit test XML report for GitLab Merge Requests&lt;/li&gt;
&lt;li&gt;Generating Cobertura coverage XML report for GitLab Merge Requests&lt;/li&gt;
&lt;li&gt;Validating Go coverage value with customazible coverage threshold&lt;/li&gt;
&lt;li&gt;Colorizing Go imports and format validation with the &lt;code&gt;colordiff&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;Colorizing Go tests with the &lt;code&gt;richgo&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;Colorizing Go coverage results and format nicely with the &lt;code&gt;column&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;Generating static HTML source code documentation with the &lt;code&gt;godoc&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;Generating static HTML coverage report with the &lt;code&gt;go tool cover&lt;/code&gt; tool&lt;/li&gt;
&lt;li&gt;Uploading static HTML source code documentation and coverage report to GitLab Pages for browsing&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Links
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Project site: &lt;a href="https://gitlab.com/tymonx/gitlab-ci"&gt;https://gitlab.com/tymonx/gitlab-ci&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Documentation: &lt;a href="https://gitlab.com/tymonx/gitlab-ci/-/wikis/home"&gt;https://gitlab.com/tymonx/gitlab-ci/-/wikis/home&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Project example: &lt;a href="https://gitlab.com/tymonx/go-logger"&gt;https://gitlab.com/tymonx/go-logger&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Generated Go documentation example: &lt;a href="https://tymonx.gitlab.io/go-logger/doc/pkg/gitlab.com/tymonx/go-logger/logger/"&gt;https://tymonx.gitlab.io/go-logger/doc/pkg/gitlab.com/tymonx/go-logger/logger/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Generated Go coverage report example: &lt;a href="https://tymonx.gitlab.io/go-logger/coverage/"&gt;https://tymonx.gitlab.io/go-logger/coverage/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>productivity</category>
      <category>devops</category>
      <category>gitlab</category>
    </item>
  </channel>
</rss>
