×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

How to make directories using syscall in Golang?

Here, we will learn to make directories using syscall in Golang.
Submitted by IncludeHelp, on November 13, 2021 [Last updated : March 05, 2023]

Making the directories using syscall in Golang

In the Go programming language, to make directories using syscall – we use the Mkdir() function of the syscall package. The Mkdir() function is used to make directories.

Syntax

func Mkdir(path string, mode uint32) (err error)

Consider the below example demonstrating how to make directories using syscall in Golang?

Golang code to make the directories using syscall

package main

import (
	"fmt"
	"syscall"
)

func main() {
	// Creating directories
	err := syscall.Mkdir("/tmp/dir1", 0754)

	// Printing message if there is no error
	if err == nil {
		fmt.Println("success")
	}
}

Output

success

Golang syscall Package Programs »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.