<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Golang on Hxysayhi</title>
    <link>https://hxysayhi.github.io/tags/golang/</link>
    <description>Recent content in Golang on Hxysayhi</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 02 Jul 2022 03:29:38 +0000</lastBuildDate>
    <atom:link href="https://hxysayhi.github.io/tags/golang/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>使用make进行golang编译中的小问题及解决方案</title>
      <link>https://hxysayhi.github.io/posts/61a056t8/</link>
      <pubDate>Sat, 02 Jul 2022 03:29:38 +0000</pubDate>
      <guid>https://hxysayhi.github.io/posts/61a056t8/</guid>
      <description>&lt;ol&gt;&#xA;&lt;li&gt;报错信息：Clock skew detected. Your build may be incomplete.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;make: Warning: Clock skew detected. Your build may be incomplete.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;表示检测到了时钟偏差，通常发生在将代码从开发主机拷贝到编译主机进行编译，而两个设备系统之间的时间上存在差距。&lt;/p&gt;&#xA;&lt;p&gt;解决方案：&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;find ./ -type f | xargs touch&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;将所有文件进行一次touch，刷新时间为本地时间，然后进行编译&lt;/p&gt;&#xA;&lt;ol start=&#34;2&#34;&gt;&#xA;&lt;li&gt;报错信息：&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;no required module provides package main.go; to add it:&#xA;    &#xA;              go get main.go&#xA;              &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;解决方案&lt;/p&gt;&#xA;&lt;p&gt;修改 makefile中 build 的命令行：&lt;/p&gt;&#xA;&lt;p&gt;由&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    go build -o bin/manager main.go&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;改为：&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    go build -o bin/manager &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;MODULE&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;/path/to/the/dir/of/main.go&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;${MODULE} 为当前项目module值，可在 go.mod中获取，即开头的 module值&lt;/p&gt;&#xA;&lt;p&gt;/path/to/the/dir/of/main.go 为main.go所在目录在本项目中的相对路径&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
