syscall.Mount cannot mount nfs server by URL

Hello everyone.
I got a nfs server and I want to mount it in my program. So I use the Code like below (just for example)

import (

func main() {
	nfsServer := os.Args[1]
	nfsPath := os.Args[2]

	data := "./data"
	err := syscall.Mount(":"+nfsPath, data, "nfs", 0, "nolock,addr="+nfsServer)
	if err != nil {

It works fine. In this case my nfs server is a IP address like

The other day I changed. my nfs server to Cloud file server which is a URL like
then I found my program is not working. When I try to mount the nfs I just got a error which is 「invalid parameter」.

So I wonder what’s wrong with my Code.

In addition. I tried mount the nfs file system by shell it works fine.
Thank you

Have a look at :

For most types all the mount program has to do is issue a simple mount(2) system call, and no detailed knowledge of the filesystem type is required. For a few types however (like nfs, nfs4, cifs, smbfs, ncpfs) ad hoc code is necessary. The nfs, nfs4, cifs, smbfs, and ncpfs filesystems have a separate mount program. In order to make it possible to treat all types in a uniform way, mount will execute the program /sbin/mount.TYPE (if that exists) when called with type TYPE. Since various versions of the smbmount program have different calling conventions, /sbin/mount.smbfs may have to be a shell script that sets up the desired call.

So the mount command might do some extra work for the syscall.Mount

As a workaround, you can call the shell from Go using os/exec.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.