Failed to read Os.stdin in Windows:/dev/stdout:access is denied.

Source: Internet
Author: User
# # # Environment: Operating system: Windows Go version:go Version go1.10.3 windows/amd64### Sample code: ' Counts: = make (Map[string]int); os.stdin.c Hmod (OS. MODESETUID) Input: = Bufio. Newscanner (OS. Stdin); Os.Stdin.WriteString ("This was a test") for;; {if res: = input. Scan (); res {test: = input. Text (); if test = = "Exit" {break;} counts[test]++;} else {fmt. Printf ("%s", input. ERR ()); break;}} "  " in the OS join. Stdin.chmod (OS. MODESETUID) failed to execute successfully before joining the line code can be successful, error reason: The currently used user rights are insufficient to read the OS. Stdin, below is the source code for creating the callout input and output: D:/programdata/golang/src/os/file.go ' var (Stdin = NewFile (uintptr. Stdin), "/dev/stdin") Stdout = NewFile (UIntPtr (syscall). Stdout), "/dev/stdout") Stderr = NewFile (UIntPtr (syscall). Stderr), "/dev/stderr") "   each time the OS package is called, it creates three global variables, essentially creating three file objects bound to the STD output/input IO, So we treat Os.stdin like a normal file object, set the UserID of file to its current user Id and have Read permission. 63 Reads
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.