Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanDescription ¶
CleanDescription takes in a string and removes any unnecessary new lines and ensures that the string is no longer than 1024 characters.
desc := "This is a long\ndescription\nwith\nmultiple\nlines." cleanDesc := CleanDescription(desc)
func IsActive ¶ added in v0.1.10
IsActive takes in an Event and returns whether the event is currently active or not based on the current time. It compares the start and finish time of the event with the current time.
event := Event{ Start: time.Now().Add(-1 * time.Hour), Finish: time.Now().Add(1 * time.Hour), } fmt.Println(IsActive(event)) // Output: true
Types ¶
type CTFTeam ¶ added in v0.1.10
type CTFTeam struct { ID int `json:"id"` Academic bool `json:"academic"` PrimaryAlias string `json:"primary_alias"` Name string `json:"name"` Logo string `json:"logo"` Country string `json:"country"` Aliases []string `json:"aliases"` Rating map[string]struct { RatingPlace int `json:"rating_place"` OrganizerPoints float64 `json:"organizer_points"` RatingPoints float64 `json:"rating_points"` CountryPlace int `json:"country_place"` } `json:"rating"` }
Struct for API Endpoint ctftime.org/api/v1/teams/
func GetCTFTeam ¶
GetCTFTeam takes in an id and returns a CTFTeam struct, along with any error that may have occurred. The function uses the ctftimeURL to make a GET request to the API and retrieve the team information by id. The response body is then parsed into a CTFTeam struct using json.Unmarshal.
team, err := GetCTFTeam(1) if err != nil { fmt.Println(err) }
type Event ¶
type Event struct { ID uint64 `json:"id"` CTFID int `json:"ctf_id"` Title string `json:"title"` Description string `json:"description"` URL string `json:"url"` Logo string `json:"logo"` Weight float64 `json:"weight"` Onsite bool `json:"onsite"` Location string `json:"location"` Restrictions string `json:"restrictions"` Format string `json:"format"` FormatID int `json:"format_id"` Participants int `json:"participants"` CTFTimeURL string `json:"ctftime_url"` LiveFeed string `json:"live_feed"` IsVotableNow bool `json:"is_votable_now"` PublicVotable bool `json:"public_votable"` Start time.Time `json:"start"` Finish time.Time `json:"finish"` }
Struct for API Endpoint ctftime.org/api/v1/events/
func CleanCTFEvents ¶
CleanCTFEvents takes in a slice of Event structs and performs several clean up operations on the slice. Title and Description fields of each event are trimmed and cleaned. Events that have finished are removed from the slice. The remaining events are sorted into two slices: active events and upcoming events. Active events are sorted by finish time, and upcoming events are sorted by start time. The two slices are then combined and returned, along with any error that may have occurred.
ctfEvents, err := CleanCTFEvents(events) if err != nil { fmt.Println(err) }
func GetCTFEvent ¶
GetCTFEvent takes in an integer 'id' and returns an Event struct, along with any error that may have occurred. The function uses an http client to send a GET request to the ctftime API with the provided id, and parses the response body into an Event struct.
event, err := GetCTFEvent(1) if err != nil { fmt.Println(err) }
func GetCTFEvents ¶
GetCTFEvents retrieves CTF events from the ctftime API within the next 180 days. The events are unmarshaled from json and cleaned before being returned.
events, err := GetCTFEvents() if err != nil { fmt.Println(err) }