Can I use ipfs as a library?

I am extending some IPFS functionalities and I would like to ask if it’s possible to use go-ipfs as library. For example to add a file I would use the same logic like the add.go cmd does:
func (adder *Adder) add(reader io.Reader) (ipld.Node, error) {
	chnk, err := chunker.FromString(reader, adder.Chunker)
	if err != nil {
		return nil, err

I am having some doubts because as AFIK, running an IPFS CLI cmd converts the commands into HTTP requests. Why is this done in this way? Some exclusive locks, shared resources?

Update: run into an exclusive lock ipfs/repo.lock failed: resource temporarily unavailable but solved it by running the IPFS daemon from within my code and keeping the pointer to it. AddHandler seems to work. Let’s see about the cat.