阻止go build覆盖go.mod中的版本

时间:2019-02-13 16:08:34

标签: go module dependencies

我有一个go模块,可以导入项目foo。 foo的最新标签显示为v1.4

当我在项目中执行go build时,它将更新go.mod以表示

module github.com/myid/mymod

require (
   github.com/myid/foo v1.4
)

我希望它使用master分支而不是v1.4标签...所以我做了一个 go get github.com/myid/foo@master并以pkg格式下载了master分支,并更新了go.mod为

require (
    github.com/myid/foo v1-XXXXXXX-XXXXXXX
)

我确认哈希与主哈希相同

但是当我再次执行go build时,它会更新回最新的标签。

如何使用master分支而不切换回v1.4?

谢谢

2 个答案:

答案 0 :(得分:1)

任何遇到此问题的人的 Necro 答案:

在使用 1.16(等等)时,go build 模块不再自动碰撞

见:https://golang.org/doc/go1.16#go-command

答案 1 :(得分:0)

import matplotlib from matplotlib import pyplot as plt matplotlib.use("TkAgg") from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk from matplotlib.figure import Figure import numpy as np import numpy.ma as ma import cv2 from mpl_toolkits.mplot3d import axes3d from os import listdir from os.path import isfile, join import ellipse as el import tkinter as tk from tkinter import ttk LARGE_FONT= ("Verdana", 12) class SeaofBTCapp(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) tk.Tk.wm_title(self, "Sea of BTC Client") container = tk.Frame(self) container.pack(side="top", fill="both", expand = True) container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1) self.frames = {} for F in (StartPage, PageOne): frame = F(container, self) self.frames[F] = frame frame.grid(row=0, column=0, sticky="nsew") self.show_frame(StartPage) def show_frame(self, cont): frame = self.frames[cont] frame.tkraise() class StartPage(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self,parent) label = ttk.Label(self, text="Start Page", font=LARGE_FONT) label.pack(pady=10,padx=10) button = ttk.Button(self, text="Visit Page 1", command=lambda: controller.show_frame(PageOne)) button.pack() class PageOne(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) label = ttk.Label(self, text="Graph!!!", font=LARGE_FONT) label.pack(pady=10,padx=10) button1 = ttk.Button(self, text="Back to Home", command=lambda: controller.show_frame(StartPage)) button1.pack() labelText=tk.StringVar() labelText.set("Enter x") labelx=ttk.Label(self, textvariable=labelText) labelx.pack(side=tk.TOP) directory=tk.StringVar(None) x_coordinate=ttk.Entry(self,textvariable=directory) x_coordinate.pack(side=tk.TOP) #a = f.add_subplot(111) #a.plot([1,2,3,4,5,6,7,8],[5,6,1,3,8,9,3,5]) mypath='C:\\Users\\mehmet\\Desktop\\a1' onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ] images = np.empty(len(onlyfiles), dtype=object) for n in range(0, len(onlyfiles)): images[n] = cv2.imread( join(mypath,onlyfiles[n]),cv2.IMREAD_GRAYSCALE) image = np.stack([images[i] for i in range(13,299)]) arr_size = (265,490,286) sphere_center = (int(directory.get()),238,76) a=11 b=10 c=12 sphere = el.create_bin_sphere(arr_size,sphere_center, a,b,c) sphere1=255*sphere.astype(np.uint8) sphere2=np.swapaxes(sphere1,0,2) dst = cv2.bitwise_or(sphere2, image) img_p=dst[:,:,120] f = Figure(figsize=(5,5), dpi=100) a = f.add_subplot(111) a.imshow(img_p,cmap='gray') canvas = FigureCanvasTkAgg(f, self) canvas.draw() canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True) app = SeaofBTCapp() app.mainloop()``` 命令自动将非规范的semantic versions解析为规范版本或pseudo-versions

go不是规范的语义版本。