Skip to content

improve code organization with packages#475

Open
ruebenramirez wants to merge 2 commits intomasterfrom
testing-go-code-organization-via-packages
Open

improve code organization with packages#475
ruebenramirez wants to merge 2 commits intomasterfrom
testing-go-code-organization-via-packages

Conversation

@ruebenramirez
Copy link
Copy Markdown
Owner

No description provided.

@ruebenramirez ruebenramirez self-assigned this Nov 16, 2023
return blogTitle
}

func ScrapePost(postUrl string, titleSelector string, postSelector string) (string, string) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported function requires a name that starts with a capital letter (https://go.dev/tour/basics/3)


// example usage
postUrl := "https://blog.ruebenramirez.com/posts/2023-11-05-celebratin-60-pounds-down/"
title, postHtml := lib.ScrapePost(postUrl, titleSelector, postSelector)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling the exported function from the lib package.

import (
"fmt"

"bopbot/newsletter/scrape/lib"
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

importing scrape's lib package

@@ -0,0 +1,26 @@
package lib
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utils.go is a member of scrape's lib package

@@ -0,0 +1,55 @@
package lib
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scrape.go is a member of scrape's lib package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant