--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
For other vcs than git I . . .
const (
PathSeparator = '/' // OS-specific path separator
PathListSeparator = ':' // OS-specific path list separator
)It would be my strong recommendation as a user of both Windows and Linux to just standardize on "\n".I wouldn't consider "\r\n" to be os dependent, just application dependent. All applications I use (including visual studio) understand "\n" as a line ending.
On Tue, Nov 3, 2015 at 3:32 PM, Manlio Perillo <manlio....@gmail.com> wrote:
> You can implement it yourself:
No, I was talking about, taking right from my code, :
fmt.Fprintf(w, "CE: \r\n=>\r\n\r\n")
That's just ugly.

--
The TextWriter that Manlio sketched would work as the "w" in your fmt.Fprintf example, except the Write method should accept a []byte and return an error. Then TextWriter would implement the io.Writer interface.
BTW, if you open your file using Wordpad rather than Notepad, it will split the lines correctly.
On Tue, Nov 3, 2015 at 1:17 PM Tong Sun wrote:On Tue, Nov 3, 2015 at 3:37 PM, Tong Sun wrote:
On Tue, Nov 3, 2015 at 3:32 PM, Manlio Perillo wrote:
> You can implement it yourself:
No, I was talking about, taking right from my code, :
fmt.Fprintf(w, "CE: \r\n=>\r\n\r\n")
That's just ugly.
Try run this under DOS,and redirect output to a file,You'll get:BTW, Perl conceal the trouble of handling "\n" as well.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/VwpNO73V1CE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
There is no clear line between text and binary files. Is XML a text format? How about EPS? What if the EPS file has a TIFF preview?
...
(Yes, it would be a good idea for the standard library to provide some sort of Reader that normalizes newlines, and a Writer that converts \n to \r\n, but I am glad that by default Go gives us access to the exact content of files.)
> IMHO, yes it is -- whenever '\n' is used, it means text output. Otherwise, I'd use '\x0A' instead.
So your proposal is that, when compiling for Windows, \n should mean the two-byte sequence CR/LF instead of just a line feed?
-j
> what it the reason why it has no support in the Go standard library?
Partly it’s Go’s Unix heritage. Unix doesn’t distinguish text and binary files. Other modern operating systems don’t make nearly as much distinction between the two as older ones did, either. On Windows, I think the only difference is whether \n gets converted to \r\n. I think some older OSes had completely separate APIs for the two.
There is no clear line between text and binary files. Is XML a text format? How about EPS? What if the EPS file has a TIFF preview?
If a system automatically translates line endings, it also needs a way to turn that translation off. That adds yet more complexity.
And there’s no guarantee (especially in the age of the internet) that a text file has the standard line endings for the platform it is being processed on. Many text-like file formats have a standard for what the line endings should be, which applies no matter what platform they are processed on.
The problem is that Go standard io interfaces only operate on byte slices.The io package has a WriteString function, and a stringWriter interface that is not exported.Maybe the io package should export a StringWriter interface and some functions to create concrete types, setting the encoding/transformer and end of line "character".The interface should have a WriteString method, but also methods to query and set the encoding/ransformer and end of line character.
I may wrong with my answer. But Go outputs UTF-8, not ASCII. In my understanding, even when UTF8 maps ASCII, its line endings are different.Even with the same binary representation, the semantics are different.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/VwpNO73V1CE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.