This article is from the blog Garden , author : A Wei's blog , Reprint please indicate the original link :https://www.cnblogs.com/cenjw/p/go-ioutil-writefile-perm.html
Preface
go iouitl The file writing method under the package WriteFile
func WriteFile(filename string, data []byte, perm os.FileMode) error
perm The parameter indicates the permission of the file .WriteFile(filename, data, 0644), 0644 What authority does it represent ?
File attribute identification
File attribute identification , I believe this pair are familiar with Linux Friends of the system will not be unfamiliar .
- The first 0 position : File attribute ."-" Represents a common file ;"d" Represents a directory
- The first 1~3 position : Permissions of the file owner
- The first 4~6 position : Permissions of the user group to which the file belongs
- The first 7~9 position : The authority of others
give an example :
Each identity (owner/group/others) Three rights of each (r/w/x) Score is required Add up Of , For example, when the permission is : -rwxrwxrwx The score is :777
r: 4
w: 2
x: 1
owner = rwx = 4+2+1 = 7
group = rwx = 4+2+1 = 7
others= rwx = 4+2+1 = 7
This article is from the blog Garden , author : A Wei's blog , Reprint please indicate the original link :https://www.cnblogs.com/cenjw/p/go-ioutil-writefile-perm.html
stay go In language , It can be done by os.FileMode(perm).String() View permission id :
// A normal file is created , Everyone has all the reading 、 Write 、 Executive authority
os.FileMode(0777).String() // return -rwxrwxrwx
// A normal file is created , Everyone has access to the file 、 Write permissions , But none of them are executable
os.FileMode(0666).String() // return -rw-rw-rw-
// A normal file is created , The file owner has read and write permission to the file ,
// User groups and others have only read access , No permission to execute
os.FileMode(0644).String() // return -rw-r--r--
notes :golang When you specify permissions for creating files in , Only with "0XXX" In the form of
Go Write file permissions WriteFile(filename, data, 0644)? More articles about
- php apache User write folder permission settings
php In general, it is based on apache As a user , hold apache Join the parent folder group where your files are stored , Then change the permission of the parent folder to 775, In this way, group members have write permission , and apache If you belong to this group, you can overwrite all the files in this directory ...
- PHP Write file functions
/** * Write file functions * * @param string $filename file name * @param string $text Text string to write * @param string $openmod ...
- Ruby Writing documents
Ruby Writing documents outFile = File.new("fileName.txt","w") outFile.puts "a" outFi ...
- File default permissions umask Mask
umask command effect : Used for display . Set the default permissions for the file Format :umask [-S] -S Said to rwx The default permissions of the new file are displayed in the form The default mask for the system is 0022 Default permissions when creating files = 0666 - umas ...
- utilize php CI force_download($filename, $data) download .csv File solution file name garbled , The contents of the document are garbled
utilize php CI force_download($filename, $data) download .csv File solution file name garbled , The contents of the document are garbled 2014-07-31 12:53 1047 Human reading Comment on (0) Collection ...
- Before writing a file , Check directory write permissions (PHP)
Before writing a file , Check directory write permissions Before writing or saving a file , Make sure the directory is writable , If you can't write , Output error message . This will save you a lot of debugging time . linux In the system , Processing permissions are required , Improper directory permissions can cause many problems , File also ...
- Java Don't write documents ,LOAD DATA LOCAL INFILE Mass import data to MySQL The implementation of the ( turn )
MySQL Use load data local infile Importing data from a file is better than insert Fast sentence ,MySQL The document says to be fast 20 About times . But this method has a drawback , Before importing data , There must be documents , In other words, from the text ...
- The first 3 Chapter Linux File permission management on
3.1 file / Directory permissions 3.1.1 File permissions Every file has its owner (u:user). Subordinate to the group (g:group) And others (o:other) Operation permission for it ,a:all It also represents this 3 person . Permissions include read (r:r ...
- Encapsulate a help class to write files to android On external memory
Project address : Click on the open Project brief introduction : Write a document to android A helper class for external storage , And it's demo Program How does it work ? 1. establish AppExternalFileWriter Object and pass context( Up and down ...
- summary java Create and write files in 5 Ways of planting
stay java There are many ways to create files and write files , Have you really summed up ? Now the author will help you to sum up java Five ways to create files in . Files.newBufferedWriter(Java 8) Files. ...
Random recommendation
- Against password cracking —— Web Slow front end Hash
( to update :https://www.cnblogs.com/index-html/p/frontend_kdf.html ) 0x00 Preface Martial arts in the world , Fast break not only . But it's different in cryptography . The faster algorithm , The easier it is to break. . ...
- The simplest JavaScript template engine
After staying in a small company for a long time, I feel that my knowledge is very small , Recently, I visited the blog Garden and some technical websites to see what you are saying JavaScript About the template engine , No concept at all , This is 08 It began to be popular in ... I thought it was very profound knowledge , Later, I saw it on the Internet ...
- ios sound recording 、 Audio playback function
#import <AVFoundation/AVFoundation.h> { NSInteger _timeCount; NSTimer *_timer; } @pro ...
- android eclipse Associated source code , And source code ( Code ) as well as jar Check out the software
1.eclipse Associated source code Step one : Download the corresponding version of the source code from Baidu , I am here 4.2 That is to say API=17 Version of . Step two : Find you install sdk The catalog of , G:\Program Files\adt-bundle-wi ...
- Use jqueryui
$(function () { $('#search_button').button(); /* Open both dialogs at the same time $('#reg').dialog(); $('#login').dialog(); ...
- Java: Talking about InputStream Of close Method
principle : It's best to use it at any time InputStream perhaps OutputStream When , stay finally Call in close() Method , Turn off... Explicitly . A typical example InputStream in = null; t ...
- Windows Heap management in programming ( Too low , Generally don't care )
Abstract : This paper mainly focuses on Windows Heap management technology in memory management is discussed , And briefly introduces the creation of heap . Allocation and reallocation of memory blocks . Undo of heap and new and delete The use of operators and so on . key word : Pile up : Heap management 1 introduction In most ...
- [BZOJ 3894] Arts and Sciences Division 【 Minimum cut 】
Topic link :BZOJ - 3894 Topic analysis Minimum cut model , Set a point with S Connected means selected text , And T Connected means optional . So first of all, add all the possible weights , Then subtract the minimum cut , That is, the weight that cannot be obtained . So for each point , from ...
- Excel Too many cells will cover the next range
Excel Too many cells will cover the range of the next cell. Read step by step Excel Cell contents in , There are different alignments . Users can according to their own needs , When processing data , Set your own alignment . When you're dealing with data , If set ...
- Elasticsearch java api Common query methods QueryBuilder Construction example
Reprint :http://m.blog.csdn.net/u012546526/article/details/74184769 Elasticsearch java api Common query methods QueryBuil ...
[email protected] Hdmi2.0 optical transceiver HDMI HD video optical transceiver"/>







