示範一下從入門到放棄

This commit is contained in:
tdc 2022-09-14 16:19:08 +08:00
parent dd7cfc995e
commit 8d2880c643
6 changed files with 120 additions and 6 deletions

7
AutoBuild/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "AutoBuild"
version = "0.1.0"

12
AutoBuild/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "AutoBuild"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[[bin]]
name = "AutoBuild"
path = "main.rs"

5
AutoBuild/go.mod Normal file
View File

@ -0,0 +1,5 @@
module autobuild
go 1.18
require github.com/thoas/go-funk v0.9.2 // indirect

8
AutoBuild/go.sum Normal file
View File

@ -0,0 +1,8 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/thoas/go-funk v0.9.2 h1:oKlNYv0AY5nyf9g+/GhMgS/UO2ces0QRdPKwkhY3VCk=
github.com/thoas/go-funk v0.9.2/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@ -1,14 +1,62 @@
package main
import (
"log"
"reflect"
"time"
)
type FilterList struct {
abp []string
hosts []string
}
type HEAD struct {
abp string
hosts string
}
func main() {
type FilterList struct {
abp []string
hosts []string
}
filterlist := FilterList{
filterlist := &FilterList{
[]string{"experimental.txt", "filter.txt"},
[]string{"hosts.txt", "nofarm_hosts.txt"}}
//fmt.Println(filterlist)
heads := HEAD{
abp: "[Adblock Plus]\n" +
"! Title: LowTechFilter {name}\n" +
"! Version: {version}\n" +
"! Expires: 1 hour\n" +
"! Homepage: https://t.me/AdBlock_TW\n" +
"! ----------------------------------------------------------------------\n",
hosts: "! FutaHosts\n" +
"! LowTechFilter {name}\n" +
"! URL: <https://github.com/FutaGuard/LowTechFilter>\n" +
"! Version: {version}\n" +
"! --------------------------------------------------\n",
}
url := "https://filter.futa.gg/"
log.Println(url)
log.Println(heads)
location, _ := time.LoadLocation("Asia/Taipei")
now := time.Now().In(location)
log.Println(now)
//fields := reflect.VisibleFields(reflect.TypeOf(filterlist))
v := reflect.ValueOf(filterlist).Elem()
log.Println(v.FieldByName("abp").s)
//for _, field := range fields {
// data := reflect.Indirect(v).FieldByName(field.Name)
// log.Println(data)
//}
log.Println(v)
menu := map[string][]string{
"abp": {"experimental.txt", "filter.txt"},
"hosts": {"hosts.txt", "nofarm_hosts.txt"},
}
for category, data := range menu {
log.Println(category, data)
}
//log.Println(menu)
}

34
AutoBuild/main.rs Normal file
View File

@ -0,0 +1,34 @@
fn main() {
struct FilterList<'a> {
abp: Vec<&'a str>,
hosts: Vec<&'a str>,
}
struct HEAD<'a> {
abp: &'a str,
hosts: &'a str,
}
let filterlist = FilterList {
abp: vec!["experimental.txt", "filter.txt"],
hosts: vec!["hosts.txt", "nofarm_hosts.txt"],
};
let url: &str = "https://filter.futa.gg/";
let head = HEAD {
abp: "[Adblock Plus]\n
! Title: LowTechFilter {name}\n
! Version: {version}\n
! Expires: 1 hour\n
! Homepage: https://t.me/AdBlock_TW\n
! ----------------------------------------------------------------------\n",
hosts: "! FutaHosts\n\
! LowTechFilter {name}\n\
! URL: <https://github.com/FutaGuard/LowTechFilter>\n\
! Version: {version}\n\
! --------------------------------------------------\n",
};
println!("{:?}", head.hosts);
for val in head {
println!("{:?}", val)
}
// println!("{:?}", filterlist::field_names());
}