ADVERTISEMENT
ADVERTISEMENT

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

Parameter(s):

  • 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 »


ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.