php editor Baicao will answer your question about moving from a local import path to a remote import path in Golang. In Golang development, we often encounter the situation of moving from the local import path to the remote import path, especially when multiple people collaborate on development or project migration. This article will detail how to handle this issue correctly to ensure your code runs smoothly. Let’s take a look!
Question content
I have just started breaking my application into different repositories. Like many people, I'm going through the trouble of dealing with Go and changing repositories. But there are many questions and answers to these questions, so I won't ask them here.
Instead, I have a simple question but I can't understand it. All my modules, since it's a big application, are just local references. For example core/validate
etc.
Move content into multiple repositories. Seemed to cause problems with local references, so I changed the path to the remote path, e.g. gitlab.com/<group>/core.git/validate</group>
as several Q&A suggested.
However, this will cause a problem, if gitlab.com/<group>/core.git/config</group>
refers to gitlab.com/<group>/core. git/validate</group>
does not mean that gitlab.com/ <group>/core.git/config</group>
now points to pck/mod/gitlab.com/...
Are some of the content either pointing to the remote server, or anywhere but each other, like when they only have relative paths like core/validate
? When I change them it looks like this because my IDE (GoLand) shows the reference not found.
I haven't tried doing go mod init
and rebuilding the mod from scratch, but go mod tidy
doesn't work and I don't know if I have to go as well. It's fine to change the remote path in work
, but now I just can't find the import shown in the IDE.
It seems that if you use a remote reference to make changes you make in your code while developing, you have to push the changes so that it is where the reference points and maybe do go get
Change to reference local remote path, this seems like a bad way of developing and therefore can't be correct.
So, how do these remote paths work with development, what am I missing?
Solution
There are several concepts that can cause confusion.
A module is a collection of packages. You can name your module "mymodule" and then all packages under "mymodule" will be named "mymodule/pkg1", "mymodule/pkg2/otherpkg", etc.
Then you have the import path of the package. The import path shows the location of the package. For example, if your source code is in "mymodule/pkg1" and you import "mymodule/pkg2", then this is a reference to the package under the same module.
Now assume you have another module named "othermodule" on "github.com/mygroup/othermodule". You import a package in this module as "github.com/mygroup/othermodule/pkg1". If "othermodule/pkg1" references "othermodule/pkg2", then it still imports "othermodule/pkg2" because it is in the same module. But from "mymodule/pkg1" you import it as "github.com/mygroup/othermodule/pkg2".
The Go module system uses version references from other modules. When you include a package from a module, the specific version of the module is added to go.mod. If you push new changes to the module, you must update the reference to include those changes. That's why it's best not to split a tightly coupled project into multiple modules.
If you want to develop multiple modules together, use the "replace" directive to use a local copy of the module instead of pointing to the version on the repository.
The above is the detailed content of Golang, problem of moving from local import path to remote import path. For more information, please follow other related articles on the PHP Chinese website!

我有一个golang代码,它使用chromedp连接到用户的本地chrome这是我的代码:packagemainimport("context""fmt""log""os""time""github.com/chromedp/chromedp""github.com/gin-gonic/gin")funcmain(){api:=gin.default()api.get("api

在我的ubuntu22.10digitalocean服务器上,我正在尝试使用golang和fiber以及html模板引擎。到目前为止很喜欢它。一切正常,包括mysql连接和发送电子邮件。除了一件事。我不断收到错误渲染:模板索引不存在。文件系统:├──/gogo├──main├──main.go├──go.mod├──go.sum├──/views└──index.html└──/public

我在调用以下函数时遇到错误“ORA-00911:无效字符”。如果我使用带有硬编码值的SQL查询(截至目前,它已在下面的代码片段中注释掉),那么我可以在邮递员中以JSON响应获取数据库记录,没有任何问题。所以,看起来我的论点做错了。仅供参考,我正在使用“github.com/sijms/go-ora/v2”包连接到oracledb。另外,“DashboardRecordsRequest”结构位于数据模型包中,但我已将其粘贴到下面的代码片段中以供参考。请注意,当我进行POC时,我们将使用存

Mac电脑是许多开发者钟爱的工作平台,而Golang作为一种高效的编程语言,也受到了越来越多人的喜爱。本文将详细介绍如何在Mac电脑上配置和安装Golang的开发环境,同时提供具体的代码示例,帮助读者快速入门和使用Golang进行开发。步骤一:下载Golang安装包首先,我们需要从Golang官方网站(https://golang.org/dl/)下载适用于

从零开始学习Golang开发:详细步骤解析,需要具体代码示例随着互联网的快速发展,编程语言也在不断地涌现出来。其中一种备受瞩目的语言就是Go语言,简称Golang。Golang是由Google开发的一种静态类型、编译型的高性能编程语言,它的设计目标是提供一种简单、高效、可靠的开发语言。对于初学者来说,从零开始学习Golang开发可能会感到困惑和畏惧。本文将按

我在mongo中有这个文档{"_id":{"$oid":"649d3d688a1f30bf82e77342"},"test_value":{"$numberlong":"10"}}我想用这个golang代码将“test_value”减一jsonInput:=[]map[string]interface{}{{"$match":map[string]interface{}{

在该领域的一位开发人员几个月前离开后,我一直在尝试解决并发问题,但我找不到解决此问题的适当方法。对于上下文,我们将客户数据加载到如下结构中:[键]->{值}[客户特定哈希]->{数据点/文件切片}示例-格式确实很糟糕,抱歉:[a60d849ad97bfb833e1096941]->{{StartDate:'01-02-2022',EndDate:'28-02-2022',DataFrames:[1598,921578,12981,21749,1925

Golang类型转换的常见错误及解决方法在使用Golang进行开发的过程中,类型转换无疑是一个经常遇到的问题。虽然Golang是一种静态类型的语言,但是在一些情况下我们仍然需要进行类型转换,比如从interface{}类型转换为具体的结构体类型,或者从一个基本数据类型转换为另一个基本数据类型。然而,类型转换时经常会出现一些错误,本文将介绍一些常见的类型转换错


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
