PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, August 21, 2022

[FIXED] how to run a go get command with certain environment values?

 August 21, 2022     environment-variables, go, goproxy, visual-studio-code, windows     No comments   

Issue

I want to run a go get command when GOPROXY='direct', I've tried to run this command using the VS code terminal:

GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo

but I'm getting this error:

GOPROXY=direct : The term 'GOPROXY=direct' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or if a path 
was included, verify that the path is correct and try again.
At line:1 char:1
+ GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (GOPROXY=direct:String) [], CommandNotFoundEx  
   ception
    + FullyQualifiedErrorId : CommandNotFoundException

I've also tried:

go env set GOPROXY='direct'

but when I run go env command the GOPROXY value is still like this GOPROXY=https://proxy.golang.org,direct and I also tried to define a GOPROXY variable in the windows environment variable and giving it the value of direct but it also failed to do the job.


Solution

Make sure your VSCode terminal is a bash one, not a CMD or Powershell.

In a CMD or Powershell, the syntax var=xxx cmd would not be correctly interpreted as: set a variable and execute a command inheriting its environment variables, including the one set.



Answered By - VonC
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing