Tag Archives: Go

Git error: the requested URL returned error: 500

When Git clone found the following error, research for a long time did not find the reason

$ git clone --bare http://github/lqiqiqi/deepchem deepchem
Cloning into bare repository 'deepchem'...
fatal: unable to access 'http://github/lqiqiqi/deepchem/': The requested URL returned error: 500

Finally found the correct is http://github.com/lqiqiqi/deepchem
url to write wrong, grieve

Solve the error error fetching remote repo origin problem in Git on Jenkins

The following error popped up in the Jenkins compilation today

 > git fetch --tags --progress https://github.com/XXX.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'

But then there are some logs

stdout: 
stderr: From https://github.com/XXX
 ! [rejected]          snap/master/20191024_1946 -> snap/master/20191024_1946  (would clobber existing tag)

To prevent any last minute code>Error remote repo ‘origin’ after last minute promotion, all methods were tried and failed.

    gilis-remote-t view remote tagsgit tag-l view local taggtag-d XXX ## delete local taggit fetch origin –prune tags ## finally pull remote tags

Problem solving

Git pull error: pull is not possible because you have unmerged files

The following errors occurred during Git pull:

error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

Local pushes and merges form merge-head (FETCH-HEAD) and HEAD(push -HEAD) references. A HEAD represents a local reference that has been formed after a recent successful push. Merge-head represents a reference formed after a successful local pull. We can use merge-head or HEAD to achieve a similar effect to SVN Revet.

To solve

    flushes out local conflicting files, requiring not only a merge-head or HEAD reset, but also a -hard reset. The local workspace will not be flushed without the following hard. It just overwhelms the stage.
git reset --hard FETCH_HEAD
    then executes the following command, and it will succeed.
git pull

Error: You have not concluded your merge (MERGE_HEAD exists)

Difference between Git fetch and Git pull: Error: You have not concluded your merge (MERGE_HEAD exists)

The difference between FETCH and pull is that you can fetch the latest version from remote to local
1. Fetch: only fetch the latest version from remote to local, not merge(merge)

git fetch origin master   //Get the latest version on the origin/master branch from the master master branch on a remote origin.
git log -p master..origin/master //Compare the difference between a local master branch and an origin/master branch.
git merge origin/master          //consolidation

2. Pull: get the latest version remotely and merge(merge) locally

git pull origin master  //This is equivalent to doing a git fetch and a git merge.

In practice, it may be better to git fetch, because before merge, it can be decided whether to merge according to the actual situation
Besides, it causes error: error: You have not concluded your merge (MERGE_HEAD exists). may be caused by the failure of automatically merging the code pulled down before
Solution 1: keep the local changes and abort the merge -& GT; Re-amalgamate -& GT; To pull

git merge --abort //Termination of pooling
git reset --merge //re-merger
git pull //refetch

Solution 2: Abandon the local code, and the remote version overwrites the local version (careful)

git fetch --all
git reset --hard origin/master
git fetch

Error: Error Building Trees

background
Due to the excessive number of articles in Add. I was impatient and just used the task manager to turn off idea. After restarting idea to update. Gitignore file, Error Building Trees are submitted.
The solution
Force reset Git

git reset --hard

 

Go get github.com/kotakanbe/go -Problems encountered in CVE dictionary Download

(QIANG)

recently installed vuls on centos, which is the reason for QIANG’s frequent situation. Therefore, document several problems encountered and solutions

1.github.com undownloadable issues

before the reference to reprint an article in the link: https://blog.csdn.net/Jesusons/article/details/104267286
at the end of the centos/etc/hosts add

151.101.72.133 assets-cdn.github.com
151.101.229.194 github.global.ssl.fastly.net

will solve the problem

2. Resolve unknown import path “golang.org/x/sys/unix” : unrecognized import path “golang.org/x/sys”

is still QIANG, so you can’t directly visit golang.org. Fortunately, since Go 1.11, the Go module package dependency management tool has been officially supported. As long as you start Go modules, you can download it smoothly.

启用 Go Modules 功能
export GO111MODULE=on
 配置 GOPROXY 环境变量
export GOPROXY=https://goproxy.io

put a download interface after solving these two problems

GoLand:Unresolved reference ‘NewFunction‘

GoLand: Unresolved reference ‘NewFunction’

(I) describe

after the upgrade to Goland, all the package references prompt Unresolved reference ‘method name’.

(b) cause

The idea folder in the project before

was created by the old version of Goland and should contain some data incompatible with the new version.

(iii) solution

remove the. Idea folder from the project and Goland will be automatically regenerated.

How to compare the equality of structures in golang

if the object is created by the same struct without complex type can be directly used by == on the ratio and pointer

Simple type

sortable data type

Integer
Floating point
String

data type that can be compared

in addition to the above three, there are
Boolean,
Complex,
Pointer,
Channel,
Interface
Array

complex non-comparable data type

Slice
Map
Function

as follows

type User struct {
	age  int
	name string
}

func main() {
	user := User{
		1,
		"d",
	}
	user2 := User{
		1,
		"d",
	}
	fmt.Println(user == user2)  //打印的结果是true 会去自动对比内部的属性是否相等
	//但是如果结构体内部含有map,slice,Function 使用==比较编译会报错
}

the == operator
example

can be used if two objects that are not created in the same structure can be converted to each other and do not contain non-comparable member variables

type USER struct {
	age  int
	name string
	u    Name
}
type Name struct {
	a string
}
type USER2 struct {
	age  int
	name string
	u    Name
}

func main() {
	user := USER{
		1,
		"d",
		Name{""},
	}
	user3 := USER2{
		1,
		"d",
		Name{""},
	}
	user2 := USER(user3)
	fmt.Println(user2 == user) //编译通过 打印结果是true
}

refer to official document

How to Fix GIT Push Error

problem 1:

after creating a new local branch, push the local branch to the remote library, and report an error

when using git pull or git push

gitThere is no tracking information for the current branch.

Please specify which branch you want to merge with.

See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> merged0.9.6

because there is no connection between the local branch and the remote branch (you can see the association between the local branch and the remote branch using git branch-vv). At the command line prompt, simply execute the following command to

git branch --set-upstream-to=origin/ upstream/local branch name

View all branches of local and remote repositories
git branch -a
view branches of remote repositories
git branch -r


problem 2
git push again,

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/caizelin111/securitydemo'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Solutions:

1, the git pull origin master – allow – unrelated – nothing// the remote warehouse and local synchronization, eliminate the differences between </ p>

2, readd and commit corresponding files

3, git push origin master

4, at this point can upload successfully