func main() { var aArgs = base.GetArgs(map[string]int{"tel": 0, "mp3": 0, "gain": 0, "user_uploads": 1, "format": 1, "q": 1}) var sCurrentDir, _ = os.Getwd() _ = sCurrentDir var sBookID = aArgs[""][0] var oStartTime = time.Now() var oPrevTime = time.Now() var iVotesPerLoop = 16 var iVotesCast = 0 for { for iV := 0; iV < iVotesPerLoop-1; iV++ { go vVote(sBookID) } vVote(sBookID) iVotesCast += iVotesPerLoop var oNow = time.Now() var nDeltaSeconds = oNow.Sub(oPrevTime).Seconds() var nPerHour = float64(60*60) * (float64(iVotesPerLoop) / nDeltaSeconds) var sPerHour = strconv.FormatFloat(nPerHour, 'f', 4, 64) var nTotalDeltaSeconds = oNow.Sub(oStartTime).Seconds() var nTotalPerHour = float64(60*60) * (float64(iVotesCast) / nTotalDeltaSeconds) var sTotalPerHour = strconv.FormatFloat(nTotalPerHour, 'f', 4, 64) base.Dump(strconv.Itoa(iVotesCast) + " votes cast") base.Dump("spamming at " + sTotalPerHour + " (" + sPerHour + ") per Hour") oPrevTime = oNow } }
func main() { aArgs := base.GetArgs(map[string]int{}) sCurrentDir, _ := os.Getwd() base.Dump(aArgs) base.Dump(sCurrentDir) oStream := audio.NewStream() var iSampleRate = 44100 var oRand = rand.New(rand.NewSource(time.Now().Unix())) var cSamplesWritten = oStream.Start(iSampleRate, time.Duration(100)*time.Millisecond) defer oStream.Stop() var oStartTime = time.Now() //var iCooldownSamples = iSampleRate * 44 / 100; //var oCooldownDuration = (1000 * time.Duration(iCooldownSamples) / time.Duration(iSampleRate)) * time.Millisecond; var iNextPlayStart = 0 base.Dump(time.Now()) for { var iSamplesWritten = <-cSamplesWritten if iSamplesWritten > iNextPlayStart-5*iSampleRate { var aSound = SoundA(iSampleRate, time.Duration(2)*time.Second/time.Duration(4), 16, 32) for iKey := range aSound { var nWavePart = float64(iKey) / float64(len(aSound)) var nVolume = 0.75 + 0.25*float32(math.Sin(math.Pi*nWavePart)) aSound[iKey] = nVolume * aSound[iKey] } for iS := 0; iS < len(aSound); iS++ { } if true || oRand.Intn(32) > 0 { oStream.Play(iNextPlayStart, &aSound) } iNextPlayStart += len(aSound) } var oTimePassed = time.Now().Sub(oStartTime) if oTimePassed > time.Duration(1)*time.Hour { break } //time.Sleep(time.Duration(50) * time.Millisecond); } base.Dump(time.Now()) /*oStream.Play(0, aSound); oStream.Play(0, aSound);*/ /*for { //aSound = []float32{-1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1}; //base.Dump("play"); //oStream.PlayNow(aSound); time.Sleep(time.Duration(500) * time.Millisecond); }*/ time.Sleep(time.Second) }
func main() { var aArgs = base.GetArgs(map[string]int{"tel": 0, "mp3": 0, "gain": 0, "user_uploads": 1, "format": 1, "q": 1}) var sCurrentDir, _ = os.Getwd() var sUserName = aArgs[""][0] fmt.Println(sUserName) //var sJson = "{\"current_page\":12,\"total_pages\":68,\"total_items\":135,\"photos\":[{\"id\":45898264,\"user_id\":1171535,\"name\":\"following the rainbow\",\"description\":\"\",\"camera\":\"Canon EOS 5D Mark II\",\"lens\":\"\",\"focal_length\":\"135\",\"iso\":\"100\",\"shutter_speed\":\"1/320\",\"aperture\":\"3.2\",\"times_viewed\":33776,\"rating\":50.0,\"status\":1,\"created_at\":\"2013-09-10T04:09:20-04:00\",\"category\":0,\"location\":null,\"latitude\":null,\"longitude\":null,\"taken_at\":\"2013-09-03T19:55:30-04:00\",\"hi_res_uploaded\":0,\"for_sale\":false,\"width\":1549,\"height\":1894,\"votes_count\":2440,\"favorites_count\":1656,\"comments_count\":168,\"nsfw\":false,\"sales_count\":0,\"for_sale_date\":null,\"highest_rating\":98.8,\"highest_rating_date\":\"2013-09-11T04:45:22-04:00\",\"license_type\":0,\"converted\":27,\"collections_count\":0,\"privacy\":false,\"image_url\":\"http://ppcdn.500px.org/45898264/4b3078bd16cbebc01151b7c37d19d34b02ffba11/5.jpg\",\"images\":[{\"size\":5,\"url\":\"http://ppcdn.500px.org/45898264/4b3078bd16cbebc01151b7c37d19d34b02ffba11/5.jpg\",\"https_url\":\"https://gp1.wac.edgecastcdn.net/806614/photos/photos.500px.net/45898264/4b3078bd16cbebc01151b7c37d19d34b02ffba11/5.jpg\"}],\"positive_votes_count\":2440,\"user\":{\"id\":1171535,\"username\":\"ElenaShumilova\",\"firstname\":\"Elena\",\"lastname\":\"Shumilova\",\"city\":\"Andreapol\",\"country\":\"Russia\",\"fullname\":\"Elena Shumilova\",\"userpic_url\":\"http://pacdn.500px.org/1171535/a54cf3d035dad57d6fdbb82b14f625c16f30b5dc/1.jpg?127\",\"userpic_https_url\":\"https://gp1.wac.edgecastcdn.net/806614/avatars/avatars.500px.net/1171535/a54cf3d035dad57d6fdbb82b14f625c16f30b5dc/1.jpg?127\",\"upgrade_status\":0,\"affection\":151952,\"followers_count\":30519}},{\"id\":45200950,\"user_id\":1171535,\"name\":\"Untitled\",\"description\":null,\"camera\":\"Canon EOS 5D Mark II\",\"lens\":null,\"focal_length\":\"135\",\"iso\":\"100\",\"shutter_speed\":\"1/800\",\"aperture\":\"4\",\"times_viewed\":12717,\"rating\":49.8,\"status\":1,\"created_at\":\"2013-09-04T14:15:56-04:00\",\"category\":0,\"location\":null,\"latitude\":null,\"longitude\":null,\"taken_at\":\"2013-05-08T21:30:00-04:00\",\"hi_res_uploaded\":0,\"for_sale\":false,\"width\":1479,\"height\":1026,\"votes_count\":957,\"favorites_count\":539,\"comments_count\":36,\"nsfw\":false,\"sales_count\":0,\"for_sale_date\":null,\"highest_rating\":94.7,\"highest_rating_date\":\"2013-09-05T14:03:50-04:00\",\"license_type\":0,\"converted\":27,\"collections_count\":0,\"privacy\":false,\"image_url\":\"http://ppcdn.500px.org/45200950/75b4becc573dd1864bca7398deb1b208b100a32d/5.jpg\",\"images\":[{\"size\":5,\"url\":\"http://ppcdn.500px.org/45200950/75b4becc573dd1864bca7398deb1b208b100a32d/5.jpg\",\"https_url\":\"https://gp1.wac.edgecastcdn.net/806614/photos/photos.500px.net/45200950/75b4becc573dd1864bca7398deb1b208b100a32d/5.jpg\"}],\"positive_votes_count\":957,\"user\":{\"id\":1171535,\"username\":\"ElenaShumilova\",\"firstname\":\"Elena\",\"lastname\":\"Shumilova\",\"city\":\"Andreapol\",\"country\":\"Russia\",\"fullname\":\"Elena Shumilova\",\"userpic_url\":\"http://pacdn.500px.org/1171535/a54cf3d035dad57d6fdbb82b14f625c16f30b5dc/1.jpg?127\",\"userpic_https_url\":\"https://gp1.wac.edgecastcdn.net/806614/avatars/avatars.500px.net/1171535/a54cf3d035dad57d6fdbb82b14f625c16f30b5dc/1.jpg?127\",\"upgrade_status\":0,\"affection\":151952,\"followers_count\":30519}}],\"filters\":{\"category\":false,\"exclude\":false,\"user_id\":1171535},\"feature\":\"user\"}" //json.Read(sJson); //log.Fatal("---"); var oClient = &Client{} var aPhotos = oClient.aGetUserPhotos(sUserName) vDownloadPhotos(aPhotos, sCurrentDir) }
func main() { aArgs := base.GetArgs(map[string]int{}) sCurrentDir, _ := os.Getwd() base.Dump(aArgs) base.Dump(sCurrentDir) oStream := audio.NewStream() var iSampleRate = 44100 var iMinWaveSamples = iSampleRate / 32 var iMaxWaveSamples = iSampleRate / 16 var nWavePart = float64(0) aSound := make([]float32, 64*iSampleRate) rand.Seed(time.Now().Unix()) var iSoundAt = 0 for iSoundAt < len(aSound) { var iWaveSamples = iMinWaveSamples + rand.Intn(iMaxWaveSamples-iMinWaveSamples) if iWaveSamples > len(aSound)-iSoundAt { iWaveSamples = len(aSound) - iSoundAt } for iWS := 0; iWS < iWaveSamples; iWS++ { nWavePart = float64(iWS) / float64(iWaveSamples) aSound[iSoundAt+iWS] = float32(0.8) * float32(math.Sin(math.Pi*nWavePart)) if nWavePart < 0.5 { aSound[iSoundAt+iWS] = 1 } else { aSound[iSoundAt+iWS] = -1 } } iSoundAt += iWaveSamples } //base.Dump(aSound); oStream.Play(0, aSound) oStream.Start(iSampleRate) time.Sleep(time.Duration(100000) * time.Second) }
func main() { aArgs := base.GetArgs(map[string]int{}) sCurrentDir, _ := os.Getwd() base.Dump(aArgs) base.Dump(sCurrentDir) var oRand = rand.New(rand.NewSource(time.Now().Unix())) var iRandomIntRange = 20 var aRandomInts = make([]int, 999) var aInts = map[int]int{} for iI := -iRandomIntRange; iI <= iRandomIntRange; iI++ { aInts[iI] = 0 } base.Dump(aInts) for iKey := range aRandomInts { var iRandomInt = int(oRand.NormFloat64() * float64(iRandomIntRange/2)) aRandomInts[iKey] = iRandomInt if _, bSet := aInts[iRandomInt]; bSet { aInts[iRandomInt]++ } } for iI := -iRandomIntRange; iI <= iRandomIntRange; iI++ { var iCount = aInts[iI] var sBar = "" for iC := 0; iC < iCount; iC++ { sBar += "#" } base.Dump(sBar) } }
func main() { aArgs := base.GetArgs(map[string]int{"? h help": 0, "p plain": 0, "r replace": 0, "c count": 0}) _, bHelp := aArgs["? h help"] //_ , bPlain := aArgs["p plain"]; _, bReplace := aArgs["r replace"] _, bCount := aArgs["c count"] bHelp = (bHelp || (0 == len(aArgs))) if bHelp { fmt.Println("this tool is for grepping when there are no line breaks") fmt.Println("usage: streamo [regular expression] <[output template (default='\\0')]>") fmt.Println("options:") fmt.Println("-? -h --help: this help page") fmt.Println("-r --replace : output is input with matches replaced according to output template") fmt.Println("-c --count : only count matches, print count") fmt.Println("planned options:") fmt.Println("-p --plain : search for string instead of regular expression") return } sRegExp := aArgs[""][0] oRegExA := regexp.MustCompile(sRegExp) bStartPattern := regexp.MustCompile("^\\^").MatchString(sRegExp) bEndPattern := regexp.MustCompile("\\$$").MatchString(sRegExp) sOutputTemplate := "\\0" if len(aArgs[""]) > 1 { sOutputTemplate = aArgs[""][1] } sPart := "" iRead := 0 iCount := 0 iPartOffset := 0 aNewLetter := make([]byte, 1) var e error oIn := bufio.NewReader(os.Stdin) for { iRead, e = oIn.Read(aNewLetter) sNewLetter := fmt.Sprintf("%s", aNewLetter[:iRead]) aMatches := oRegExA.FindAllStringSubmatch(sPart, -1) aMatchIndices := oRegExA.FindAllStringSubmatchIndex(sPart, -1) if len(aMatches) != 0 { aLastMatch := aMatches[len(aMatches)-1] aLastMatchIndices := aMatchIndices[len(aMatchIndices)-1] aMatchIndicesNext := oRegExA.FindAllStringSubmatchIndex(sPart+sNewLetter, -1) bOutput := true if e == nil { if len(aMatchIndicesNext) > 0 { aLastMatchIndicesNext := aMatchIndicesNext[len(aMatchIndicesNext)-1] if aLastMatchIndices[0] == aLastMatchIndicesNext[0] && aLastMatchIndices[1] != aLastMatchIndicesNext[1] { bOutput = false } } } if bOutput { if bStartPattern && iPartOffset+aLastMatchIndices[0] != 0 { bOutput = false } if bEndPattern && e == nil { bOutput = false } } if bOutput { sOutput := sOutputTemplate for iNr, sValue := range aLastMatch { sOutput = strings.Replace(sOutput, "\\"+strconv.Itoa(iNr), sValue, -1) } if bCount { iCount++ } else if bReplace { fmt.Print(oRegExA.ReplaceAllLiteralString(sPart, sOutput)) } else { fmt.Print(sOutput + "\n") } sPart = sPart[(aLastMatchIndices[1]):] iPartOffset += aLastMatchIndices[1] + 1 } } if e != nil { break } sPart += sNewLetter } if bReplace { fmt.Print(sPart) } if bCount { fmt.Println(iCount) } }
func main() { aArgs := base.GetArgs(map[string]int{"v": 1, "mode": 1}) sCurrentDir, _ := os.Getwd() base.Dump(aArgs) base.Dump(sCurrentDir) var nVolume float32 = 1.0 if len(aArgs["v"]) > 0 { var nVolume64, _ = strconv.ParseFloat(aArgs["v"][0], 32) nVolume = float32(nVolume64) } base.Dump("nVolume = " + strconv.FormatFloat(float64(nVolume), 'f', 4, 32)) oStream := audio.NewStream() oStream.SetVolume(nVolume) var iSampleRate = 44100 //if _, bSet := aArgs["mode"]; !bSet { // aArgs["mode"] = []string{"a"}; //} //var sMode = aArgs["mode"]; var cSamplesWritten = oStream.Start(iSampleRate, time.Duration(100)*time.Millisecond) defer oStream.Stop() var sDuration = "1h" if len(aArgs[""]) > 0 { sDuration = aArgs[""][0] } var oDuration, errParse = time.ParseDuration(sDuration) if errParse != nil { oDuration = time.Duration(60) * time.Minute } base.Dump(oDuration) fSound := func(iSampleRate int) []float32 { return SoundA(iSampleRate, time.Duration(2)*time.Second, 16, 32) } if len(aArgs["mode"]) > 0 && aArgs["mode"][0] == "b" { fSound = func(iSampleRate int) []float32 { return SoundB(iSampleRate /*, time.Duration(2) * time.Second*/, 16, 32) } } var iNextPlayStart = 0 var oStartTime = time.Now() var oLastLoggedTime = time.Time{} var iTotalSamples = int(float64(iSampleRate) * oDuration.Seconds()) var iSamplesPushed = 0 for { var iSamplesWritten = <-cSamplesWritten if iSamplesWritten > iNextPlayStart-5*iSampleRate { var oNow = time.Now() if oNow.Sub(oLastLoggedTime) > (time.Duration(1) * time.Minute) { base.Dump(time.Now()) oLastLoggedTime = oNow } var aSound = fSound(iSampleRate) for iKey := range aSound { var nWavePart = float64(iKey) / float64(len(aSound)) var nVolume = 0.75 + 0.25*float32(math.Sin(math.Pi*nWavePart)) aSound[iKey] = nVolume * aSound[iKey] } var iSamplesLeft = iTotalSamples - iSamplesPushed if iSamplesLeft < 0 { break } if iSamplesLeft < len(aSound) { for iS := iSamplesLeft; iS < len(aSound); iS++ { aSound[iS] = 0 } } oStream.Play(iNextPlayStart, &aSound) iSamplesPushed += len(aSound) iNextPlayStart += len(aSound) } var oTimePassed = time.Now().Sub(oStartTime) if oTimePassed > oDuration { break } time.Sleep(time.Duration(50) * time.Millisecond) } time.Sleep(time.Second) }
func main() { aArgs := base.GetArgs(map[string]int{"?": 0, "h": 0, "q": 1, "tel": 0, "mp3": 0, "gain": 0, "user_uploads": 1, "format": 1, "convert_only": 0}) sCurrentDir, _ := os.Getwd() sTargetDir := sCurrentDir aVideoIDs := aArgs[""] for sKey, sID := range aVideoIDs { aParams := aGetParams(sID) if sParam, bSet := aParams["v"]; bSet { aVideoIDs[sKey] = sParam } } _, bHelp := aArgs["h"] _, bQuestionMark := aArgs["?"] if bHelp || bQuestionMark { fmt.Println("this is for downloading youtube videos.") fmt.Println("usage: youtube [OPTIONS] [YOUTUBE_IDS]") fmt.Println("options:") fmt.Println("-h, --help: this help page") fmt.Println("-q [max_quality]: set maximum quality. standard youtube qualities are: 240, 320, 480, 720, 1080") fmt.Println("-mp3: convert to mp3") fmt.Println("-gain: make mp3 louder if very quiet") fmt.Println("-user_uploads [user_id]: download all videos from a youtube user") return } _, bTel := aArgs["tel"] _, bMP3 := aArgs["mp3"] _, bGain := aArgs["gain"] _, bConvertOnly := aArgs["convert_only"] if bConvertOnly { return } if bTel { bMP3 = true bGain = true sTargetDir = "/aaa/downloads/telefon" if _, err := os.Stat(sTargetDir); os.IsNotExist(err) { sTargetDir = "/aaa/cache/telefon" } } bUseList := false oList := &list.VideoList{} if _, bSet := aArgs["user_uploads"]; bSet { bUseList = true sUserID := aArgs["user_uploads"][0] sTargetDir = sCurrentDir + "/" + sUserID os.Mkdir(sTargetDir, 0744) sVideoListFile := sTargetDir + "/download_list" oList = list.MakeVideoList(sVideoListFile) if len(oList.Videos) == 0 { aVideoIDs := youtube.GetUserVideoIDs(sUserID) for _, sVideoID := range aVideoIDs { oList.AddVideo(sVideoID) } oList.Write() } aVideoIDs = oList.GetFreshVideos() } var iMaxQuality = 999999 if _, bSet := aArgs["q"]; bSet { if len(aArgs["q"]) > 0 { iMaxQuality64, _ := strconv.ParseInt(aArgs["q"][0], 10, 64) iMaxQuality = int(iMaxQuality64) } } else { if bMP3 { iMaxQuality = 360 } } fFileNameMaker := func(oDownloadData *youtube.DownloadData) string { if bTel { sAuthorTitle := oDownloadData.Author + " - " + oDownloadData.Title for _, sReplaceWithUnderline := range []string{" ", "/", ":", "?", "|", "\"", "'"} { sAuthorTitle = strings.Replace(sAuthorTitle, sReplaceWithUnderline, "_", -1) } sFileName := oDownloadData.VideoID + "_[" + sAuthorTitle + "]_" sFileName += oDownloadData.SourceTypeID + "_" + oDownloadData.Quality + "." + oDownloadData.FileType return sFileName } return oDownloadData.FileName } for _, sVideoID := range aVideoIDs { err := youtube.YoutubeDownload(sVideoID, iMaxQuality, bMP3, bGain, sTargetDir, fFileNameMaker) fmt.Println(sVideoID + " fertig") if bUseList { if err == nil { oList.FlagVideo(sVideoID, VideoSuccessFlag) } else { oList.FlagVideo(sVideoID, VideoErrorFlag+err.Error()) } oList.Write() } else { if err != nil { log.Fatal(err) } } } }
func main() { aArgs := base.GetArgs(map[string]int{}) sCurrentDir, _ := os.Getwd() base.Dump(aArgs) base.Dump(sCurrentDir) oStream := audio.NewStream() var iSampleRate = 44100 var oRand = rand.New(rand.NewSource(time.Now().Unix())) var cSamplesWritten = oStream.Start(iSampleRate, time.Duration(100)*time.Millisecond) defer oStream.Stop() var oStartTime = time.Now() //var iCooldownSamples = iSampleRate * 44 / 100; //var oCooldownDuration = (1000 * time.Duration(iCooldownSamples) / time.Duration(iSampleRate)) * time.Millisecond; var sDuration = "1h" if len(aArgs[""]) > 0 { sDuration = aArgs[""][0] } var oDuration, errParse = time.ParseDuration(sDuration) if errParse != nil { oDuration = time.Duration(60) * time.Minute } base.Dump(oDuration) var oImage = image.NewImage(20000, 200) oImage.FillRect(0, 0, oImage.Width(), oImage.Height(), image.NewColor(255, 255, 255, 255)) oImage.DrawPoint(10, 10, image.NewColor(255, 0, 0, 255)) var iNextPlayStart = 0 for { var iSamplesWritten = <-cSamplesWritten if iSamplesWritten > iNextPlayStart-5*iSampleRate { base.Dump(time.Now()) var aSound = SoundA(iSampleRate, time.Duration(2)*time.Second/time.Duration(8), 16, 32) for iKey := range aSound { var nWavePart = float64(iKey) / float64(len(aSound)) var nVolume = 0.75 + 0.25*float32(math.Sin(math.Pi*nWavePart)) //nVolume = float32(1.0); aSound[iKey] = nVolume * aSound[iKey] } // for iS := 0; iS < len(aSound); iS ++ {} if true || oRand.Intn(32) > 0 { oStream.Play(iNextPlayStart, &aSound) drawSound(oImage, &aSound, iNextPlayStart, 8) } iNextPlayStart += len(aSound) } var oTimePassed = time.Now().Sub(oStartTime) if oTimePassed > oDuration { break } time.Sleep(time.Duration(50) * time.Millisecond) } /*oStream.Play(0, aSound); oStream.Play(0, aSound);*/ /*for { //aSound = []float32{-1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1}; //base.Dump("play"); //oStream.PlayNow(aSound); time.Sleep(time.Duration(500) * time.Millisecond); }*/ time.Sleep(time.Second) }
func main() { aArgs := base.GetArgs(map[string]int{"?": 0, "r": 0}) _, bHelp := aArgs["?"] bHelp = bHelp || len(aArgs[""]) < 1 if bHelp { base.Dump("usage: \nautoheader [files]") return } _, bRecursive := aArgs["r"] aFiles := aArgs[""] rxC := regexp.MustCompile("\\.c$") aDirs := []string{} aFilesTemp := aFiles aFiles = []string{} for _, sFile := range aFilesTemp { if !base.FileExists(sFile) { log.Fatal("error: file " + sFile + " don't exist") } if base.IsDirectory(sFile) { aDirs = append(aDirs, sFile) } else { if rxC.MatchString(sFile) { aFiles = append(aFiles, sFile) } } } for 0 < len(aDirs) { aDirsTemp := aDirs aDirs = []string{} for _, sDir := range aDirsTemp { aDirFiles, _ := ioutil.ReadDir(sDir) for _, oFile := range aDirFiles { sFile := oFile.Name() if oFile.IsDir() { aDirs = append(aDirs, sDir+"/"+sFile) } else { if rxC.MatchString(sFile) { aFiles = append(aFiles, sDir+"/"+sFile) } } } } if !bRecursive { break } } base.Dump(aFiles) rxF := regexp.MustCompile("\n[^\n]*\\S+ +(\\S+) +\\([^\\)\\;]*\\) {") rxAuto := regexp.MustCompile("\n///#///\n[\\s\\S]+\n///#///\n") aRXSFH := []*regexp.Regexp{ /*regexp.MustCompile("^\n *static ")*/ } aRXSFF := []*regexp.Regexp{regexp.MustCompile("^_")} for _, sFile := range aFiles { sFC := sFile //sFB := rxC.ReplaceAllString(sFC, ".b"); //sContentB := ""; sFH := rxC.ReplaceAllString(sFC, ".h") aContentC, _ := ioutil.ReadFile(sFC) sContentC := string(aContentC) sDeclarations := "" aFunctionHeads := rxF.FindAllStringSubmatch(sContentC, -1) for _, aFunctionHead := range aFunctionHeads { sFunctionHead := aFunctionHead[0] sFunctionName := aFunctionHead[1] bDeclare := true for _, rxSFH := range aRXSFH { if rxSFH.MatchString(sFunctionHead) { bDeclare = false } } for _, rxSFF := range aRXSFF { if rxSFF.MatchString(sFunctionName) { bDeclare = false } } if bDeclare { sDeclarations += strings.Replace(sFunctionHead, "{", ";", 1) } } sDeclarations += "\n" sWrite := "\n///#///\n" + sDeclarations + "\n///#///\n" sContentH := "" if base.FileExists(sFH) { aContentH, _ := ioutil.ReadFile(sFH) sContentH = string(aContentH) } if rxAuto.MatchString(sContentH) { sWrite = rxAuto.ReplaceAllString(sContentH, sWrite) } else { sWrite = sContentH + sWrite } ioutil.WriteFile(sFH, []byte(sWrite), 0644) } }