Skip to content

Commit b78586a

Browse files
committed
add os.linesep
1 parent 698cf9f commit b78586a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

os/os.module.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ func getpathsep() py.String {
4242
return py.String(":")
4343
}
4444

45+
// getlinesep returns the line seperator (newline character). This is '\r\n' for windows and '\n' for posix
46+
func getlinesep() py.String {
47+
if runtime.GOOS == "windows" {
48+
return py.String("\r\n")
49+
}
50+
return py.String("\n")
51+
}
52+
4553
func init() {
4654
methods := []*py.Method{
4755
py.MustNewMethod("getcwd", getCwd, 0, "Get the current working directory"),
@@ -64,6 +72,7 @@ func init() {
6472
"extsep": py.String("."),
6573
"altsep": py.None,
6674
"pathsep": getpathsep(),
75+
"linesep": getlinesep(),
6776
}
6877

6978
py.RegisterModule(&py.ModuleImpl{

0 commit comments

Comments
 (0)