我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Golang:带有->字符的命令行参数

I need to accept command line argument to run a Go program in the below format:

 go run app.go 1->A

I am using os.Args[1]. But it only accepts till '1-' . '>A' is being skipped.

Any help to resolve this issue is highly appreciated.

Thanks

Your shell is interpreting the > as IO redirection. The shell opened the file A as standard output for the command and passed the argument 1- to the command.

Quote the argument to avoid this:

go run app.go "1->A"

近期文章

  • GO-函数返回后代码停止执行
  • 去,从字节数组中提取天数
  • API调用中的JSON无法正确解码,我得到的是空白结构
  • 我们可以将从ubuntu生成的go build的输出运行到Windows吗
  • 限制变量存储错误的范围
  • 开始-如何组合多个字符串以输出唯一的“压缩”字符串?
  • 将JSON解码为接口值
  • Go应用在本地运行良好,运行GoApp服务时产生404
  • 使用Go确定进程/程序是否已终止
  • 将嵌套地图编组到JSON中
  • 为什么下面的代码示例经过几次迭代后仍然卡住?
  • 正则表达式以匹配所有之间
  • vs2012 热键无法正常注册
  • 解析文件,忽略注释和空白行
  • 使用golang将数千个节点插入neo4j
  • 关闭文件,然后在golang中重命名
  • Golang坚持认为包作用域函数具有特定类型
  • Elastigo和Go,使用带有变量的Raw json字符串进行搜索
  • 如何在JavaScript中使用动态Golang HTML模板ID?
  • 如何在大猩猩复用路由中获得OR模式

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华