设置后,环境变量保持不变

时间:2017-06-13 19:54:01

标签: go

我通过观看在线教程开始学习Go编程。我使用Windows命令提示符。但是,在我输入set GOOS = darwin然后使用go env打印环境变量后,GOOS未设置为GOOS=darwin,但默认设置为GOOS=windows

这是我得到的。有人能告诉我哪里出错了,以至于我无法对GOOS进行更改吗?

C:\GoPath\src\palindrome>set GOOS = darwin

C:\GoPath\src\palindrome>go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

1 个答案:

答案 0 :(得分:3)

"变量名或字符串周围的任何额外空格都不会被忽略,SET不像许多其他脚本语言那样容忍额外的空格。"

public void aliceEncrypt(byte[] plaintext, byte[] sharedSecret, Socket socket) { try { Cipher cipher = Cipher.getInstance("RC4/ECB/NoPadding"); Key sk = new SecretKeySpec(sharedSecret, "RC4"); cipher.init(Cipher.ENCRYPT_MODE, sk); CipherOutputStream cos = new CipherOutputStream(socket.getOutputStream(), cipher); ObjectOutputStream oos = new ObjectOutputStream(cos); oos.writeObject(plaintext); oos.close(); } catch (Exception e) { e.printStackTrace(); } } public byte[] bobDecrypt( byte[] sharedSecret, Socket socket) { try { Cipher cipher = Cipher.getInstance("RC4/ECB/NoPadding"); Key sk = new SecretKeySpec(sharedSecret, "RC4"); cipher.init(Cipher.DECRYPT_MODE, sk); CipherInputStream cis = new CipherInputStream(socket.getInputStream(), cipher); ObjectInputStream ois = new ObjectInputStream(cis); byte[] bytes = (byte[]) ois.readObject(); return bytes; } catch (Exception e) { e.printStackTrace(); return null; } } 更改为set GOOS = darwin - 即您在set GOOS=darwin的输出中看到的格式相同。