GoLang
xxxxxxxxxx
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
err := os.Mkdir("subdir", 0755)
check(err)
defer os.RemoveAll("subdir")
createEmptyFile := func(name string) {
d := []byte("")
check(ioutil.WriteFile(name, d, 0644))
}
createEmptyFile("subdir/file1")
err = os.MkdirAll("subdir/parent/child", 0755)
check(err)
createEmptyFile("subdir/parent/file2")
createEmptyFile("subdir/parent/file3")
createEmptyFile("subdir/parent/child/file4")
c, err := ioutil.ReadDir("subdir/parent")
check(err)
fmt.Println("Listing subdir/parent")
for _, entry := range c {
fmt.Println(" ", entry.Name(), entry.IsDir())
}
err = os.Chdir("subdir/parent/child")
check(err)
c, err = ioutil.ReadDir(".")
check(err)
fmt.Println("Listing subdir/parent/child")
for _, entry := range c {
fmt.Println(" ", entry.Name(), entry.IsDir())
}
err = os.Chdir("../../..")
check(err)
fmt.Println("Visiting subdir")
err = filepath.Walk("subdir", visit)
}
func visit(p string, info os.FileInfo, err error) error {
if err != nil {
return err
}
fmt.Println(" ", p, info.IsDir())
return nil
}
Listing subdir/parent child true file2 false file3 false Listing subdir/parent/child file4 false Visiting subdir subdir true subdir/file1 false subdir/parent true subdir/parent/child true subdir/parent/child/file4 false subdir/parent/file2 false subdir/parent/file3 false
Linux - anc-api-tools ని ఎలా ఇన్స్టాల్ చేయాలి
Linux - curvedns ని ఎలా ఇన్స్టాల్ చేయాలి
Python - సంఖ్య సానుకూలంగా ఉందా, ప్రతికూలంగా ఉందా లేదా 0 అని తనిఖీ చేయండి
Linux - zenmap ని ఎలా ఇన్స్టాల్ చేయాలి
C - పూర్ణాంకంలో అంకెల సంఖ్యను లెక్కించండి
C++ - లీప్ ఇయర్ని తనిఖీ చేయండి
JavaScript - స్ట్రింగ్ కొన్ని అక్షరాలతో ప్రారంభమై ముగుస్తుందో లేదో తనిఖీ చేయండి
C++ - సంఖ్య ప్రధానమైనదా కాదా అని తనిఖీ చేయండి
Kotlin - ఒక సంఖ్యను n దశాంశ స్థానాలకు రౌండ్ చేయండి
Kotlin - ఒక సంఖ్యను రివర్స్ చేయండి
Linux - xbitmaps ని ఎలా ఇన్స్టాల్ చేయాలి
C - డైనమిక్ మెమరీ కేటాయింపును ఉపయోగించి అతిపెద్ద సంఖ్యను కనుగొనండి
Linux - zstd ని ఎలా ఇన్స్టాల్ చేయాలి
Linux - zfs-test ని ఎలా ఇన్స్టాల్ చేయాలి
Linux - zookeeper-bin ని ఎలా ఇన్స్టాల్ చేయాలి
Java - ఒక సంఖ్యను రివర్స్ చేయండి
Python - Excel (XLSX) ఫైల్లను వ్రాయడం
Linux - zita-ajbridge ని ఎలా ఇన్స్టాల్ చేయాలి
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month