douhui3760 2019-07-03 21:06
浏览 234

使用golang exec库将gitconfig参数传递到git bash中

I am trying to write a go script to setup the user's name in the gitconfig file.

I tried the following arguments shown in the code below in the terminal and it works when I manually input the arguments sequentially, but it does not work from golang.

cl := exec.Command("git", "-C", "config", "--global", "", 
stdout, err := cl.CombinedOutput()
if err != nil {
fmt.Printf("%s", stdout)

From the code snippet I expect the code to generate a .gitconfig file and for the file to contain the name of the user. When I run the code I get exit status 128.

  • 写回答

1条回答 默认 最新

  • dqvj51875 2019-07-03 21:20

    You probably shouldn't include the -C option without also giving it a path. If you are trying to add something to the global config, you probably don't need the -C option at all.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 abaqus里的python算法
  • ¥15 单细胞测序筛选簇中基因
  • ¥100 如何在思科模拟器中进入CEF模式
  • ¥15 Simulink 仿真如何使用MATLAB function模块获取到仿真过程中某一仿真时刻输入到模块的函数的值?
  • ¥50 关于#微信小程序#的问题:微信小程序支持h5实现webrtc h264 h265低延迟传输渲染,能付费帮我们解决一下吗
  • ¥20 请问ansys License manager 这个问题如何解决
  • ¥15 memory.limit()' is no longer supported
  • ¥15 基于stm32f4产生两路pwm信号并可由串口通信调节
  • ¥15 C++/QT设置函数调用条件(多个功能调用同一,且各自调用条件不同)
  • ¥15 UE5样条线生成的网格UV问题