package main import ( "federated.computer/wp-sync-slowtwitch/services/wordpress" "fmt" ) const baseUrl = "https://go-api-playground.local/wp-json/wp/v2/" const user = "admin" const password = "S34E keY1 A1uX 6ncs Rx4T f21W" var appCache AppCache func main() { //Get user and cache //Get category and cache //Get single category from cache by name //Get tag and cache //Get single tag from cache by name //Get photo and cache with URL //Create Category (with parent) + add to cache //Create Tag + add to cache //Upload Photo + add to cache //Use cached data to correctly build post form submissions posts := wordpress.GetPosts(baseUrl, user, password) for i, postData := range posts { fmt.Println("Post Number:", i+1, postData.Title.Rendered) } } type AppCache struct { UsersCache map[string]wordpress.UserData } func (appCache *AppCache) GetUser(username string) (wordpress.UserData, bool) { user, ok := appCache.UsersCache[username] return user, ok } func (appCache *AppCache) SetUser(user wordpress.UserData) { if appCache.UsersCache == nil { appCache.UsersCache = make(map[string]wordpress.UserData) } appCache.UsersCache[user.Username] = user }