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

取代目前的程序

In Ruby, you can use Kernel.exec to replace the current executing process by the one triggered.

Is it possible to do the same thing in Go?

This is the equivalent to Kernel.exec:

package main

import "fmt"
import "syscall"

func main() {
    if err := syscall.Exec("/bin/ls", []string{"ls", "-l"}, []string{}); err != nil {
      fmt.Println(err)
    }
}

but it is not portable.

近期文章

  • Go中工会的最佳实践
  • 在for循环中使用指针-Golang
  • “ itoa”在strconv.Itoa中代表什么?
  • Go中的“供应”是什么意思?
  • 在个人git仓库上使用“ go get” [重复]
  • 用Go语言循环遍历数组
  • 如何在golang中将[32]字节与[]字节进行比较?
  • 如何在Golang SSH中使用加密的私钥
  • 如何在if-else中初始化错误类型
  • 在交换机中使用时,关键字类型是什么意思?
  • Go中的标志包-我是否必须始终设置默认值?
  • 使用reflect.Typeof()的golang类型断言
  • 在Golang中获取远程SSL证书
  • 是否可以将多个通道复用为一个?
  • 使用Go中的电子邮件地址创建证书签名请求(CSR)
  • 转到频道与Java BlockingQueue
  • 如何在html / template中使用范围内的索引来遍历并行数组?
  • Golang XML属性和值
  • 为什么此Go代码被阻止?
  • 如何从地图获取键作为字符串数组?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华