×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang os.PathListSeparator Constant with Examples

Golang | os.PathListSeparator Constant: Here, we are going to learn about the PathListSeparator constant of the os package with its usages, syntax, and examples.
Submitted by IncludeHelp, on October 26, 2021

os.PathListSeparator

In the Go language, the os package provides a platform-independent interface to operating system (Unix-like) functionality. The PathListSeparator constant is used to get the operating specific path list separator. The value of the PathListSeparator constant may be different based on the operating system.

Syntax

PathListSeparator int32

Implementation in the package source code:

PathListSeparator     = ':' 
// Here, ':' is Unix-based path list separator

Parameters

  • None

Return Value

The return type of the os.PathListSeparator constant is an int32, it returns ':' (Unix-based operating system) i.e., the value of PathListSeparator constant is ':' on Unix operating system.

Example 1

// Golang program to demonstrate the
// example of PathListSeparator constant

package main

import (
	"fmt"
	"os"
)

func main() {
	// Printing the type and value
	fmt.Printf("Type of os.PathListSeparator: %T\n",
		os.PathListSeparator)
	fmt.Printf("Value of os.PathListSeparator: %c\n",
		os.PathListSeparator)
}

Output:

Type of os.PathListSeparator: int32
Value of os.PathListSeparator: :

Example 2

// Golang program to demonstrate the
// example of PathListSeparator constant

package main

import (
	"fmt"
	"os"
)

func main() {
	path1 := "dir" + string(os.PathListSeparator) + "example"
	fmt.Println("path1: " + path1)
}

Output:

path1: dir:example

Golang os Package »




Comments and Discussions!

Load comments ↻





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