Skip to content

Commit

Permalink
Add Go script
Browse files Browse the repository at this point in the history
  • Loading branch information
Glaived committed Jul 28, 2017
1 parent 033e0b6 commit f326902
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

import (
"fmt"
"os"
"os/exec"
"path/filepath"
)

func RemoveContents(dir string) error{
d, err := os.Open(dir)
if err != nil{
return err
}

defer d.Close()
names, err := d.Readdirnames(-1)
if err != nil{
return err
}

for _, name := range names{
err = os.RemoveAll(filepath.Join(dir, name))
if err != nil{
return err
}
}

return nil
}

func StartProcess(Filename string) {
// Filename = "cmd /C start \"" + Filename + "\""
cmd := exec.Command(Filename)
err := cmd.Start()
if err!=nil{
fmt.Println(err)
}
}

func main(){
err := RemoveContents("C:\\Program Files (x86)\\Steam\\appcache\\httpcache")
if err != nil{
fmt.Println(err)
os.Exit(1)
}

StartProcess("C:\\Program Files (x86)\\Steam\\steam.exe")
}

0 comments on commit f326902

Please sign in to comment.